]> source.dussan.org Git - aspectj.git/commitdiff
ignore duplicate aop.xml definition
authormwebster <mwebster>
Fri, 15 Sep 2006 11:13:14 +0000 (11:13 +0000)
committermwebster <mwebster>
Fri, 15 Sep 2006 11:13:14 +0000 (11:13 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
weaver/src/org/aspectj/weaver/tools/AbstractTrace.java

index 45fb96d8ae74330a98fb35ce3c3de50b4b3c9e36..3f4ad572924e08f5c3c8d24df5dd06e4a346c9d5 100644 (file)
@@ -21,9 +21,11 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.aspectj.asm.IRelationship;
@@ -193,10 +195,18 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                        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();
-                           info("using configuration " + weavingContext.getFile(xml));
-                           definitions.add(DocumentParser.parse(xml));
+                   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()) {
index 6034a1f0515ba68a320660c53e615f6a4ae6373c..b426c0e9e8afde8b25cf93b1432556a3cb0e3459 100644 (file)
@@ -12,6 +12,7 @@ package org.aspectj.weaver.tools;
 
 import java.io.File;
 import java.lang.reflect.Array;
+import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
@@ -123,6 +124,7 @@ public abstract class AbstractTrace implements Trace {
                            || obj instanceof Class
                            || obj instanceof File
                            || obj instanceof StringBuffer
+                           || obj instanceof URL
                    ) return obj;
                else if (obj.getClass().isArray()) {
                        return formatArray(obj);