[jboss-cvs] JBossAS SVN: r80847 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/core/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 12 04:22:14 EST 2008


Author: wolfc
Date: 2008-11-12 04:22:14 -0500 (Wed, 12 Nov 2008)
New Revision: 80847

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21Home.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21Base.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/unit/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/unit/Inherited21BeanTestCase.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
Log:
EJBTHREE-1581: call super @Init methods as well

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-11-12 08:32:35 UTC (rev 80846)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -73,7 +73,6 @@
 import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
 import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionRemoteProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateful.StatefulLocalProxyFactory;
@@ -898,14 +897,23 @@
    */
 
    public void invokeInit(Object bean, Class[] initParameterTypes,
+         Object[] initParameterValues)
+   {
+      invokeInit(bean, bean.getClass(), initParameterTypes, initParameterValues);
+   }
+   
+   private void invokeInit(Object bean, Class<?> cls, Class<?>[] initParameterTypes,
                           Object[] initParameterValues)
    {
+      Class<?> superclass = cls.getSuperclass();
+      if(superclass != null)
+         invokeInit(bean, superclass, initParameterTypes, initParameterValues);
       int numParameters = 0;
       if(initParameterTypes != null)
          numParameters = initParameterTypes.length;
       try
       {
-         for(Method method : bean.getClass().getDeclaredMethods())
+         for(Method method : cls.getDeclaredMethods())
          {
             if(numParameters != method.getParameterTypes().length)
                continue;

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -0,0 +1,35 @@
+/*
+ * 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.core.test.ejbthree1581;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Bank21 extends EJBLocalObject
+{
+   String getActivated();
+   
+   boolean hasSessionContext();
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21Home.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21Home.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/Bank21Home.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -0,0 +1,36 @@
+/*
+ * 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.core.test.ejbthree1581;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Bank21Home extends EJBLocalHome
+{
+   Bank21 create() throws RemoteException, CreateException;
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -0,0 +1,37 @@
+/*
+ * 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.core.test.ejbthree1581;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateful;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at LocalHome(Bank21Home.class)
+public class BankBean21 extends BankBean21Base
+{
+   private static final long serialVersionUID = 1L;
+
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21Base.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21Base.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/BankBean21Base.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -0,0 +1,90 @@
+/*
+ * 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.core.test.ejbthree1581;
+
+import java.rmi.RemoteException;
+
+import javax.annotation.Resource;
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.Init;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remove;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+/**
+ * Because Ejb3DescriptorHandler isn't exercised all methods are annotated.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BankBean21Base implements SessionBean
+{
+   private static final long serialVersionUID = 1L;
+   
+   /** read-only */
+   protected SessionContext ctx;
+   
+   private String activated = "";
+   
+   @PostActivate
+   public void ejbActivate() throws RemoteException
+   {
+      activated += "_ACTIVATED";
+   }
+
+   @Init
+   public void ejbCreate() throws CreateException, RemoteException
+   {
+      activated += "_CREATED";
+   }
+   
+   @PrePassivate
+   public void ejbPassivate() throws RemoteException
+   {
+   }
+
+   @Remove
+   public void ejbRemove() throws RemoteException
+   {
+   }
+
+   public String getActivated()
+   {
+      return activated;
+   }
+   
+   public boolean hasSessionContext()
+   {
+      return ctx != null;
+   }
+   
+   // allow write ctx
+   @Resource
+   public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
+   {
+      assert ctx != null : "ctx is null";
+      this.ctx = ctx;
+   }
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/unit/Inherited21BeanTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/unit/Inherited21BeanTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1581/unit/Inherited21BeanTestCase.java	2008-11-12 09:22:14 UTC (rev 80847)
@@ -0,0 +1,65 @@
+/*
+ * 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.core.test.ejbthree1581.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.ejbthree1581.Bank21;
+import org.jboss.ejb3.core.test.ejbthree1581.Bank21Home;
+import org.jboss.ejb3.core.test.ejbthree1581.BankBean21;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Inherited21BeanTestCase extends AbstractEJB3TestCase
+{
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      AbstractEJB3TestCase.beforeClass();
+      
+      deploySessionEjb(BankBean21.class);
+   }
+   
+   @Test
+   public void testCreation() throws Exception
+   {
+      Bank21Home home = lookup("BankBean21/localHome", Bank21Home.class);
+      Bank21 bean = home.create();
+      String actual = bean.getActivated();
+      assertEquals("_CREATED", actual);
+   }
+   
+   @Test
+   public void testInjection() throws Exception
+   {
+      Bank21Home home = lookup("BankBean21/localHome", Bank21Home.class);
+      Bank21 bean = home.create();
+      boolean injected = bean.hasSessionContext();
+      assertTrue(injected);
+   }
+}




More information about the jboss-cvs-commits mailing list