1 5 package com.opensymphony.workflow.util; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 9 import com.opensymphony.workflow.*; 10 11 import org.apache.commons.logging.Log; 12 import org.apache.commons.logging.LogFactory; 13 14 import webwork.action.ActionContext; 15 16 import webwork.dispatcher.GenericDispatcher; 17 18 import java.security.Principal ; 19 20 import java.util.*; 21 22 23 37 public class WebWorkExecutor implements FunctionProvider { 38 40 private static final Log log = LogFactory.getLog(WebWorkExecutor.class); 41 42 44 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 45 final WorkflowContext wfContext = (WorkflowContext) transientVars.get("context"); 46 47 String actionName = (String ) args.get("action.name"); 48 GenericDispatcher gd = new GenericDispatcher(actionName); 49 gd.prepareContext(); 50 ActionContext.setPrincipal(new Principal () { 51 public String getName() { 52 return wfContext.getCaller(); 53 } 54 }); 55 ActionContext.setApplication(args); 56 ActionContext.setSession(ps.getProperties("")); 57 ActionContext.setLocale(Locale.getDefault()); 58 59 Map params = new HashMap(transientVars); 60 params.putAll(args); 61 ActionContext.setParameters(Collections.unmodifiableMap(params)); 62 63 try { 64 gd.executeAction(); 65 gd.finish(); 66 gd.finalizeContext(); 67 } catch (Exception e) { 68 throw new WorkflowException("Could not execute action " + actionName, e); 69 } 70 } 71 } 72 | Popular Tags |