diff options
author | aclement <aclement> | 2008-08-06 18:10:47 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-08-06 18:10:47 +0000 |
commit | df49b5c64ad56dcb67424bbcdbe27976c5b77477 (patch) | |
tree | 9d25e83de733646b60f562de573a0dead10f031d /loadtime | |
parent | 84ac656f3c14285968fda4c83f09201d04571f70 (diff) | |
download | aspectj-df49b5c64ad56dcb67424bbcdbe27976c5b77477.tar.gz aspectj-df49b5c64ad56dcb67424bbcdbe27976c5b77477.zip |
238666: Allow the ltw configuration to be directly specified rather than discovered on the classpath
Diffstat (limited to 'loadtime')
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index d96bb33d3..cf73de3ca 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -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()) { |