KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > hibernate > ejb > interfaces > AggregateProfileServiceUtil


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.hibernate.ejb.interfaces;
8
9 /**
10  * Utility class for ProfileService.
11  */

12 public class AggregateProfileServiceUtil
13 {
14
15    private static Object JavaDoc lookupHome(java.util.Hashtable JavaDoc environment, String JavaDoc jndiName, Class JavaDoc narrowTo) throws javax.naming.NamingException JavaDoc {
16       // Obtain initial context
17
javax.naming.InitialContext JavaDoc initialContext = new javax.naming.InitialContext JavaDoc(environment);
18       try {
19          Object JavaDoc objRef = initialContext.lookup(jndiName);
20          // only narrow if necessary
21
if (narrowTo.isInstance(java.rmi.Remote JavaDoc.class))
22             return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
23          else
24             return objRef;
25       } finally {
26          initialContext.close();
27       }
28    }
29
30    // Home interface lookup methods
31

32    /**
33     * Obtain remote home interface from default initial context
34     * @return Home interface for ProfileService. Lookup using JNDI_NAME
35     */

36    public static AggregateProfileServiceHome getHome() throws javax.naming.NamingException JavaDoc
37    {
38          return (AggregateProfileServiceHome) lookupHome(null, AggregateProfileServiceHome.JNDI_NAME, AggregateProfileServiceHome.class);
39    }
40
41    /**
42     * Obtain remote home interface from parameterised initial context
43     * @param environment Parameters to use for creating initial context
44     * @return Home interface for ProfileService. Lookup using JNDI_NAME
45     */

46    public static AggregateProfileServiceHome getHome( java.util.Hashtable JavaDoc environment ) throws javax.naming.NamingException JavaDoc
47    {
48        return (AggregateProfileServiceHome) lookupHome(environment, AggregateProfileServiceHome.JNDI_NAME, AggregateProfileServiceHome.class);
49    }
50
51 }
Popular Tags