當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerMethod.getBeanType方法代碼示例

本文整理匯總了Java中org.springframework.web.method.HandlerMethod.getBeanType方法的典型用法代碼示例。如果您正苦於以下問題:Java HandlerMethod.getBeanType方法的具體用法?Java HandlerMethod.getBeanType怎麽用?Java HandlerMethod.getBeanType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.method.HandlerMethod的用法示例。


在下文中一共展示了HandlerMethod.getBeanType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isAsyncRequest

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
/**
 * 判斷請求是否是異步請求
 * @param request
 * @param handler
 * @return
 */
public static boolean isAsyncRequest(HttpServletRequest request, Object handler){
	boolean isAsync = false;
	if(handler instanceof HandlerMethod){
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		isAsync = handlerMethod.hasMethodAnnotation(ResponseBody.class);
		if(!isAsync){
			Class<?> controllerClass = handlerMethod.getBeanType();
			isAsync = controllerClass.isAnnotationPresent(ResponseBody.class) || controllerClass.isAnnotationPresent(RestController.class);
		}
		if(!isAsync){
			isAsync = ResponseEntity.class.equals(handlerMethod.getMethod().getReturnType());
		}
	}
	if(!isAsync){
		isAsync = HttpUtils.isAsynRequest(request);
	}
	return isAsync;
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:25,代碼來源:SpringMvcUtils.java

示例2: getAnnotation

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
private Auth getAnnotation(HandlerMethod handlerMethod) {
    Auth annotation = handlerMethod.getMethodAnnotation(Auth.class);

    Class<?> beanType = handlerMethod.getBeanType();
    if (beanType.isAnnotationPresent(Auth.class)) {
        annotation = beanType.getAnnotation(Auth.class);
    }
    return annotation;
}
 
開發者ID:XiaoMi,項目名稱:shepher,代碼行數:10,代碼來源:AuthorizationInterceptor.java

示例3: getInterceptors

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
private List<? extends HandlerInterceptor> getInterceptors(HttpServletRequest request, Object handler) {
    if (handler instanceof HandlerMethod) {
        HandlerMethod hm = (HandlerMethod) handler;

        Class<?> c = hm.getBeanType();
        Method method = hm.getMethod();

        List<? extends HandlerInterceptor> interceptors = interceptorCaches.get(method);
        if (interceptors == null) {
            interceptors = searchInterceptors(c, method, request);
        }
        return interceptors;
    }
    return null;
}
 
開發者ID:cyanqueen,項目名稱:backbone,代碼行數:16,代碼來源:AnnotationBasedProcessorInterceptor.java

示例4: preHandle

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
	ReturnUtil returnUtil = ReturnUtil.init();
	if(handler instanceof HandlerMethod) {
		HandlerMethod hm = (HandlerMethod) handler;
		Class<?> clazz = hm.getBeanType();
		Method m = hm.getMethod();
		try{
			if(clazz != null && m != null){
				boolean isClzAnnotation = clazz.isAnnotationPresent(Authority.class);
				boolean isMethondAnnotation = m.isAnnotationPresent(Authority.class);
				Authority authority = null;
				// 如果方法和類聲明中同時存在這個注解,那麽方法中的會覆蓋類中的設定。
				if(isMethondAnnotation){
					authority = m.getAnnotation(Authority.class);
				}else if(isClzAnnotation){
					authority = clazz.getAnnotation(Authority.class);
				}
				
				JSONObject handlerJson = JSONObject.parseObject(JSONObject.toJSONString(handler));
				if(authority != null){
					if(defaultAuthorityInterface == null){
						defaultAuthorityInterface = new DefaultAuthorityInterfaceImpl();
					}
					if(AuthorityType.NoValidate == authority.value()){
						returnUtil = defaultAuthorityInterface.NoValidate(request, response, handlerJson);// 標記為不驗證,放行
					}else if(AuthorityType.NoAuthority == authority.value()){
						returnUtil = defaultAuthorityInterface.NoAuthority(request, response, handlerJson);// TODO: 不驗證權限,驗證是否登錄
					}else{
						returnUtil = defaultAuthorityInterface.Validate(request, response, handlerJson);// TODO: 驗證登錄及權限
					}
				}
				if(authority!=null && AuthorityType.Validate == authority.value() && Statics.Record_System_Log && returnUtil.getCode()==ReturnUtil.SUCCESS_CODE && authority.addLog()){
					addSystemLog(request, returnUtil, handlerJson,authority.explain().equals("")?returnUtil.gDataMap().get("name").toString():authority.explain());
				}
				if(returnUtil ==null || returnUtil.getCode()==ReturnUtil.SUCCESS_CODE){
					 if(Statics.out_implement_time){
						 request.setAttribute("start_implement_time", System.currentTimeMillis());
						 request.setAttribute("implement_method_name", handlerJson.getString("beanType")+"."+handlerJson.getJSONObject("method").getString("name"));
					 }
					return true;
				}
				response.setCharacterEncoding("UTF-8");
				response.setContentType("application/json; charset=utf-8");
			}
		}catch (Exception e){
			returnUtil.addError("請求異常:"+e.toString());
		}
	}
	DataUtil.OutStreamByResponse(response, returnUtil.toString());
	return false;
}
 
開發者ID:zhiqiang94,項目名稱:BasicsProject,代碼行數:53,代碼來源:AuthorityAnnotationInterceptor.java


注:本文中的org.springframework.web.method.HandlerMethod.getBeanType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。