本文整理汇总了Java中com.jfinal.aop.Invocation.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java Invocation.invoke方法的具体用法?Java Invocation.invoke怎么用?Java Invocation.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jfinal.aop.Invocation
的用法示例。
在下文中一共展示了Invocation.invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例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());
}
}
示例4: 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));
}
}
示例5: 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':'身份验证失败,请重新登陆.'}");
}
}
示例6: 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();
}
}
示例7: 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);
}
}
示例8: intercept
import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
if (!config.isServerEnable()) {
inv.getController().renderJson(Ret.fail("msg", "sorry, you have no permission to visit this page. "));
return;
}
inv.invoke();
}
示例9: intercept
import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
ZkClient zkClient=inv.getController().getSessionAttr("zk-client");
if(zkClient!=null) {
inv.invoke();
}else{
inv.getController().redirect("/index.html");
}
}
示例10: intercept
import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
logger.info("================Before invoking:{}", inv.getActionKey());
inv.invoke();
logger.info("================After invoking:{}", inv.getActionKey());
}
示例11: 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"));
}
}
示例12: 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();
}
示例13: 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();
}
示例14: intercept
import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation inv) {
AuthzHandler ah = ShiroKit.getAuthzHandler(inv.getActionKey());
// 存在访问控制处理器。
if (ah != null) {
try {
// 执行权限检查。
ah.assertAuthorized();
} catch (UnauthenticatedException lae) {
// RequiresGuest,RequiresAuthentication,RequiresUser,未满足时,抛出未经授权的异常。
// 如果没有进行身份验证,返回HTTP401状态码
inv.getController().renderError(401);
return;
} catch (AuthorizationException ae) {
// RequiresRoles,RequiresPermissions授权异常
// 如果没有权限访问对应的资源,返回HTTP状态码403。
inv.getController().renderError(403);
return;
} catch (Exception e) {
// 出现了异常,应该是没有登录。
inv.getController().renderError(401);
return;
}
}
// 执行正常逻辑
inv.invoke();
}
示例15: intercept
import com.jfinal.aop.Invocation; //导入方法依赖的package包/类
@Override
public void intercept(Invocation ai) {
try {
ai.invoke();
} catch (Exception e) {
ExceptionRender exceptionRender = matchRender(e);
if (exceptionRender == null) {
exceptionRender = defaultRender;
}
if (exceptionRender != null) {
ai.getController().render(exceptionRender.setException(e));
}
}
}