[jboss-cvs] JBossAS SVN: r64923 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 28 15:12:55 EDT 2007
Author: flavia.rainone at jboss.com
Date: 2007-08-28 15:12:55 -0400 (Tue, 28 Aug 2007)
New Revision: 64923
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
Log:
[JBAOP-387] Replaced RuntimeExceptions by specific exceptions.
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2007-08-28 18:16:31 UTC (rev 64922)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2007-08-28 19:12:55 UTC (rev 64923)
@@ -26,7 +26,6 @@
import java.security.ProtectionDomain;
import java.util.ArrayList;
-import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtField;
@@ -34,13 +33,8 @@
import javassist.CtNewMethod;
import org.jboss.aop.AspectManager;
-import org.jboss.aop.instrument.OptimizedMethodInvocations;
import org.jboss.aop.instrument.TransformerCommon;
-import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.Joinpoint;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.joinpoint.MethodJoinpoint;
-import org.jboss.aop.util.ReflectToJavassist;
import org.jboss.aop.util.logging.AOPLogger;
import org.jboss.logging.Logger;
@@ -54,8 +48,6 @@
{
private static final Logger logger = AOPLogger.getLogger(PerVmAdvice.class);
- private static long counter = 0;
-
public static synchronized Interceptor generateOptimized(Joinpoint joinpoint, AspectManager manager, String adviceName, AspectDefinition a) throws Exception
{
Object aspect = manager.getPerVMAspect(a);
@@ -84,17 +76,8 @@
{
}
- ClassPool pool;
- try
- {
- pool = AspectManager.instance().findClassPool(cl);
- }
- catch (RuntimeException e)
- {
- // AutoGenerated
- throw new RuntimeException(e);
- }
-
+ ClassPool pool = AspectManager.instance().findClassPool(cl);
+
if (iclass == null)
{
//Aspects deployed in the lib folder, such as the AOP/MC integration aspects like the JMXIntroduction
@@ -118,14 +101,17 @@
if (methods[i].getName().equals(adviceName)) matches.add(methods[i]);
}
if(matches.size() == 0)
- throw new RuntimeException("Class "+aspect.getClass()+" didnt include any method called "+adviceName+", no interceptor will be created.");
+ throw new NoMatchingAdviceException(aspect.getClass(), adviceName);
for(int i=0; i < matches.size(); i++)
{
Method method = (Method) matches.get(i);
if(method.getParameterTypes().length != 1)
{
- throw new RuntimeException("Only one argument of type invocations is supported. Method "+method.toString()+" does not comply!");
+ throw new InvalidAdviceException(
+ "Only one argument of type invocations is supported. Method '"
+ + method.toString() + "' (aspect class " +
+ aspect.getClass().getName() + ") does not comply");
}
// we only support params that implements org.jboss.aop.joinpoint.Invocation
@@ -143,7 +129,11 @@
}
}
if(!foundInterface)
- throw new RuntimeException("Aspect method must have a parameter that implements Invocation. "+method.getName()+"class: "+paramClass.getCanonicalName());
+ throw new InvalidAdviceException(
+ "Aspect method must have a parameter that implements Invocation. "
+ + "Parameter of advice '" + method.getName()+
+ "' (aspect class" + aspect.getClass().getName() +
+ ") does not comply: " + paramClass.getCanonicalName());
}
CtClass clazz = TransformerCommon.makeClass(pool, name);
More information about the jboss-cvs-commits
mailing list