[jboss-cvs] JBossAS SVN: r73665 - in projects/ejb3/trunk/proxy/src: main/java/org/jboss/ejb3/proxy/jndiregistrar and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun May 25 05:58:43 EDT 2008


Author: ALRubinger
Date: 2008-05-25 05:58:42 -0400 (Sun, 25 May 2008)
New Revision: 73665

Removed:
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/registry/
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/plugin/inmemory/
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/plugin/jndi/
   projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/plugin/
Modified:
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/Ejb3RegistrarProxyObjectFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java
   projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml
Log:
[EJBTHREE-1345] Removed ProxyFactoryRegistry, using Ejb3Registrar (MC) instead

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java	2008-05-25 09:58:42 UTC (rev 73665)
@@ -31,13 +31,13 @@
 import javax.naming.StringRefAddr;
 import javax.naming.spi.ObjectFactory;
 
+import org.jboss.ejb3.common.registrar.spi.DuplicateBindException;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
 import org.jboss.ejb3.common.string.StringUtils;
 import org.jboss.ejb3.proxy.factory.ProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionLocalProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
 import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryAlreadyRegisteredException;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -92,16 +92,11 @@
    private Context context;
 
    /**
-    * Implementation of ProxyFactoryRegistry to use
-    */
-   private ProxyFactoryRegistry registry;
-
-   /**
     * Fully-qualified class name of the JNDI Object Factory to Reference for SLSBs
     */
    private String statelessSessionProxyObjectFactoryType;
 
-   //TODO MDB, @Service, SFSB
+   //TODO @Service, SFSB
 
    // --------------------------------------------------------------------------------||
    // Constructor --------------------------------------------------------------------||
@@ -112,22 +107,15 @@
     * which may be null.
     * 
     * @param context The JNDI Context into which Objects will be bound
-    * @param registry The ProxyFactoryRegistry with which ProxyFactories will be registered
     * @param statelessSessionProxyObjectFactoryType String representation of the JNDI Object Factory to use for SLSBs
     */
-   public JndiRegistrar(final Context context, final ProxyFactoryRegistry registry,
-         String statelessSessionProxyObjectFactoryType)
+   public JndiRegistrar(final Context context, String statelessSessionProxyObjectFactoryType)
    {
       // Set the Context
       assert context != null : this + " may not be configured with null  " + Context.class.getName();
       this.setContext(context);
       log.debug("Using  " + Context.class.getName() + ": " + context);
 
-      // Set the ProxyFactoryRegistry
-      assert registry != null : this + " may not be configured with null  " + ProxyFactoryRegistry.class.getName();
-      this.setRegistry(registry);
-      log.debug("Using " + ProxyFactoryRegistry.class.getSimpleName() + ": " + registry);
-
       /*
        * Perform some assertions and logging
        */
@@ -578,32 +566,27 @@
    {
       // Get a unique key
       String key = this.getProxyFactoryRegistryKey(smd, isLocal);
-      assert !this.getRegistry().isRegistered(key) : "Attempting to register " + factory + " with "
-            + this.getRegistry() + " an already registered key, \"" + key + "\"";
 
-      /*
-       * Note on registry key collisions:
-       * 
-       * Indicates that either the keys created are not unique or that we're attempting to redeploy 
-       * an EJB that was not properly deregistered.  Either way, this is a programmatic problem
-       * and not the fault of the application developer/deployer
-       */
-
-      // Log
-      log.debug("Registering " + factory + " into " + ProxyFactoryRegistry.class.getSimpleName() + " under key \""
-            + key + "\"...");
-
       // Register
+      log.debug("Registering " + factory + " under key \"" + key + "\"...");
       try
       {
-         this.getRegistry().registerProxyFactory(key, factory);
+         Ejb3RegistrarLocator.locateRegistrar().bind(key, factory);
       }
-      catch (ProxyFactoryAlreadyRegisteredException e)
+      catch (DuplicateBindException e)
       {
          throw new RuntimeException("Could not register " + factory + " under an already registered key, \"" + key
-               + "\", with " + this.getRegistry(), e);
+               + "\"", e);
       }
 
+      /*
+       * Note on registry key collisions:
+       * 
+       * Indicates that either the keys created are not unique or that we're attempting to redeploy 
+       * an EJB that was not properly deregistered.  Either way, this is a programmatic problem
+       * and not the fault of the bean developer/deployer
+       */
+
       // Return the key
       return key;
    }
@@ -612,16 +595,6 @@
    // Accessors / Mutators -----------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
-   public ProxyFactoryRegistry getRegistry()
-   {
-      return registry;
-   }
-
-   public void setRegistry(ProxyFactoryRegistry registry)
-   {
-      this.registry = registry;
-   }
-
    public Context getContext()
    {
       return context;

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/Ejb3RegistrarProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/Ejb3RegistrarProxyObjectFactory.java	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/Ejb3RegistrarProxyObjectFactory.java	2008-05-25 09:58:42 UTC (rev 73665)
@@ -25,10 +25,6 @@
 
 import javax.naming.spi.ObjectFactory;
 
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.common.registrar.spi.NotBoundException;
-import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
 import org.jboss.logging.Logger;
 
 /**
@@ -52,48 +48,12 @@
    private static final Logger log = Logger.getLogger(Ejb3RegistrarProxyObjectFactory.class);
 
    // --------------------------------------------------------------------------------||
-   // Instance Members ---------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   //TODO
-   // Inject via IoC, must be configurable
-   private ProxyFactoryRegistry proxyFactoryRegistry;
-
-   // --------------------------------------------------------------------------------||
    // Constructor --------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
    public Ejb3RegistrarProxyObjectFactory()
    {
-      // Set the ProxyFactoryRegistry as obtained from the EJB3 Registrar
-      //TODO ProxyFactoryRegistry will be replaced by IoC itself
-      ProxyFactoryRegistry registry = null;
-      try
-      {
-         registry = (ProxyFactoryRegistry) Ejb3RegistrarLocator.locateRegistrar().lookup(
-               ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_PROXY_FACTORY_REGISTRY);
-      }
-      catch (NotBoundException e)
-      {
-         throw new RuntimeException(ProxyFactoryRegistry.class.getSimpleName()
-               + " is required to be bound in the Object Store, but was not", e);
-      }
-      this.setProxyFactoryRegistry(registry);
-   }
 
-   // --------------------------------------------------------------------------------||
-   // Accessors / Mutators -----------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   @Override
-   protected ProxyFactoryRegistry getProxyFactoryRegistry()
-   {
-      return this.proxyFactoryRegistry;
    }
 
-   public void setProxyFactoryRegistry(ProxyFactoryRegistry proxyFactoryRegistry)
-   {
-      this.proxyFactoryRegistry = proxyFactoryRegistry;
-   }
-
 }

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java	2008-05-25 09:58:42 UTC (rev 73665)
@@ -21,8 +21,6 @@
  */
 package org.jboss.ejb3.proxy.objectfactory;
 
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
-
 /**
  * ProxyFactoryReferenceAddressTypes
  * 
@@ -38,48 +36,48 @@
    // --------------------------------------------------------------------------------||
    // Constants ----------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
-   
+
    /*
     * The following are Reference Address Types denoting the type of interface
     * represented by the contents, which should be the fully-qualified class
     * name of the interface
     */
-   
+
    /**
     * Reference Address Type for EJB3 Remote Business Interfaces
     */
    String REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE = "Remote Business Interface";
-   
+
    /**
     * Reference Address Type for EJB3 Local Business Interfaces
     */
    String REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL = "Local Business Interface";
-   
+
    /**
     * Reference Address Type for EJB2.x Remote Home Interfaces
     */
    String REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE = "EJB 2.x Remote Home Interface";
-   
+
    /**
     * Reference Address Type for EJB2.x Local Home Interfaces
     */
    String REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL = "EJB 2.x Local Home Interface";
-   
+
    /*
     * The following are Reference Address Types denoting metadata
     * used for interaction with the ProxyFactoryRegistry
     */
-   
+
    /**
     * Reference Address Type for the key to which the desired ProxyFactory
-    * is bound in the ProxyFactoryRegistry
+    * is bound 
     */
-   String REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY = ProxyFactoryRegistry.class.getSimpleName() + "Key";
-   
+   String REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY = "ProxyFactoryKey";
+
    /*
     * The following are ReferenceAddress types denoting the Name of the EJB Container associated 
     * with a Reference
     */
    String REF_ADDR_TYPE_EJBCONTAINER_NAME = "EJB Container Name";
-   
+
 }

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java	2008-05-25 09:58:42 UTC (rev 73665)
@@ -35,9 +35,9 @@
 import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
 
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.factory.ProxyFactory;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
 import org.jboss.logging.Logger;
 
 /**
@@ -103,22 +103,21 @@
       assert proxyFactoryRegistryKeys.size() == 1 : assertionErrorMessage;
       String proxyFactoryRegistryKey = proxyFactoryRegistryKeys.get(0);
 
-      // Obtain Proxy Factory Registry
-      ProxyFactoryRegistry registry = this.getProxyFactoryRegistry();
-      assert registry != null : "Returned null " + ProxyFactoryRegistry.class.getName();
-
       // Obtain Proxy Factory
       ProxyFactory proxyFactory = null;
       try
       {
-         proxyFactory = registry.getProxyFactory(proxyFactoryRegistryKey);
+         Object pfObj = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryRegistryKey);
+         assert pfObj != null : ProxyFactory.class.getName() + " from key " + proxyFactoryRegistryKey + " was null";
+         assert pfObj instanceof ProxyFactory : " Object obtained from key " + proxyFactoryRegistryKey
+               + " was expected to be of type " + ProxyFactory.class.getName() + " but was instead " + pfObj;
+         proxyFactory = (ProxyFactory) pfObj;
       }
-      catch (ProxyFactoryNotRegisteredException pfnre)
+      catch (NotBoundException nbe)
       {
-         throw new RuntimeException(pfnre);
+         throw new RuntimeException("Could not obtain " + ProxyFactory.class.getSimpleName() + " from expected key \""
+               + proxyFactoryRegistryKey + "\"", nbe);
       }
-      assert proxyFactory != null : ProxyFactory.class.getName() + " returned from " + registry + " at key "
-            + proxyFactoryRegistryKey + " was null";
 
       // Return the proxy returned from the ProxyFactory
       Object proxy = this.getProxy(proxyFactory, name, refAddrs);
@@ -155,8 +154,6 @@
 
    protected abstract Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses);
 
-   protected abstract ProxyFactoryRegistry getProxyFactoryRegistry();
-
    // --------------------------------------------------------------------------------||
    // Internal Helper Methods --------------------------------------------------------||
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java	2008-05-25 09:58:42 UTC (rev 73665)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3.test.proxy.common.container;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
 import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
@@ -45,13 +47,23 @@
    // Instance Members ---------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
+   /**
+    * Cache of SFSB instances in key = sessionId and value = instance
+    */
+   private Map<Object, Object> cache;
+
    // --------------------------------------------------------------------------------||
-   // Constructor ---------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
    public StatefulContainer(JBossSessionBeanMetaData metaData, ClassLoader classLoader) throws ClassNotFoundException
    {
+      // Call super
       super(metaData, classLoader);
+
+      // Instanciate Cache
+      this.setCache(new HashMap<Object, Object>());
+
    }
 
    // --------------------------------------------------------------------------------||
@@ -65,11 +77,25 @@
     */
    public Object createSession()
    {
-      /* 
-       * Just create a UUID, in practice this would create a new instance and 
-       * associate it with an ID in the cache 
-       */
-      return UUID.randomUUID();
+      // Create a new Session ID
+      Object sessionId = UUID.randomUUID();
+
+      // Create a new Instance
+      Object instance = null;
+      try
+      {
+         instance = this.getBeanClass().newInstance();
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error in creating new instance of " + this.getBeanClass(), t);
+      }
+
+      // Place in cache
+      this.getCache().put(sessionId, instance);
+
+      // Return
+      return sessionId;
    }
 
    /**
@@ -83,4 +109,18 @@
             + UUID.randomUUID();
    }
 
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   protected Map<Object, Object> getCache()
+   {
+      return cache;
+   }
+
+   protected void setCache(Map<Object, Object> cache)
+   {
+      this.cache = cache;
+   }
+
 }

Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml	2008-05-25 04:30:32 UTC (rev 73664)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml	2008-05-25 09:58:42 UTC (rev 73665)
@@ -1,10 +1,10 @@
 <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
   xmlns="urn:jboss:bean-deployer:2.0">
- 
+
   <!-- JNDI -->
   <bean name="NameServer" class="org.jnp.server.SingletonNamingServer" />
-  
+
   <!--
     
     
@@ -27,16 +27,13 @@
         <inject bean="org.jboss.ejb3.JndiContext" />
       </parameter>
       <parameter>
-        <inject bean="org.jboss.ejb3.ProxyFactoryRegistry" />
-      </parameter>
-      <parameter>
         org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory
       </parameter>
     </constructor>
     <depends>NameServer</depends>
   </bean>
-  
-  <bean name="org.jboss.ejb3.JndiContext" class="javax.naming.InitialContext" />
-  <bean name="org.jboss.ejb3.ProxyFactoryRegistry" class="org.jboss.ejb3.proxy.plugin.inmemory.registry.InMemoryProxyFactoryRegistry" />
-    
+
+  <bean name="org.jboss.ejb3.JndiContext"
+    class="javax.naming.InitialContext" />
+
 </deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list