tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aner <aner.pe...@ncstech.com>
Subject Naming factory for generic java beans
Date Fri, 31 Aug 2001 17:23:10 GMT
Hi,

I recently worked on getting a JDBC connection pool/DataSource working on
Tomcat 4.0b7.  I was interested in trying out the OracleConnectionCacheImpl
which Oracle provides in their JDBC drivers.

I eventually found out that the only way to make an instance of this class
available from JNDI was to create my own Factory class for it.  It seemed
to me like there should be a simpler way to do something like this so I
created a factory class (BeanFactory) which can instantiate any class which
conforms to the JavaBeans spec (i.e. most classes...).

What would I have to do to contribute this class so it ships as a standard
part of Tomcat?  The class has worked out well for my purposes but I am not
sure if the ClassLoader portion of the code is doing the right thing, I copied
it from one of the other factory classes in org.apache.naming.factory.

Using this class, I am able to make the Oracle DataSource implementation
available to all my servlets using the following xml fragment in server.xml

<DefaultContext>
  <Resource name="jdbc/myDataSource" auth="SERVLET"
    type="oracle.jdbc.pool.OracleConnectionCacheImpl"/>
  <ResourceParams name="jdbc/myDataSource">
    <parameter>
      <name>factory</name>
      <value>org.apache.naming.factory.BeanFactory</value>
    </parameter>
    <parameter><name>driverType</name><value>thin</value></parameter>
    <parameter><name>serverName</name><value>hue</value></parameter>
    <parameter><name>networkProtocol</name><value>tcp</value></parameter>

    <parameter><name>databaseName</name><value>XXXX</value></parameter>
    <parameter><name>portNumber</name><value>NNNN</value></parameter>
    <parameter><name>user</name><value>XXXX</value></parameter>
    <parameter><name>password</name><value>XXXX</value></parameter>
    <parameter><name>maxLimit</name><value>5</value></parameter>
  </ResourceParams>
</DefaultContext>

Similarly, you could make ANY JavaBean available from jndi using this factory.

I have attached my implementation to this message if anybody is interested in
getting it incorporated into Tomcat.

Thanks,

	- Aner
Mime
View raw message