private static ThreadLocal<Dispatcher> instance = new ThreadLocal<Dispatcher>();
//Store the dispatcher instance for this thread. public static void setInstance(Dispatcher instance) { Dispatcher.instance.set(instance);
// Tie the ObjectFactory threadlocal instance to this Dispatcher instance if (instance != null) { Container cont = instance.getContainer(); if (cont != null) { ObjectFactory.setObjectFactory(cont.getInstance(ObjectFactory.class)); } else { LOG.warn("This dispatcher instance doesn't have a container, so the object factory won't be set."); } } else { ObjectFactory.setObjectFactory(null); } }
//Provide the dispatcher instance for the current thread. public static Dispatcher getInstance() { return instance.get(); }
// If there was a previous value stack, then create a new copy and pass it in to be used by the new Action ValueStack stack = (ValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); if (stack != null) { extraContext.put(ActionContext.VALUE_STACK, ValueStackFactory.getFactory().createValueStack(stack)); }
// if the ActionMapping says to go straight to a result, do it! if (mapping.getResult() != null) { Result result = mapping.getResult(); result.execute(proxy.getInvocation()); } else { proxy.execute(); }
// If there was a previous value stack then set it back onto the request if (stack != null) { request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); }