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 RemoteEJBValidator implements Validator { 34 36 private static final Log log = LogFactory.getLog(RemoteEJBValidator.class); 37 38 40 public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException, WorkflowException { 41 String ejbLocation = (String ) args.get(AbstractWorkflow.EJB_LOCATION); 42 43 ValidatorRemote 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 = (ValidatorRemote) create.invoke(home, new Object [0]); 49 } catch (Exception e) { 50 String message = "Could not get handle to remote EJB validator: " + ejbLocation; 51 log.error(message, e); 52 throw new WorkflowException(message, e); 53 } 54 55 try { 56 sessionBean.validate(transientVars, args, ps); 57 } catch (RemoteException e) { 58 String message = "Remote exception while executing remote EJB validator: " + ejbLocation; 59 throw new WorkflowException(message, e); 60 } 61 } 62 } 63 | Popular Tags |