[jboss-cvs] JBossAS SVN: r75840 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: proxy/factory/stateful and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 15 08:54:04 EDT 2008


Author: ALRubinger
Date: 2008-07-15 08:54:04 -0400 (Tue, 15 Jul 2008)
New Revision: 75840

Added:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulLocalProxyFactory.java
Removed:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/BaseSessionProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulRemoteProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulClusterProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulRemoteProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/BaseStatelessRemoteProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessClusterProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessLocalProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessRemoteProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
Log:
[JBMETA-68] Update EJB3 to integrate with jboss-metadata changes

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/BaseSessionProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/BaseSessionProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/BaseSessionProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -29,6 +29,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -57,6 +58,10 @@
 import org.jboss.ejb3.session.SessionContainer;
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossSessionBeanJndiNameResolver;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
 import org.jboss.util.naming.Util;
 
 /**
@@ -187,7 +192,42 @@
          log.debug("Binding proxy for " + getContainer().getEjbName() + " in JNDI at " + this.getJndiName());
          Util.rebind(getContainer().getInitialContext(), this.getJndiName(), proxy);
          
-         // 
+         // Bind a proxy per business interface
+         //TODO This ugly block should be using polymorphism, but I'll allow it as the proxy mechanism 
+         // is going to be replaced entirely by EJB3 Proxy soon
+         JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) container.getXml();
+         BusinessRemotesMetaData remotes = smd.getBusinessRemotes();
+         BusinessLocalsMetaData locals = smd.getBusinessLocals();
+         Set<String> businessInterfaces = new HashSet<String>();
+         boolean isLocal = this.isLocal();
+         if (!isLocal)
+         {
+            if (remotes != null)
+            {
+               businessInterfaces.addAll(remotes);
+            }
+         }
+         else
+         {
+            if (locals != null)
+            {
+               businessInterfaces.addAll(locals);
+            }
+         }
+         for (String businessInterface : businessInterfaces)
+         {
+            String jndiName = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessInterface);
+            log.debug("Binding proxy for " + getContainer().getEjbName() + ", interface " + businessInterface
+                  + " in JNDI at " + jndiName);
+            if(Proxy.isProxyClass(proxy.getClass()))
+            {
+               for(Class<?> in : proxy.getClass().getInterfaces())
+               {
+                 log.debug("Proxy Interface for JNDI Name " + jndiName + ": " + in);
+               }
+            }
+            Util.rebind(this.getContainer().getInitialContext(), jndiName, proxy);
+         }
          
       } catch (NamingException e)
       {
@@ -200,6 +240,15 @@
    }
    
    /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   protected abstract boolean isLocal();
+   
+   /**
     * Whether or not to bind the home and business interfaces together
     * 
     * @return

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -44,11 +44,9 @@
 import javax.management.ObjectName;
 
 import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.KernelAbstraction;
 import org.jboss.ejb3.KernelAbstractionFactory;
-import org.jboss.ejb3.annotation.JndiBindingPolicy;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.LocalHomeBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
@@ -61,10 +59,6 @@
 import org.jboss.ejb3.stateless.StatelessContainer;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.BasicJndiBindingPolicy;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DeploymentSummary;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
 import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossEnterpriseBeanJndiNameResolver;
 import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossSessionBeanJndiNameResolver;
 
@@ -971,6 +965,9 @@
             .getXml());
    }
 
+   /*
+    * Commented out; not used
+    */
 //   /**
 //    * Obtains the JNDI Binding Policy for the specified container
 //    * 
@@ -1019,22 +1016,22 @@
 //         throw new RuntimeException(e);
 //      }
 //   }
-
-   private static EjbDeploymentSummary getDeploymentSummaryFromContainer(EJBContainer container)
-   {
-      // Construct Deployment Summary
-      DeploymentSummary dsummary = new DeploymentSummary();
-      dsummary.setDeploymentName(container.getDeployment().getName());
-      DeploymentScope scope = container.getDeployment().getEar();
-      if (scope != null)
-      {
-         dsummary.setDeploymentScopeBaseName(scope.getBaseName());
-      }
-      
-      // Construct EjbDeploymetSummary
-      EjbDeploymentSummary summary = new EjbDeploymentSummary(container.getXml(),dsummary);
-      
-      // Return
-      return summary;
-   }
+//
+//   private static EjbDeploymentSummary getDeploymentSummaryFromContainer(EJBContainer container)
+//   {
+//      // Construct Deployment Summary
+//      DeploymentSummary dsummary = new DeploymentSummary();
+//      dsummary.setDeploymentName(container.getDeployment().getName());
+//      DeploymentScope scope = container.getDeployment().getEar();
+//      if (scope != null)
+//      {
+//         dsummary.setDeploymentScopeBaseName(scope.getBaseName());
+//      }
+//      
+//      // Construct EjbDeploymetSummary
+//      EjbDeploymentSummary summary = new EjbDeploymentSummary(container.getXml(),dsummary);
+//      
+//      // Return
+//      return summary;
+//   }
 }
\ No newline at end of file

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -85,24 +85,26 @@
       this.init();
       
       // Bind the Proxy Factory
-      Context ctx = getContainer().getInitialContext();
-      Name name = ctx.getNameParser("").parse(jndiName);
-      ctx = Util.createSubcontext(ctx, name.getPrefix(name.size() - 1));
-      String atom = name.get(name.size() - 1);
+      //Context ctx = getContainer().getInitialContext();
+      //Name name = ctx.getNameParser("").parse(jndiName);
+      //ctx = Util.createSubcontext(ctx, name.getPrefix(name.size() - 1));
+      //String atom = name.get(name.size() - 1);
       RefAddr refAddr = new StringRefAddr(JndiSessionProxyObjectFactory.REF_ADDR_NAME_JNDI_BINDING_DELEGATE_PROXY_FACTORY, jndiName + PROXY_FACTORY_NAME);
       Reference ref = new Reference(Object.class.getName(), refAddr, JndiSessionProxyObjectFactory.class.getName(), null);
-      try
-      {
-         log.debug("Binding reference for " + getContainer().getEjbName() + " in JNDI at " + jndiName);
-         Util.rebind(ctx, atom, ref);
-      }
-      catch (NamingException e)
-      {
-         NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name "
-               + getContainer().getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
-         namingException.setRootCause(e);
-         throw namingException;
-      }
+//      try
+//      {
+//         log.debug("Binding reference for " + getContainer().getEjbName() + " in JNDI at " + jndiName);
+//         Util.rebind(ctx, atom, ref);
+//      }
+//      catch (NamingException e)
+//      {
+//         NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name "
+//               + getContainer().getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
+//         namingException.setRootCause(e);
+//         throw namingException;
+//      }
+      
+      this.bindProxy(ref);
    }
 
    public void stop() throws Exception

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulRemoteProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/BaseStatefulRemoteProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -36,6 +36,8 @@
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.stateful.StatefulHandleRemoteImpl;
 import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossSessionBeanJndiNameResolver;
 import org.jboss.remoting.InvokerLocator;
 
 /**
@@ -62,7 +64,8 @@
    // Constructor
    public BaseStatefulRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
-      super(container, binding.jndiBinding());
+      super(container, JbossSessionBeanJndiNameResolver
+            .resolveRemoteBusinessDefaultJndiName((JBossSessionBeanMetaData) container.getXml()));
       
       this.binding = binding;
       

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulClusterProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulClusterProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -109,6 +109,19 @@
    }
    
    /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return false;
+   }
+   
+   /**
     * Defines the access type for this Proxies created by this Factory
     * 
     * @return

Copied: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulLocalProxyFactory.java (from rev 75726, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java)
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulLocalProxyFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulLocalProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.proxy.factory.stateful;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.rmi.dgc.VMID;
+
+import javax.ejb.EJBLocalObject;
+import javax.ejb.LocalHome;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.SpecificationInterfaceType;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.proxy.handler.stateful.StatefulLocalHomeProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.stateful.StatefulLocalProxyInvocationHandler;
+import org.jboss.ejb3.session.ProxyAccessType;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.proxy.ejb.handle.StatefulHandleImpl;
+import org.jboss.util.NotImplementedException;
+import org.jboss.util.naming.Util;
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class StatefulLocalProxyFactory extends BaseStatefulProxyFactory
+{
+   private VMID vmid = Ejb3Registry.getVMID();
+   
+   /**
+    * Do not call, only for externalizable
+    */
+   public StatefulLocalProxyFactory()
+   {
+      super();
+   }
+   
+   public StatefulLocalProxyFactory(SessionSpecContainer container, LocalBinding binding)
+   {
+      super(container, binding.jndiBinding());
+   }
+   
+   /**
+    * Returns the interface type for Home
+    * 
+    * @return
+    */
+   @Override
+   protected Class<?> getHomeType()
+   {
+      return ProxyFactoryHelper.getLocalHomeInterface(this.getContainer());
+   }
+   
+   /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return true;
+   }
+
+   /**
+    * Defines the access type for this Proxies created by this Factory
+    * 
+    * @return
+    */
+   @Override
+   protected ProxyAccessType getProxyAccessType(){
+      return ProxyAccessType.LOCAL;
+   }
+   
+   protected void validateEjb21Views()
+   { 
+      // Obtain Container
+      SessionContainer container = this.getContainer();
+      
+      // Obtain @LocalHome
+      LocalHome localHome = container.getAnnotation(LocalHome.class);
+
+      // Ensure that if EJB 2.1 Components are defined, they're complete
+      this.validateEjb21Views(localHome == null ? null : localHome.value(), ProxyFactoryHelper
+            .getLocalInterfaces(container));
+
+   }
+   
+   /**
+    * Whether or not to bind the home and business interfaces together
+    * 
+    * @return
+    */
+   @Override
+   protected boolean bindHomeAndBusinessTogether()
+   {
+      return ProxyFactoryHelper.getLocalHomeJndiName(this.getContainer()).equals(this.jndiName);
+   }
+
+   public void start() throws Exception
+   {
+      super.start();
+
+      try
+      {
+         Util.rebind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME, this);
+      }
+      catch (NamingException e)
+      {
+         NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name "
+               + getContainer().getEjbName() + " into JNDI under jndiName: "
+               + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
+         namingException.setRootCause(e);
+         throw namingException;
+      }
+
+      SessionContainer statefulContainer = (SessionContainer) getContainer();
+      LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
+      if (localHome != null && !bindHomeAndBusinessTogether())
+      {
+         Class<?>[] interfaces =
+         {localHome.value()};
+         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(statefulContainer.getBeanClass().getClassLoader(),
+               interfaces, new StatefulLocalHomeProxyInvocationHandler(statefulContainer));
+         Util.rebind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer),
+               homeProxy);
+      }
+   }
+
+   public void stop() throws Exception
+   {
+      super.stop();
+      Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
+      SessionContainer statefulContainer = this.getContainer();
+      LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
+      if (localHome != null && !bindHomeAndBusinessTogether())
+      {
+         Util.unbind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer));
+      }
+   }
+
+   public Object createProxyBusiness()
+   {
+      SessionContainer sfsb = (SessionContainer) getContainer();
+      Object id = sfsb.createSession();
+      return this.createProxyBusiness(id);
+   }
+   
+   public EJBLocalObject createProxyEjb21(String businessInterfaceType)
+   {
+      Object id = getContainer().createSession();
+      return this.createProxyEjb21(id, businessInterfaceType);
+   }
+   
+   public Object createProxyBusiness(String businessInterfaceType)
+   {
+      return this.createProxyBusiness(null, businessInterfaceType);
+   }
+
+   public Object createProxyBusiness(Object id)
+   {
+      return this.createProxyBusiness(id, null);
+   }
+
+   public Object createProxyBusiness(Object id, String businessInterfaceType)
+   {
+      return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS, businessInterfaceType);
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T extends EJBLocalObject> T createProxyEjb21(Object id, String businessInterfaceType)
+   {
+      return (T) this.createProxy(id, SpecificationInterfaceType.EJB21, null);
+   }
+
+   private Object createProxy(Object id, SpecificationInterfaceType type, String businessInterfaceType)
+   {
+      StatefulLocalProxyInvocationHandler proxy = new StatefulLocalProxyInvocationHandler(this.getContainer(), id,
+            vmid, businessInterfaceType);
+      return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructProxyBusiness(proxy) : this
+            .constructEjb21Proxy(proxy);
+   }
+
+   public Object createProxy(Class<?>[] initTypes, Object[] initValues)
+   {
+      SessionContainer sfsb = (SessionContainer) getContainer();
+      Object id = sfsb.createSession(initTypes, initValues);
+      return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS, null);
+   }
+
+   public Object createProxyEjb21(Class<?>[] initTypes, Object[] initValues, String businessInterfaceType)
+   {
+      SessionContainer sfsb = (SessionContainer) getContainer();
+      Object id = sfsb.createSession(initTypes, initValues);
+      return this.createProxyEjb21(id, businessInterfaceType);
+   }
+
+   protected StatefulHandleImpl createHandle()
+   {
+      throw new NotImplementedException("NYI");
+   }
+   
+   @Override
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      super.readExternal(in);
+      vmid = (VMID)in.readObject();
+   }
+
+   @Override
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      super.writeExternal(out);
+      out.writeObject(vmid);
+   }
+}

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulRemoteProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateful/StatefulRemoteProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -63,6 +63,19 @@
    {
       super(container, binding);
    }
+   
+   /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return false;
+   }
 
    @Override
    public void start() throws Exception

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/BaseStatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/BaseStatelessRemoteProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/BaseStatelessRemoteProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -14,6 +14,8 @@
 import org.jboss.ejb3.session.SessionContainer;
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.stateless.StatelessHandleRemoteImpl;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossSessionBeanJndiNameResolver;
 import org.jboss.remoting.InvokerLocator;
 
 public abstract class BaseStatelessRemoteProxyFactory extends BaseStatelessProxyFactory implements RemoteProxyFactory
@@ -28,7 +30,8 @@
    // Constructor
    public BaseStatelessRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
-      super(container, binding.jndiBinding());
+      super(container, JbossSessionBeanJndiNameResolver
+            .resolveRemoteBusinessDefaultJndiName((JBossSessionBeanMetaData) container.getXml()));
       
       this.binding = binding;
       

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessClusterProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessClusterProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -81,6 +81,19 @@
       this.binding = binding;
       this.clustered = clustered;
    }
+   
+   /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return false;
+   }
 
    public void start() throws Exception
    {

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessLocalProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessLocalProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -33,6 +33,8 @@
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.stateless.StatelessHandleRemoteImpl;
 import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.JbossSessionBeanJndiNameResolver;
 import org.jboss.util.naming.Util;
 
 
@@ -48,7 +50,8 @@
    
    public StatelessLocalProxyFactory(SessionSpecContainer container, LocalBinding binding)
    {
-      super(container, binding.jndiBinding());
+      super(container, JbossSessionBeanJndiNameResolver
+            .resolveLocalBusinessDefaultJndiName((JBossSessionBeanMetaData) container.getXml()));
    }
    
    /**
@@ -68,6 +71,19 @@
    {
       return ProxyAccessType.LOCAL;
    }
+   
+   /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return true;
+   }
 
    
    protected void validateEjb21Views(){

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessRemoteProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/stateless/StatelessRemoteProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -69,6 +69,19 @@
    {
       super.init();
    }
+   
+   /**
+    * Returns whether this Proxy Factory is local.  A Hack until EJB3 Proxy 
+    * is in place, but this keeps us moving forward easily.
+    * 
+    * @deprecated Hack
+    * @return
+    */
+   @Deprecated
+   protected boolean isLocal()
+   {
+      return false;
+   }
 
    public void start() throws Exception
    {

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -68,6 +68,7 @@
 import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateful.BaseStatefulRemoteProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateful.StatefulClusterProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateful.StatefulLocalProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateful.StatefulProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateful.StatefulRemoteProxyFactory;
 import org.jboss.ejb3.proxy.impl.EJBMetaDataImpl;

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2008-07-15 12:33:00 UTC (rev 75839)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2008-07-15 12:54:04 UTC (rev 75840)
@@ -1,233 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.stateful;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.rmi.dgc.VMID;
-
-import javax.ejb.EJBLocalObject;
-import javax.ejb.LocalHome;
-import javax.naming.NamingException;
-
-import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.ejb3.SpecificationInterfaceType;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.stateful.BaseStatefulProxyFactory;
-import org.jboss.ejb3.proxy.handler.stateful.StatefulLocalHomeProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.stateful.StatefulLocalProxyInvocationHandler;
-import org.jboss.ejb3.session.ProxyAccessType;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.ejb3.session.SessionSpecContainer;
-import org.jboss.proxy.ejb.handle.StatefulHandleImpl;
-import org.jboss.util.NotImplementedException;
-import org.jboss.util.naming.Util;
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class StatefulLocalProxyFactory extends BaseStatefulProxyFactory
-{
-   private VMID vmid = Ejb3Registry.getVMID();
-   
-   /**
-    * Do not call, only for externalizable
-    */
-   public StatefulLocalProxyFactory()
-   {
-      super();
-   }
-   
-   public StatefulLocalProxyFactory(SessionSpecContainer container, LocalBinding binding)
-   {
-      super(container, binding.jndiBinding());
-   }
-   
-   /**
-    * Returns the interface type for Home
-    * 
-    * @return
-    */
-   @Override
-   protected Class<?> getHomeType()
-   {
-      return ProxyFactoryHelper.getLocalHomeInterface(this.getContainer());
-   }
-
-   /**
-    * Defines the access type for this Proxies created by this Factory
-    * 
-    * @return
-    */
-   @Override
-   protected ProxyAccessType getProxyAccessType(){
-      return ProxyAccessType.LOCAL;
-   }
-   
-   protected void validateEjb21Views()
-   { 
-      // Obtain Container
-      SessionContainer container = this.getContainer();
-      
-      // Obtain @LocalHome
-      LocalHome localHome = container.getAnnotation(LocalHome.class);
-
-      // Ensure that if EJB 2.1 Components are defined, they're complete
-      this.validateEjb21Views(localHome == null ? null : localHome.value(), ProxyFactoryHelper
-            .getLocalInterfaces(container));
-
-   }
-   
-   /**
-    * Whether or not to bind the home and business interfaces together
-    * 
-    * @return
-    */
-   @Override
-   protected boolean bindHomeAndBusinessTogether()
-   {
-      return ProxyFactoryHelper.getLocalHomeJndiName(this.getContainer()).equals(this.jndiName);
-   }
-
-   public void start() throws Exception
-   {
-      super.start();
-
-      try
-      {
-         Util.rebind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME, this);
-      }
-      catch (NamingException e)
-      {
-         NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name "
-               + getContainer().getEjbName() + " into JNDI under jndiName: "
-               + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
-         namingException.setRootCause(e);
-         throw namingException;
-      }
-
-      SessionContainer statefulContainer = (SessionContainer) getContainer();
-      LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
-      if (localHome != null && !bindHomeAndBusinessTogether())
-      {
-         Class<?>[] interfaces =
-         {localHome.value()};
-         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(statefulContainer.getBeanClass().getClassLoader(),
-               interfaces, new StatefulLocalHomeProxyInvocationHandler(statefulContainer));
-         Util.rebind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer),
-               homeProxy);
-      }
-   }
-
-   public void stop() throws Exception
-   {
-      super.stop();
-      Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
-      SessionContainer statefulContainer = this.getContainer();
-      LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
-      if (localHome != null && !bindHomeAndBusinessTogether())
-      {
-         Util.unbind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer));
-      }
-   }
-
-   public Object createProxyBusiness()
-   {
-      SessionContainer sfsb = (SessionContainer) getContainer();
-      Object id = sfsb.createSession();
-      return this.createProxyBusiness(id);
-   }
-   
-   public EJBLocalObject createProxyEjb21(String businessInterfaceType)
-   {
-      Object id = getContainer().createSession();
-      return this.createProxyEjb21(id, businessInterfaceType);
-   }
-   
-   public Object createProxyBusiness(String businessInterfaceType)
-   {
-      return this.createProxyBusiness(null, businessInterfaceType);
-   }
-
-   public Object createProxyBusiness(Object id)
-   {
-      return this.createProxyBusiness(id, null);
-   }
-
-   public Object createProxyBusiness(Object id, String businessInterfaceType)
-   {
-      return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS, businessInterfaceType);
-   }
-
-   @SuppressWarnings("unchecked")
-   public <T extends EJBLocalObject> T createProxyEjb21(Object id, String businessInterfaceType)
-   {
-      return (T) this.createProxy(id, SpecificationInterfaceType.EJB21, null);
-   }
-
-   private Object createProxy(Object id, SpecificationInterfaceType type, String businessInterfaceType)
-   {
-      StatefulLocalProxyInvocationHandler proxy = new StatefulLocalProxyInvocationHandler(this.getContainer(), id,
-            vmid, businessInterfaceType);
-      return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructProxyBusiness(proxy) : this
-            .constructEjb21Proxy(proxy);
-   }
-
-   public Object createProxy(Class<?>[] initTypes, Object[] initValues)
-   {
-      SessionContainer sfsb = (SessionContainer) getContainer();
-      Object id = sfsb.createSession(initTypes, initValues);
-      return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS, null);
-   }
-
-   public Object createProxyEjb21(Class<?>[] initTypes, Object[] initValues, String businessInterfaceType)
-   {
-      SessionContainer sfsb = (SessionContainer) getContainer();
-      Object id = sfsb.createSession(initTypes, initValues);
-      return this.createProxyEjb21(id, businessInterfaceType);
-   }
-
-   protected StatefulHandleImpl createHandle()
-   {
-      throw new NotImplementedException("NYI");
-   }
-   
-   @Override
-   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
-   {
-      super.readExternal(in);
-      vmid = (VMID)in.readObject();
-   }
-
-   @Override
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      super.writeExternal(out);
-      out.writeObject(vmid);
-   }
-}




More information about the jboss-cvs-commits mailing list