summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/extensibility/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-09-20 20:55:35 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-09-20 20:55:35 +0000
commitcca68a5ef9d90b383c37841cfcce0279a2bb4c56 (patch)
tree8ea64ba5d2d9070d5f2abc0dbea24cc437700fac /sca-java-2.x/trunk/modules/extensibility/src/main
parenta92930a64d956ecdbd1dce35789749c5e97e2e46 (diff)
Use all attributes to detect duplication
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1173363 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/extensibility/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java19
1 files changed, 4 insertions, 15 deletions
diff --git a/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
index 973664f382..b71ebdffd7 100644
--- a/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
+++ b/sca-java-2.x/trunk/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
@@ -105,6 +105,7 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
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 implements ServiceDiscoverer {
}
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 implements ServiceDiscoverer {
*/
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();