From 0498e9dd768e270b74045acd96075306c29a9b4a Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 16 Dec 2011 10:17:13 +0000 Subject: TUSCANY-3998: Apply patch from Greg Dritschler to provide a way to override Tuscany system definition.xml documents git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1215081 13f79535-47bb-0310-9956-ffa450edef68 --- .../xml/DefaultDefinitionsExtensionPoint.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'sca-java-2.x/trunk/modules/assembly-xml') diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java index af59324c7c..99f66b1d78 100644 --- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java @@ -80,18 +80,26 @@ public class DefaultDefinitionsExtensionPoint implements DefinitionsExtensionPoi // Get the definitions declarations Collection 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 definitionResources = new HashSet(); 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; -- cgit v1.2.3