01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: /*
06: * Generated file - Do not edit!
07: */
08: package com.opensymphony.workflow.spi.ejb;
09:
10: /**
11: * Utility class for CurrentStep.
12: * @author <a href="mailto:hani@formicary.net">Hani Suleiman</a>
13: * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a>
14: */
15: public class CurrentStepHomeFactory {
16: //~ Static fields/initializers /////////////////////////////////////////////
17:
18: public static final String COMP_NAME = "java:comp/env/ejb/CurrentStep";
19: public static final String JNDI_NAME = "CurrentStep";
20:
21: /** Cached local home (EJBLocalHome). Uses lazy loading to obtain its value (loaded by getLocalHome() methods). */
22: private static com.opensymphony.workflow.spi.ejb.CurrentStepLocalHome cachedLocalHome = null;
23:
24: //~ Methods ////////////////////////////////////////////////////////////////
25:
26: // Home interface lookup methods
27:
28: /**
29: * Obtain local home interface from default initial context
30: * @return Local home interface for CurrentStep. Lookup using COMP_NAME
31: */
32: public static com.opensymphony.workflow.spi.ejb.CurrentStepLocalHome getLocalHome()
33: throws javax.naming.NamingException {
34: if (cachedLocalHome == null) {
35: cachedLocalHome = (com.opensymphony.workflow.spi.ejb.CurrentStepLocalHome) lookupHome(
36: null,
37: COMP_NAME,
38: com.opensymphony.workflow.spi.ejb.CurrentStepLocalHome.class);
39: }
40:
41: return cachedLocalHome;
42: }
43:
44: private static Object lookupHome(java.util.Hashtable environment,
45: String jndiName, Class narrowTo)
46: throws javax.naming.NamingException {
47: // Obtain initial context
48: javax.naming.InitialContext initialContext = new javax.naming.InitialContext(
49: environment);
50:
51: try {
52: Object objRef = initialContext.lookup(jndiName);
53:
54: // only narrow if necessary
55: if (java.rmi.Remote.class.isAssignableFrom(narrowTo)) {
56: return javax.rmi.PortableRemoteObject.narrow(objRef,
57: narrowTo);
58: } else {
59: return objRef;
60: }
61: } finally {
62: initialContext.close();
63: }
64: }
65: }
|