KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > util > jndi > JNDIFunctionProvider


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

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 JavaDoc;
15
16 import javax.naming.InitialContext JavaDoc;
17 import javax.naming.NamingException JavaDoc;
18
19
20 /**
21  *
22  *
23  * @author $Author: hani $
24  * @version $Revision: 1.4 $
25  */

26 public class JNDIFunctionProvider implements FunctionProvider {
27     //~ Static fields/initializers /////////////////////////////////////////////
28

29     private static final Log log = LogFactory.getLog(JNDIFunctionProvider.class);
30
31     //~ Methods ////////////////////////////////////////////////////////////////
32

33     public void execute(Map JavaDoc transientVars, Map JavaDoc args, PropertySet ps) throws WorkflowException {
34         String JavaDoc location = (String JavaDoc) 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 JavaDoc().lookup(location);
47             } catch (NamingException JavaDoc e) {
48                 provider = (FunctionProvider) new InitialContext JavaDoc().lookup("java:comp/env/" + location);
49             }
50         } catch (NamingException JavaDoc e) {
51             String JavaDoc 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