[jboss-cvs] JBossAS SVN: r81901 - projects/aop/branches/Branch_2_0/aop/src/main/org/jboss/aop/instrument.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 1 08:53:19 EST 2008
Author: stalep
Date: 2008-12-01 08:53:19 -0500 (Mon, 01 Dec 2008)
New Revision: 81901
Modified:
projects/aop/branches/Branch_2_0/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorInstrumentor.java
Log:
backported from trunk
Modified: projects/aop/branches/Branch_2_0/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorInstrumentor.java
===================================================================
--- projects/aop/branches/Branch_2_0/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorInstrumentor.java 2008-12-01 13:51:31 UTC (rev 81900)
+++ projects/aop/branches/Branch_2_0/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorInstrumentor.java 2008-12-01 13:53:19 UTC (rev 81901)
@@ -657,33 +657,49 @@
// AutoGenerated
throw new RuntimeException(e);
}
-
- //Add _setInstance method
- body =
- "{ " +
- " synchronized(this) " +
- " { " +
- " " + INSTANCE_ADVISOR + " == $1; " +
- " } " +
- "}";
- try
+
+ // check if the clazz already contain a _setInstanceAdvisor method
+ // if it do, do not add another one.
+ //why doesnt this work..??
+ //if(clazz.getMethod("_setInstanceAdvisor", "org.jboss.aop.InstanceAdvisor") != null)
+ //workaround:
+ CtMethod[] methodz = clazz.getMethods();
+ boolean setInstanceAdvisorFound = false;
+ for(CtMethod m : methodz)
+ if(m.getName().equals("_setInstanceAdvisor"))
+ {
+ setInstanceAdvisorFound = true;
+ }
+
+ if(!setInstanceAdvisorFound)
{
- CtMethod getInstanceAdvisor = CtNewMethod.make(
- CtClass.voidType,
- "_setInstanceAdvisor",
- new CtClass[] {forName("org.jboss.aop.InstanceAdvisor")},
- new CtClass[0],
- body,
- clazz);
- addSyntheticAttribute(getInstanceAdvisor);
- clazz.addMethod(getInstanceAdvisor);
+ //Add _setInstance method
+ body =
+ "{ " +
+ " synchronized(this) " +
+ " { " +
+ " " + INSTANCE_ADVISOR + " == $1; " +
+ " } " +
+ "}";
+ try
+ {
+ CtMethod getInstanceAdvisor = CtNewMethod.make(
+ CtClass.voidType,
+ "_setInstanceAdvisor",
+ new CtClass[] {forName("org.jboss.aop.InstanceAdvisor")},
+ new CtClass[0],
+ body,
+ clazz);
+ addSyntheticAttribute(getInstanceAdvisor);
+ clazz.addMethod(getInstanceAdvisor);
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
}
- catch (Exception e)
- {
- // AutoGenerated
- throw new RuntimeException(e);
- }
-
+
}
@Override
More information about the jboss-cvs-commits
mailing list