]> source.dussan.org Git - aspectj.git/commitdiff
124460: world knows if XML files are being used to influence weaving
authoraclement <aclement>
Sat, 31 Jan 2009 01:15:27 +0000 (01:15 +0000)
committeraclement <aclement>
Sat, 31 Jan 2009 01:15:27 +0000 (01:15 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java

index 5e8116859f0e0ed29d2fddadd0a83af4e74cc339..b2307d006c967d48d000da4267444e4208e54179 100644 (file)
@@ -16,6 +16,7 @@ package org.aspectj.weaver.bcel;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -67,6 +68,8 @@ import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
+import org.aspectj.weaver.loadtime.definition.Definition;
+import org.aspectj.weaver.loadtime.definition.DocumentParser;
 import org.aspectj.weaver.model.AsmRelationshipProvider;
 import org.aspectj.weaver.patterns.DeclareAnnotation;
 import org.aspectj.weaver.patterns.DeclareParents;
@@ -79,6 +82,7 @@ public class BcelWorld extends World implements Repository {
        protected Repository delegate;
        private BcelWeakClassLoaderReference loaderRef;
        private final BcelWeavingSupport bcelWeavingSupport = new BcelWeavingSupport();
+       private List/* File */xmlFiles;
 
        private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelWorld.class);
 
@@ -788,4 +792,37 @@ public class BcelWorld extends World implements Repository {
                return (AsmManager) getModel(); // For now... always an AsmManager in a bcel environment
        }
 
+       /**
+        * These are aop.xml files that can be used to alter the aspects that actually apply from those passed in - and also their scope
+        * of application to other files in the system.
+        * 
+        * @param xmlFiles list of File objects representing any aop.xml files passed in to configure the build process
+        */
+       public void setXmlFiles(List xmlFiles) {
+               this.xmlFiles = xmlFiles;
+               for (Iterator iterator = xmlFiles.iterator(); iterator.hasNext();) {
+                       File xmlfile = (File) iterator.next();
+                       try {
+                               Definition d = DocumentParser.parse(xmlfile.toURI().toURL());
+                               xmlAspectNames.addAll(d.getAspectClassNames());
+                               isXmlConfiguredWorld = true;
+                       } catch (MalformedURLException e) {
+                               e.printStackTrace();
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public boolean isXmlConfigured() {
+               return isXmlConfiguredWorld;
+       }
+
+       // public boolean specifiesInclusionOfAspect(String name) {
+       // return xmlAspectNames.contains(name);
+       // }
+
+       private boolean isXmlConfiguredWorld = false;
+       private List/* String */xmlAspectNames = new ArrayList();
+
 }
\ No newline at end of file