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