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 JNDIValidator implements Validator { 27 29 private static final Log log = LogFactory.getLog(JNDIValidator.class); 30 31 33 public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException, 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 Validator validator; 41 42 try { 43 try { 44 validator = (Validator) new InitialContext ().lookup(location); 45 } catch (NamingException e) { 46 validator = (Validator) new InitialContext ().lookup("java:comp/env/" + location); 47 } 48 } catch (NamingException e) { 49 String message = "Could not look up JNDI Validator at: " + location; 50 throw new WorkflowException(message, e); 51 } 52 53 validator.validate(transientVars, args, ps); 54 } 55 } 56 | Popular Tags |