[Jboss-cvs] JBossAS SVN: r56434 - in trunk/ejb3/src: main/org/jboss/ejb3 main/org/jboss/ejb3/iiop main/org/jboss/ejb3/service main/org/jboss/ejb3/stateful test/org/jboss/ejb3/test/iiop test/org/jboss/ejb3/test/iiop/unit

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 30 06:52:56 EDT 2006


Author: wolfc
Date: 2006-08-30 06:52:40 -0400 (Wed, 30 Aug 2006)
New Revision: 56434

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
Log:
EJBTHREE-667: HandleDelegate fixes & Service bean

Modified: trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -294,9 +294,12 @@
 
          Interceptor[] aspects = info.getInterceptors();
          // FIXME: Ahem, stateful container invocation works on all.... (violating contract though)
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, aspects, id);
+         EJBContainerInvocation nextInvocation = new StatefulContainerInvocation(info, aspects, id);
          nextInvocation.setAdvisor(this);
          nextInvocation.setArguments(args);
+         
+         // allow a container to supplement information into an invocation
+         nextInvocation = populateInvocation(nextInvocation);
 
          ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
          try
@@ -408,5 +411,16 @@
       throw new RuntimeException("NYI");
    }
    
-   abstract protected void removeHandle(Handle handle);
+   /**
+    * Allow a container sub class to supplement an invocation. Per default nothing to supplement.
+    * 
+    * @param invocation
+    * @return
+    */
+   protected EJBContainerInvocation populateInvocation(EJBContainerInvocation invocation)
+   {
+      return invocation;
+   }
+   
+   abstract protected void removeHandle(Handle handle) throws Exception;
 }
\ No newline at end of file

Modified: trunk/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -37,6 +37,7 @@
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.aop.Advisor;
 import org.jboss.ejb3.Container;
+import org.jboss.ejb3.NonSerializableFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.SessionContainer;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
@@ -53,6 +54,7 @@
 import org.jboss.metadata.IorSecurityConfigMetaData;
 import org.jboss.mx.loading.RepositoryClassLoader;
 import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.proxy.ejb.handle.HandleDelegateImpl;
 import org.jboss.system.Registry;
 import org.jboss.web.WebClassLoader;
 import org.jboss.web.WebServiceMBean;
@@ -369,6 +371,11 @@
          
          rebind(ctx, getJndiName() + "Home", (org.omg.CORBA.Object) homeObject);
       }
+      
+      // bind HandleDelegate stuff
+      Context compCtx = (Context) new InitialContext().lookup("java:comp");
+      NonSerializableFactory.rebind(compCtx, "ORB", orb);
+      NonSerializableFactory.rebind(compCtx, "HandleDelegate", new HandleDelegateImpl());
    }
    
    public void stop() throws Exception

Modified: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -317,6 +317,7 @@
       }
    }
 
+   @Override
    protected EJBContainerInvocation populateInvocation(EJBContainerInvocation invocation)
    {
       invocation.setTargetObject(singleton);

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -869,10 +869,13 @@
       throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
    }
 
-   protected void removeHandle(Handle arg)
+   protected void removeHandle(Handle arg) throws Exception
    {
+      /*
       StatefulHandleImpl handle = (StatefulHandleImpl) arg;
 
       destroySession(handle.id);
+      */
+      arg.getEJBObject().remove();
    }
 }

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.iiop;
+
+import javax.ejb.Remote;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.ejb.Service;
+import org.jboss.ejb3.iiop.IORFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Service
+ at Remote(MyStateful.class)
+ at RemoteBinding(factory=IORFactory.class)
+public class MyServiceBean
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(MyServiceBean.class);
+   
+   private String name;
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public String sayHello()
+   {
+      return "Hello " + name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java	2006-08-30 08:37:29 UTC (rev 56433)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java	2006-08-30 10:52:40 UTC (rev 56434)
@@ -37,17 +37,13 @@
 
 import org.jboss.ejb3.test.CustomJNDIJBossTestCase;
 import org.jboss.ejb3.test.iiop.HomedStatelessHome;
+import org.jboss.ejb3.test.iiop.MySession;
+import org.jboss.ejb3.test.iiop.MyStateful;
 import org.jboss.ejb3.test.iiop.MyStatefulHome;
 import org.jboss.ejb3.test.iiop.TxTester;
-import org.jboss.ejb3.test.iiop.MySession;
-import org.jboss.ejb3.test.iiop.MyStateful;
 import org.jboss.security.SecurityAssociation;
 import org.jboss.security.SimplePrincipal;
-import org.jboss.test.JBossIIOPTestCase;
-import org.jboss.test.JBossTestCase;
 
-import com.sun.naming.internal.ResourceManager;
-
 /**
  * TODO: use JBossIIOPTestCase
  *
@@ -140,6 +136,9 @@
       Handle h2 = (Handle) mo.get();
       Object o = h2.getEJBObject();
       MySession session2 = (MySession) PortableRemoteObject.narrow(o, MySession.class);
+      String me = new Date().toString();
+      String response = session2.sayHelloTo(me);
+      assertEquals("Hi " + me, response);
    }
    
    public void testGetHomeHandle() throws Exception
@@ -193,8 +192,11 @@
       Object obj = ctx.lookup("MyStatefulBean/remoteHome");
       MyStatefulHome home = (MyStatefulHome) PortableRemoteObject.narrow(obj, MyStatefulHome.class);
       MyStateful session = home.create();
-      MyStateful session2 = session;
-      // TODO: use handle
+      Handle h = session.getHandle();
+      MarshalledObject mo = new MarshalledObject(h);
+      Handle h2 = (Handle) mo.get();
+      Object o = h2.getEJBObject();
+      MyStateful session2 = (MyStateful) PortableRemoteObject.narrow(o, MyStateful.class);
       assertTrue(session.isIdentical(session2));
    }
    
@@ -206,7 +208,15 @@
       MyStateful session = home.create();
       session.setName("Me");
       home.remove(session.getHandle());
-      session.sayHello();
+      try
+      {
+         session.sayHello();
+         fail("should throw an exception");
+      }
+      catch(Exception e)
+      {
+         // TODO: check exception (NoSuchEJBException)
+      }
    }
    
    public void testSecurity() throws Exception
@@ -223,6 +233,16 @@
       System.err.println("whoAmI = " + actual);
    }
    
+   public void testService() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyServiceBean/remote");
+      MyStateful bean1 = (MyStateful) PortableRemoteObject.narrow(obj, MyStateful.class);
+      bean1.setName("bean1");
+      String response = bean1.sayHello();
+      assertEquals("Hello bean1", response);
+   }
+   
    public void testTxPropegation() throws Exception
    {
       InitialContext ctx = getInitialContext();




More information about the jboss-cvs-commits mailing list