[jboss-cvs] JBossAS SVN: r60823 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/interceptor.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 23 06:02:59 EST 2007
Author: wolfc
Date: 2007-02-23 06:02:59 -0500 (Fri, 23 Feb 2007)
New Revision: 60823
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java
Log:
Merged EJBTHREE-891
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java 2007-02-23 10:56:21 UTC (rev 60822)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java 2007-02-23 11:02:59 UTC (rev 60823)
@@ -21,10 +21,6 @@
*/
package org.jboss.ejb3.interceptor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import javax.jms.MessageListener;
import org.jboss.annotation.ejb.Management;
import org.jboss.annotation.ejb.Producer;
import org.jboss.annotation.ejb.Producers;
@@ -40,6 +36,11 @@
import org.jboss.logging.Logger;
import org.jboss.util.MethodHashing;
+import javax.jms.MessageListener;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
* @version $Revision$
@@ -49,12 +50,13 @@
static Logger log = Logger.getLogger(EJB3InterceptorsFactory.class);
final static long MESSAGE_LISTENER_ON_MESSAGE;
- static
+
+ static
{
try
{
Class clazz = MessageListener.class;
- Method m = clazz.getDeclaredMethod("onMessage", new Class[] {javax.jms.Message.class});
+ Method m = clazz.getDeclaredMethod("onMessage", new Class[]{javax.jms.Message.class});
MESSAGE_LISTENER_ON_MESSAGE = MethodHashing.calculateHash(m);
}
catch (Exception e)
@@ -89,10 +91,10 @@
{
EJBContainer container = (EJBContainer) advisor;
Class beanClass = container.getBeanClass();
-
+
try
{
- Method method =((MethodJoinpoint)jp).getMethod();
+ Method method = ((MethodJoinpoint) jp).getMethod();
if (isBusinessMethod(container, method))
{
InterceptorInfo[] infos = container.getInterceptorRepository().getBusinessInterceptors(container, method);
@@ -103,7 +105,7 @@
}
catch (RuntimeException e)
{
- throw new RuntimeException("An exception occurred initialising interceptors for " + beanClass + "." + ((MethodJoinpoint)jp).getMethod().getName(), e);
+ throw new RuntimeException("An exception occurred initialising interceptors for " + beanClass + "." + ((MethodJoinpoint) jp).getMethod().getName(), e);
}
}
return new EJB3InterceptorsInterceptor(new InterceptorInfo[0], null);
@@ -117,34 +119,27 @@
private boolean isBusinessMethod(EJBContainer container, Method method)
{
long hash = MethodHashing.calculateHash(method);
- if (container instanceof MDB)
+ ArrayList<Class> businessInterfaces = getBusinessInterfaces(container);
+ for (Class businessInterface : businessInterfaces)
{
- return hash == MESSAGE_LISTENER_ON_MESSAGE;
- }
- else
- {
- ArrayList<Class> businessInterfaces = getBusinessInterfaces(container);
- for (Class businessInterface : businessInterfaces)
+ for (Method interfaceMethod : businessInterface.getMethods())
{
- for (Method interfaceMethod : businessInterface.getMethods())
+ if (MethodHashing.calculateHash(interfaceMethod) == hash)
{
- if (MethodHashing.calculateHash(interfaceMethod) == hash)
- {
- return true;
- }
+ return true;
}
}
}
-
+
return false;
}
-
+
private ArrayList<Class> getBusinessInterfaces(EJBContainer container)
{
ArrayList<Class> interfaces = new ArrayList<Class>();
if (container instanceof ConsumerContainer)
{
- Producers producers = (Producers)container.resolveAnnotation(Producers.class);
+ Producers producers = (Producers) container.resolveAnnotation(Producers.class);
if (producers != null)
{
for (Producer producer : producers.value())
@@ -152,13 +147,13 @@
interfaces.add(producer.producer());
}
}
-
- Producer producer = (Producer)container.resolveAnnotation(Producer.class);
+
+ Producer producer = (Producer) container.resolveAnnotation(Producer.class);
if (producer != null)
{
interfaces.add(producer.producer());
}
-
+
for (Class implIf : container.getBeanClass().getInterfaces())
{
if (implIf.getAnnotation(Producer.class) != null)
@@ -167,6 +162,10 @@
}
}
}
+ else if (container instanceof MDB)
+ {
+ interfaces.add(((MDB)container).getMessagingType());
+ }
else
{
Class[] remotes = ProxyFactoryHelper.getRemoteInterfaces(container);
@@ -179,10 +178,10 @@
{
interfaces.addAll(Arrays.asList(locals));
}
-
+
if (container instanceof ServiceContainer)
{
- Management man = (Management)container.resolveAnnotation(Management.class);
+ Management man = (Management) container.resolveAnnotation(Management.class);
if (man != null)
{
Class iface = man.value();
@@ -191,7 +190,7 @@
interfaces.add(iface);
}
}
-
+
Class[] implIfaces = container.getBeanClass().getInterfaces();
for (Class iface : implIfaces)
{
@@ -202,8 +201,8 @@
}
}
}
-
+
return interfaces;
}
-
+
}
More information about the jboss-cvs-commits
mailing list