本文整理汇总了Java中net.sourceforge.stripes.controller.ExecutionContext.getActionBeanContext方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext.getActionBeanContext方法的具体用法?Java ExecutionContext.getActionBeanContext怎么用?Java ExecutionContext.getActionBeanContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.stripes.controller.ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.getActionBeanContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
Dispatch dispatch = DispatcherUtil.getDispatch(request);
if(SecurityLogic.isAllowed(request, dispatch, actionBean, handler)) {
logger.debug("Security check passed.");
return context.proceed();
} else {
return new ForbiddenAccessResolution();
}
}
示例2: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
if (request.getDispatcherType() == DispatcherType.REQUEST) {
logger.debug("Starting page response timer");
StopWatch stopWatch = new StopWatch();
// There is no need to stop this timer.
stopWatch.start();
request.setAttribute(RequestAttributes.STOP_WATCH, stopWatch);
}
Resolution resolution = dispatch(actionContext);
return resolution != null ? resolution : context.proceed();
}
示例3: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
Object action = context.getActionBean();
ActionBeanContext actionContext = context.getActionBeanContext();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
ServletContext servletContext = actionContext.getServletContext();
Injections.inject(action, servletContext, request);
return context.proceed();
}
示例4: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
Subject subject = SecurityUtils.getSubject();
if (!SecurityLogic.satisfiesRequiresAdministrator(request, actionBean, handler)) {
return new ForbiddenAccessResolution();
}
logger.debug("Checking page permissions");
boolean isNotAdmin = !SecurityLogic.isAdministrator(request);
if (isNotAdmin) {
ServletContext servletContext = context.getActionBeanContext().getServletContext();
Configuration configuration = (Configuration) servletContext.getAttribute(BaseModule.PORTOFINO_CONFIGURATION);
Permissions permissions;
Dispatch dispatch = DispatcherUtil.getDispatch(request);
String resource;
boolean allowed;
if(dispatch != null) {
logger.debug("The protected resource is a page action");
resource = dispatch.getLastPageInstance().getPath();
allowed = SecurityLogic.hasPermissions(configuration, dispatch, subject, handler);
} else {
logger.debug("The protected resource is a plain Stripes ActionBean");
resource = request.getRequestURI();
permissions = new Permissions();
allowed = SecurityLogic.hasPermissions
(configuration, permissions, subject, handler, actionBean.getClass());
}
if(!allowed) {
logger.info("Access to {} is forbidden", resource);
return new ForbiddenAccessResolution();
}
}
logger.debug("Security check passed.");
return context.proceed();
}
示例5: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
logger.debug("Starting page response timer");
StopWatch stopWatch = new StopWatch();
// There is no need to stop this timer.
stopWatch.start();
request.setAttribute(RequestAttributes.STOP_WATCH, stopWatch);
Dispatch dispatch = DispatcherUtil.getDispatch(request);
if (dispatch != null) {
logger.debug("Preparing PageActions");
for(PageInstance page : dispatch.getPageInstancePath()) {
if(page.getParent() == null) {
logger.debug("Not preparing root");
continue;
}
if(page.isPrepared()) {
continue;
}
logger.debug("Preparing PageAction {}", page);
PageAction actionBean = ensureActionBean(page);
configureActionBean(actionBean, page, request);
try {
actionBean.setContext(actionContext);
actionBean.setPageInstance(page);
Resolution resolution = actionBean.preparePage();
if(resolution != null) {
logger.debug("PageAction prepare returned a resolution: {}", resolution);
request.setAttribute(INVALID_PAGE_INSTANCE, page);
return resolution;
}
page.setPrepared(true);
} catch (Throwable t) {
request.setAttribute(INVALID_PAGE_INSTANCE, page);
logger.error("PageAction prepare failed for " + page, t);
if(!PageActionLogic.isEmbedded(actionBean)) {
String msg = MessageFormat.format
(ElementsThreadLocals.getText("this.page.has.thrown.an.exception.during.execution"), ExceptionUtils.getRootCause(t));
SessionMessages.addErrorMessage(msg);
}
return new ForwardResolution("/m/pageactions/redirect-to-last-working-page.jsp");
}
}
PageInstance pageInstance = dispatch.getLastPageInstance();
request.setAttribute(RequestAttributes.PAGE_INSTANCE, pageInstance);
}
return context.proceed();
}