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 RemoteEJBCondition implements Condition { 34 36 private static final Log log = LogFactory.getLog(RemoteEJBCondition.class); 37 38 40 public boolean passesCondition(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 41 String ejbLocation = (String ) args.get(AbstractWorkflow.EJB_LOCATION); 42 43 ConditionRemote sessionBean = null; 44 45 try { 46 EJBHome home = (EJBHome ) PortableRemoteObject.narrow(new InitialContext ().lookup(ejbLocation), EJBHome .class); 47 Method create = home.getClass().getMethod("create", new Class [0]); 48 sessionBean = (ConditionRemote) create.invoke(home, new Object [0]); 49 } catch (Exception e) { 50 String message = "Could not get handle to Remote Condition: " + ejbLocation; 51 throw new WorkflowException(message, e); 52 } 53 54 try { 55 return sessionBean.passesCondition(transientVars, args, ps); 56 } catch (RemoteException e) { 57 String message = "Remote exception encountered while executing Remote Condition: " + ejbLocation; 58 throw new WorkflowException(message, e); 59 } 60 } 61 } 62 | Popular Tags |