You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2010/07/06 21:33:24 UTC
svn commit: r960991 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/assembler/classic/
main/java/org/apache/openejb/core/interceptor/
test/java/org/apache/openejb/core/stateful/
Author: jgallimore
Date: Tue Jul 6 19:33:23 2010
New Revision: 960991
URL: http://svn.apache.org/viewvc?rev=960991&view=rev
Log:
OPENEJB-1299 patch from Shawn Jiang
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/CallbackOverridesTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java?rev=960991&r1=960990&r2=960991&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java Tue Jul 6 19:33:23 2010
@@ -272,6 +272,25 @@ public class InterceptorBindingBuilder {
}
if (method.getDeclaringClass().getName().equals(callbackInfo.className)){
methods.add(method);
+ } else {
+ // check for a private method on the declared class
+
+ // find declared class
+ Class c = clazz;
+ while (c != null && !c.getName().equals(callbackInfo.className)) c = c.getSuperclass();
+
+ // get callback method
+ if (c != null) {
+ try {
+ method = getMethod(c, callbackInfo.method, InvocationContext.class);
+ // make sure it is private
+ if (Modifier.isPrivate(method.getModifiers())) {
+ SetAccessible.on(method);
+ methods.add(method);
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
}
} catch (NoSuchMethodException e) {
logger.warning("Interceptor method not found (skipping): public Object " + callbackInfo.method + "(InvocationContext); in class " + clazz.getName());
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java?rev=960991&r1=960990&r2=960991&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/interceptor/ReflectionInvocationContext.java Tue Jul 6 19:33:23 2010
@@ -163,24 +163,11 @@ public class ReflectionInvocationContext
this.args = args;
}
public Object invoke() throws Exception {
- Method targetMethod = getMethod(target.getClass(), method.getName(), method.getParameterTypes());
- targetMethod.setAccessible(true);
- Object value = targetMethod.invoke(target, args);
+
+ Object value = method.invoke(target, args);
return value;
}
- private Method getMethod(Class<?> cls, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- try {
- Method method = cls.getDeclaredMethod(methodName, parameterTypes);
- return method;
- } catch (NoSuchMethodException e) {
- if (! (Object.class.equals(cls))) {
- return getMethod(cls.getSuperclass(), methodName, parameterTypes);
- }
-
- throw e;
- }
- }
public String toString() {
return method.getDeclaringClass().getName() + "." + method.getName();
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/CallbackOverridesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/CallbackOverridesTest.java?rev=960991&r1=960990&r2=960991&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/CallbackOverridesTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/CallbackOverridesTest.java Tue Jul 6 19:33:23 2010
@@ -68,8 +68,8 @@ public class CallbackOverridesTest exten
ChildBean childBean = (ChildBean) context.lookup("ChildBeanLocalBean");
- // TODO: Broken -- See OPENEJB-1299
-// assertEquals(asList(ParentInterceptor.class, ChildInterceptor.class, ParentBean.class, ChildBean.class), callbacks);
+
+ assertEquals(asList(ParentInterceptor.class, ChildInterceptor.class, ParentBean.class, ChildBean.class), callbacks);
callbacks.clear();
@@ -134,7 +134,7 @@ public class CallbackOverridesTest exten
@Stateful
@Interceptors(ChildInterceptor.class)
- public static class ChildBean {
+ public static class ChildBean extends ParentBean {
@PostConstruct