tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1139958 - in /openejb/trunk/openejb3/server: openejb-client/src/main/java/org/apache/openejb/client/ openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/ openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/
Date Sun, 26 Jun 2011 22:28:46 GMT
Author: dblevins
Date: Sun Jun 26 22:28:45 2011
New Revision: 1139958

URL: http://svn.apache.org/viewvc?rev=1139958&view=rev
Log:
Fixed bug in OPENEJB-1616 that broke the openejb side of things and added a small test case
Can't immediately think of a good way to test the Reference passing support, but we should
add a test for that too.
Maybe we just drop the DBCP specific support and convert that over to using the more generic
Reference support

Modified:
    openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIResponse.java
    openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
    openejb/trunk/openejb3/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/AppClientTest.java

Modified: openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIResponse.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIResponse.java?rev=1139958&r1=1139957&r2=1139958&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIResponse.java
(original)
+++ openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIResponse.java
Sun Jun 26 22:28:45 2011
@@ -142,6 +142,8 @@ public class JNDIResponse implements Clu
                 m.writeExternal(out);
                 break;
             case ResponseCodes.JNDI_DATA_SOURCE:
+                DataSourceMetaData ds = (DataSourceMetaData) result;
+                ds.writeExternal(out);
                 break;
             case ResponseCodes.JNDI_INJECTIONS:
                 InjectionMetaData imd = (InjectionMetaData) result;

Modified: openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java?rev=1139958&r1=1139957&r2=1139958&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
(original)
+++ openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java
Sun Jun 26 22:28:45 2011
@@ -204,7 +204,7 @@ class JndiRequestHandler {
             } else if (object == null) {
                 throw new NullPointerException("lookup of '"+name+"' returned null");
             } else if (object instanceof DataSource) {
-                if (object.getClass().getName().equals("org.apache.commons.dbcp.BasicDataSource"))
{
+                if (isDbcpDataSource(object)) {
                     try {
                         DbcpDataSource cf = new DbcpDataSource(object);
                         DataSourceMetaData dataSourceMetaData = new DataSourceMetaData(cf.getDriverClassName(),
cf.getUrl(), cf.getUsername(), cf.getPassword());
@@ -438,6 +438,15 @@ class JndiRequestHandler {
 
     }
 
+    private boolean isDbcpDataSource(Object object) {
+
+        for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
{
+            if (clazz.getName().equals("org.apache.commons.dbcp.BasicDataSource")) return
true;
+        }
+
+        return false;
+    }
+
     private void log(EJBMetaDataImpl metaData) {
         if (logger.isDebugEnabled()) {
             final StringBuilder sb = new StringBuilder();

Modified: openejb/trunk/openejb3/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/AppClientTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/AppClientTest.java?rev=1139958&r1=1139957&r2=1139958&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/AppClientTest.java
(original)
+++ openejb/trunk/openejb3/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/AppClientTest.java
Sun Jun 26 22:28:45 2011
@@ -27,12 +27,12 @@ import org.apache.openejb.core.ServerFed
 import org.apache.openejb.jee.ApplicationClient;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.StatelessBean;
-import org.apache.openejb.jee.oejb3.EjbDeployment;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.ServiceDaemon;
 import org.apache.openejb.server.ServicePool;
 
+import javax.annotation.Resource;
 import javax.ejb.CreateException;
 import javax.ejb.EJB;
 import javax.ejb.EJBHome;
@@ -41,6 +41,7 @@ import javax.ejb.Remote;
 import javax.ejb.RemoteHome;
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.sql.DataSource;
 import java.rmi.RemoteException;
 import java.util.Properties;
 
@@ -102,7 +103,12 @@ public class AppClientTest extends TestC
         assertTrue(business instanceof OrangeBusinessRemote);
         OrangeBusinessRemote orangeBusinessRemote = (OrangeBusinessRemote) business;
         assertEquals("nap", orangeBusinessRemote.echo("pan"));
-        
+
+        final Object dataSourceObject = context.lookup("comp/env/datasource");
+        assertTrue(dataSourceObject instanceof DataSource);
+//        DataSource dataSource = (DataSource) dataSourceObject;
+//        assertEquals("nap", orangeBusinessRemote.echo("pan"));
+
         props.put("openejb.client.moduleId", "openejb/global");
         context = new InitialContext(props);
 
@@ -136,6 +142,9 @@ public class AppClientTest extends TestC
 
     public static class OrangeAppClient {
 
+        @Resource(name = "datasource")
+        public static DataSource dataSource;
+
         @EJB(name = "home")
         public static OrangeHome orangeHome;
 



Mime
View raw message