1 package indyjug.jboss.ejb;
2 
3 public class StockTraderUtil
4 {
5     private static StockTraderHome cachedRemoteHome = null;
6 
7     /**
8      * Obtain remote home interface from default initial context
9      * @return Home interface for MileageManager. Lookup using COMP_NAME
10     */
11    public static StockTraderHome getHome() throws javax.naming.NamingException
12    {
13        if (cachedRemoteHome == null)
14        {
15            // Obtain initial context
16            javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
17
18            try
19            {
20                java.lang.Object objRef = initialContext.lookup(StockTraderHome.COMP_NAME);
21                cachedRemoteHome = (StockTraderHome)javax.rmi.PortableRemoteObject.narrow(objRef,
22                        StockTraderHome.class);
23            }
24            finally
25            {
26                initialContext.close();
27            }
28        }
29
30        return cachedRemoteHome;
31    }
32
33    /**
34     * Obtain remote home interface from parameterised initial context
35     * @param environment Parameters to use for creating initial context
36     * @return Home interface for MileageManager. Lookup using COMP_NAME
37     */
38    public static StockTraderHome getHome(java.util.Hashtable environment)
39        throws javax.naming.NamingException
40    {
41        // Obtain initial context
42        javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
43
44        try
45        {
46            java.lang.Object objRef = initialContext.lookup(StockTraderHome.COMP_NAME);
47
48            return (StockTraderHome)javax.rmi.PortableRemoteObject.narrow(objRef,
49                StockTraderHome.class);
50        }
51        finally
52        {
53            initialContext.close();
54        }
55    }
56}
57