Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 84711 Details for
Bug 193065
Improve the extensibility of AspectJ weaver to support PointcutDoctor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Test case and javadoc
CustomMunger3nd-sumbittion-tests-javadoc-Dec072007.txt (text/plain), 10.01 KB, created by
Linton Ye
on 2007-12-07 03:21:39 EST
(
hide
)
Description:
Test case and javadoc
Filename:
MIME Type:
Creator:
Linton Ye
Created:
2007-12-07 03:21:39 EST
Size:
10.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P weaver >Index: src/org/aspectj/weaver/CustomMungerFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.aspectj/modules/weaver/src/org/aspectj/weaver/CustomMungerFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 CustomMungerFactory.java >--- src/org/aspectj/weaver/CustomMungerFactory.java 2 Dec 2007 11:42:42 -0000 1.1 >+++ src/org/aspectj/weaver/CustomMungerFactory.java 7 Dec 2007 08:00:43 -0000 >@@ -14,8 +14,45 @@ > > import java.util.Collection; > >+/** >+ * <p> >+ * This interface is introduced to support tools like PointcutDoctor. >+ * </p> >+ * <p> >+ * A CustomMungerFactory is used to create ShadowMungers and/or >+ * ConcreteTypeMungers so that an extender can extract extra information during >+ * the weaving process. >+ * </p> >+ * <p> >+ * A CustomMungerFactory is assigned to a weaver through its AjCompiler in >+ * extenders' code, and gets invoked by the weaver right before the weaving >+ * starts. The custom shadow/type mungers being created will be added into the >+ * shadow/type munger list in the weaver and participate the weaving process. >+ * For example, the match method of each custom shadow munger will be called >+ * against each shadow. >+ * </p> >+ * @author lintonye >+ * >+ */ > public interface CustomMungerFactory { >- public Collection/*ShadowMunger*/ createCustomShadowMungers(ResolvedType aspectType); >- public Collection/*ConcreteTypeMunger*/ createCustomTypeMungers(ResolvedType aspectType); >-// public Collection<Declare> createCustomDeclares(ResolvedType aspectType); >+ >+ /** >+ * @param aspectType >+ * @return a Collection<ShadowMunger> of custom shadow mungers for the >+ * given aspect >+ */ >+ public Collection/* ShadowMunger */createCustomShadowMungers( >+ ResolvedType aspectType); >+ >+ /** >+ * @param aspectType >+ * @return a Collection<ConcreteTypeMunger> of custom type mungers for the >+ * given aspect >+ */ >+ public Collection/* ConcreteTypeMunger */createCustomTypeMungers( >+ ResolvedType aspectType); >+ >+ public Collection/* ShadowMunger */getAllCreatedCustomShadowMungers(); >+ >+ public Collection/* ConcreteTypeMunger */getAllCreatedCustomTypeMungers(); > } >#P tests >Index: bugs/pointcutdoctor-bug193065/Foo.java >=================================================================== >RCS file: bugs/pointcutdoctor-bug193065/Foo.java >diff -N bugs/pointcutdoctor-bug193065/Foo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs/pointcutdoctor-bug193065/Foo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+public class Foo { >+ public void method1() { >+ >+ } >+ >+ public void method2() { >+ >+ } >+} >Index: bugs/pointcutdoctor-bug193065/Bar.java >=================================================================== >RCS file: bugs/pointcutdoctor-bug193065/Bar.java >diff -N bugs/pointcutdoctor-bug193065/Bar.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs/pointcutdoctor-bug193065/Bar.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+public class Bar { >+ public void bar() { >+ Foo f = new Foo(); >+ f.method1(); >+ } >+} >Index: bugs/pointcutdoctor-bug193065/Aspect.aj >=================================================================== >RCS file: bugs/pointcutdoctor-bug193065/Aspect.aj >diff -N bugs/pointcutdoctor-bug193065/Aspect.aj >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs/pointcutdoctor-bug193065/Aspect.aj 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+ >+public aspect Aspect { >+ //:method-call(void Foo.method1())=real >+ //:(virtual) method-call(void Foo.method2())=virtual >+ pointcut calls(): call(* Foo.*(..)); >+ >+ //:(virtual) method-call(void Bar.bar())=virtual >+ pointcut callBar():call(* Bar.*(..)); >+ >+ //:method-call(void Foo.method1())=real >+ //:(virtual) method-call(void Foo.method2())=virtual >+ pointcut callsWithin(): call(* Foo.*(..)) && within(Bar); >+ >+ //:method-call(void Foo.method1())=real >+ //:(virtual) method-call(void Foo.method2())=virtual >+ pointcut callsWithincode(): call(* Foo.*(..))&&withincode(* Bar.*(..)); >+ >+} >Index: src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java >=================================================================== >RCS file: src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java >diff -N src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,127 @@ >+/* ******************************************************************* >+ * Copyright (c) 2007 Contributors >+ * All rights reserved. >+ * This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Linton Ye https://bugs.eclipse.org/bugs/show_bug.cgi?id=193065 >+ * ******************************************************************/ >+ >+package org.aspectj.systemtest.ajc154; >+ >+import java.io.File; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.aspectj.ajde.core.AjCompiler; >+import org.aspectj.bridge.ISourceLocation; >+import org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbed; >+import org.aspectj.weaver.Advice; >+import org.aspectj.weaver.Checker; >+import org.aspectj.weaver.ConcreteTypeMunger; >+import org.aspectj.weaver.CustomMungerFactory; >+import org.aspectj.weaver.Member; >+import org.aspectj.weaver.ResolvedType; >+import org.aspectj.weaver.ResolvedTypeMunger; >+import org.aspectj.weaver.Shadow; >+import org.aspectj.weaver.ShadowMunger; >+import org.aspectj.weaver.World; >+import org.aspectj.weaver.AjAttribute.AdviceAttribute; >+import org.aspectj.weaver.patterns.DeclareErrorOrWarning; >+import org.aspectj.weaver.patterns.IfPointcut; >+import org.aspectj.weaver.patterns.Pointcut; >+ >+public class CustomMungerExtensionTest extends AjdeInteractionTestbed { >+ >+ @Override >+ protected void setUp() throws Exception { >+ super.setUp(); >+ sandboxDir = new File("."); >+ } >+ >+ public void testExtension() { >+ String testFileDir = "bugs/pointcutdoctor-bug193065"; >+ AjCompiler compiler = getCompilerForProjectWithName(testFileDir); >+ compiler.setCustomMungerFactory(new DumbCustomMungerFactory()); >+ >+ doBuild(testFileDir); >+ >+ CustomMungerFactory factory = (CustomMungerFactory)compiler.getCustomMungerFactory(); >+ assertTrue(factory.getAllCreatedCustomShadowMungers().size()>0); >+ for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();) >+ assertTrue(((DumbShadowMunger)i.next()).called); >+ >+ assertTrue(factory.getAllCreatedCustomTypeMungers().size()>0); >+ for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();) >+ assertTrue(((DumbTypeMunger)i.next()).called); >+ } >+ >+ class DumbCustomMungerFactory implements CustomMungerFactory { >+ Collection allShadowMungers = new ArrayList(); >+ Collection allTypeMungers = new ArrayList(); >+ public Collection createCustomShadowMungers(ResolvedType aspectType) { >+ List/* ShadowMunger */ mungers = new ArrayList/*ShadowMunger*/(); >+ Pointcut pointcut = new IfPointcut("abc"); >+ mungers.add(new DumbShadowMunger(new DeclareErrorOrWarning(false, pointcut, ""))); >+ allShadowMungers.addAll(mungers); >+ return mungers; >+ } >+ >+ public Collection createCustomTypeMungers(ResolvedType aspectType) { >+ List/*ConcreteTypeMunger*/ mungers = new ArrayList/*ShadowMunger*/(); >+ mungers.add(new DumbTypeMunger(null, aspectType)); >+ allTypeMungers.addAll(mungers); >+ return mungers; >+ } >+ >+ public Collection getAllCreatedCustomShadowMungers() { >+ return allShadowMungers; >+ } >+ >+ public Collection getAllCreatedCustomTypeMungers() { >+ return allTypeMungers; >+ } >+ } >+ >+ class DumbShadowMunger extends Checker { >+ public DumbShadowMunger(DeclareErrorOrWarning deow) { >+ super(deow); >+ } >+ @Override >+ public ISourceLocation getSourceLocation() { >+ return ISourceLocation.EMPTY; >+ } >+ >+ boolean called; >+ @Override >+ public boolean match(Shadow shadow, World world) { >+ called = true; >+ return false; >+ } >+ } >+ >+ class DumbTypeMunger extends ConcreteTypeMunger { >+ boolean called; >+ >+ public DumbTypeMunger(ResolvedTypeMunger munger, ResolvedType aspectType) { >+ super(munger, aspectType); >+ } >+ >+ @Override >+ public ConcreteTypeMunger parameterizedFor(ResolvedType targetType) { >+ return null; >+ } >+ >+ @Override >+ public boolean matches(ResolvedType onType) { >+ called = true; >+ return false; >+ } >+ } >+} >#P ajde.core >Index: src/org/aspectj/ajde/core/AjCompiler.java >=================================================================== >RCS file: /cvsroot/tools/org.aspectj/modules/ajde.core/src/org/aspectj/ajde/core/AjCompiler.java,v >retrieving revision 1.5 >diff -u -r1.5 AjCompiler.java >--- src/org/aspectj/ajde/core/AjCompiler.java 4 Dec 2007 08:24:27 -0000 1.5 >+++ src/org/aspectj/ajde/core/AjCompiler.java 7 Dec 2007 08:00:44 -0000 >@@ -59,10 +59,24 @@ > buildManager = new AjdeCoreBuildManager(this); > } > >- public void setCustomMungerFactory(Class factoryClass) { >- buildManager.setCustomMungerFactory(factoryClass); >+ /** >+ * Set a CustomMungerFactory to the compiler's weaver >+ * >+ * The type of factory should be org.aspectj.weaver.CustomMungerFactory but >+ * due to dependency problem of project ajde.core, it is Object for now. >+ * >+ * @param factory >+ */ >+ public void setCustomMungerFactory(Object factory) { >+ buildManager.setCustomMungerFactory(factory); > } >- >+ >+ /** >+ * @return the CustomMungerFactory from the compiler's weaver >+ * >+ * The return type should be org.aspectj.weaver.CustomMungerFactory but >+ * due to dependency problem of project ajde.core, it is Object for now. >+ */ > public Object getCustomMungerFactory() { > return buildManager.getCustomMungerFactory(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
aclement
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 193065
:
81273
|
83799
| 84711