[jboss-cvs] JBossAS SVN: r74060 - in projects/ejb3/trunk: proxy/src/main/java/org/jboss/ejb3/proxy/factory and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 3 22:25:33 EDT 2008


Author: ALRubinger
Date: 2008-06-03 22:25:33 -0400 (Tue, 03 Jun 2008)
New Revision: 74060

Added:
   projects/ejb3/trunk/test/src/main/java/org/jboss/ejb3/test/common/
   projects/ejb3/trunk/test/src/main/java/org/jboss/ejb3/test/common/MetaDataHelper.java
Removed:
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
Modified:
   projects/ejb3/trunk/proxy/pom.xml
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
   projects/ejb3/trunk/test/pom.xml
Log:
[EJBTHREE-1390] Moving sources, updating dependencies in preparation for releases

Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/pom.xml	2008-06-04 02:25:33 UTC (rev 74060)
@@ -34,33 +34,9 @@
   <build>
 
     <plugins>
-      <!--
+
+      <!-- Build a CP File for use by MockServer -->     
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <compilerArgument>-verbose</compilerArgument>
-        </configuration>
-      </plugin>
-      -->
-      <!-- Surefire -->
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <redirectTestOutputToFile>true</redirectTestOutputToFile>
-          <printSummary>true</printSummary>
-          <testFailureIgnore>false</testFailureIgnore>
-          <includes>
-            <include>**/*TestCase.java</include>
-            <include>**/*TestSuite.java</include>
-          </includes>
-          <!-- Note: Fiddling with forkMode screws up surefire.test.class.path -->
-          <forkMode>always</forkMode>
-          <argLine>-ea</argLine>
-        </configuration>
-      </plugin>
-      
-      <plugin>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>
@@ -143,7 +119,7 @@
      <dependency>
       <groupId>org.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-test</artifactId>
-      <version>0.1.0</version>
+      <version>0.1.1-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
 

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -90,7 +90,7 @@
    protected Constructor<?> createProxyConstructor(Set<Class<?>> interfaces, ClassLoader cl)
    {
       // Add interfaces common to all proxies
-      interfaces.addAll(this.getProxyInterfaces());
+      interfaces.addAll(this.getCommonProxyInterfaces());
 
       Class<?> proxyClass = Proxy.getProxyClass(cl, interfaces.toArray(new Class<?>[]
       {}));
@@ -112,7 +112,7 @@
     * 
     * @return
     */
-   protected Set<Class<?>> getProxyInterfaces()
+   protected Set<Class<?>> getCommonProxyInterfaces()
    {
       // Initialize
       Set<Class<?>> interfaces = new HashSet<Class<?>>();

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.proxy.factory.session;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -37,6 +38,7 @@
 import org.jboss.ejb3.common.string.StringUtils;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryBase;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.stateless.StatelessProxyInvocationHandler;
 import org.jboss.ejb3.proxy.intf.SessionProxy;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -191,8 +193,11 @@
          assert constructor != null : "No business proxy constructor for \"" + businessInterfaceName
                + "\" was found; not created at start() properly?  Bad value bound as RefAddr in JNDI?";
 
+         // Create new Invocation Handler
+         SessionProxyInvocationHandler handler = this.getInvocationHandlerConstructor().newInstance(businessInterfaceName);
+
          // Create a new Proxy instance, and return
-         return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance(businessInterfaceName));
+         return constructor.newInstance(handler);
       }
       catch (Throwable t)
       {
@@ -439,10 +444,10 @@
     * @return
     */
    @Override
-   protected Set<Class<?>> getProxyInterfaces()
+   protected Set<Class<?>> getCommonProxyInterfaces()
    {
       // Initialize
-      Set<Class<?>> interfaces = super.getProxyInterfaces();
+      Set<Class<?>> interfaces = super.getCommonProxyInterfaces();
 
       // Add
       interfaces.add(SessionProxy.class);

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -105,10 +105,10 @@
     * @return
     */
    @Override
-   protected Set<Class<?>> getProxyInterfaces()
+   protected Set<Class<?>> getCommonProxyInterfaces()
    {
       // Initialize
-      Set<Class<?>> interfaces = super.getProxyInterfaces();
+      Set<Class<?>> interfaces = super.getCommonProxyInterfaces();
 
       // Add
       interfaces.add(StatefulSessionProxy.class);

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -27,6 +27,7 @@
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactoryBase;
 import org.jboss.ejb3.proxy.handler.session.stateless.StatelessProxyInvocationHandler;
+import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
 /**
@@ -40,6 +41,18 @@
 public abstract class StatelessSessionProxyFactoryBase extends SessionProxyFactoryBase implements SessionProxyFactory
 {
    // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(StatelessSessionProxyFactoryBase.class);
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private Constructor<StatelessProxyInvocationHandler> invocationHandlerConstructor;
+
+   // --------------------------------------------------------------------------------||
    // Constructor --------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
@@ -85,15 +98,35 @@
    @Override
    protected final Constructor<StatelessProxyInvocationHandler> getInvocationHandlerConstructor()
    {
-      try
+      // If not created
+      if (this.invocationHandlerConstructor == null)
       {
-         return StatelessProxyInvocationHandler.class.getConstructor(new Class[]
-         {String.class});
+         // Initialize
+         Constructor<StatelessProxyInvocationHandler> ctor = null;
+         try
+         {
+            // Create
+            Class<?>[] args = new Class[]
+            {String.class};
+            log.debug("Creating " + Constructor.class.getSimpleName() + " to "
+                  + StatelessProxyInvocationHandler.class.getName() + " with arguments: " + args);
+            ctor = StatelessProxyInvocationHandler.class.getConstructor(args);
+         }
+         catch (NoSuchMethodException e)
+         {
+            throw new RuntimeException("Could not find Constructor with one String argument for "
+                  + StatelessProxyInvocationHandler.class.getName(), e);
+         }
+         this.setInvocationHandlerConstructor(ctor);
       }
-      catch (NoSuchMethodException e)
-      {
-         throw new RuntimeException("Could not find Constructor with one String argument for "
-               + StatelessProxyInvocationHandler.class.getName(), e);
-      }
+
+      // Return
+      return this.invocationHandlerConstructor;
    }
+
+   private void setInvocationHandlerConstructor(
+         Constructor<StatelessProxyInvocationHandler> invocationHandlerConstructor)
+   {
+      this.invocationHandlerConstructor = invocationHandlerConstructor;
+   }
 }

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -172,8 +172,8 @@
       String remoteHome = StringUtils.adjustWhitespaceStringToNull(smd.getHome());
 
       // Determine if there are local/remote views
-      boolean hasLocalView = (localHome != null || businessLocals.size() < 1);
-      boolean hasRemoteView = (remoteHome != null || businessRemotes.size() < 1);
+      boolean hasLocalView = (localHome != null || (businessLocals != null && businessLocals.size() > 0));
+      boolean hasRemoteView = (remoteHome != null || (businessRemotes != null && businessRemotes.size() > 0));
 
       // If no local or remote views
       if (!hasLocalView && !hasRemoteView)
@@ -201,11 +201,14 @@
          List<RefAddr> refAddrsForDefaultRemote = new ArrayList<RefAddr>();
 
          // For each of the remote business interfaces, make a Reference Address
-         for (String businessRemote : businessRemotes)
+         if (businessRemotes != null)
          {
-            RefAddr refAddr = new StringRefAddr(
-                  ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
-            refAddrsForDefaultRemote.add(refAddr);
+            for (String businessRemote : businessRemotes)
+            {
+               RefAddr refAddr = new StringRefAddr(
+                     ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
+               refAddrsForDefaultRemote.add(refAddr);
+            }
          }
 
          // Determine if remote home and business remotes are bound to same JNDI Address
@@ -259,25 +262,27 @@
 
          // Bind the Default Remote Reference to JNDI
          String defaultRemoteAddress = smd.determineJndiName();
-         log.debug("Default Remote View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+         log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
                + defaultRemoteAddress + "\"");
          this.bind(defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey, containerName);
 
          // Bind ObjectFactory specific to each Remote Business Interface
-         for (String businessRemote : businessRemotes)
+         if (businessRemotes != null)
          {
-            RefAddr refAddrBusinessInterface = new StringRefAddr(
-                  ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
-            RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
-            Reference ref = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessRemote,
-                  this.getSessionProxyObjectFactoryType(), null);
-            ref.add(refAddrBusinessInterface);
-            ref.add(refAddrRemoting);
-            String address = smd.determineResolvedJndiName(businessRemote);
-            log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
-                  + " to be bound into JNDI at \"" + address + "\"");
-            this.bind(ref, address, remoteProxyFactoryKey, containerName);
-
+            for (String businessRemote : businessRemotes)
+            {
+               RefAddr refAddrBusinessInterface = new StringRefAddr(
+                     ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
+               RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
+               Reference ref = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessRemote,
+                     this.getSessionProxyObjectFactoryType(), null);
+               ref.add(refAddrBusinessInterface);
+               ref.add(refAddrRemoting);
+               String address = smd.determineResolvedJndiName(businessRemote);
+               log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+                     + " to be bound into JNDI at \"" + address + "\"");
+               this.bind(ref, address, remoteProxyFactoryKey, containerName);
+            }
          }
       }
       // If there's a local view
@@ -345,7 +350,7 @@
 
          // Bind the Default Local Reference to JNDI
          String defaultLocalAddress = smd.determineLocalJndiName();
-         log.debug("Default Local View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+         log.debug("Default Local Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
                + defaultLocalAddress + "\"");
          this.bind(defaultLocalRef, defaultLocalAddress, localProxyFactoryKey, containerName);
 

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
-  *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.proxy.common;
-
-import java.lang.reflect.AnnotatedElement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-
-import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
-import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
-import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
-import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
-
-/**
- * Utils
- * 
- * Utilities for Generating Test EJBs
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class Utils
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(Utils.class);
-
-   // --------------------------------------------------------------------------------||
-   // Functional Methods -------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Creates and returns a SLSB Container for the SLSB Implementation Class specified
-    * 
-    * @param slsbImplementationClass
-    * @return
-    * @throws Throwable
-    */
-   public static StatelessContainer createSlsb(Class<?> slsbImplementationClass) throws Throwable
-   {
-      // Get Metadata
-      JBossSessionBeanMetaData beanMetaData = Utils.getMetadataFromBeanImplClass(slsbImplementationClass);
-
-      // Make a Container
-      StatelessContainer container = new StatelessContainer(beanMetaData, Thread.currentThread()
-            .getContextClassLoader());
-
-      // Return
-      return container;
-   }
-
-   /**
-    * Creates and returns a SLSB Container for the SLSB Implementation Class specified
-    * 
-    * @param sfsbImplementationClass
-    * @return
-    * @throws Throwable
-    */
-   public static StatefulContainer createSfsb(Class<?> sfsbImplementationClass) throws Throwable
-   {
-      // Get Metadata
-      JBossSessionBeanMetaData beanMetaData = Utils.getMetadataFromBeanImplClass(sfsbImplementationClass);
-
-      // Make a Container
-      StatefulContainer container = new StatefulContainer(beanMetaData, Thread.currentThread().getContextClassLoader());
-
-      // Return
-      return container;
-   }
-
-   /**
-    * Mock the appropriate deployers and populate metadata for the EJB with the
-    * specified implementation class
-    * 
-    * @param beanImplClass
-    * @return
-    */
-   private static JBossSessionBeanMetaData getMetadataFromBeanImplClass(Class<?> beanImplClass)
-   {
-      // emulate annotation deployer
-      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
-      Collection<Class<?>> classes = new HashSet<Class<?>>();
-      classes.add(beanImplClass);
-      EjbJar30MetaData metaData = new EjbJar30Creator(finder).create(classes);
-
-      // emulate merge deployer
-      JBossMetaData mergedMetaData = new JBossMetaData();
-      mergedMetaData.merge(null, metaData);
-      
-      // Get delegate
-      JBossSessionBeanMetaData beanMetaDataDelegate = (JBossSessionBeanMetaData) mergedMetaData
-            .getEnterpriseBean(beanImplClass.getSimpleName());
-      
-      // Add Remote Binding manually
-      List<RemoteBindingMetaData> remoteBindings = new ArrayList<RemoteBindingMetaData>();
-      RemoteBindingMetaData remoteBinding = new RemoteBindingMetaData();
-      remoteBinding.setClientBindUrl("socket://localhost:3874");
-      remoteBindings.add(remoteBinding);
-      beanMetaDataDelegate.setRemoteBindings(remoteBindings);
-
-      // Use a Session JNDI Binding Policy for the metadata
-      JBossSessionPolicyDecorator beanMetaData = new JBossSessionPolicyDecorator(beanMetaDataDelegate);
-
-      // Log out JNDI Names
-      log.info("Business Remote JNDI Name: " + beanMetaData.determineJndiName()); // [beanName]/remote
-      for (String businessInterface : beanMetaData.getBusinessRemotes())
-      {
-         log.info("Business Remote JNDI Name for " + businessInterface + ": "
-               + beanMetaData.determineResolvedJndiName(businessInterface));
-      }
-      log.info("Local JNDI Name: " + beanMetaData.determineLocalJndiName()); // [beanName]/local
-      for (String businessInterface : beanMetaData.getBusinessLocals())
-      {
-         log.info("Business Local JNDI Name for " + businessInterface + ": "
-               + beanMetaData.determineResolvedJndiName(businessInterface));
-      }
-      log.info("Local Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getLocalHome()));
-      log.info("Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getHome()));
-
-      return beanMetaData;
-   }
-
-}

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -28,6 +28,7 @@
 import org.jboss.aop.Dispatcher;
 import org.jboss.beans.metadata.api.annotations.Start;
 import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
 import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
@@ -208,12 +209,15 @@
    {
       // Initialize
       String jndiRegistrarBindName = this.getJndiRegistrarBindName();
+      
+      // Obtain Registrar
+      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
 
       // Lookup
       Object obj = null;
       try
       {
-         obj = Ejb3RegistrarLocator.locateRegistrar().lookup(jndiRegistrarBindName);
+         obj = registrar.lookup(jndiRegistrarBindName);
       }
       // If not installed, warn and return null
       catch (NotBoundException e)
@@ -225,10 +229,10 @@
       }
 
       // Cast
-      JndiSessionRegistrarBase registrar = (JndiSessionRegistrarBase) obj;
+      JndiSessionRegistrarBase jndiRegistrar = (JndiSessionRegistrarBase) obj;
 
       // Return
-      return registrar;
+      return jndiRegistrar;
    }
 
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/trunk/test/pom.xml
===================================================================
--- projects/ejb3/trunk/test/pom.xml	2008-06-04 02:21:05 UTC (rev 74059)
+++ projects/ejb3/trunk/test/pom.xml	2008-06-04 02:25:33 UTC (rev 74060)
@@ -4,7 +4,7 @@
   <parent>
     <artifactId>jboss-ejb3-build</artifactId>
     <groupId>org.jboss.ejb3</groupId>
-    <version>0.13.4</version>
+    <version>0.13.6</version>
     <relativePath>../build/pom.xml</relativePath>
   </parent>
 
@@ -78,6 +78,11 @@
       <artifactId>jboss-kernel</artifactId>
     </dependency>
     
+    <dependency>
+      <groupId>org.jboss.metadata</groupId>
+      <artifactId>jboss-metadata</artifactId>
+    </dependency>
+    
   </dependencies>
 
   <scm>

Copied: projects/ejb3/trunk/test/src/main/java/org/jboss/ejb3/test/common/MetaDataHelper.java (from rev 73914, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MetaDataHelper.java)
===================================================================
--- projects/ejb3/trunk/test/src/main/java/org/jboss/ejb3/test/common/MetaDataHelper.java	                        (rev 0)
+++ projects/ejb3/trunk/test/src/main/java/org/jboss/ejb3/test/common/MetaDataHelper.java	2008-06-04 02:25:33 UTC (rev 74060)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.common;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
+import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MetaDataHelper
+{
+   private static final Logger log = Logger.getLogger(MetaDataHelper.class);
+
+   /**
+    * Create an empty JBossSessionBeanMetaData to satisfy BeanInterceptorMetaDataBridge.
+    * 
+    * @return
+    */
+   public static JBossSessionBeanMetaData createMockBeanMetaData()
+   {
+      JBossMetaData metaData = new JBossMetaData();
+      JBossEnterpriseBeansMetaData enterpriseBeans = new JBossEnterpriseBeansMetaData();
+      metaData.setEnterpriseBeans(enterpriseBeans);
+      metaData.setAssemblyDescriptor(new JBossAssemblyDescriptorMetaData());
+      JBossSessionBeanMetaData sessionBeanMetaData = new JBossSessionBeanMetaData();
+      sessionBeanMetaData.setEnterpriseBeansMetaData(enterpriseBeans);
+      return sessionBeanMetaData;
+   }
+
+   /**
+    * Mock the appropriate deployers and populate metadata for the EJB with the
+    * specified implementation class
+    * 
+    * @param beanImplClass
+    * @return
+    */
+   public static JBossSessionBeanMetaData getMetadataFromBeanImplClass(Class<?> beanImplClass)
+   {
+      //TODO
+      /*
+       * EjbJar30Creator will be replaced by JBossSessionBeanMetaDataCreator
+       * http://www.jboss.com/index.html?module=bb&op=viewtopic&t=136416
+       */
+
+      // emulate annotation deployer
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      Collection<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(beanImplClass);
+      EjbJar30MetaData metaData = new EjbJar30Creator(finder).create(classes);
+
+      // emulate merge deployer
+      JBossMetaData mergedMetaData = new JBossMetaData();
+      mergedMetaData.merge(null, metaData);
+
+      // Get delegate
+      JBossSessionBeanMetaData beanMetaDataDelegate = (JBossSessionBeanMetaData) mergedMetaData
+            .getEnterpriseBean(beanImplClass.getSimpleName());
+
+      //TODO When JBossSessionBeanMetaDataCreator is done, remove this
+      // Add Remote Binding manually
+      if (beanMetaDataDelegate.getBusinessRemotes() != null)
+      {
+         List<RemoteBindingMetaData> remoteBindings = new ArrayList<RemoteBindingMetaData>();
+         RemoteBindingMetaData remoteBinding = new RemoteBindingMetaData();
+         remoteBinding.setClientBindUrl("socket://localhost:3874"); //TODO Hardcoded bad
+         remoteBindings.add(remoteBinding);
+         beanMetaDataDelegate.setRemoteBindings(remoteBindings);
+      }
+
+      // Use a Session JNDI Binding Policy for the metadata
+      JBossSessionPolicyDecorator beanMetaData = new JBossSessionPolicyDecorator(beanMetaDataDelegate);
+
+      /*
+       * Log Out JNDI Names
+       */
+
+      // Business Remotes
+      BusinessRemotesMetaData businessRemotes = beanMetaData.getBusinessRemotes();
+      if (businessRemotes != null)
+      {
+         log.info("Business Remote JNDI Name: " + beanMetaData.determineJndiName()); // [beanName]/remote
+         for (String businessInterface : beanMetaData.getBusinessRemotes())
+         {
+            log.info("Business Remote JNDI Name for " + businessInterface + ": "
+                  + beanMetaData.determineResolvedJndiName(businessInterface));
+         }
+      }
+
+      // Business Locals
+      BusinessLocalsMetaData businessLocals = beanMetaData.getBusinessLocals();
+      if (businessLocals != null)
+      {
+         log.info("Local JNDI Name: " + beanMetaData.determineLocalJndiName()); // [beanName]/local
+         for (String businessInterface : beanMetaData.getBusinessLocals())
+         {
+            log.info("Business Local JNDI Name for " + businessInterface + ": "
+                  + beanMetaData.determineResolvedJndiName(businessInterface));
+         }
+      }
+
+      // Local Home
+      String localHome = beanMetaData.getLocalHome();
+      if (localHome != null && !localHome.trim().equals(""))
+      {
+         log.info("Local Home JNDI Name: " + beanMetaData.determineResolvedJndiName(localHome));
+      }
+
+      // Home
+      String home = beanMetaData.getHome();
+      if (home != null && !home.trim().equals(""))
+      {
+         log.info("Home JNDI Name: " + beanMetaData.determineResolvedJndiName(home));
+      }
+
+      return beanMetaData;
+   }
+}




More information about the jboss-cvs-commits mailing list