tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1173363 - /tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
Date Tue, 20 Sep 2011 20:55:35 GMT
Author: rfeng
Date: Tue Sep 20 20:55:35 2011
New Revision: 1173363

URL: http://svn.apache.org/viewvc?rev=1173363&view=rev
Log:
Use all attributes to detect duplication

Modified:
    tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java

Modified: tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java?rev=1173363&r1=1173362&r2=1173363&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
Tue Sep 20 20:55:35 2011
@@ -105,6 +105,7 @@ public final class ServiceDiscovery impl
 
     public Collection<ServiceDeclaration> getServiceDeclarations(String name, boolean
byRanking) throws IOException {
         Collection<ServiceDeclaration> declarations = getServiceDiscoverer().getServiceDeclarations(name);
+        // declarations = removeDuplicateDeclarations(declarations);
         // Check if any of the service declarations has attributes that are overrided
         if (!serviceAttributes.isEmpty()) {
             for (ServiceDeclaration declaration : declarations) {
@@ -119,18 +120,6 @@ public final class ServiceDiscovery impl
         }
         if (!declarations.isEmpty()) {
             List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations);
-            /*
-            for (ServiceDeclaration sd1 : declarations) {
-                for (Iterator<ServiceDeclaration> i = declarationList.iterator(); i.hasNext();)
{
-                    ServiceDeclaration sd2 = i.next();
-                    if (sd1 != sd2 && sd1.getAttributes().equals(sd2.getAttributes()))
{
-                        logger
-                            .warning("Duplicate service declarations: " + sd1.getLocation()
+ "," + sd2.getLocation());
-                        i.remove();
-                    }
-                }
-            }
-            */
             Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER);
             return declarationList;
         } else {
@@ -294,11 +283,11 @@ public final class ServiceDiscovery impl
      */
     public static Collection<ServiceDeclaration> removeDuplicateDeclarations(Collection<ServiceDeclaration>
declarations) {
         // Use LinkedHashMap to maintain the insertion order
-        Map<String, ServiceDeclaration> map = new LinkedHashMap<String, ServiceDeclaration>();
+        Map<Map<String, String>, ServiceDeclaration> map = new LinkedHashMap<Map<String,
String>, ServiceDeclaration>();
         for (ServiceDeclaration sd : declarations) {
-            ServiceDeclaration existed = map.put(sd.getClassName(), sd);
+            ServiceDeclaration existed = map.put(sd.getAttributes(), sd);
             if (existed != null) {
-                logger.warning("Duplicate service declaration is ignored: " + existed + "
<-> " + sd);
+                logger.warning("Duplicate service declaration is detected: " + existed +
" <-> " + sd);
             }
         }
         return map.values();



Mime
View raw message