KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > model > ejb > EJBLocalHomeProxy


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jndi.browser.model.ejb;
8
9 import javax.ejb.EJBLocalHome JavaDoc;
10 import javax.naming.Context JavaDoc;
11 import javax.rmi.PortableRemoteObject JavaDoc;
12
13 import org.ejtools.jndi.browser.model.JNDIEntry;
14
15 /**
16  * Proxy that hide the remote aspect of the EJB Local Home interface.
17  *
18  * @author letiemble
19  * @created 13 décembre 2001
20  * @version $Revision: 1.2 $
21  * @todo Reference to Rickard Öberg
22  * @javabean:class displayName="Enterprise Java Bean"
23  * shortDescription="EJB Local Home interface"
24  * @javabean:icons color16="/toolbarButtonGraphics/development/EnterpriseJavaBeanJar16.gif"
25  * @javabean:property name="name"
26  * class="java.lang.String"
27  * displayName="Name"
28  * shortDescription="Name of the EJB Local Home"
29  * @javabean:property name="className"
30  * class="java.lang.String"
31  * displayName="Home interface"
32  * shortDescription="Class of EJB Local Home"
33  */

34 public class EJBLocalHomeProxy extends JNDIEntry
35 {
36    /** EJB Home */
37    protected EJBLocalHome JavaDoc home;
38    /** EJB Home class */
39    protected Class JavaDoc homeClass;
40
41
42    /**
43     * Create the proxy by encapsulating the EJB Home interface
44     *
45     * @param context Description of the Parameter
46     * @param jndiName Description of the Parameter
47     * @exception Exception Exception in case of errors
48     */

49    public EJBLocalHomeProxy(Context JavaDoc context, String JavaDoc jndiName)
50       throws Exception JavaDoc
51    {
52       // Try to narrow to an EJBHome class
53
Object JavaDoc o = context.lookup(jndiName);
54       home = (EJBLocalHome JavaDoc) PortableRemoteObject.narrow(o, EJBLocalHome JavaDoc.class);
55
56       // Search for the Home interface
57
Class JavaDoc[] intf = home.getClass().getInterfaces();
58       for (int i = 0; i < intf.length; i++)
59       {
60          if (EJBLocalHome JavaDoc.class.isAssignableFrom(intf[i]))
61          {
62             homeClass = intf[i];
63          }
64       }
65
66       this.setName(jndiName);
67       this.setClassName(homeClass.getName());
68    }
69
70
71    /**
72     * Implementation of toString() method.
73     *
74     * @return The name of the ejb home
75     */

76    public String JavaDoc toString()
77    {
78       return homeClass.getName().substring(homeClass.getName().lastIndexOf(".") + 1);
79    }
80
81 }
82
Popular Tags