Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.conn
Class ContainerPoolFactory

    java.lang.Object
      org.apache.cayenne.conn.ContainerPoolFactory

All Implemented Interfaces:
  javax.naming.spi.ObjectFactory

    public class ContainerPoolFactory

extends java.lang.Object
implements javax.naming.spi.ObjectFactory

Basic JNDI object factory that creates an instance of `PoolManager` that has been configured based on the `RefAddr` values of the specified `Reference`.

Here is a sample Tomcat 4.x configuration that sets this class as a default factory for javax.sql.DataSource objects:

`

    <ResourceParams name="jdbc/mydb">
        <parameter>
            <name>factory</name>
            <value>org.apache.cayenne.conn.ContainerPoolFactory</value>
        </parameter>

        <parameter>
            <name>username</name>
            <value>andrei</value>
        </parameter>

        <parameter>
            <name>password</name>
            <value>bla-bla</value>
        </parameter>

        <parameter>
            <name>driver</name>
            <value>org.gjt.mm.mysql.Driver</value>
        </parameter>

        <parameter>
            <name>url</name>
            <value>jdbc:mysql://noise/cayenne</value>
        </parameter>

        <parameter>
            <name>min</name>
            <value>1</value>
        </parameter>

        <parameter>
            <name>max</name>
            <value>3</value>
        </parameter>
    </ResourceParams>

`

After ContainerPoolFactory was configured to be used within the container (see above for Tomcat example), you can reference your "jdbc/mydb" DataSource in web application deployment descriptor like that (per Servlet Specification):

`

    <resource-ref>
        <es-ref-name>jdbc/mydb</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

`

Author:
  Andrei Adamchik

Constructor Summary
`ContainerPoolFactory()`

Method Summary
`java.lang.Object` | `getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)` Creates and returns a new `PoolManager` instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ContainerPoolFactory

    public ContainerPoolFactory()

Method Detail

### getObjectInstance

    public java.lang.Object getObjectInstance(java.lang.Object obj,
                                              javax.naming.Name name,
                                              javax.naming.Context nameCtx,
                                              java.util.Hashtable environment)
                                       throws java.lang.Exception

  Creates and returns a new `PoolManager` instance. If no instance can be created, returns `null` instead.

  Specified by:
    `getObjectInstance` in interface `javax.naming.spi.ObjectFactory`
  Parameters:
    `obj` - The possibly null object containing location or reference information that can be used in creating an object
    `name` - The name of this object relative to `nameCtx`
    `nameCtx` - The context relative to which the `name` parameter is specified, or `null` if `name` is relative to the default initial context
    `environment` - The possibly null environment that is used in creating this object
  Throws:
    `java.lang.Exception` - if an exception occurs creating the instance

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.