1 5 package com.opensymphony.workflow.util.ejb.local; 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 java.lang.reflect.Method ; 15 16 import java.util.Map ; 17 18 import javax.ejb.EJBHome ; 19 20 import javax.naming.InitialContext ; 21 22 import javax.rmi.PortableRemoteObject ; 23 24 25 31 public class LocalEJBFunctionProvider implements FunctionProvider { 32 34 private static final Log log = LogFactory.getLog(LocalEJBFunctionProvider.class); 35 36 38 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 39 FunctionProvider sessionBean = null; 40 String ejbLocation = (String ) args.get(AbstractWorkflow.EJB_LOCATION); 41 42 try { 43 EJBHome home = (EJBHome ) PortableRemoteObject.narrow(new InitialContext ().lookup(ejbLocation), EJBHome .class); 44 Method create = home.getClass().getMethod("create", new Class [0]); 45 sessionBean = (FunctionProvider) create.invoke(home, new Object [0]); 46 } catch (Exception e) { 47 String message = "Could not get handle to local EJB at: " + ejbLocation; 48 log.error(message, e); 49 throw new WorkflowException(message, e); 50 } 51 52 sessionBean.execute(transientVars, args, ps); 53 } 54 } 55 | Popular Tags |