当前位置: 首页>>代码示例>>Java>>正文


Java Invocation.getController方法代码示例

本文整理汇总了Java中com.jfinal.aop.Invocation.getController方法的典型用法代码示例。如果您正苦于以下问题:Java Invocation.getController方法的具体用法?Java Invocation.getController怎么用?Java Invocation.getController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jfinal.aop.Invocation的用法示例。


在下文中一共展示了Invocation.getController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {

    JbootWechatController controller = (JbootWechatController) inv.getController();

    /**
     * 是否允许访问,默认情况下只有是微信浏览器允许访问
     */
    if (controller.isAllowVisit()) {
        doIntercept(inv);
        return;
    }

    controller.doNotAlloVisitRedirect();

}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:17,代码来源:WechatUserInterceptor.java

示例2: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
    try {
        JbootWechatController controller = (JbootWechatController) inv.getController();
        ApiConfig config = controller.getApiConfig();

        if (config == null) {
            inv.getController().renderText("error : cannot get apiconfig,please config jboot.properties");
            return;
        }

        ApiConfigKit.setThreadLocalAppId(config.getAppId());
        inv.invoke();
    } finally {
        ApiConfigKit.removeThreadLocalAppId();
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:18,代码来源:WechatApiConfigInterceptor.java

示例3: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation ai) {
    Controller controller = ai.getController();
    HttpServletRequest request = controller.getRequest();
    //webRoot
    controller.setAttr("_webRootPath", request.getScheme() + "://"
            + request.getServerName() + (request.getServerPort() == 80 ? "" : ":" + request.getServerPort())
            + request.getContextPath());

    ai.invoke();

    if (!ReturnKit.isJson(controller)) {
        //local 数据
        controller.setAttr("_localParas", request.getQueryString());
        controller.setAttr("_localUri", ai.getActionKey());
    }
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:18,代码来源:URLInterceptor.java

示例4: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
public void intercept(Invocation ai) {
	Controller controller = ai.getController();
	Field[] fields = controller.getClass().getDeclaredFields();
	for (Field field : fields) {
		Object bean = null;
		if (field.isAnnotationPresent(Inject.BY_NAME.class))
			bean = ctx.getBean(field.getName());
		else if (field.isAnnotationPresent(Inject.BY_TYPE.class))
			bean = ctx.getBean(field.getType());
		else
			continue ;
		
		try {
			if (bean != null) {
				field.setAccessible(true);
				field.set(controller, bean);
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	ai.invoke();
}
 
开发者ID:OpeningO,项目名称:JFinal-ext2,代码行数:25,代码来源:IocInterceptor.java

示例5: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation ai) {
    Method actionMethod = ai.getMethod();
    WcJFinalBaseController wxJFinalBaseController = (WcJFinalBaseController) ai.getController();

    // 判断action是否需要验证用户是否登录
    if (!actionMethod.isAnnotationPresent(VerifyLogin.class)) {
        ai.invoke();
        return;
    }

    // 验证用户是否已登录
    if (wxJFinalBaseController.getMemberId() != null) {
        ai.invoke();
        return;
    }

    // 页面跳转-异步请求返回错误报文|重定向到注册
    if (FrontUtil.isAjax(wxJFinalBaseController.getRequest())) {
        DefaultStatus defaultStatus = new DefaultStatus(801, "用户未登录");
        wxJFinalBaseController.renderJson(ResultHelper.failResult(defaultStatus));
    } else {
        wxJFinalBaseController.redirect("/toRegister?sourceUrl=" + WcUtil.getSourceUrl(wxJFinalBaseController));
    }
}
 
开发者ID:efsn,项目名称:wechat-standard,代码行数:26,代码来源:AuthenticationInterceptor.java

示例6: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
public void intercept(Invocation inv) {
	Controller controller = inv.getController();
	if (!(controller instanceof MsgController))
		throw new RuntimeException("控制器需要继承 MsgController");
	
	// 如果是服务器配置请求,则配置服务器并返回
	if (isConfigServerRequest(controller)) {
		configServer(controller);
		return ;
	}
	
	// 签名检测
	if (checkSignature(controller)) {
		inv.invoke();
	} else {
		controller.renderText("签名验证失败,请确定是微信服务器在发送消息过来");
	}
}
 
开发者ID:efsn,项目名称:wechat-standard,代码行数:19,代码来源:MsgInterceptor.java

示例7: doIntercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
private void doIntercept(Invocation invocation) {
    long start = System.currentTimeMillis();
    //未安装情况下无法设置缓存
    if (!ZrlogConfig.isInstalled()) {
        invocation.getController().render("/install/index.jsp");
    } else {
        if (invocation.getController() instanceof BaseController) {
            HttpServletRequest request = invocation.getController().getRequest();
            BaseController baseController = ((BaseController) invocation.getController());
            baseController.setAttr("requrl", ZrlogUtil.getFullUrl(request));
            cacheService.refreshInitDataCache(baseController, false);
            lastAccessTime = System.currentTimeMillis();
        }
    }
    invocation.invoke();
    //开发环境下面打印整个请求的耗时,便于优化代码
    if (BlogBuildInfoUtil.isDev()) {
        LOGGER.info(invocation.getActionKey() + " used time " + (System.currentTimeMillis() - start));
    }
}
 
开发者ID:94fzb,项目名称:zrlog,代码行数:21,代码来源:InitDataInterceptor.java

示例8: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation invocation) {
    if (invocation.getController() instanceof BaseController) {
        BaseController baseController = (BaseController) invocation.getController();
        String ipStr = baseController.getStrValueByKey("blackList");
        if (ipStr != null) {
            Set<String> ipSet = new HashSet<>(Arrays.asList(ipStr.split(",")));
            String requestIP = WebTools.getRealIp(baseController.getRequest());
            if (ipSet.contains(requestIP)) {
                baseController.render(JFinal.me().getConstants().getErrorView(403));
            } else {
                invocation.invoke();
            }
        } else {
            invocation.invoke();
        }
    } else {
        invocation.invoke();
    }
}
 
开发者ID:94fzb,项目名称:zrlog,代码行数:21,代码来源:BlackListInterceptor.java

示例9: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
	try {
		inv.invoke();
	} catch(Exception e) {
		BaseController controller = (BaseController)inv.getController();
		String exceptionMessage = "Oop~ Server Exception";
		Throwable t = e.getCause();
		if(t != null) exceptionMessage = t.getMessage();
		else if(StrKit.notBlank(e.getMessage())) exceptionMessage = e.getMessage();
		else e.printStackTrace();
		controller.Error(500, isDebug ? exceptionMessage : null);
	}
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:15,代码来源:ErrorInterceptor.java

示例10: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
public void intercept(Invocation ai) {

		try {
			ai.invoke();
		} catch (Exception e) {
			log.error("异常:", e);
			Controller controller = ai.getController();
			controller.setAttr("error", e.toString());
			controller.render(Config.getStr("PAGES.500"));
		}

	}
 
开发者ID:jflyfox,项目名称:jflyfox_jfinal,代码行数:13,代码来源:ExceptionInterceptor.java

示例11: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
public void intercept(Invocation ai) {

		Controller controller = ai.getController();

		HttpServletRequest request = controller.getRequest();
		HttpSession session = request.getSession();
		Object obj = session.getAttribute(Attr.SESSION_IS_MOILE);
		if (obj == null) {
			boolean isMoile = HttpRequestDeviceUtils.isMobileDevice(request);
			session.setAttribute(Attr.SESSION_IS_MOILE, isMoile);
		}

		ai.invoke();
	}
 
开发者ID:jflyfox,项目名称:jflyfox_jfinal,代码行数:15,代码来源:SessionAttrInterceptor.java

示例12: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
public void intercept(Invocation ai) {

		Controller controller = ai.getController();

		// 设置公共属性
		if (controller instanceof BaseController) {
			BaseForm form = ((BaseController) controller).getModelByForm(BaseForm.class);
			controller.setAttr("form", form);
		}

		ai.invoke();
	}
 
开发者ID:jflyfox,项目名称:jflyfox_jfinal,代码行数:13,代码来源:JflyfoxInterceptor.java

示例13: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
/**
 * 参数处理
 * 1. 参数为空时直接调用
 * 2. 参数不为空时先判断是否使用?间隔,使用了?间隔先split一下参数,拿到?之前的参数,查找是否有这个action。没有就404,有就直接invoke
 */
@Override
public void intercept(Invocation ai) {
	// 获取controller
	Controller controller = ai.getController();
	// 获取controller 的参数
	String param = controller.getPara();
	if (param == null) {
		ai.invoke();
	} else {
		String[] params = null;
		if (param.contains("?")) {
			params = param.split("?");
		}
		if (params != null) {
			param = params[0];
		}
		
		boolean contained = false;
		Method[] methods = controller.getClass().getMethods();
		for (Method method : methods) {
			if (param.equals(method.getName())) {
				contained = true;
				break;
			}
		}
		if (!contained){
			controller.renderError(404);
		} 
		ai.invoke();
	}
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:37,代码来源:NotFoundActionInterceptor.java

示例14: intercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation ai) {
    String actionKey = ai.getActionKey();
    Controller c = ai.getController();
    LogConfig log = acitonLogs.get(actionKey);
    if (log != null) {
        logFromConfig(c, log);
    }
    ai.invoke();
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:11,代码来源:SysLogInterceptor.java

示例15: doIntercept

import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes"})
public void doIntercept(Invocation ai) {
    rule = configRule();
    Controller controller = ai.getController();
    List<Model<?>> list = PoiImporter.processSheet(controller.getFile().getFile(), rule, clazz);
    execPreListProcessor(list);
    for (Model<?> model : list) {
        execPreExcelProcessor(model);
        callback((M) model);
        execPostExcelProcessor(model);
    }
    execPostListProcessor(list);
    ai.invoke();
}
 
开发者ID:jayqqaa12,项目名称:jbase,代码行数:15,代码来源:ExcelUploadInterceptor.java


注:本文中的com.jfinal.aop.Invocation.getController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。