1 5 package com.opensymphony.workflow.util.jndi; 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.util.Map ; 15 16 import javax.naming.InitialContext ; 17 import javax.naming.NamingException ; 18 19 20 26 public class JNDIFunctionProvider implements FunctionProvider { 27 29 private static final Log log = LogFactory.getLog(JNDIFunctionProvider.class); 30 31 33 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 34 String location = (String ) args.get(AbstractWorkflow.JNDI_LOCATION); 35 36 if (location == null) { 37 throw new WorkflowException(AbstractWorkflow.JNDI_LOCATION + " argument is null"); 38 } 39 40 location = location.trim(); 41 42 FunctionProvider provider; 43 44 try { 45 try { 46 provider = (FunctionProvider) new InitialContext ().lookup(location); 47 } catch (NamingException e) { 48 provider = (FunctionProvider) new InitialContext ().lookup("java:comp/env/" + location); 49 } 50 } catch (NamingException e) { 51 String message = "Could not get handle to JNDI FunctionProvider at: " + location; 52 throw new WorkflowException(message, e); 53 } 54 55 provider.execute(transientVars, args, ps); 56 } 57 } 58 | Popular Tags |