[jboss-cvs] JBossAS SVN: r59484 - in branches/Branch_AOP_1_5/aop: src/main/org/jboss/aop/instrument and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 10 12:18:40 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-01-10 12:18:32 -0500 (Wed, 10 Jan 2007)
New Revision: 59484
Added:
branches/Branch_AOP_1_5/aop/src/resources/test/field/
branches/Branch_AOP_1_5/aop/src/resources/test/field/jboss-aop.xml
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldPerJoinpointInterceptor.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldTestCase.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/POJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/ScopedPojo.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SetOrGetOnlyPOJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubPOJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubSubPOJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/TraceInterceptor.java
Modified:
branches/Branch_AOP_1_5/aop/build.xml
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
Log:
[JBAOP-339] Port changes for [JBAOP-301] to the 1.5 branch
Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/build.xml 2007-01-10 17:18:32 UTC (rev 59484)
@@ -708,6 +708,10 @@
</annotationc>
<antcall target="_run-bootclasspath-test" inheritRefs="true">
+ <param name="test" value="field"/>
+ </antcall>
+
+ <antcall target="_run-bootclasspath-test" inheritRefs="true">
<param name="test" value="instanceofintroduced"/>
</antcall>
<antcall target="_run-bootclasspath-test" inheritRefs="true">
@@ -919,6 +923,9 @@
</annotationc>
<antcall target="_run-precompiled-test" inheritRefs="true">
+ <param name="test" value="field"/>
+ </antcall>
+ <antcall target="_run-precompiled-test" inheritRefs="true">
<param name="test" value="instanceofintroduced"/>
</antcall>
<antcall target="_run-precompiled-test" inheritRefs="true">
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -22,6 +22,7 @@
package org.jboss.aop.instrument;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -549,15 +550,19 @@
{
AOPClassPool pool = AOPClassPool.createAOPClassPool(clazz.getClassPool(), AOPClassPoolRepository.getInstance());
- Iterator it = clazz.getRefClasses().iterator();
- while (it.hasNext())
+ //Class.getRefClasses() only gets classes explicitly referenced in the class. We need to check the super classes and do some extra handling
+ for (ReferenceClassIterator it = new ReferenceClassIterator(clazz.getRefClasses()) ; it.hasNext() ; )
{
- ref = (String) it.next();
+ ref = it.next();
if (!manager.convertReference(ref)
|| manager.isNonAdvisableClassName(ref)
|| ref.startsWith("java.")
|| ref.startsWith("javax.")
- || ref.startsWith("[")) continue;
+ || ref.startsWith("["))
+ {
+ continue;
+ }
+
// Only need a temporary advisor for resolving metadata
CtClass ctRef = null;
try
@@ -579,6 +584,8 @@
}
if (!isTransformable(ctRef)) continue;
+ it.addSuperClass(ctRef);
+
ClassAdvisor advisor = manager.getTempClassAdvisor(ctRef);
if (!manager.shouldSkipFieldAccess(ref) && !ref.equals(clazz.getName()))
{
@@ -1032,4 +1039,57 @@
protected abstract CtMethod createMixinInvokeMethod(CtClass clazz, CtClass mixinClass, String initializer, CtMethod method, long hash)
throws CannotCompileException, NotFoundException, Exception;
+ private static class ReferenceClassIterator
+ {
+ int size;
+ int current;
+ ArrayList classes;
+ HashSet handledClasses;
+ String currentEntry;
+
+ public ReferenceClassIterator(Collection refClasses)
+ {
+ size = refClasses.size();
+ classes = new ArrayList(refClasses.size());
+ classes.addAll(refClasses);
+ handledClasses = new HashSet(refClasses.size());
+ }
+
+ boolean hasNext()
+ {
+ while (current < size)
+ {
+ String s = (String) classes.get(current++);
+ if (!handledClasses.contains(s))
+ {
+ handledClasses.add(s);
+ currentEntry = s;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ String next()
+ {
+ return currentEntry;
+ }
+
+ void addSuperClass(CtClass clazz)throws NotFoundException
+ {
+ if (clazz != null)
+ {
+ CtClass superClass = clazz.getSuperclass();
+ if (superClass != null)
+ {
+ String name = superClass.getName();
+ if (!handledClasses.contains(name))
+ {
+ classes.add(name);
+ size++;
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
Added: branches/Branch_AOP_1_5/aop/src/resources/test/field/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/field/jboss-aop.xml 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/field/jboss-aop.xml 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+ <bind pointcut="field(* org.jboss.test.aop.field.POJO->field)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+ <bind pointcut="field(* org.jboss.test.aop.field.SubSubPOJO->field)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+ <bind pointcut="field(* org.jboss.test.aop.field.POJO->pojoInherited)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+ <bind pointcut="field(* org.jboss.test.aop.field.SubPOJO->subpojoInherited)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+ <bind pointcut="field(* org.jboss.test.aop.field.SubSubPOJO->mine)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+
+ <interceptor name="field" class="org.jboss.test.aop.field.FieldPerJoinpointInterceptor" scope="PER_JOINPOINT"/>
+ <interceptor name="staticField" class="org.jboss.test.aop.field.FieldPerJoinpointInterceptor" scope="PER_CLASS_JOINPOINT"/>
+ <bind pointcut="field(* org.jboss.test.aop.field.ScopedPojo->field*)">
+ <interceptor-ref name="field"/>
+ </bind>
+ <bind pointcut="field(* org.jboss.test.aop.field.ScopedPojo->staticField)">
+ <interceptor-ref name="staticField"/>
+ </bind>
+
+ <bind pointcut="set(* org.jboss.test.aop.field.SetOrGetOnlyPOJO->setOnly)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+ <bind pointcut="get(* org.jboss.test.aop.field.SetOrGetOnlyPOJO->getOnly)">
+ <interceptor class="org.jboss.test.aop.field.TraceInterceptor"/>
+ </bind>
+</aop>
\ No newline at end of file
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldPerJoinpointInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldPerJoinpointInterceptor.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldPerJoinpointInterceptor.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.field;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.FieldInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class FieldPerJoinpointInterceptor implements Interceptor
+{
+ public static FieldPerJoinpointInterceptor last;
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ if (!(invocation instanceof FieldInvocation))
+ {
+ throw new RuntimeException("Should only be attached to fields");
+ }
+
+ FieldInvocation fi = (FieldInvocation)invocation;
+ last = this;
+ System.out.println("PerJoinpointInterceptor " + this + " intercepting " + fi.getField().getName());
+ return invocation.invokeNext();
+ }
+
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldTestCase.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/FieldTestCase.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.field;
+
+import java.lang.reflect.Field;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.aop.Advised;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassAdvisor;
+import org.jboss.aop.InstanceAdvisor;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.joinpoint.FieldJoinpoint;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class FieldTestCase extends TestCase
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("FieldTestCase");
+ suite.addTestSuite(FieldTestCase.class);
+ return suite;
+ }
+
+ public FieldTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testField()
+ {
+ System.out.println("*** testField");
+ SubPOJO spojo = new SubPOJO(4);
+ assertEquals("Field is not set correctly", spojo.getPOJOField(), (spojo.getSubPOJOField()/2));
+ }
+
+ public void testField2()
+ {
+ System.out.println("*** testField2");
+ SubSubPOJO spojo = new SubSubPOJO(4);
+ assertEquals("Field is not set correctly", spojo.getSubSubPOJOField()/2, (spojo.getSubPOJOField()));
+ }
+
+ public void testFieldInheritance()
+ {
+ System.out.println("*** testFieldInheritance");
+ SubSubPOJO pojo = new SubSubPOJO(4);
+
+ TraceInterceptor.intercepted = false;
+ pojo.mine = 5;
+ assertTrue(TraceInterceptor.intercepted);
+
+
+ TraceInterceptor.intercepted = false;
+ pojo.pojoInherited = 5;
+ assertTrue(TraceInterceptor.intercepted);
+
+ TraceInterceptor.intercepted = false;
+ pojo.subpojoInherited = 5;
+ assertTrue(TraceInterceptor.intercepted);
+ }
+
+ public void testPerJoinpoint() throws Exception
+ {
+ ScopedPojo pojo1 = new ScopedPojo();
+ ScopedPojo pojo2 = new ScopedPojo();
+
+ FieldPerJoinpointInterceptor.last = null;
+ pojo1.field1 = 10;
+ assertNotNull(FieldPerJoinpointInterceptor.last);
+ FieldPerJoinpointInterceptor fieldWrite1 = FieldPerJoinpointInterceptor.last;
+
+ FieldPerJoinpointInterceptor.last = null;
+ int x = pojo1.field1;
+ assertNotNull(FieldPerJoinpointInterceptor.last);
+ FieldPerJoinpointInterceptor fieldRead1 = FieldPerJoinpointInterceptor.last;
+
+ assertSame(fieldRead1, fieldWrite1);
+
+ FieldPerJoinpointInterceptor.last = null;
+ pojo2.field1 = 10;
+ assertNotNull(FieldPerJoinpointInterceptor.last);
+ FieldPerJoinpointInterceptor fieldWrite2 = FieldPerJoinpointInterceptor.last;
+
+ assertNotSame(fieldRead1, fieldWrite2);
+
+ FieldPerJoinpointInterceptor.last = null;
+ pojo1.field2 = 10;
+ assertNotNull(FieldPerJoinpointInterceptor.last);
+ FieldPerJoinpointInterceptor field2Write1 = FieldPerJoinpointInterceptor.last;
+
+ assertNotSame(field2Write1, fieldRead1);
+
+ FieldPerJoinpointInterceptor.last = null;
+ ScopedPojo.staticField = 10;
+ assertNotNull(FieldPerJoinpointInterceptor.last);
+ FieldPerJoinpointInterceptor staticWrite = FieldPerJoinpointInterceptor.last;
+ FieldPerJoinpointInterceptor.last = null;
+ x = ScopedPojo.staticField;
+ assertEquals(staticWrite, FieldPerJoinpointInterceptor.last);
+
+
+ Field field1 = pojo1.getClass().getField("field1");
+ Field field2 = pojo1.getClass().getField("field2");
+ Field staticField = pojo1.getClass().getField("staticField");
+
+ AspectDefinition def = AspectManager.instance().getAspectDefinition("field");
+ assertNotNull(def);
+ InstanceAdvisor ia1 = ((Advised)pojo1)._getInstanceAdvisor();
+ InstanceAdvisor ia2 = ((Advised)pojo2)._getInstanceAdvisor();
+ FieldPerJoinpointInterceptor ia1Field1 = (FieldPerJoinpointInterceptor)ia1.getPerInstanceJoinpointAspect(new FieldJoinpoint(field1), def);
+ assertNotNull(ia1Field1);
+ FieldPerJoinpointInterceptor ia2Field1 = (FieldPerJoinpointInterceptor)ia2.getPerInstanceJoinpointAspect(new FieldJoinpoint(field1), def);
+ assertNotNull(ia2Field1);
+ FieldPerJoinpointInterceptor ia1Field2 = (FieldPerJoinpointInterceptor)ia1.getPerInstanceJoinpointAspect(new FieldJoinpoint(field2), def);
+ assertNotNull(ia1Field2);
+
+ assertSame(fieldRead1, ia1Field1);
+ assertSame(fieldWrite2, ia2Field1);
+ assertSame(field2Write1, ia1Field2);
+
+ AspectDefinition statDef = AspectManager.instance().getAspectDefinition("staticField");
+ assertNotNull(statDef);
+ FieldPerJoinpointInterceptor advStatic = (FieldPerJoinpointInterceptor)((ClassAdvisor)((Advised)pojo1)._getAdvisor()).getFieldAspect(new FieldJoinpoint(staticField), statDef);
+ assertSame(advStatic, staticWrite);
+
+ }
+
+ public void testSetOnly() throws Exception
+ {
+ SetOrGetOnlyPOJO pojo = new SetOrGetOnlyPOJO();
+ TraceInterceptor.intercepted = false;
+ pojo.setOnly = 10;
+ assertTrue(TraceInterceptor.intercepted);
+
+ TraceInterceptor.intercepted = false;
+ assertEquals(10, pojo.setOnly);
+ assertFalse(TraceInterceptor.intercepted);
+ }
+
+ public void testGetOnly() throws Exception
+ {
+ SetOrGetOnlyPOJO pojo = new SetOrGetOnlyPOJO();
+ TraceInterceptor.intercepted = false;
+ pojo.getOnly = 10;
+ assertFalse(TraceInterceptor.intercepted);
+
+ TraceInterceptor.intercepted = false;
+ assertEquals(10, pojo.getOnly);
+ assertTrue(TraceInterceptor.intercepted);
+ }
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/POJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/POJO.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/POJO.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.field;
+
+/**
+*
+* @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+* @version $Revision
+*/
+public class POJO
+{
+ int field;
+ public int pojoInherited;
+
+ public POJO() {}
+
+ public POJO(int i)
+ {
+ field = i;
+ }
+
+ public int getPOJOField()
+ {
+ return field;
+ }
+
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/ScopedPojo.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/ScopedPojo.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/ScopedPojo.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.field;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedPojo
+{
+ public int field1;
+ public int field2;
+ public static int staticField;
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SetOrGetOnlyPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SetOrGetOnlyPOJO.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SetOrGetOnlyPOJO.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.field;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SetOrGetOnlyPOJO
+{
+ int setOnly;
+ int getOnly;
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubPOJO.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubPOJO.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.field;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SubPOJO extends POJO
+{
+ private int field;
+ int subpojoInherited;
+
+ public SubPOJO() { }
+
+ public SubPOJO(int i)
+ {
+ super(i/2);
+ field = i;
+ }
+
+ public int getSubPOJOField()
+ {
+ return field;
+ }
+
+
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubSubPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubSubPOJO.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/SubSubPOJO.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.field;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SubSubPOJO extends SubPOJO
+{
+ public int field;
+ public int mine;
+
+ public SubSubPOJO(int i)
+ {
+ super(i);
+ field = i * 2;
+ }
+
+ public int getSubSubPOJOField()
+ {
+ return field;
+ }
+
+
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/TraceInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/TraceInterceptor.java 2007-01-10 16:46:11 UTC (rev 59483)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/field/TraceInterceptor.java 2007-01-10 17:18:32 UTC (rev 59484)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.field;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.FieldReadInvocation;
+import org.jboss.aop.joinpoint.FieldWriteInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class TraceInterceptor implements Interceptor
+{
+ public static boolean intercepted;
+ public String getName()
+ {
+ return "TraceInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ intercepted = true;
+ String msg = null;
+ if (invocation instanceof FieldReadInvocation)
+ {
+ msg = "read field name: " + ((FieldReadInvocation)invocation).getField();
+ }
+ else if (invocation instanceof FieldWriteInvocation)
+ {
+ msg = "write field name: " + ((FieldWriteInvocation)invocation).getField();
+ }
+
+ try
+ {
+ System.out.println("<<< Trace : " + msg);
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ System.out.println(">>> Leaving Trace");
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list