Spring Framework HandlerMethod - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework HandlerMethod class.

This code example shows how to use the following methods:getBeanType, getMethod
	public AnnotatedMethodHandlerInterceptor(Class<A> annotationType) { 
		this.annotationType = annotationType; 
	} 
 
	protected A getAnnotation(HandlerMethod handlerMethod) { 
		return annotationScanner.getMethodOrTypeAnnotation(annotationType, handlerMethod.getMethod(), handlerMethod.getBeanType()); 
	} 
 
	private boolean shouldIntercept(HandlerMethod handlerMethod) { 
		return getAnnotation(handlerMethod) != null; 
	} 
 
	@Override 
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 
 
		if (handler instanceof HandlerMethod) { 
			HandlerMethod handlerMethod = HandlerMethod.class.cast(handler); 
			if (shouldIntercept(handlerMethod)) { 
				return preHandleInternal(request, response, handlerMethod); 
			} 
5
CodeRank
This code example shows how to use the following methods:
  
    private Router.Route route; 
     
    public RouterHandler(Object bean, Method method, Router.Route route) { 
        // calling the actual HandlerMethod constructor 
        super(bean, method); 
        this.route = route; 
    } 
 
    public Route getRoute() { 
        return route; 
    } 
     
} 
5
CodeRank
This code example shows how to use the following methods:getBeanType, getMethod
  private ModelUtils() { 
    throw new UnsupportedOperationException();
  } 
 
  public static ResolvedType handlerReturnType(TypeResolver resolver, HandlerMethod handlerMethod) {
    Class hostClass = use(handlerMethod.getBeanType())
            .or(handlerMethod.getMethod().getDeclaringClass());
    return new HandlerMethodResolver(resolver).methodReturnType(handlerMethod.getMethod(), hostClass);
  } 
 
  public static String getModelName(TypeResolver resolver, Type clazz) {
    return ResolvedTypes.typeName(asResolved(resolver, clazz));
  } 
 
  public static String getResponseClassName(ResolvedType returnType) {
    return ResolvedTypes.responseTypeName(returnType);
  } 
} 
5
CodeRank
This code example shows how to use the following methods:
    public void setup() throws Exception { 
        MockServletContext sc = new MockServletContext(); 
        request = new MockHttpServletRequest(sc); 
        webRequest = new ServletWebRequest(request); 
        RequestContextHolder.setRequestAttributes(webRequest); 
        HandlerMethod handler = new HandlerMethod(new ControllerFqcnPrefixingSessionAttributeStoreTestController(), 
            ControllerFqcnPrefixingSessionAttributeStoreTestController.class.getMethod("handlerMethod")); 
        PostBackManager.begin(request, handler); 
    } 
 
    @Test 
    public void コントローラのFQCN付き属性キーでセッションに保存() { 
        ControllerFqcnPrefixingSessionAttributeStore store = new ControllerFqcnPrefixingSessionAttributeStore(); 
        store.storeAttribute(webRequest, "test", "test"); 
        HttpSession session = request.getSession(); 
        String s = (String) session.getAttribute(ControllerFqcnPrefixingSessionAttributeStoreTestController.class.getName() + ".test"); 
        assertThat(s, is("test")); 
    } 
 
    @Test 
4
CodeRank
This code example shows how to use the following methods:
	} 
	 
	@Test
	public void testHandleWithDefaultPolicy() throws Exception {
		 
		final HandlerMethod handler = new HandlerMethod(
				controller, 
				controller.getClass().getMethod("handleWithDefaultPolicy"));
		 
		assertNotNull(interceptor.getCacheControl(null, null, handler));
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getMethodAnnotation
            return true; 
        } 
    } 
 
    private void internalPreProcess(HandlerMethod handlerMethod, HttpServletRequest request) { 
        Token token = handlerMethod.getMethodAnnotation(Token.class); 
        if (token != null) { 
            if (token.check()) { 
                if (!manager.isTokenValid(request, token.scope(), token.reset())) { throw new InvalidTokenException(); } 
            } 
            if (token.save()) { 
                manager.saveToken(request, token.scope()); 
            } 
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
        request = new MockHttpServletRequest();
        response = new MockHttpServletResponse();
        TokenHandlerInterceptorTestController controller = new TokenHandlerInterceptorTestController();
        tokenSaveHanlder = new HandlerMethod(controller, TokenHandlerInterceptorTestController.class.getMethod("tokenSave"));
        tokenCheckHanlder = new HandlerMethod(controller, TokenHandlerInterceptorTestController.class.getMethod("tokenCheck"));
        tokenResetAfterCheck = new HandlerMethod(controller, TokenHandlerInterceptorTestController.class.getMethod("tokenResetAfterCheck"));
        nothing = new HandlerMethod(controller, TokenHandlerInterceptorTestController.class.getMethod("nothing"));
    } 
 
    @Test
    public void Tokenアノテーションを指定してsessionにトークンを保存する() throws Exception {
        TokenManager manager = new TokenManager();
        manager.afterPropertiesSet();
 
        TokenHandlerInterceptor tokenHandler = new TokenHandlerInterceptor();
        Field managerField = tokenHandler.getClass().getDeclaredField("manager");
        managerField.setAccessible(true);
        managerField.set(tokenHandler, manager);   
        tokenHandler.preHandle(request, response, tokenSaveHanlder);
 
3
CodeRank
This code example shows how to use the following methods:getMethodAnnotation
  public ApiOperation getApiOperationAnnotation() { 
    return this.handlerMethod.getMethodAnnotation(ApiOperation.class);
  } 
 
  public ApiParam getApiParamAnnotation() { 
    return this.handlerMethod.getMethodAnnotation(ApiParam.class);
  } 
 
  public RequestMappingInfo getRequestMappingInfo() {
    return requestMappingInfo;
  } 
 
  public HandlerMethod getHandlerMethod() {
    return handlerMethod;
  } 
 
  public Map<String, Object> getContext() {
    return context;
  } 
 
4
CodeRank
See Code Examples for Spring Framework HandlerMethod Methods: