public class SessionInterceptor extends AbstractInterceptor { @Override public String intercept(ActionInvocation invocation) throws Exception { Map<String,Object> session = invocation.getInvocationContext().getSession(); if(session.isEmpty()) return "session"; // session is empty/expired return invocation.invoke(); }
public StrutsConversationAdapter(ActionInvocation invocation, ConversationContextManager conversationContextManager) { this.invocation = invocation; this.actionContext = invocation.getInvocationContext(); this.conversationContextManager = conversationContextManager; }
public abstract class ThreadUnsafeInterceptor extends AbstractInterceptor { private Map<String, Object> session; // <!-- Thread Unsafe public final String intercept(ActionInvocation invocation) throws Exception { session = invocation.getInvocationContext().getSession(); /* Do stuff */ System.out.println(session.get("myObject")); return invocation.invoke(); } }
public abstract class ThreadSafeInterceptor extends AbstractInterceptor { public final String intercept(ActionInvocation invocation) throws Exception { Map<String, Object> session; // <!-- Thread Safe session = invocation.getInvocationContext().getSession(); /* Do stuff */ System.out.println(session.get("myObject")); return invocation.invoke(); } }
/** * Save the given locale to the ActionInvocation. * * @param invocation The ActionInvocation. * @param locale The locale to save. */ protected void saveLocale(ActionInvocation invocation, Locale locale) { invocation.getInvocationContext().setLocale(locale); }
public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); // ... }
public String intercept(ActionInvocation invocation) throws Exception { Map session = invocation.getInvocationContext().getSession() Object loginObject = session.getAttribute("login"); if (loginObject == null) { return LOGIN; } return invocation.invoke(); }
@Override public String intercept(ActionInvocation ai) throws Exception { final ActionContext context = ai.getInvocationContext(); HttpServletRequest request = (HttpServletRequest)context.get(StrutsStatics.HTTP_REQUEST); request.setAttribute("redirUrl", "http://the.new.target.org"); return "redir"; }
@Override protected String doIntercept(ActionInvocation actionInvocation) throws Exception { String invoke = actionInvocation.invoke(); HttpServletResponse response = (HttpServletResponse) actionInvocation.getInvocationContext() .get(StrutsStatics.HTTP_RESPONSE); log.debug("Set struts header response status to: {}", response.getStatus()); response.addHeader(HEADER_STRUTS_STATUS_CODE, "" + response.getStatus()); return invoke; } }
public String intercept(ActionInvocation invocation) throws Exception { final ActionContext context = invocation.getInvocationContext(); Map<String,Object> parameters = (Map<String,Object>)context.get(ActionContext.PARAMETERS); Map<String, Object> parametersCopy = new HashMap<String, Object>(); parametersCopy.putAll(parameters); parametersCopy.put("myParam", "changedValue"); context.put(ActionContext.PARAMETERS, parametersCopy); return invocation.invoke(); }
public void execute(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); AgiActionName action = History.repeat(context); AgiEntryPoint.setNextAction(context, action); } }
protected Locale readStoredLocalFromCurrentInvocation(ActionInvocation invocation) { // no overriding locale definition found, stay with current invocation (=browser) locale Locale locale = invocation.getInvocationContext().getLocale(); if (locale != null && LOG.isDebugEnabled()) { LOG.debug("applied invocation context locale=#0", locale); } return locale; }
public void execute(ActionInvocation action) throws Exception { Class<?> c = getTemplateClassForTargetName(); if (c == null) { System.err.println("no such template: " + _target); return; } ActionContext context = action.getInvocationContext(); AgiTemplate template = buildTemplateInstance(context, c); AgiActionName nextAction = executeTemplate(context, template); if (nextAction != null) AgiEntryPoint.setNextAction(context, nextAction); }
@Override public String intercept(ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX); if (null != reqCtx) { Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG); Locale locale = new Locale(currentLang.getCode(), ""); invocation.getInvocationContext().setLocale(locale); } return invocation.invoke(); }
public void beforeResult(ActionInvocation invocation, String resultCode) { Map<Object, Object> fakie = (Map<Object, Object>) invocation.getInvocationContext().get(ORIGINAL_PROPERTY_OVERRIDE); if (fakie != null) { invocation.getStack().setExprOverrides(fakie); } } });
public void execute(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); int count = getBackCount(context); AgiActionName action = null; for (int i = 0; i < count; i++) action = History.back(context); AgiEntryPoint.setNextAction(context, action); }
@SuppressWarnings("unchecked") public SavedActionInvocation( ActionInvocation invocation ) { namespace = invocation.getProxy().getNamespace(); actionName = invocation.getProxy().getActionName(); methodName = invocation.getProxy().getMethod(); parameterMap = new HashMap<String, Object>(); parameterMap.putAll( invocation.getInvocationContext().getParameters() ); }
@Override public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); String id = getSessionId(context); XWorkRequestAttributes attributes = new XWorkRequestAttributes(context, id); RequestContextHolder.setRequestAttributes(attributes); String result = invocation.invoke(); RequestContextHolder.resetRequestAttributes(); attributes.requestCompleted(); return result; }
private void copyStack(ActionInvocation invocation, CompoundRoot root) { List list = prepareList(root); Map<String, Object> ctxMap = invocation.getInvocationContext().getContextMap(); for (Object object : list) { if (shouldCopy(object)) { reflectionProvider.copy(object, invocation.getAction(), ctxMap, prepareExcludes(), includes); } } }
protected ActionProxy getTokenReadyActionProxy(String multipartName, File file, String actionUri) { this.preProxySetup(); this.setTokens(); ActionProxy proxy = this.getProxy(actionUri); proxy.getInvocation().getInvocationContext().setParameters(buildMultipartParams(multipartName, file)); return proxy; }