You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2014/03/06 04:55:08 UTC

svn commit: r1574760 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java

Author: lu4242
Date: Thu Mar  6 03:55:08 2014
New Revision: 1574760

URL: http://svn.apache.org/r1574760
Log:
ORCHESTRA-66 DataSource has a new method getParentLogger() in java 7 that needs to be overriden

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java?rev=1574760&r1=1574759&r2=1574760&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java Thu Mar  6 03:55:08 2014
@@ -23,10 +23,14 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
 import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.logging.Logger;
 
 /**
  * Manage all borrowed connections and hand out
@@ -267,4 +271,38 @@ public class ConnectionManagerDataSource
         }
         */
     }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException
+    {
+        // Use reflection for Java 6 and 7 compatibility
+        DataSource ds = getDataSource();
+        if (ds != null)
+        {
+            try
+            {
+                Method m = ds.getClass().getMethod("getParentLogger");
+                if (m != null)
+                {
+                    return (Logger) m.invoke(ds);
+                }
+            }
+            catch (NoSuchMethodException ex)
+            {
+            }
+            catch (SecurityException ex)
+            {
+            }
+            catch (IllegalAccessException ex)
+            {
+            }
+            catch (IllegalArgumentException ex)
+            {
+            }
+            catch (InvocationTargetException ex)
+            {
+            }
+        }
+        throw new SQLFeatureNotSupportedException();
+    }
 }