KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > media > entity > MediaEntityManagerUtil


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.media.entity;
8
9 /**
10  * Utility class for MediaEntityManager.
11  */

12 public class MediaEntityManagerUtil
13 {
14    /** Cached remote home (EJBHome). Uses lazy loading to obtain its value (loaded by getHome() methods). */
15    private static org.jboss.media.entity.MediaEntityManagerHome cachedRemoteHome = null;
16
17    /** Cached local home (EJBLocalHome). Uses lazy loading to obtain its value (loaded by getLocalHome() methods). */
18    private static org.jboss.media.entity.MediaEntityManagerLocalHome cachedLocalHome = null;
19
20    // Home interface lookup methods
21

22    /**
23     * Obtain remote home interface from default initial context
24     * @return Home interface for MediaEntityManager. Lookup using JNDI_NAME
25     */

26    public static org.jboss.media.entity.MediaEntityManagerHome getHome() throws javax.naming.NamingException JavaDoc
27    {
28       if (cachedRemoteHome == null) {
29          // Obtain initial context
30
javax.naming.InitialContext JavaDoc initialContext = new javax.naming.InitialContext JavaDoc();
31          try {
32             java.lang.Object JavaDoc objRef = initialContext.lookup(org.jboss.media.entity.MediaEntityManagerHome.JNDI_NAME);
33             cachedRemoteHome = (org.jboss.media.entity.MediaEntityManagerHome) javax.rmi.PortableRemoteObject.narrow(objRef, org.jboss.media.entity.MediaEntityManagerHome.class);
34          } finally {
35             initialContext.close();
36          }
37       }
38       return cachedRemoteHome;
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 MediaEntityManager. Lookup using JNDI_NAME
45     */

46    public static org.jboss.media.entity.MediaEntityManagerHome getHome( java.util.Hashtable JavaDoc environment ) throws javax.naming.NamingException JavaDoc
47    {
48       // Obtain initial context
49
javax.naming.InitialContext JavaDoc initialContext = new javax.naming.InitialContext JavaDoc(environment);
50       try {
51          java.lang.Object JavaDoc objRef = initialContext.lookup(org.jboss.media.entity.MediaEntityManagerHome.JNDI_NAME);
52          return (org.jboss.media.entity.MediaEntityManagerHome) javax.rmi.PortableRemoteObject.narrow(objRef, org.jboss.media.entity.MediaEntityManagerHome.class);
53       } finally {
54          initialContext.close();
55       }
56    }
57
58    /**
59     * Obtain local home interface from default initial context
60     * @return Local home interface for MediaEntityManager. Lookup using JNDI_NAME
61     */

62    public static org.jboss.media.entity.MediaEntityManagerLocalHome getLocalHome() throws javax.naming.NamingException JavaDoc
63    {
64       // Local homes shouldn't be narrowed, as there is no RMI involved.
65
if (cachedLocalHome == null) {
66          // Obtain initial context
67
javax.naming.InitialContext JavaDoc initialContext = new javax.naming.InitialContext JavaDoc();
68          try {
69             cachedLocalHome = (org.jboss.media.entity.MediaEntityManagerLocalHome) initialContext.lookup(org.jboss.media.entity.MediaEntityManagerLocalHome.JNDI_NAME);
70          } finally {
71             initialContext.close();
72          }
73       }
74       return cachedLocalHome;
75    }
76
77 }
Popular Tags