1 5 package com.opensymphony.workflow.util; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 9 import com.opensymphony.workflow.FunctionProvider; 10 import com.opensymphony.workflow.WorkflowException; 11 12 import com.opensymphony.xwork.ActionContext; 13 import com.opensymphony.xwork.ActionProxy; 14 import com.opensymphony.xwork.ActionProxyFactory; 15 16 import java.util.Collections ; 17 import java.util.HashMap ; 18 import java.util.Locale ; 19 import java.util.Map ; 20 21 22 37 public class XWorkExecutor implements FunctionProvider { 38 40 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 41 String actionName = (String ) args.get("action.name"); 42 String namespace = (String ) args.get("namespace"); 43 44 Map extraContext = new HashMap (); 45 extraContext.put(ActionContext.APPLICATION, args); 46 extraContext.put(ActionContext.SESSION, ps.getProperties("")); 47 extraContext.put(ActionContext.LOCALE, Locale.getDefault()); 48 49 Map params = new HashMap (transientVars); 50 params.putAll(args); 51 extraContext.put(ActionContext.PARAMETERS, Collections.unmodifiableMap(params)); 52 53 try { 54 ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext, false); 55 proxy.execute(); 56 } catch (Exception e) { 57 throw new WorkflowException("Could not execute action " + actionName, e); 58 } 59 } 60 } 61 | Popular Tags |