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


Java Invocation类代码示例

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


Invocation类属于com.jfinal.aop包,在下文中一共展示了Invocation类的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包/类
public void intercept(Invocation inv) {
    JCache cache = getCache();
    Jedis jedis = cache.getThreadLocalJedis();
    if (jedis != null) {
        inv.invoke();
        return ;
    }

    try {
        jedis = cache.jedisPool.getResource();
        cache.setThreadLocalJedis(jedis);
        inv.invoke();
    }
    finally {
        cache.removeThreadLocalJedis();
        jedis.close();
    }
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:19,代码来源:JRedisInterceptor.java

示例4: 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

示例5: 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

示例6: intercept

import com.jfinal.aop.Invocation; //导入依赖的package包/类
@Override
public void intercept(final Invocation inv) {
	Db.tx(new IAtom() {
		@Override
		public boolean run() throws SQLException {
			try {
				inv.invoke();
			} catch (Exception e) {
				if (inv.getTarget() instanceof ControllerExt) {
					ControllerExt controller = inv.getTarget();
					controller.onExceptionError(e);
				}
				return false;
			}
			return true;
		}
	});
}
 
开发者ID:OpeningO,项目名称:JFinal-ext2,代码行数:19,代码来源:DbTxInterceptor.java

示例7: 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

示例8: 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

示例9: intercept

import com.jfinal.aop.Invocation; //导入依赖的package包/类
@Override
public void intercept(Invocation inv) {
    if(inv.getActionKey().equals("/")){
        inv.getController().render("/login/login.html");
    }else if(inv.getActionKey().equals("/users/login")){
        inv.invoke();
    }else {
        String uid = inv.getController().getPara("uid");
        if(uid!=null) {
            int prefix = uid.indexOf("#");
            if (prefix > 0) {
                uid = uid.replace("#", "");
            }
            if (uid != null) {
                List<UserModel> users = UserModel.me.find("select * from bee_users where uid=?", uid);
                if (users.size() == 1) {
                    inv.getController().setAttr("userid", users.get(0).get("id"));
                    inv.getController().setAttr("usergroup", users.get(0).get("workgroup"));
                    inv.invoke();
                    return;
                }
            }
        }
        inv.getController().renderText("{'issuccess':false,'data':{},'message':'身份验证失败,请重新登陆.'}");
    }
}
 
开发者ID:guangchiguangchi,项目名称:little-bee,代码行数:27,代码来源:LoginInterceptor.java

示例10: intercept

import com.jfinal.aop.Invocation; //导入依赖的package包/类
@Override
public void intercept(Invocation invocation) {
    try {
        String actionKey = invocation.getActionKey();
        //这样写一点页不优雅,路径少还好,多了就痛苦了
        if (actionKey.startsWith("/admin") || actionKey.startsWith("/api/admin")) {
            adminInterceptor.intercept(invocation);
        } else {
            visitorInterceptor.intercept(invocation);
        }
    } catch (Exception e) {
        e.printStackTrace();
        invocation.getController().renderError(500);
        LOGGER.error("interceptor exception ", e);
    }
}
 
开发者ID:94fzb,项目名称:zrlog,代码行数:17,代码来源:RouterInterceptor.java

示例11: 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

示例12: 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

示例13: blockUnLoginRequestHandler

import com.jfinal.aop.Invocation; //导入依赖的package包/类
private void blockUnLoginRequestHandler(Invocation ai) {
    if (ai.getActionKey().startsWith("/api")) {
        ExceptionResponse exceptionResponse = new ExceptionResponse();
        exceptionResponse.setError(1);
        exceptionResponse.setMessage(I18NUtil.getStringFromRes("admin.session.timeout", ai.getController().getRequest()));
        ai.getController().renderJson(exceptionResponse);
    } else {
        //在重定向到登陆页面时,同时携带了当前的请求路径,方便登陆成功后的跳转
        HttpServletRequest request = ai.getController().getRequest();
        try {
            String url = request.getRequestURL().toString();
            if (WebTools.getRealScheme(request).equals("https")) {
                url = "https://" + request.getHeader("Host") + request.getRequestURI();
                if (StringUtils.isNotEmpty(request.getQueryString())) {
                    url += "?" + request.getQueryString();
                }
            }
            ai.getController().redirect(request.getContextPath()
                    + "/admin/login?redirectFrom="
                    + url + URLEncoder.encode(request.getQueryString() != null ? "?" + request.getQueryString() : "", "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            LOGGER.error("", e);
        }
    }
}
 
开发者ID:94fzb,项目名称:zrlog,代码行数:26,代码来源:AdminInterceptor.java

示例14: tryDoRender

import com.jfinal.aop.Invocation; //导入依赖的package包/类
/**
 * 尝试通过Controller的放回值来进行数据的渲染
 *
 * @param ai
 * @param controller
 * @return true 表示已经渲染数据了,false 表示并未按照约定编写,及没有进行渲染
 */
private boolean tryDoRender(Invocation ai, Controller controller) {
    Object returnValue = ai.getReturnValue();
    boolean rendered = false;
    if (returnValue != null) {
        if (ai.getActionKey().startsWith("/api/admin")) {
            controller.renderJson(ai.getReturnValue());
            rendered = true;
        } else if (ai.getActionKey().startsWith("/admin") && returnValue instanceof String) {
            if (JFinal.me().getConstants().getViewType() == ViewType.JSP) {
                String templatePath = returnValue.toString() + ".jsp";
                if (new File(PathKit.getWebRootPath() + templatePath).exists()) {
                    controller.render(templatePath);
                    rendered = true;
                } else {
                    rendered = false;
                }
            }
        }
    } else {
        rendered = true;
    }
    return rendered;
}
 
开发者ID:94fzb,项目名称:zrlog,代码行数:31,代码来源:AdminInterceptor.java

示例15: 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


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