]> source.dussan.org Git - aspectj.git/commitdiff
238666: Allow the ltw configuration to be directly specified rather than discovered...
authoraclement <aclement>
Wed, 6 Aug 2008 18:10:47 +0000 (18:10 +0000)
committeraclement <aclement>
Wed, 6 Aug 2008 18:10:47 +0000 (18:10 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java

index d96bb33d375f7309c96f29dda932b598482b5a0b..cf73de3ca82aebe9f5625731fa69ab4b1e40147d 100644 (file)
@@ -17,6 +17,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -196,24 +197,40 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
 
             String resourcePath = System.getProperty("org.aspectj.weaver.loadtime.configuration",AOP_XML);
             if (trace.isTraceEnabled()) trace.event("parseDefinitions",this,resourcePath);
+            
                StringTokenizer st = new StringTokenizer(resourcePath,";");
 
                while(st.hasMoreTokens()){
-                       Enumeration xmls = weavingContext.getResources(st.nextToken());
-//                     System.out.println("? registerDefinitions: found-aop.xml=" + xmls.hasMoreElements() + ", loader=" + loader);
-
-                       Set seenBefore = new HashSet();
-                       while (xmls.hasMoreElements()) {
-                           URL xml = (URL) xmls.nextElement();
-                           if (trace.isTraceEnabled()) trace.event("parseDefinitions",this,xml);
-                           if (!seenBefore.contains(xml)) {
-                               info("using configuration " + weavingContext.getFile(xml));
-                               definitions.add(DocumentParser.parse(xml));
-                                   seenBefore.add(xml);
-                           }
-                           else {
-                               warn("ignoring duplicate definition: " + xml);
-                           }
+                       String nextDefinition = st.nextToken();
+                       if (nextDefinition.startsWith("file:")) {
+                               try {
+                                       String fpath = new URL(nextDefinition).getFile();
+                                       File configFile = new File(fpath);
+                                       if (!configFile.exists()) {
+                                               warn("configuration does not exist: "+nextDefinition);
+                                       } else {
+                                               definitions.add(DocumentParser.parse(configFile.toURL()));
+                                       }
+                               } catch (MalformedURLException mue) {
+                                       error("malformed definition url: "+nextDefinition);
+                               }
+                       } else {
+                               Enumeration xmls = weavingContext.getResources(nextDefinition);
+       //                      System.out.println("? registerDefinitions: found-aop.xml=" + xmls.hasMoreElements() + ", loader=" + loader);
+       
+                               Set seenBefore = new HashSet();
+                               while (xmls.hasMoreElements()) {
+                                   URL xml = (URL) xmls.nextElement();
+                                   if (trace.isTraceEnabled()) trace.event("parseDefinitions",this,xml);
+                                   if (!seenBefore.contains(xml)) {
+                                       info("using configuration " + weavingContext.getFile(xml));
+                                       definitions.add(DocumentParser.parse(xml));
+                                           seenBefore.add(xml);
+                                   }
+                                   else {
+                                       warn("ignoring duplicate definition: " + xml);
+                                   }
+                               }
                        }
                }
                if (definitions.isEmpty()) {