Java Code Examples for org.springframework.web.servlet.HandlerMapping#getHandler()
The following examples show how to use
org.springframework.web.servlet.HandlerMapping#getHandler() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HandlerMappingIntrospector.java From spring-analysis-note with MIT License | 6 votes |
/** * Find the {@link HandlerMapping} that would handle the given request and * return it as a {@link MatchableHandlerMapping} that can be used to test * request-matching criteria. * <p>If the matching HandlerMapping is not an instance of * {@link MatchableHandlerMapping}, an IllegalStateException is raised. * @param request the current request * @return the resolved matcher, or {@code null} * @throws Exception if any of the HandlerMapping's raise an exception */ @Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { Object handler = handlerMapping.getHandler(wrapper); if (handler == null) { continue; } if (handlerMapping instanceof MatchableHandlerMapping) { return ((MatchableHandlerMapping) handlerMapping); } throw new IllegalStateException("HandlerMapping is not a MatchableHandlerMapping"); } return null; }
Example 2
Source File: HandlerMappingIntrospector.java From java-technology-stack with MIT License | 6 votes |
/** * Find the {@link HandlerMapping} that would handle the given request and * return it as a {@link MatchableHandlerMapping} that can be used to test * request-matching criteria. * <p>If the matching HandlerMapping is not an instance of * {@link MatchableHandlerMapping}, an IllegalStateException is raised. * @param request the current request * @return the resolved matcher, or {@code null} * @throws Exception if any of the HandlerMapping's raise an exception */ @Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { Object handler = handlerMapping.getHandler(wrapper); if (handler == null) { continue; } if (handlerMapping instanceof MatchableHandlerMapping) { return ((MatchableHandlerMapping) handlerMapping); } throw new IllegalStateException("HandlerMapping is not a MatchableHandlerMapping"); } return null; }
Example 3
Source File: HandlerMappingIntrospector.java From foremast with Apache License 2.0 | 6 votes |
/** * Find the {@link HandlerMapping} that would handle the given request and * return it as a {@link MatchableHandlerMapping} that can be used to test * request-matching criteria. * <p>If the matching HandlerMapping is not an instance of * {@link MatchableHandlerMapping}, an IllegalStateException is raised. * @param request the current request * @return the resolved matcher, or {@code null} * @throws Exception if any of the HandlerMapping's raise an exception */ public HandlerExecutionChain getHandlerExecutionChain(HttpServletRequest request) throws Exception { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { Object handler = handlerMapping.getHandler(wrapper); if (handler == null) { continue; } if (handler instanceof HandlerExecutionChain) { return (HandlerExecutionChain)handler; } throw new IllegalStateException("HandlerMapping is not a MatchableHandlerMapping"); } return null; }
Example 4
Source File: HandlerMappingIntrospector.java From foremast with Apache License 2.0 | 6 votes |
/** * Find the {@link HandlerMapping} that would handle the given request and * return it as a {@link MatchableHandlerMapping} that can be used to test * request-matching criteria. * <p>If the matching HandlerMapping is not an instance of * {@link MatchableHandlerMapping}, an IllegalStateException is raised. * @param request the current request * @return the resolved matcher, or {@code null} * @throws Exception if any of the HandlerMapping's raise an exception */ public HandlerExecutionChain getHandlerExecutionChain(HttpServletRequest request) throws Exception { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { Object handler = handlerMapping.getHandler(wrapper); if (handler == null) { continue; } if (handler instanceof HandlerExecutionChain) { return (HandlerExecutionChain)handler; } throw new IllegalStateException("HandlerMapping is not a MatchableHandlerMapping"); } return null; }
Example 5
Source File: HandlerMappingIntrospector.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Find the {@link HandlerMapping} that would handle the given request and * return it as a {@link MatchableHandlerMapping} that can be used to test * request-matching criteria. * <p>If the matching HandlerMapping is not an instance of * {@link MatchableHandlerMapping}, an IllegalStateException is raised. * @param request the current request * @return the resolved matcher, or {@code null} * @throws Exception if any of the HandlerMapping's raise an exception */ public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { Object handler = handlerMapping.getHandler(wrapper); if (handler == null) { continue; } if (handlerMapping instanceof MatchableHandlerMapping) { return ((MatchableHandlerMapping) handlerMapping); } throw new IllegalStateException("HandlerMapping is not a MatchableHandlerMapping"); } return null; }
Example 6
Source File: HandlerMappingIntrospector.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { HandlerExecutionChain handler = null; try { handler = handlerMapping.getHandler(wrapper); } catch (Exception ex) { // Ignore } if (handler == null) { continue; } if (handler.getInterceptors() != null) { for (HandlerInterceptor interceptor : handler.getInterceptors()) { if (interceptor instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) interceptor).getCorsConfiguration(wrapper); } } } if (handler.getHandler() instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) handler.getHandler()).getCorsConfiguration(wrapper); } } return null; }
Example 7
Source File: SimpleUrlHandlerMappingTests.java From spring-analysis-note with MIT License | 5 votes |
private HandlerExecutionChain getHandler(HandlerMapping hm, MockHttpServletRequest req) throws Exception { HandlerExecutionChain hec = hm.getHandler(req); HandlerInterceptor[] interceptors = hec.getInterceptors(); if (interceptors != null) { for (HandlerInterceptor interceptor : interceptors) { interceptor.preHandle(req, null, hec.getHandler()); } } return hec; }
Example 8
Source File: HandlerMappingIntrospector.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { HandlerExecutionChain handler = null; try { handler = handlerMapping.getHandler(wrapper); } catch (Exception ex) { // Ignore } if (handler == null) { continue; } if (handler.getInterceptors() != null) { for (HandlerInterceptor interceptor : handler.getInterceptors()) { if (interceptor instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) interceptor).getCorsConfiguration(wrapper); } } } if (handler.getHandler() instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) handler.getHandler()).getCorsConfiguration(wrapper); } } return null; }
Example 9
Source File: SimpleUrlHandlerMappingTests.java From java-technology-stack with MIT License | 5 votes |
private HandlerExecutionChain getHandler(HandlerMapping hm, MockHttpServletRequest req) throws Exception { HandlerExecutionChain hec = hm.getHandler(req); HandlerInterceptor[] interceptors = hec.getInterceptors(); if (interceptors != null) { for (HandlerInterceptor interceptor : interceptors) { interceptor.preHandle(req, null, hec.getHandler()); } } return hec; }
Example 10
Source File: HandlerMappingIntrospector.java From foremast with Apache License 2.0 | 5 votes |
@Override public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { HandlerExecutionChain handler = null; try { handler = handlerMapping.getHandler(wrapper); } catch (Exception ex) { // Ignore } if (handler == null) { continue; } if (handler.getInterceptors() != null) { for (HandlerInterceptor interceptor : handler.getInterceptors()) { if (interceptor instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) interceptor).getCorsConfiguration(wrapper); } } } if (handler.getHandler() instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) handler.getHandler()).getCorsConfiguration(wrapper); } } return null; }
Example 11
Source File: HandlerMappingIntrospector.java From foremast with Apache License 2.0 | 5 votes |
@Override public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { HandlerExecutionChain handler = null; try { handler = handlerMapping.getHandler(wrapper); } catch (Exception ex) { // Ignore } if (handler == null) { continue; } if (handler.getInterceptors() != null) { for (HandlerInterceptor interceptor : handler.getInterceptors()) { if (interceptor instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) interceptor).getCorsConfiguration(wrapper); } } } if (handler.getHandler() instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) handler.getHandler()).getCorsConfiguration(wrapper); } } return null; }
Example 12
Source File: HandlerMappingIntrospector.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { Assert.notNull(this.handlerMappings, "Handler mappings not initialized"); HttpServletRequest wrapper = new RequestAttributeChangeIgnoringWrapper(request); for (HandlerMapping handlerMapping : this.handlerMappings) { HandlerExecutionChain handler = null; try { handler = handlerMapping.getHandler(wrapper); } catch (Exception ex) { // Ignore } if (handler == null) { continue; } if (handler.getInterceptors() != null) { for (HandlerInterceptor interceptor : handler.getInterceptors()) { if (interceptor instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) interceptor).getCorsConfiguration(wrapper); } } } if (handler.getHandler() instanceof CorsConfigurationSource) { return ((CorsConfigurationSource) handler.getHandler()).getCorsConfiguration(wrapper); } } return null; }
Example 13
Source File: SimpleUrlHandlerMappingTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private HandlerExecutionChain getHandler(HandlerMapping hm, MockHttpServletRequest req) throws Exception { HandlerExecutionChain hec = hm.getHandler(req); HandlerInterceptor[] interceptors = hec.getInterceptors(); if (interceptors != null) { for (HandlerInterceptor interceptor : interceptors) { interceptor.preHandle(req, null, hec.getHandler()); } } return hec; }
Example 14
Source File: WallRideDispatcherServlet.java From wallride with Apache License 2.0 | 5 votes |
@Override protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception { if (!CollectionUtils.isEmpty(this.parentHandlerMappings)) { for (HandlerMapping hm : this.parentHandlerMappings) { if (logger.isTraceEnabled()) { logger.trace("Testing handler map [" + hm + "] in DispatcherServlet with name '" + getServletName() + "'"); } HandlerExecutionChain handler = hm.getHandler(request); if (handler != null) { return handler; } } } return super.getHandler(request); }