tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1215081 - /tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
Date Fri, 16 Dec 2011 10:17:13 GMT
Author: antelder
Date: Fri Dec 16 10:17:13 2011
New Revision: 1215081

URL: http://svn.apache.org/viewvc?rev=1215081&view=rev
Log:
TUSCANY-3998: Apply patch from Greg Dritschler to provide a way to override Tuscany system
definition.xml documents

Modified:
    tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java

Modified: tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java?rev=1215081&r1=1215080&r2=1215081&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
Fri Dec 16 10:17:13 2011
@@ -80,18 +80,26 @@ public class DefaultDefinitionsExtension
         // Get the definitions declarations
         Collection<ServiceDeclaration> definitionsDeclarations;
         try {
-            definitionsDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DEFINITIONS_FILE);
+            // Get definitions declarations in ranking order.
+            definitionsDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DEFINITIONS_FILE,
true);
         } catch (IOException e) {
             throw new IllegalStateException(e);
         }
 
         // Find each definitions
+        Set<String> definitionResources = new HashSet<String>();
         for (ServiceDeclaration definitionsDeclaration : definitionsDeclarations) {
-            URL url = definitionsDeclaration.getResource(definitionsDeclaration.getClassName());
-            if (url == null) {
-                throw new IllegalArgumentException(definitionsDeclaration.getClassName()
+ " cannot be found");
+            // Only process the first instance of a given resource name.
+            // This allows definitions files to be overridden by an embedder. 
+            String resourceName = definitionsDeclaration.getClassName();
+            if (!definitionResources.contains(resourceName)) {
+                definitionResources.add(resourceName);
+                URL url = definitionsDeclaration.getResource(resourceName);
+                if (url == null) {
+                    throw new IllegalArgumentException(definitionsDeclaration.getClassName()
+ " cannot be found");
+                }
+                documents.add(url);
             }
-            documents.add(url);
         }
 
         documentsLoaded = true;



Mime
View raw message