Index: /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
===================================================================
--- /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java (revision 279846)
+++ /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java (working copy)
@@ -94,6 +94,7 @@
private String url = null;
private String username = null;
private String password = null;
+ private boolean jetspeedEngineScoped = true;
/**
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
@@ -206,6 +207,26 @@
this.platform = platform;
}
+ /**
+ * @see setJetspeedEngineScoped
+ * @return Returns if Jetspeed engine's ENC is used for JNDI lookups.
+ */
+ public boolean isJetspeedEngineScoped() {
+ return jetspeedEngineScoped;
+ }
+
+ /**
+ * Sets the attribute "org.apache.jetspeed.engineScoped"
+ * of the JDBC connection descriptor to "true" or
+ * "false". If set, JNDI lookups of the connection will
+ * be done using the environment naming context (ENC) of the Jetspeed
+ * engine.
+ * @param jetspeedEngineScoped whether to use Jetspeed engine's ENC.
+ */
+ public void setJetspeedEngineScoped(boolean jetspeedEngineScoped) {
+ this.jetspeedEngineScoped = jetspeedEngineScoped;
+ }
+
public void afterPropertiesSet () throws Exception
{
// Try to find JCD
@@ -275,6 +296,10 @@
} else {
platform = jcd.getDbms();
}
+
+ // special attributes
+ jcd.addAttribute("org.apache.jetspeed.engineScoped",
+ Boolean.toString(jetspeedEngineScoped));
}
/**
@@ -414,4 +439,5 @@
public void setLogWriter(PrintWriter out) throws SQLException {
}
}
+
}
Index: /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java
===================================================================
--- /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java (revision 279846)
+++ /home/mnl/devel/eclipse-workspace/jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java (working copy)
@@ -86,18 +86,26 @@
{
try
{
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try
+ if (Boolean.getBoolean(this.jcd.getAttribute("org.apache.jetspeed.engineScoped", "false"))) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ connectionFactory = (ConnectionFactory)
+ ClassHelper.newInstance (cpd.getConnectionFactory(), true);
+ connectionFactories.put(cpd.getConnectionFactory(), connectionFactory);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ connectionFactories.put(cpd.getConnectionFactory(), connectionFactory);
+ }
+ }
+ else
{
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
connectionFactory = (ConnectionFactory)
- ClassHelper.newInstance (cpd.getConnectionFactory(), true);
- connectionFactories.put(cpd.getConnectionFactory(), connectionFactory);
+ ClassHelper.newInstance (cpd.getConnectionFactory(), true);
}
- finally
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
}
catch (InstantiationException e)
{
@@ -172,16 +180,22 @@
}
if (con == null)
{
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try
+ if (Boolean.getBoolean(this.jcd.getAttribute("org.apache.jetspeed.engineScoped", "false"))) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ con = this.connectionFactory.lookupConnection(jcd);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+ else
{
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
con = this.connectionFactory.lookupConnection(jcd);
}
- finally
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
if (con == null) throw new PersistenceBrokerException("Cannot get connection for " + jcd);
if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)