KickJava   Java API By Example, From Geeks To Geeks.

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


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 environment entry.
14  *
15  * @author letiemble
16  * @created 13 décembre 2001
17  * @version $Revision: 1.2 $
18  * @javabean:class displayName="JNDI Entry"
19  * shortDescription="JNDI Entry"
20  * @javabean:icons color16="/toolbarButtonGraphics/general/File16.gif"
21  * @javabean:property name="name"
22  * class="java.lang.String"
23  * displayName="Name"
24  * shortDescription="Name of the entry"
25  * @javabean:property name="className"
26  * class="java.lang.String"
27  * displayName="Class"
28  * shortDescription="Class of the entry"
29  * @javabean:property name="value"
30  * class="java.lang.String"
31  * displayName="Value"
32  * shortDescription="Value of the environment entry"
33  */

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

47    public JNDIEnvEntry(Context JavaDoc context, String JavaDoc jndiName)
48       throws Exception JavaDoc
49    {
50       Object JavaDoc o = context.lookup(jndiName);
51
52       Class JavaDoc clazz = o.getClass();
53       if (clazz.getName().startsWith("java.lang."))
54       {
55          this.value = o;
56       }
57       if (clazz.equals(java.net.URL JavaDoc.class))
58       {
59          this.value = o;
60       }
61       if (this.value == null)
62       {
63          throw new Exception JavaDoc("This object is not a valid environment entry");
64       }
65       this.setName(jndiName);
66       this.setClassName(clazz.getName());
67    }
68
69
70    /**
71     * Gets the value attribute of the JNDIEnvEntry object
72     *
73     * @return The value value
74     */

75    public String JavaDoc getValue()
76    {
77       return this.value.toString();
78    }
79 }
80
Popular Tags