[jboss-cvs] JBossAS SVN: r108643 - in projects/ejb3/branches/infinispan-int: core/src/main/java/org/jboss/injection and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 18 18:03:39 EDT 2010


Author: pferraro
Date: 2010-10-18 18:03:39 -0400 (Mon, 18 Oct 2010)
New Revision: 108643

Modified:
   projects/ejb3/branches/infinispan-int/core/pom.xml
   projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java
   projects/ejb3/branches/infinispan-int/proxy-impl/pom.xml
   projects/ejb3/branches/infinispan-int/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
   projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/session/unit/ProxyServiceTestCase.java
   projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
   projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
Log:
merge --depth=infinity -r108617:108625 from trunk

Modified: projects/ejb3/branches/infinispan-int/core/pom.xml
===================================================================
--- projects/ejb3/branches/infinispan-int/core/pom.xml	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/core/pom.xml	2010-10-18 22:03:39 UTC (rev 108643)
@@ -17,7 +17,7 @@
   <!-- Artifact Information -->
   <artifactId>jboss-ejb3-core</artifactId>
   <packaging>jar</packaging>
-  <version>1.5.5-SNAPSHOT</version>
+  <version>1.5.6-SNAPSHOT</version>
   <name>JBoss EJB 3.0 Core</name>
   <url>http://labs.jboss.com/jbossejb3</url>
   <description>JBoss EJB 3.0 Core</description>

Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java	2010-10-18 22:03:39 UTC (rev 108643)
@@ -182,7 +182,7 @@
       {
          // EJBTHREE-712
          // TODO: refactor with handlePropertyAnnotation
-         String resTypeName = envRef.getType();
+         String resTypeName = getResourceEnvRefType(container, envRef);
          String mappedName = envRef.getMappedName();
          String encName = "env/" + envRef.getResourceEnvRefName();
          if (resTypeName != null)
@@ -313,6 +313,57 @@
       // TODO: Check for injection targets and if there's a mismatch in the types between
       // different injection targets, then throw an error
       ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
+      return getTargetType(container, injectionTarget);
+   }
+   
+   /**
+    * Returns the resource-env-ref-type for the passed {@link ResourceEnvironmentReferenceMetaData}.
+    * <p>
+    *   If the passed resource-env-ref has the resource-env-entry-type explicitly specified, then
+    *   that value is returned. Else, this method checks for the presence of any
+    *   injection targets for this resource-env-ref. If there's a injection target, then
+    *   the resource-env-entry-type is deduced based on the field/method of the injection target. 
+    * </p>
+    * <p>
+    *   This method returns null if the resource-env-entry-type isn't explicitly specified and 
+    *   if the resource-env-entry-type could not be deduced from the injection targets of this
+    *   resource-env-ref.
+    * </p>
+    * @param container The container to which this env-entry belongs
+    * @param resourceEnvRef The resource-env-ref metadata
+    * @return
+    */
+   private static String getResourceEnvRefType(InjectionContainer container, ResourceEnvironmentReferenceMetaData resourceEnvRef)
+   {
+      // first check whether the type is explicitly specified
+      String explicitType = resourceEnvRef.getType();
+      if (explicitType != null)
+      {
+         return explicitType;
+      }
+      // check if this env-entry has an injection-target. If yes, then 
+      // fetch the type from the injection target's field/method type
+      Set<ResourceInjectionTargetMetaData> injectionTargets = resourceEnvRef.getInjectionTargets();
+      if (injectionTargets == null || injectionTargets.isEmpty())
+      {
+         return null;
+      }
+      // even if there are multiple injection targets, we just check for the first one
+      // TODO: Check for injection targets and if there's a mismatch in the types between
+      // different injection targets, then throw an error
+      ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
+      return getTargetType(container, injectionTarget);
+   }
+   
+   /**
+    * Returns the fully qualified classname of the type of the injection target (field/method).
+    * 
+    * @param container The container
+    * @param injectionTargets The injection target
+    * @return
+    */
+   private static String getTargetType(InjectionContainer container, ResourceInjectionTargetMetaData injectionTarget)
+   {
       AccessibleObject accessibleObject = InjectionUtil.findInjectionTarget(container.getClassloader(), injectionTarget);
       if (accessibleObject instanceof Field)
       {

Modified: projects/ejb3/branches/infinispan-int/proxy-impl/pom.xml
===================================================================
--- projects/ejb3/branches/infinispan-int/proxy-impl/pom.xml	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/proxy-impl/pom.xml	2010-10-18 22:03:39 UTC (rev 108643)
@@ -16,7 +16,7 @@
   <!-- Artifact Configuration -->
   <groupId>org.jboss.ejb3</groupId>
   <artifactId>jboss-ejb3-proxy-impl</artifactId>
-  <version>1.0.11-SNAPSHOT</version>
+  <version>1.0.12-SNAPSHOT</version>
   <name>JBoss EJB 3.x Proxy Implementation (Internals)</name>
   <description>JBoss EJB 3.x Proxy Implementation (Internals)</description>
   <url>http://www.jboss.org/jbossejb3</url>

Modified: projects/ejb3/branches/infinispan-int/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/branches/infinispan-int/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java	2010-10-18 22:03:39 UTC (rev 108643)
@@ -309,9 +309,22 @@
          return false;
       }
 
+      // object identity
+      if (proxy == argument)
+      {
+         return true;
+      }
+
       // Ensure we've got j.l.r.Proxies
-      assert Proxy.isProxyClass(proxy.getClass()) && Proxy.isProxyClass(argument.getClass()) : "invokeEquals handles only "
-            + Proxy.class.getName();
+      if (!Proxy.isProxyClass(proxy.getClass()) || !Proxy.isProxyClass(argument.getClass()))
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Not equal; Either " + proxy + " or " + argument + " is not a " + Proxy.class.getName() + " type");
+         }
+         return false;
+      }
+      
 
       // Get the InvocationHandlers
       InvocationHandler proxyHandler = Proxy.getInvocationHandler(proxy);
@@ -331,7 +344,21 @@
       // Cast
       SessionProxyInvocationHandler proxySHandler = (SessionProxyInvocationHandler) proxyHandler;
       SessionProxyInvocationHandler argumentSHandler = (SessionProxyInvocationHandler) argumentHandler;
-
+      
+      // Ensure the business interface types are equal
+      String proxySBusinessInterface = proxySHandler.getBusinessInterfaceType();
+      String argumentSBusinessInterface = argumentSHandler.getBusinessInterfaceType();
+      if (proxySBusinessInterface == null || !proxySBusinessInterface.equals(argumentSBusinessInterface))
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Business interface type of proxy: " + proxySBusinessInterface
+                  + " and business interface type of argument " + argumentSBusinessInterface + " are not equal");
+         }
+         return false;
+      }
+      
+      
       // Ensure target containers are equal
       String proxyContainerName = proxySHandler.getContainerName();
       assert proxyContainerName != null : "Container Name for " + proxySHandler + " was not set and is required";

Modified: projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/session/unit/ProxyServiceTestCase.java
===================================================================
--- projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/session/unit/ProxyServiceTestCase.java	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/session/unit/ProxyServiceTestCase.java	2010-10-18 22:03:39 UTC (rev 108643)
@@ -21,7 +21,6 @@
  */
 package org.jboss.ejb3.test.proxy.impl.session.unit;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 
@@ -123,21 +122,6 @@
    }
 
    /**
-    * Tests that proxies with the same target container are
-    * equal
-    */
-   @Test
-   public void testProxiesSameTargetContainerEqual() throws Exception
-   {
-      // Lookup
-      Object bean1 = context.lookup("MyServiceBean/local");
-      Object bean2 = context.lookup("MyServiceBean/remote");
-
-      // Ensure equal
-      assertEquals("@Service proxies with the same target container must be equal", bean1, bean2);
-   }
-
-   /**
     * Tests that proxies with the different target containers are
     * not equal
     */

Modified: projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java	2010-10-18 22:03:39 UTC (rev 108643)
@@ -36,6 +36,8 @@
 import org.jboss.ejb3.test.proxy.impl.common.Utils;
 import org.jboss.ejb3.test.proxy.impl.common.container.StatefulContainer;
 import org.jboss.ejb3.test.proxy.impl.common.ejb.sfsb.MyStatefulBean;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.sfsb.MyStatefulLocalBusiness;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.sfsb.MyStatefulRemoteBusiness;
 import org.jboss.ejb3.test.proxy.impl.spec_3_4_5.ProxyEqualityTestCaseBase;
 import org.jboss.logging.Logger;
 import org.junit.BeforeClass;
@@ -118,7 +120,35 @@
       TestCase.assertTrue("Hash Codes for unequal Proxies should (most likely) not be equal",
             proxy1.hashCode() != proxy2.hashCode());
    }
+   
+   /**
+    * EJB 3.0 Core Specification 3.4.5.2
+    * 
+    * Tests that 2 different business interface views of the same SFSB are *not* equal
+    */
+   @Test
+   public void testSfsbDifferenetBusinessInterfaceNotEqual() throws Throwable
+   {
+      // Make a Remote Proxy Factory
+      StatefulSessionRemoteProxyFactory remoteProxyFactory = this.createSessionRemoteProxyFactory();
+      remoteProxyFactory.start();
 
+      // Make a Local Proxy Factory
+      StatefulSessionLocalProxyFactory localProxyFactory = this.createSessionLocalProxyFactory();
+      localProxyFactory.start();
+
+      // Create 2 Proxies
+      Object businessRemoteProxy = remoteProxyFactory.createProxyBusiness(MyStatefulRemoteBusiness.class.getName());
+      Object businessLocalProxy = localProxyFactory.createProxyBusiness(MyStatefulLocalBusiness.class.getName());
+
+      // Ensure they're *not* equal to one another
+      TestCase
+            .assertFalse(
+                  "EJB 3.0 Core Specification 3.4.5.2 Violation: Session bean references to either different business interface types or different session beans will not be equal.",
+                  businessRemoteProxy.equals(businessLocalProxy));
+         
+   }
+
    // --------------------------------------------------------------------------------||
    // Helper Methods -----------------------------------------------------------------||
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java	2010-10-18 20:59:44 UTC (rev 108642)
+++ projects/ejb3/branches/infinispan-int/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java	2010-10-18 22:03:39 UTC (rev 108643)
@@ -29,6 +29,8 @@
 import org.jboss.ejb3.test.proxy.impl.common.container.SessionContainer;
 import org.jboss.ejb3.test.proxy.impl.common.container.StatelessContainer;
 import org.jboss.ejb3.test.proxy.impl.common.ejb.slsb.MyStatelessBean;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.slsb.MyStatelessLocal;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.slsb.MyStatelessRemote;
 import org.jboss.ejb3.test.proxy.impl.spec_3_4_5.ProxyEqualityTestCaseBase;
 import org.jboss.logging.Logger;
 import org.junit.BeforeClass;
@@ -68,8 +70,8 @@
       StatelessSessionLocalProxyFactory factory = this.createSessionLocalProxyFactory();
 
       // Create 2 Proxies
-      Object proxy1 = factory.createProxyDefault();
-      Object proxy2 = factory.createProxyDefault();
+      Object proxy1 = factory.createProxyBusiness(MyStatelessLocal.class.getName());
+      Object proxy2 = factory.createProxyBusiness(MyStatelessLocal.class.getName());
 
       // Ensure they're equal to one another
       TestCase
@@ -96,8 +98,8 @@
          factory.start();
 
          // Create 2 Proxies
-         Object proxy1 = factory.createProxyDefault();
-         Object proxy2 = factory.createProxyDefault();
+         Object proxy1 = factory.createProxyBusiness(MyStatelessRemote.class.getName());
+         Object proxy2 = factory.createProxyBusiness(MyStatelessRemote.class.getName());
 
          // Ensure they're equal to one another
          TestCase
@@ -112,7 +114,46 @@
          getBootstrap().undeploy(SlsbProxyEqualityTestCase.class);
       }
    }
+   
+   /**
+    * EJB 3.0 Core Specification 3.4.5.2
+    * 
+    * Tests that 2 different business interface views of the same SLSB are *not* equal
+    */
+   @Test
+   public void testSlsbDifferenetBusinessInterfaceNotEqual() throws Throwable
+   {
+      // Bind the Connector
+      getBootstrap().deploy(SlsbProxyEqualityTestCase.class);
+      try
+      {
+         // Make a Remote Proxy Factory
+         StatelessSessionRemoteProxyFactory remoteProxyFactory = this.createSessionRemoteProxyFactory();
+         remoteProxyFactory.start();
+         
+         // Make a Local Proxy Factory
+         StatelessSessionLocalProxyFactory localProxyFactory = this.createSessionLocalProxyFactory();
+         localProxyFactory.start();
 
+
+         // Create 2 Proxies
+         Object businessRemoteProxy = remoteProxyFactory.createProxyBusiness(MyStatelessRemote.class.getName());
+         Object businessLocalProxy = localProxyFactory.createProxyBusiness(MyStatelessLocal.class.getName());
+
+         // Ensure they're *not* equal to one another
+         TestCase
+               .assertFalse(
+                     "EJB 3.0 Core Specification 3.4.5.2 Violation: Session bean references to either different business interface types or different session beans will not be equal.",
+                     businessRemoteProxy.equals(businessLocalProxy));
+         
+      }
+      finally
+      {
+         // Bind the Connector
+         getBootstrap().undeploy(SlsbProxyEqualityTestCase.class);
+      }
+   }
+
    // --------------------------------------------------------------------------------||
    // Lifecycle Methods --------------------------------------------------------------||
    // --------------------------------------------------------------------------------||



More information about the jboss-cvs-commits mailing list