01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.util.jndi;
06:
07: import com.opensymphony.module.propertyset.PropertySet;
08:
09: 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: *
21: *
22: * @author $Author: hani $
23: * @version $Revision: 1.4 $
24: */
25: public class JNDIValidator implements Validator {
26: //~ Static fields/initializers /////////////////////////////////////////////
27:
28: private static final Log log = LogFactory
29: .getLog(JNDIValidator.class);
30:
31: //~ Methods ////////////////////////////////////////////////////////////////
32:
33: public void validate(Map transientVars, Map args, PropertySet ps)
34: throws InvalidInputException, WorkflowException {
35: String location = (String) args
36: .get(AbstractWorkflow.JNDI_LOCATION);
37:
38: if (location == null) {
39: throw new WorkflowException(AbstractWorkflow.JNDI_LOCATION
40: + " argument is null");
41: }
42:
43: Validator validator;
44:
45: try {
46: try {
47: validator = (Validator) new InitialContext()
48: .lookup(location);
49: } catch (NamingException e) {
50: validator = (Validator) new InitialContext()
51: .lookup("java:comp/env/" + location);
52: }
53: } catch (NamingException e) {
54: String message = "Could not look up JNDI Validator at: "
55: + location;
56: throw new WorkflowException(message, e);
57: }
58:
59: validator.validate(transientVars, args, ps);
60: }
61: }
|