KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > model > sql > DataSourceProxy


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.sql;
8
9 import java.sql.SQLException JavaDoc;
10
11 import javax.naming.Context JavaDoc;
12 import javax.rmi.PortableRemoteObject JavaDoc;
13 import javax.sql.DataSource JavaDoc;
14
15 import org.ejtools.jndi.browser.model.JNDIContext;
16
17 /**
18  * Describe a mail session.
19  *
20  * @author letiemble
21  * @created 13 décembre 2001
22  * @version $Revision: 1.2 $
23  * @todo Javadoc to complete
24  * @javabean:class displayName="Data Source"
25  * shortDescription="Data Source"
26  * @javabean:icons color16="/toolbarButtonGraphics/development/JDBCDataSource16.gif"
27  * @javabean:property name="name"
28  * class="java.lang.String"
29  * displayName="Name"
30  * shortDescription="Name of the entry"
31  * @javabean:property name="className"
32  * class="java.lang.String"
33  * displayName="Class"
34  * shortDescription="Class of the entry"
35  * @javabean:property name="loginTimeout"
36  * class="int"
37  * displayName="Login Timeout"
38  * shortDescription="Login Timeout of the DataSource"
39  */

40 public class DataSourceProxy extends JNDIContext
41 {
42    /** Description of the Field */
43    protected DataSource JavaDoc source;
44
45
46    /**
47     * Constructor for the SessionProxy object
48     *
49     * @param context Description of the Parameter
50     * @param jndiName Description of the Parameter
51     * @exception Exception Description of the Exception
52     */

53    public DataSourceProxy(Context JavaDoc context, String JavaDoc jndiName)
54       throws Exception JavaDoc
55    {
56       // Try to narrow to an EJBHome class
57
Object JavaDoc o = context.lookup(jndiName);
58       source = (DataSource JavaDoc) PortableRemoteObject.narrow(o, DataSource JavaDoc.class);
59
60       this.setName(jndiName);
61       this.setClassName(source.getClass().getName());
62    }
63
64
65    /**
66     * Gets the loginTimeout attribute of the DataSourceProxy object
67     *
68     * @return The loginTimeout value
69     */

70    public int getLoginTimeout()
71    {
72       try
73       {
74          return this.source.getLoginTimeout();
75       }
76       catch (SQLException JavaDoc sqle)
77       {
78       }
79       return -1;
80    }
81 }
82
Popular Tags