KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > model > Proxy


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;
8
9 import javax.naming.Context JavaDoc;
10
11
12 /**
13  * Describe a Proyx entry.
14  *
15  * @author letiemble
16  * @created 13 décembre 2001
17  * @version $Revision: 1.2 $
18  * @todo Javadoc to complete
19  * @javabean:class displayName="Proxy Class"
20  * shortDescription="Proxy Class"
21  * @javabean:icons color16="/toolbarButtonGraphics/general/File16.gif"
22  * @javabean:property name="name"
23  * class="java.lang.String"
24  * displayName="Name"
25  * shortDescription="Name of the entry"
26  * @javabean:property name="className"
27  * class="java.lang.String"
28  * displayName="Class"
29  * shortDescription="Class of the entry"
30  * @javabean:property name="interfaces"
31  * class="java.lang.Class"
32  * displayName="Interfaces"
33  * shortDescription="Interfaces implemented by this proxy"
34  */

35 public class Proxy extends JNDIEntry
36 {
37    /** Description of the Field */
38    protected Object JavaDoc proxy = null;
39
40
41    /**
42     * Constructor for the JNDILinkRef object
43     *
44     * @param context Description of the Parameter
45     * @param jndiName Description of the Parameter
46     * @exception Exception Description of the Exception
47     */

48    public Proxy(Context JavaDoc context, String JavaDoc jndiName)
49       throws Exception JavaDoc
50    {
51       Object JavaDoc o = context.lookup(jndiName);
52       Class JavaDoc clazz = o.getClass();
53
54       if (java.lang.reflect.Proxy.isProxyClass(clazz))
55       {
56          proxy = o;
57       }
58       else
59       {
60          if (clazz.getName().startsWith("$Proxy"))
61          {
62             proxy = o;
63          }
64       }
65
66       if (proxy == null)
67       {
68          throw new Exception JavaDoc("This object is not a proxy");
69       }
70
71       this.setName(jndiName);
72       this.setClassName(clazz.getName());
73    }
74
75
76    /**
77     * Gets the linkName attribute of the JNDILinkRef object
78     *
79     * @return The linkName value
80     */

81    public Class JavaDoc[] getInterfaces()
82    {
83       return proxy.getClass().getInterfaces();
84    }
85 }
86
Popular Tags