You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2006/02/22 07:28:51 UTC
svn commit: r379712 - in
/portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components:
datasource/DBCPDatasourceComponent.java
rdbms/ojb/ConnectionRepositoryEntry.java
Author: taylor
Date: Tue Feb 21 22:28:47 2006
New Revision: 379712
URL: http://svn.apache.org/viewcvs?rev=379712&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-495
configuring portal with Spring transactions to support commit and rollback
Modified:
portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
Modified: portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java?rev=379712&r1=379711&r2=379712&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java (original)
+++ portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/datasource/DBCPDatasourceComponent.java Tue Feb 21 22:28:47 2006
@@ -28,6 +28,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
/**
* <p>
@@ -46,6 +47,7 @@
private static final Log log = LogFactory.getLog(DBCPDatasourceComponent.class);
protected PoolingDataSource dataSource;
+ //protected DataSource dataSource;
private String user;
@@ -146,6 +148,10 @@
try
{
log.info("Attempting to start DBCPCDatasourceComponent.");
+// System.out.println("****************** setting data source");
+// dataSource = new DriverManagerDataSource(driverName, connectURI, user, password);
+// System.out.println("****************** set data source");
+
Class.forName(driverName);
// Validate the connection before we go any further
@@ -166,7 +172,7 @@
dsConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
- dataSource = new PoolingDataSource(connectionPool);
+ dataSource = new PoolingDataSource(connectionPool);
log.info("DBCPCDatasourceComponent successfuly started!");
}
@@ -189,6 +195,7 @@
*/
public void stop()
{
+/*
try
{
dsConnectionFactory.getPool().close();
@@ -199,7 +206,7 @@
new IllegalStateException("Unable to sfaely shutdown the DBCPConnection pool: " + e.toString());
ise.initCause(e);
}
-
+*/
}
}
Modified: portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java?rev=379712&r1=379711&r2=379712&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java (original)
+++ portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java Tue Feb 21 22:28:47 2006
@@ -26,6 +26,7 @@
import javax.naming.InitialContext;
import javax.sql.DataSource;
+import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ojb.broker.PBKey;
@@ -40,6 +41,7 @@
import org.apache.ojb.broker.util.ClassHelper;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
/**
* A JavaBean that configures an entry in OJB's ConnectionRepository
@@ -78,7 +80,8 @@
* @author Michael Lipp
* @version $Id$
*/
-public class ConnectionRepositoryEntry
+public class ConnectionRepositoryEntry
+ extends BasicDataSource
implements BeanNameAware, InitializingBean
{
private static final Log log = LogFactory.getLog(ConnectionRepositoryEntry.class);
@@ -96,10 +99,16 @@
private String password = null;
private boolean jetspeedEngineScoped = true;
+ public ConnectionRepositoryEntry()
+ {
+ super();
+ }
+
/**
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
- public void setBeanName(String beanName) {
+ public void setBeanName(String beanName)
+ {
// Use the bean's name as fallback if a JCD alias is not set
// explicitly
if (jcdAlias == null) {
@@ -110,91 +119,108 @@
/**
* @return Returns the jcdAlias.
*/
- public String getJcdAlias() {
+ public String getJcdAlias()
+ {
return jcdAlias;
}
/**
* @param jcdAlias The jcdAlias to set.
*/
- public void setJcdAlias(String jcdAlias) {
+ public void setJcdAlias(String jcdAlias)
+ {
this.jcdAlias = jcdAlias;
}
/**
* @return Returns the jndiName.
*/
- public String getJndiName() {
+ public String getJndiName()
+ {
return jndiName;
}
/**
* @param jndiName The jndiName to set.
*/
- public void setJndiName(String jndiName) {
+ public void setJndiName(String jndiName)
+ {
this.jndiName = jndiName;
}
/**
* @return Returns the driverClassName.
*/
- public String getDriverClassName() {
- return driverClassName;
+ public String getDriverClassName()
+ {
+ return driverClassName;
}
/**
* @param driverClassName The driverClassName to set.
*/
- public void setDriverClassName(String driverClassName) {
+ public void setDriverClassName(String driverClassName)
+ {
+ super.setDriverClassName(driverClassName);
this.driverClassName = driverClassName;
}
/**
* @return Returns the password.
*/
- public String getPassword() {
+ public String getPassword()
+ {
return password;
}
/**
* @param password The password to set.
*/
- public void setPassword(String password) {
+ public void setPassword(String password)
+ {
+ super.setPassword(password);
this.password = password;
}
/**
* @return Returns the url.
*/
- public String getUrl() {
+ public String getUrl()
+ {
return url;
}
/**
* @param url The url to set.
*/
- public void setUrl(String url) {
+ public void setUrl(String url)
+ {
+ super.setUrl(url);
this.url = url;
}
/**
* @return Returns the username.
*/
- public String getUsername() {
+ public String getUsername()
+ {
return username;
}
/**
* @param username The username to set.
*/
- public void setUsername(String username) {
+ public void setUsername(String username)
+ {
+ super.setUsername(username);
this.username = username;
}
/**
* @return Returns the platform.
*/
- public String getPlatform() {
+ public String getPlatform()
+ {
return platform;
}
@@ -203,7 +229,8 @@
* the value derived from the data source or database driver.
* @param platform The platform to set.
*/
- public void setPlatform(String platform) {
+ public void setPlatform(String platform)
+ {
this.platform = platform;
}
@@ -211,7 +238,8 @@
* @see setJetspeedEngineScoped
* @return Returns if Jetspeed engine's ENC is used for JNDI lookups.
*/
- public boolean isJetspeedEngineScoped() {
+ public boolean isJetspeedEngineScoped()
+ {
return jetspeedEngineScoped;
}
@@ -223,7 +251,8 @@
* engine.
* @param jetspeedEngineScoped whether to use Jetspeed engine's ENC.
*/
- public void setJetspeedEngineScoped(boolean jetspeedEngineScoped) {
+ public void setJetspeedEngineScoped(boolean jetspeedEngineScoped)
+ {
this.jetspeedEngineScoped = jetspeedEngineScoped;
}
@@ -238,22 +267,28 @@
jcd.setJcdAlias(jcdAlias);
cr.addDescriptor(jcd);
}
- if (platform != null && platform.length() == 0) {
+ if (platform != null && platform.length() == 0)
+ {
platform = null;
}
DataSource ds = null;
JdbcMetadataUtils jdbcMetadataUtils = new JdbcMetadataUtils ();
- if (jndiName != null) {
+ if (jndiName != null)
+ {
// using "preconfigured" data source
- if (connectionFactoryClass == null) {
+ if (connectionFactoryClass == null)
+ {
connectionFactoryClass = ConnectionFactoryManagedImpl.class.getName ();
}
Context initialContext = new InitialContext();
ds = (DataSource) initialContext.lookup(jndiName);
jcd.setDatasourceName(jndiName);
- } else {
+ }
+ else
+ {
// have to get data source ourselves
- if (connectionFactoryClass == null) {
+ if (connectionFactoryClass == null)
+ {
connectionFactoryClass = ConnectionFactoryDBCPImpl.class.getName ();
}
jcd.setDriver(driverClassName);
@@ -269,7 +304,8 @@
// But although JdbcMetadataUtils exposes the methods used in
// fillJCDFromDataSource as public (and these do not require a DataSource)
// the method itself does more than is made available by the exposed methods.
- ds = new MinimalDataSource (jcd);
+ // ds = new MinimalDataSource (jcd);
+ ds = this;
}
ConnectionPoolDescriptor cpd = jcd.getConnectionPoolDescriptor();
if (cpd == null)
@@ -310,7 +346,8 @@
* throws SQLException
*/
private void updateOraclePlatform(JdbcConnectionDescriptor jcd, DataSource ds)
- throws LookupException, IllegalAccessException, InstantiationException, SQLException {
+ throws LookupException, IllegalAccessException, InstantiationException, SQLException
+ {
Connection con = null;
try
{
@@ -367,8 +404,8 @@
* a minimal DataSource implementation that satisfies the requirements
* of JdbcMetadataUtil.
*/
- private class MinimalDataSource implements DataSource {
-
+ private class MinimalDataSource implements DataSource
+ {
private JdbcConnectionDescriptor jcd = null;
/**
@@ -416,7 +453,8 @@
/**
* @see javax.sql.DataSource#getLoginTimeout()
*/
- public int getLoginTimeout() throws SQLException {
+ public int getLoginTimeout() throws SQLException
+ {
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org