[jboss-cvs] JBossAS SVN: r67500 - trunk/ejb3/src/main/org/jboss/ejb3/stateful.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 27 09:16:58 EST 2007
Author: adrian at jboss.org
Date: 2007-11-27 09:16:58 -0500 (Tue, 27 Nov 2007)
New Revision: 67500
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveFactory.java
Log:
Fix NPEs, better errors, etc. - provide defaults in case it doesn't configured the way we expect
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveFactory.java 2007-11-27 13:54:21 UTC (rev 67499)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveFactory.java 2007-11-27 14:16:58 UTC (rev 67500)
@@ -21,12 +21,16 @@
*/
package org.jboss.ejb3.stateful;
+import java.lang.reflect.Method;
+
import javax.ejb.Remove;
import org.jboss.aop.Advisor;
import org.jboss.aop.InstanceAdvisor;
import org.jboss.aop.advice.AspectFactory;
import org.jboss.aop.joinpoint.Joinpoint;
import org.jboss.aop.joinpoint.MethodJoinpoint;
+import org.jboss.ejb.RemoveImpl;
+import org.jboss.logging.Logger;
/**
* comment
@@ -35,6 +39,8 @@
*/
public class StatefulRemoveFactory implements AspectFactory
{
+ private static final Logger log = Logger.getLogger(StatefulRemoveFactory.class);
+
public Object createPerVM()
{
throw new IllegalStateException("PER_VM NOT APPLICABLE");
@@ -52,7 +58,16 @@
public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
{
- Remove rm = (Remove) advisor.resolveAnnotation(((MethodJoinpoint) jp).getMethod(), Remove.class);
+ if (jp instanceof MethodJoinpoint == false)
+ throw new IllegalArgumentException("Joinpoint is not a method: " + jp);
+ MethodJoinpoint methodJoinpoint = MethodJoinpoint.class.cast(jp);
+ Method method = methodJoinpoint.getMethod();
+ Remove rm = (Remove) advisor.resolveAnnotation(method, Remove.class);
+ if (rm == null)
+ {
+ log.warn("Cannot find @" + Remove.class.getName() + " for " + method + " assuming defaults");
+ rm = new RemoveImpl();
+ }
return new StatefulRemoveInterceptor(rm.retainIfException());
}
More information about the jboss-cvs-commits
mailing list