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