portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject svn commit: r280147 - in /portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb: ConnectionManagerImpl.java ConnectionRepositoryEntry.java
Date Sun, 11 Sep 2005 15:55:17 GMT
Author: dlestrat
Date: Sun Sep 11 08:55:15 2005
New Revision: 280147

URL: http://svn.apache.org/viewcvs?rev=280147&view=rev
Log:
Apply latest patch from Michael:

http://issues.apache.org/jira/browse/JS2-326#action_12323144

Keep them coming ;)

Modified:
    portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.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/rdbms/ojb/ConnectionManagerImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java?rev=280147&r1=280146&r2=280147&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionManagerImpl.java
Sun Sep 11 08:55:15 2005
@@ -86,17 +86,25 @@
             {
                 try
                 {
-                    ClassLoader cl = Thread.currentThread().getContextClassLoader();    
           
-                    try
-                    {
-                        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-                        connectionFactory = (ConnectionFactory)
-                            ClassHelper.newInstance (cpd.getConnectionFactory(), true);
-                        connectionFactories.put(cpd.getConnectionFactory(), connectionFactory);
+                    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);
+                        }
                     }
-                    finally
+                    else
                     {
-                        Thread.currentThread().setContextClassLoader(cl);
+                        connectionFactory = (ConnectionFactory)
+                        ClassHelper.newInstance (cpd.getConnectionFactory(), true);
                     }
                 }
                 catch (InstantiationException e)
@@ -172,15 +180,21 @@
         }
         if (con == null)
         {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-            try
-            {
-                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-                con = this.connectionFactory.lookupConnection(jcd);
+            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);
+                }
             }
-            finally
+            else
             {
-                Thread.currentThread().setContextClassLoader(cl);
+                con = this.connectionFactory.lookupConnection(jcd);
             }
             
             if (con == null) throw new PersistenceBrokerException("Cannot get connection
for " + jcd);

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=280147&r1=280146&r2=280147&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
Sun Sep 11 08:55:15 2005
@@ -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 "<code>org.apache.jetspeed.engineScoped</code>"
+     * of the JDBC connection descriptor to "<code>true</code>" or
+     * "<code>false</code>". 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 {
         }
     }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message