[jboss-cvs] JBossAS SVN: r65702 - in trunk/ejb3/src: test/org/jboss/ejb3/test/ejbthree785 and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Sep 30 13:54:52 EDT 2007
Author: ALRubinger
Date: 2007-09-30 13:54:52 -0400 (Sun, 30 Sep 2007)
New Revision: 65702
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessLocal.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/Tester.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java
Removed:
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStateless.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/AbstractStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/unit/SuperBeanTesterUnitTestCase.java
Log:
EJBTHREE785: Fixes to allow for deployment of EJBs with superclasses implementing @Local and @Remote Business Interfaces. Test case "testSuperLocalViaRemoteDelegate" still fails, see TODO in SuperBeanTesterUnitTestCase.
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -21,31 +21,30 @@
*/
package org.jboss.ejb3;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.jws.WebService;
+import javax.management.ObjectName;
+
+import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.annotation.ejb.LocalHomeBinding;
-import org.jboss.annotation.ejb.RemoteHomeBinding;
-import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.RemoteBindings;
+import org.jboss.annotation.ejb.RemoteHomeBinding;
import org.jboss.aop.Advisor;
import org.jboss.ejb.LocalImpl;
import org.jboss.ejb.RemoteImpl;
-import org.jboss.logging.Logger;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.logging.Logger;
-import javax.ejb.Local;
-import javax.ejb.LocalHome;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.jws.WebService;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
/**
* Comment
*
@@ -166,18 +165,27 @@
return li.value();
}
- /**
- * Resolve the business interfaces on an enterprise bean.
- *
- * Note: for normal operation call container.getBusinessInterfaces().
- *
- * @param beanClass
- * @return
- * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
- */
public static ArrayList<Class> getBusinessInterfaces(Class beanClass)
{
- ArrayList<Class> interfaces = new ArrayList<Class>(Arrays.asList(beanClass.getInterfaces()));
+ // Obtain all business interfaces implemented by this bean class and its superclasses
+ return getBusinessInterfaces(beanClass, null);
+ }
+
+ private static ArrayList<Class> getBusinessInterfaces(Class beanClass,ArrayList<Class> interfaces)
+ {
+ // Ensure initialized
+ if (interfaces == null)
+ {
+ interfaces = new ArrayList<Class>();
+ }
+
+ // Obtain all implemented interfaces
+ List<Class> implementedImterfaces = Arrays.asList(beanClass.getInterfaces());
+
+ // Add all interfaces implemented
+ interfaces.addAll(Arrays.asList(beanClass.getInterfaces()));
+
+ // Remove non-business interfaces
interfaces.remove(java.io.Serializable.class);
interfaces.remove(java.io.Externalizable.class);
interfaces.remove(javax.ejb.SessionSynchronization.class);
@@ -185,14 +193,25 @@
Iterator<Class> it = interfaces.iterator();
while (it.hasNext())
{
- Class nextIntf = it.next();
- if (nextIntf.getName().startsWith("javax.ejb") || nextIntf.getName().startsWith("javax.xml.ws")) it.remove();
+ String interfaceName = it.next().getName();
+ if (interfaceName.startsWith("javax.ejb"))
+ it.remove();
//FIXME Other aop frameworks might add other interfaces, this should really be configurable
- if (nextIntf.getName().startsWith("org.jboss.aop.")) it.remove();
+ if (interfaceName.startsWith("org.jboss.aop."))
+ it.remove();
+ }
+ // If there's no superclass, return
+ if (beanClass.getSuperclass() == null)
+ {
+ return interfaces;
}
- return interfaces;
+ // Include any superclasses' interfaces
+ else
+ {
+ return getBusinessInterfaces(beanClass.getSuperclass(), interfaces);
+ }
}
public static Class getLocalHomeInterface(Container container)
@@ -369,7 +388,7 @@
if (ri == null)
{
Class beanClass = container.getBeanClass();
- Class[] intfs = beanClass.getInterfaces();
+ Class[] intfs = ProxyFactoryHelper.getBusinessInterfaces(beanClass).toArray(new Class[]{});
ArrayList<Class> remotes = new ArrayList<Class>();
for (Class<?> clazz : intfs)
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/AbstractStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/AbstractStatelessBean.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/AbstractStatelessBean.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -27,7 +27,7 @@
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
* @version $Revision: $
*/
-public class AbstractStatelessBean implements MyStateless
+public class AbstractStatelessBean implements MyStatelessRemote, MyStatelessLocal
{
public String sayHiTo(String name)
{
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStateless.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStateless.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStateless.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.ejbthree785;
-
-import javax.ejb.Local;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Local
-public interface MyStateless
-{
- String sayHiTo(String name);
-}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessBean.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessBean.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -23,14 +23,22 @@
import javax.ejb.Stateless;
+import org.jboss.annotation.ejb.LocalBinding;
+import org.jboss.annotation.ejb.RemoteBinding;
+
/**
* Comment
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
* @version $Revision: $
*/
@Stateless
+ at RemoteBinding(jndiBinding = MyStatelessBean.JNDI_NAME_REMOTE)
+ at LocalBinding(jndiBinding = MyStatelessBean.JNDI_NAME_LOCAL)
public class MyStatelessBean extends AbstractStatelessBean
{
+ public static final String JNDI_NAME_REMOTE = "MyStatelessBean/remote";
+ public static final String JNDI_NAME_LOCAL = "MyStatelessBean/local";
}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessLocal.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessLocal.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessLocal.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.ejbthree785;
+
+import javax.ejb.Local;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface MyStatelessLocal
+{
+ String sayHiTo(String name);
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessRemote.java (from rev 65531, trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStateless.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessRemote.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessRemote.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.ejbthree785;
+
+import javax.ejb.Remote;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface MyStatelessRemote
+{
+ String sayHiTo(String name);
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/MyStatelessRemote.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/Tester.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/Tester.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/Tester.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -0,0 +1,15 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ejb3.test.ejbthree785;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface Tester
+{
+ String sayHiTo(String name);
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/Tester.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.ejbthree785;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
- at Remote(value=MyStateless.class)
-public class TesterBean
-{
- @EJB(beanName="MyStatelessBean")
- private MyStateless delegate;
-
- public String sayHiTo(String name)
- {
- return delegate.sayHiTo(name);
- }
-}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ejb3.test.ejbthree785;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+
+ at Stateless
+ at RemoteBinding(jndiBinding = TesterBean.JNDI_NAME)
+public class TesterBean implements Tester
+{
+ // Class Members
+ public static final String JNDI_NAME = "TesterBean/remote";
+
+ @EJB
+ private MyStatelessLocal local;
+
+ public String sayHiTo(String name)
+ {
+ return local.sayHiTo(name);
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/TesterBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/unit/SuperBeanTesterUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/unit/SuperBeanTesterUnitTestCase.java 2007-09-29 12:49:55 UTC (rev 65701)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree785/unit/SuperBeanTesterUnitTestCase.java 2007-09-30 17:54:52 UTC (rev 65702)
@@ -25,13 +25,17 @@
import junit.framework.Test;
-import org.jboss.ejb3.test.ejbthree785.MyStateless;
+import org.jboss.ejb3.test.ejbthree785.MyStatelessBean;
+import org.jboss.ejb3.test.ejbthree785.MyStatelessRemote;
+import org.jboss.ejb3.test.ejbthree785.Tester;
+import org.jboss.ejb3.test.ejbthree785.TesterBean;
import org.jboss.test.JBossTestCase;
/**
* Test to see if a super can have the business interface.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
* @version $Revision: $
*/
public class SuperBeanTesterUnitTestCase extends JBossTestCase
@@ -42,15 +46,25 @@
super(name);
}
- public void testSuper() throws Exception
+ public void testSuperRemote() throws Exception
{
- MyStateless session = (MyStateless) getInitialContext().lookup("TesterBean/remote");
+ MyStatelessRemote session = (MyStatelessRemote) getInitialContext().lookup(MyStatelessBean.JNDI_NAME_REMOTE);
Date date = new Date();
String expected = "Hi " + date.toString();
String actual = session.sayHiTo(date.toString());
assertEquals(expected, actual);
}
-
+
+ //TODO This test case fails due to Tester not getting fully deployed; related to its dependency on MyStatelessLocal
+ public void testSuperLocalViaRemoteDelegate() throws Exception
+ {
+ Tester session = (Tester) getInitialContext().lookup(TesterBean.JNDI_NAME);
+ Date date = new Date();
+ String expected = "Hi " + date.toString();
+ String actual = session.sayHiTo(date.toString());
+ assertEquals(expected, actual);
+ }
+
public static Test suite() throws Exception
{
return getDeploySetup(SuperBeanTesterUnitTestCase.class, "ejbthree785.jar");
More information about the jboss-cvs-commits
mailing list