From f2c134b2c1dfd5fedd472bafe53155db55ad9d70 Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 15 May 2009 03:41:05 +0000 Subject: Integrate the NodeConfiguration with NodeImpl git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@774994 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/assembly/xml/CompositeModelResolver.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'java/sca/modules/assembly-xml/src') diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java index 62ed95cb01..d077bc63a0 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.apache.tuscany.sca.assembly.xml; @@ -40,35 +40,36 @@ public class CompositeModelResolver implements ModelResolver { private Contribution contribution; private Map map = new HashMap(); - + public CompositeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) { this.contribution = contribution; } public void addModel(Object resolved) { Composite composite = (Composite)resolved; + // FIXME: What if two composites with the same QName are added? map.put(composite.getName(), composite); } - + public Object removeModel(Object resolved) { return map.remove(((Composite)resolved).getName()); } - + public T resolveModel(Class modelClass, T unresolved) { - + // Lookup a definition for the given namespace QName qname = ((Composite)unresolved).getName(); Composite resolved = (Composite) map.get(qname); if (resolved != null) { return modelClass.cast(resolved); } - + // No definition found, delegate the resolution to the imports for (Import import_ : this.contribution.getImports()) { if (import_ instanceof NamespaceImport) { NamespaceImport namespaceImport = (NamespaceImport)import_; if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) { - + // Delegate the resolution to the import resolver resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)unresolved); if (!resolved.isUnresolved()) { @@ -79,5 +80,5 @@ public class CompositeModelResolver implements ModelResolver { } return (T)unresolved; } - + } -- cgit v1.2.3