weaver 2004/02/27 11:35:03
Modified: portal/src/java/org/apache/jetspeed/capability/containers
capability-container.groovy
Added: components/rdbms/src/java/org/apache/jetspeed/components/datasource
BoundDBCPDatasourceComponent.java
Log:
- created a Bound datasource component that takes a JNDICOmponent
as an arg in the constructor along with a bind name.
- capability-container.groovy now uses the BoundDBCPDatasourceComponent
Revision Changes Path
1.3 +6 -6
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/capability/containers/capability-container.groovy
Index: capability-container.groovy
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/capability/containers/capability-container.groovy,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- capability-container.groovy 27 Feb 2004 18:30:00 -0000 1.2
+++ capability-container.groovy 27 Feb 2004 19:35:02 -0000 1.3
@@ -7,7 +7,7 @@
import org.hsqldb.jdbcDriver
import org.apache.jetspeed.components.jndi.JNDIComponent
import org.apache.jetspeed.components.jndi.TyrexJNDIComponent
-import org.apache.jetspeed.components.datasource.DBCPDatasourceComponent
+import org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent
import org.apache.jetspeed.components.datasource.DatasourceComponent
import org.apache.commons.pool.impl.GenericObjectPool
import org.apache.jetspeed.components.persistence.store.ojb.OJBTypeIntializer
@@ -25,11 +25,11 @@
container = new DefaultPicoContainer()
// This JNDI component helps us publish the datasource
-Class jndiClass = Class.forName("org.apache.jetspeed.components.jndi.JNDIComponent")
-Class tyrexJndiClass =
Class.forName("org.apache.jetspeed.components.jndi.TyrexJNDIComponent")
-container.registerComponentImplementation(jndiClass, tyrexJndiClass)
+Class jndiClass = JNDIComponent
+JNDIComponent jndiImpl = new TyrexJNDIComponent()
+container.registerComponentInstance(jndiClass, jndiImpl)
-Class dsClass =
Class.forName("org.apache.jetspeed.components.datasource.DatasourceComponent")
+Class dsClass = DatasourceComponent
String url = System.getProperty("org.apache.jetspeed.database.url")
String driver = System.getProperty("org.apache.jetspeed.database.driver")
String user = System.getProperty("org.apache.jetspeed.database.user")
@@ -37,7 +37,7 @@
if(url != null)
{
- container.registerComponentInstance(dsClass, new DBCPDatasourceComponent(user,
password, driver, url, 20, 5000, GenericObjectPool.WHEN_EXHAUSTED_GROW, true))
+ container.registerComponentInstance(dsClass, new
BoundDBCPDatasourceComponent(user, password, driver, url, 20, 5000,
GenericObjectPool.WHEN_EXHAUSTED_GROW, true, "jetspeed", jndiImpl))
}
//
1.1
jakarta-jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/datasource/BoundDBCPDatasourceComponent.java
Index: BoundDBCPDatasourceComponent.java
===================================================================
/*
* Created on Feb 27, 2004
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.apache.jetspeed.components.datasource;
import javax.naming.NamingException;
import org.apache.jetspeed.components.jndi.JNDIComponent;
/**
* @author Sweaver
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class BoundDBCPDatasourceComponent extends DBCPDatasourceComponent
{
private JNDIComponent jndi;
private String bindName;
/**
*
* @param user
* @param password
* @param driverName
* @param connectURI
* @param maxActive
* @param maxWait
* @param whenExhausted
* @param autoCommit
* @param bindName JNDI name to bind this <code>javax.sql.DataSource</code>
* created by this class to.
* @param jndi JNDIComponent we will use to bind.
*/
public BoundDBCPDatasourceComponent(String user, String password, String
driverName, String connectURI,
int maxActive, int maxWait, byte whenExhausted, boolean autoCommit,
String bindName, JNDIComponent jndi)
{
super(user, password, driverName, connectURI, maxActive, maxWait,
whenExhausted, autoCommit);
if(jndi == null)
{
throw new IllegalArgumentException("jndi argument cannot be null for
BoundDBCPDatasourceComponent");
}
if(bindName == null)
{
throw new IllegalArgumentException("bindName argument cannot be null for
BoundDBCPDatasourceComponent");
}
this.jndi = jndi;
this.bindName = bindName;
}
/**
* Same as [EMAIL PROTECTED] DBCPDatasourceComponent#start()}
* but also binds these <code>javax.sql.DataSource</code>
* created to the <code>bindName</code>.
*
* @see org.picocontainer.Startable#start()
*/
public void start()
{
super.start();
try
{
jndi.bindObject("comp/env/jdbc/"+bindName, getDatasource());
}
catch (NamingException e)
{
new IllegalStateException("Naming exception "+e.toString());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]