Author: aadamchik Date: Sat Feb 19 21:01:32 2011 New Revision: 1072439 URL: http://svn.apache.org/viewvc?rev=1072439&view=rev Log: deprecating unused JNDI ObjectFactory for a DataSource.
we'll no longer pretend we are in the appserver business Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ContainerPoolFactory.java Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ContainerPoolFactory.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ContainerPoolFactory.java?rev=1072439&r1=1072438&r2=1072439&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ContainerPoolFactory.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ContainerPoolFactory.java Sat Feb 19 21:01:32 2011 @@ -27,15 +27,17 @@ import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; - /** - * <p>Basic JNDI object factory that creates an instance of - * <code>PoolManager</code> that has been configured based on the - * <code>RefAddr</code> values of the specified <code>Reference</code>.</p> - * - * <p>Here is a sample Tomcat 4.x configuration that sets this class - * as a default factory for javax.sql.DataSource objects:</p> -<code><pre> + * <p> + * Basic JNDI object factory that creates an instance of <code>PoolManager</code> that has + * been configured based on the <code>RefAddr</code> values of the specified + * <code>Reference</code>. + * </p> + * <p> + * Here is a sample Tomcat 4.x configuration that sets this class as a default factory for + * javax.sql.DataSource objects: + * </p> + * <code><pre> <ResourceParams name="jdbc/mydb"> <parameter> <name>factory</name> @@ -73,39 +75,47 @@ import javax.naming.spi.ObjectFactory; </parameter> </ResourceParams> </pre></code> - * - * <p>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): </p> + * <p> + * 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): + * </p> *<code><pre> <resource-ref> <es-ref-name>jdbc/mydb</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> -</pre></code> - * +</pre></code> + * + * @deprecated since 3.1. This class does not belong in Cayenne, as Cayenne no longer + * attempts to provide appserver pieces. End users should not need this class + * and should use their container's preferred approach to map a DataSource + * instead. */ public class ContainerPoolFactory implements ObjectFactory { /** - * <p>Creates and returns a new <code>PoolManager</code> instance. If no - * instance can be created, returns <code>null</code> instead.</p> - * - * @param obj The possibly null object containing location or - * reference information that can be used in creating an object + * <p> + * Creates and returns a new <code>PoolManager</code> instance. If no instance can be + * created, returns <code>null</code> instead. + * </p> + * + * @param obj The possibly null object containing location or reference information + * that can be used in creating an object * @param name The name of this object relative to <code>nameCtx</code> - * @param nameCtx The context relative to which the <code>name</code> - * parameter is specified, or <code>null</code> if <code>name</code> - * is relative to the default initial context - * @param environment The possibly null environment that is used in - * creating this object - * + * @param nameCtx The context relative to which the <code>name</code> parameter is + * specified, or <code>null</code> if <code>name</code> is relative to the + * default initial context + * @param environment The possibly null environment that is used in creating this + * object * @exception Exception if an exception occurs creating the instance */ - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable environment) - throws Exception { + public Object getObjectInstance( + Object obj, + Name name, + Context nameCtx, + Hashtable environment) throws Exception { // We only know how to deal with <code>javax.naming.Reference</code>s // that specify a class name of "javax.sql.DataSource" if ((obj == null) || !(obj instanceof Reference)) { @@ -126,24 +136,22 @@ public class ContainerPoolFactory implem int max = 1; String username = null; String password = null; - + ra = ref.get("min"); if (ra != null) { min = Integer.parseInt(ra.getContent().toString()); } - + ra = ref.get("max"); if (ra != null) { max = Integer.parseInt(ra.getContent().toString()); } - ra = ref.get("driver"); if (ra != null) { driver = ra.getContent().toString(); } - ra = ref.get("password"); if (ra != null) { password = ra.getContent().toString(); @@ -162,4 +170,3 @@ public class ContainerPoolFactory implem return new PoolManager(driver, url, min, max, username, password); } } -