summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/implementation-spring/src/main
diff options
context:
space:
mode:
authorramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-08-11 16:32:21 +0000
committerramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-08-11 16:32:21 +0000
commitff463184eff037e62936c59cb1b6b2a21899b4ad (patch)
treeffb63fb1e2068b9927cfca91457e8c2ef4184d45 /branches/sca-java-1.x/modules/implementation-spring/src/main
parent483f8e27c5e7e4e4504f5b80201745ab194eb957 (diff)
Fixes for TUSCANY-3185
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@803196 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/implementation-spring/src/main')
-rw-r--r--branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
index 6b67ba1eeb..9e4aa9bc33 100644
--- a/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
+++ b/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -51,6 +51,7 @@ import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ServiceImpl;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.ContributionFactory;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
@@ -415,6 +416,16 @@ public class SpringXMLComponentTypeLoader {
SpringSCAServiceElement serviceElement = its.next();
Class<?> interfaze = resolveClass(resolver, serviceElement.getType());
Service theService = createService(interfaze, serviceElement.getName());
+ // Spring allows duplication of bean definitions in multiple context scenario,
+ // in such cases, the latest bean definition overrides the older ones, hence
+ // we will remove any older definition and use the latest.
+ Service duplicate = null;
+ for (Service service : componentType.getServices()) {
+ if (service.getName().equals(theService.getName()))
+ duplicate = service;
+ }
+ if (duplicate != null)
+ componentType.getServices().remove(duplicate);
componentType.getServices().add(theService);
// Add this service to the Service / Bean map
String beanName = serviceElement.getTarget();
@@ -430,7 +441,15 @@ public class SpringXMLComponentTypeLoader {
while (itr.hasNext()) {
SpringSCAReferenceElement referenceElement = itr.next();
Class<?> interfaze = resolveClass(resolver, referenceElement.getType());
- Reference theReference = createReference(interfaze, referenceElement.getName());
+ Reference theReference = createReference(interfaze, referenceElement.getName());
+ // Override the older bean definition with the latest ones.
+ Reference duplicate = null;
+ for (Reference reference : componentType.getReferences()) {
+ if (reference.getName().equals(theReference.getName()))
+ duplicate = reference;
+ }
+ if (duplicate != null)
+ componentType.getReferences().remove(duplicate);
componentType.getReferences().add(theReference);
} // end while
@@ -446,6 +465,14 @@ public class SpringXMLComponentTypeLoader {
// Get the Java class and then an XSD element type for the property
Class<?> propType = Class.forName(scaproperty.getType());
theProperty.setXSDType(JavaXMLMapper.getXMLType(propType));
+ // Override the older bean definition with the latest ones.
+ Property duplicate = null;
+ for (Property property : componentType.getProperties()) {
+ if (property.getName().equals(theProperty.getName()))
+ duplicate = property;
+ }
+ if (duplicate != null)
+ componentType.getProperties().remove(duplicate);
componentType.getProperties().add(theProperty);
// Remember the Java Class (ie the type) for this property
implementation.setPropertyClass(theProperty.getName(), propType);
@@ -472,7 +499,7 @@ public class SpringXMLComponentTypeLoader {
// Get the service interface defined by this Spring Bean and add to
// the component type of the Spring Assembly
List<Service> beanServices = beanComponentType.getServices();
- componentType.getServices().addAll(beanServices);
+ componentType.getServices().addAll(beanServices);
// Add these services to the Service / Bean map
for (Service beanService : beanServices) {
implementation.setBeanForService(beanService, beanElement);