[jboss-cvs] JBossAS SVN: r65705 - in trunk/ejb3/src/main/org/jboss/ejb3: mdb and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 1 05:55:49 EDT 2007
Author: wolfc
Date: 2007-10-01 05:55:49 -0400 (Mon, 01 Oct 2007)
New Revision: 65705
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
Log:
EJBTHREE-785: fixed local interface
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-10-01 09:49:44 UTC (rev 65704)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-10-01 09:55:49 UTC (rev 65705)
@@ -21,8 +21,10 @@
*/
package org.jboss.ejb3;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -80,7 +82,7 @@
// We have an emtpy @Local annotated bean class
- ArrayList list = getBusinessInterfaces(container.getBeanClass());
+ List list = getBusinessInterfaces(container.getBeanClass());
if (list.size() == 0)
throw new RuntimeException("Use of empty @Local on bean class and there are no valid business interfaces: " + container.getEjbName());
if (list.size() > 1)
@@ -101,7 +103,7 @@
// introspect implemented interfaces.
if (li == null)
{
- Class[] intfs = beanClass.getInterfaces();
+ List<Class<?>> intfs = getBusinessInterfaces(beanClass);
ArrayList<Class> locals = new ArrayList<Class>();
for (Class<?> clazz : intfs)
{
@@ -112,8 +114,7 @@
}
if (locals.size() > 0)
{
- intfs = locals.toArray(new Class[locals.size()]);
- li = new LocalImpl(intfs);
+ li = new LocalImpl(locals.toArray(new Class[]{}));
((Advisor) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, li);
//return li.value(); ALR Removed (EJBTHREE-751)
}
@@ -123,7 +124,7 @@
if (li == null)
{
// search for default
- ArrayList<Class> interfaces = getBusinessInterfaces(beanClass);
+ List<Class<?>> interfaces = getBusinessInterfaces(beanClass);
if (interfaces.size() != 1) return new Class[]{}; // indeterminate
Class intf = interfaces.get(0);
@@ -165,51 +166,55 @@
return li.value();
}
- public static ArrayList<Class> getBusinessInterfaces(Class beanClass)
+ /**
+ * Resolve the potential business interfaces on an enterprise bean.
+ * Returns all interfaces implemented by this class and it's supers which
+ * are potentially a business interface.
+ *
+ * Note: for normal operation call container.getBusinessInterfaces().
+ *
+ * @param beanClass the EJB implementation class
+ * @return a list of potential business interfaces
+ * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
+ */
+ public static List<Class<?>> getBusinessInterfaces(Class<?> beanClass)
{
// Obtain all business interfaces implemented by this bean class and its superclasses
- return getBusinessInterfaces(beanClass, null);
+ return getBusinessInterfaces(beanClass, new ArrayList<Class<?>>());
}
- private static ArrayList<Class> getBusinessInterfaces(Class beanClass,ArrayList<Class> interfaces)
+ private static List<Class<?>> getBusinessInterfaces(Class<?> beanClass, List<Class<?>> interfaces)
{
- // Ensure initialized
- if (interfaces == null)
+ /*
+ * 4.6.6:
+ * The following interfaces are excluded when determining whether the bean class has
+ * more than one interface: java.io.Serializable; java.io.Externaliz-
+ * able; any of the interfaces defined by the javax.ejb package.
+ */
+ for(Class<?> intf : beanClass.getInterfaces())
{
- interfaces = new ArrayList<Class>();
+ if(intf.equals(java.io.Externalizable.class))
+ continue;
+ if(intf.equals(java.io.Serializable.class))
+ continue;
+ if(intf.getName().startsWith("java.ejb"))
+ continue;
+
+ // FIXME Other aop frameworks might add other interfaces, this should really be configurable
+ if(intf.getName().startsWith("org.jboss.aop"))
+ continue;
+
+ interfaces.add(intf);
}
- // 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);
- interfaces.remove(javax.ejb.TimedObject.class);
- Iterator<Class> it = interfaces.iterator();
- while (it.hasNext())
- {
- 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 (interfaceName.startsWith("org.jboss.aop."))
- it.remove();
- }
-
// If there's no superclass, return
if (beanClass.getSuperclass() == null)
{
return interfaces;
}
- // Include any superclasses' interfaces
else
{
+ // Include any superclasses' interfaces
return getBusinessInterfaces(beanClass.getSuperclass(), interfaces);
}
}
@@ -412,7 +417,7 @@
// We have an emtpy @Remote annotated bean class
- ArrayList list = getBusinessInterfaces(container.getBeanClass());
+ List list = getBusinessInterfaces(container.getBeanClass());
if (list.size() == 0)
throw new RuntimeException("Use of empty @Remote on bean class and there are no valid business interfaces: " + container.getEjbName());
if (list.size() > 1)
Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java 2007-10-01 09:49:44 UTC (rev 65704)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java 2007-10-01 09:55:49 UTC (rev 65705)
@@ -70,7 +70,7 @@
messagingType = annotation.messageListenerInterface();
if (messagingType.getName().equals(Object.class.getName()))
{
- ArrayList<Class> list = ProxyFactoryHelper.getBusinessInterfaces(clazz);
+ List<Class<?>> list = ProxyFactoryHelper.getBusinessInterfaces(clazz);
if (list.size() > 1 || list.size() == 0) throw new RuntimeException("unable to determine messagingType interface for MDB");
messagingType = list.get(0);
}
More information about the jboss-cvs-commits
mailing list