[jboss-cvs] JBossAS SVN: r89774 - in projects/webbeans-ri-int/trunk: ejb and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 3 18:45:39 EDT 2009


Author: petemuir
Date: 2009-06-03 18:45:39 -0400 (Wed, 03 Jun 2009)
New Revision: 89774

Modified:
   projects/webbeans-ri-int/trunk/ejb/pom.xml
   projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionBeanDescriptorAdaptor.java
   projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java
   projects/webbeans-ri-int/trunk/pom.xml
Log:
support for EJB remove methods

Modified: projects/webbeans-ri-int/trunk/ejb/pom.xml
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/pom.xml	2009-06-03 22:37:25 UTC (rev 89773)
+++ projects/webbeans-ri-int/trunk/ejb/pom.xml	2009-06-03 22:45:39 UTC (rev 89774)
@@ -29,6 +29,12 @@
     </dependency>
     
     <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-endpoint-deployer</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
        <groupId>org.jboss.jpa</groupId>
        <artifactId>jboss-jpa-deployers</artifactId>
        <scope>provided</scope>

Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionBeanDescriptorAdaptor.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionBeanDescriptorAdaptor.java	2009-06-03 22:37:25 UTC (rev 89773)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionBeanDescriptorAdaptor.java	2009-06-03 22:45:39 UTC (rev 89774)
@@ -24,6 +24,7 @@
    private final boolean stateless;
    private final boolean singleton;
    private final String localJndiName;
+   private final DeploymentUnit deploymentUnit;
    
    public JBossSessionBeanDescriptorAdaptor(JBossSessionBeanMetaData sessionBeanMetaData, DeploymentUnit deploymentUnit, EjbReferenceResolver resolver)
    {
@@ -87,6 +88,7 @@
       this.stateless = sessionBeanMetaData.isStateless();
       this.singleton = false;
       this.localJndiName = sessionBeanMetaData.getLocalJndiName();
+      this.deploymentUnit = deploymentUnit;
    }
    
    public Iterable<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces()
@@ -123,5 +125,15 @@
    {
       return false;
    }
+   
+   public String getLocalJndiName()
+   {
+      return localJndiName;
+   }
+   
+   public DeploymentUnit getDeploymentUnit()
+   {
+      return deploymentUnit;
+   }
 
 }

Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java	2009-06-03 22:37:25 UTC (rev 89773)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossSessionObjectReference.java	2009-06-03 22:45:39 UTC (rev 89774)
@@ -1,41 +1,49 @@
 package org.jboss.webbeans.integration.ejb;
-import java.util.Iterator;
+import java.io.Serializable;
+import java.lang.reflect.Proxy;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
 
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.endpoint.Endpoint;
+import org.jboss.ejb3.endpoint.deployers.EndpointResolver;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
 import org.jboss.webbeans.ejb.api.SessionObjectReference;
-import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
 import org.jboss.webbeans.ejb.spi.EjbDescriptor;
 
 
 public class JBossSessionObjectReference implements SessionObjectReference
 {
+   
+   private static final String MC_BIND_NAME_ENDPOINT_RESOLVER = "EJB3EndpointResolver";
 
    private static final long serialVersionUID = 8227728506645839338L;
    
    private final Object reference;
-   
+   private final Serializable id; 
+   private final DeploymentUnit deploymentUnit;
+   private final String ejbClassName;
+    
    public JBossSessionObjectReference(EjbDescriptor<?> descriptor, Context context) throws NamingException
    {
-      Iterator<BusinessInterfaceDescriptor<?>> it = descriptor.getLocalBusinessInterfaces().iterator();
-      if (!it.hasNext())
+      if (!(descriptor instanceof JBossSessionBeanDescriptorAdaptor))
       {
-         throw new IllegalStateException("No local interfaces for " + descriptor);
+         throw new IllegalArgumentException("Can only operate on JBoss EJB3");
       }
-      String fullJndiName = it.next().getJndiName();
-      String jndiName = fullJndiName.substring(0, fullJndiName.lastIndexOf("-"));
-      reference = context.lookup(jndiName);
-   }
-   
-   public void create()
-   {
-      if (reference == null)
+      else
       {
-         
+         reference = context.lookup(((JBossSessionBeanDescriptorAdaptor<?>) descriptor).getLocalJndiName());
+         final SessionProxyInvocationHandler handler = (SessionProxyInvocationHandler) Proxy.getInvocationHandler(reference);
+         id = (Serializable) handler.getTarget();
       }
+      this.deploymentUnit = ((JBossSessionBeanDescriptorAdaptor<?>) descriptor).getDeploymentUnit();
+      this.ejbClassName = descriptor.getType().getSimpleName();
    }
    
+   @SuppressWarnings("unchecked")
    public <S> S getBusinessObject(Class<S> businessInterfaceType)
    {
       return (S) reference;
@@ -43,8 +51,18 @@
    
    public void remove()
    {
-      // TODO Auto-generated method stub
-      
+      getEndpoint().getSessionFactory().destroySession(id);      
    }
    
+   private Endpoint getEndpoint()
+   {
+      @Deprecated
+      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+
+      // Get the resolver
+      EndpointResolver resolver = registrar.lookup(MC_BIND_NAME_ENDPOINT_RESOLVER, EndpointResolver.class);
+      String endpointMcBindName = resolver.resolve(deploymentUnit, ejbClassName);
+      return registrar.lookup(endpointMcBindName, Endpoint.class);
+   }
+   
 }

Modified: projects/webbeans-ri-int/trunk/pom.xml
===================================================================
--- projects/webbeans-ri-int/trunk/pom.xml	2009-06-03 22:37:25 UTC (rev 89773)
+++ projects/webbeans-ri-int/trunk/pom.xml	2009-06-03 22:45:39 UTC (rev 89774)
@@ -34,6 +34,7 @@
     <version.jboss.metadata>1.0.0.CR18</version.jboss.metadata>
     <version.jbossxb>2.0.1.GA</version.jbossxb>
     <version.jboss.ejb3>1.0.0</version.jboss.ejb3>
+    <version.jboss.ejb3.endpoint>0.1.3</version.jboss.ejb3.endpoint>
     <version.jboss.jpa>1.0.0-CR1</version.jboss.jpa>
     <version.servlet.api>2.5</version.servlet.api>
     <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
@@ -330,6 +331,20 @@
          <artifactId>jboss-ejb3-common</artifactId>
          <version>${version.jboss.ejb3}</version>
       </dependency>
+
+
+      <dependency>
+         <groupId>org.jboss.ejb3</groupId>
+         <artifactId>jboss-ejb3-proxy</artifactId>
+         <classifier>client</classifier>
+         <version>${version.jboss.ejb3}</version>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.ejb3</groupId>
+         <artifactId>jboss-ejb3-endpoint-deployer</artifactId>
+         <version>${version.jboss.ejb3.endpoint}</version>
+      </dependency>
       
       <dependency>
          <groupId>org.jboss.jpa</groupId>




More information about the jboss-cvs-commits mailing list