1 5 package com.opensymphony.workflow.util.jndi; 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.util.Map ; 14 15 import javax.naming.InitialContext ; 16 import javax.naming.NamingException ; 17 18 19 25 public class JNDIRegister implements Register { 26 28 private static final Log log = LogFactory.getLog(JNDIRegister.class); 29 30 32 public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException { 33 String location = (String ) args.get(AbstractWorkflow.JNDI_LOCATION); 34 35 if (location == null) { 36 throw new WorkflowException(AbstractWorkflow.JNDI_LOCATION + " argument is null"); 37 } 38 39 Register r; 40 41 try { 42 try { 43 r = (Register) new InitialContext ().lookup(location); 44 } catch (NamingException e) { 45 r = (Register) new InitialContext ().lookup("java:comp/env/" + location); 47 } 48 } catch (NamingException e) { 49 String message = "Could not look up JNDI register at: " + location; 50 throw new WorkflowException(message, e); 51 } 52 53 return r.registerVariable(context, entry, args); 54 } 55 } 56 | Popular Tags |