1 5 package com.opensymphony.workflow.util.ejb.remote; 6 7 import com.opensymphony.workflow.*; 8 import com.opensymphony.workflow.spi.WorkflowEntry; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 13 import java.lang.reflect.Method ; 14 15 import java.rmi.RemoteException ; 16 17 import java.util.Map ; 18 19 import javax.ejb.EJBHome ; 20 21 import javax.naming.InitialContext ; 22 23 import javax.rmi.PortableRemoteObject ; 24 25 26 32 public class RemoteEJBRegister implements Register { 33 35 private static final Log log = LogFactory.getLog(RemoteEJBRegister.class); 36 37 39 public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException { 40 String ejbLocation = (String ) args.get(AbstractWorkflow.EJB_LOCATION); 41 RegisterRemote sessionBean = null; 42 43 try { 44 EJBHome home = (EJBHome ) PortableRemoteObject.narrow(new InitialContext ().lookup(ejbLocation), javax.ejb.EJBHome .class); 45 Method create = home.getClass().getMethod("create", new Class [0]); 46 sessionBean = (RegisterRemote) create.invoke(home, new Object [0]); 47 } catch (Exception e) { 48 String message = "Could not get handle to remote EJB register at: " + ejbLocation; 49 throw new WorkflowException(message, e); 50 } 51 52 try { 53 return sessionBean.registerVariable(context, entry, args); 54 } catch (RemoteException e) { 55 String message = "Remote exception while executing remote EJB register: " + ejbLocation; 56 log.error(message, e); 57 throw new WorkflowException(message, e); 58 } 59 } 60 } 61 | Popular Tags |