summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/sca/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java12
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java12
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java13
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java9
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java6
5 files changed, 45 insertions, 7 deletions
diff --git a/java/sca/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java b/java/sca/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java
index 6a8a68675f..bfdd9fdac7 100644
--- a/java/sca/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java
+++ b/java/sca/modules/assembly-xml-osoa/src/main/java/org/apache/tuscany/sca/assembly/xml/osoa/CompositeProcessor.java
@@ -290,10 +290,20 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
String promote = reader.getAttributeValue(null, Constants.PROMOTE);
if (promote != null) {
for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
+ String refName = tokens.nextToken();
+ Component promotedComponent = assemblyFactory.createComponent();
+ int index = refName.indexOf('/');
+ if (index == -1) {
+ error("Invalid reference name", compositeReference, refName);
+ }
+ String promotedComponentName = refName.substring(0, index);
+ promotedComponent.setName(promotedComponentName);
+ promotedComponent.setUnresolved(true);
+ compositeReference.getPromotedComponents().add(promotedComponent);
ComponentReference promotedReference =
assemblyFactory.createComponentReference();
promotedReference.setUnresolved(true);
- promotedReference.setName(tokens.nextToken());
+ promotedReference.setName(refName);
compositeReference.getPromotedReferences().add(promotedReference);
}
}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
index 0a7df27b1f..7a2eba494f 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -297,10 +297,20 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
String promote = reader.getAttributeValue(null, Constants.PROMOTE);
if (promote != null) {
for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
+ String refName = tokens.nextToken();
+ Component promotedComponent = assemblyFactory.createComponent();
+ int index = refName.indexOf('/');
+ if (index == -1) {
+ error("Invalid reference name", compositeReference, refName);
+ }
+ String promotedComponentName = refName.substring(0, index);
+ promotedComponent.setName(promotedComponentName);
+ promotedComponent.setUnresolved(true);
+ compositeReference.getPromotedComponents().add(promotedComponent);
ComponentReference promotedReference =
assemblyFactory.createComponentReference();
promotedReference.setUnresolved(true);
- promotedReference.setName(tokens.nextToken());
+ promotedReference.setName(refName);
compositeReference.getPromotedReferences().add(promotedReference);
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
index d3fa80ba74..9defd8f66c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
@@ -26,12 +26,19 @@ import java.util.List;
* @version $Rev$ $Date$
*/
public interface CompositeReference extends Reference {
+ /**
+ * Returns the promoted components. For each promoted component/reference,
+ * they have the same index in the component and reference list.
+ *
+ * @return the promoted components
+ */
+ List<Component> getPromotedComponents();
/**
- * Returns the promoted composite references.
+ * Returns the promoted component references.
*
- * @return the promoted composite references
+ * @return the promoted component references
*/
List<ComponentReference> getPromotedReferences();
-
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
index eb858b4e3d..30c4e78367 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
@@ -86,7 +86,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co
// Connect composite services and references to the component
// services and references that they promote
connectCompositeServices(composite, components, componentServices, monitor);
- connectCompositeReferences(composite, componentReferences, monitor);
+ connectCompositeReferences(composite, components, componentReferences, monitor);
}
/**
@@ -170,6 +170,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co
* @param problems
*/
private void connectCompositeReferences(Composite composite,
+ Map<String, Component> components,
Map<String, ComponentReference> componentReferences, Monitor monitor) {
// Propagate interfaces from inner composite components' references to
@@ -198,7 +199,11 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co
String componentReferenceName = componentReference.getName();
componentReference = componentReferences.get(componentReferenceName);
if (componentReference != null) {
-
+ // Set the promoted component
+ Component promotedComponent = compositeReference.getPromotedComponents().get(i);
+ promotedComponent = components.get(promotedComponent.getName());
+ compositeReference.getPromotedComponents().set(i, promotedComponent);
+
// Point to the resolved component reference
promotedReferences.set(i, componentReference);
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
index 4348e08fcb..db88798cb5 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.assembly.impl;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.CompositeReference;
@@ -31,6 +32,7 @@ import org.apache.tuscany.sca.assembly.CompositeReference;
* @version $Rev$ $Date$
*/
public class CompositeReferenceImpl extends ReferenceImpl implements CompositeReference, Cloneable {
+ private List<Component> promotedComponents = new ArrayList<Component>();
private List<ComponentReference> promotedReferences = new ArrayList<ComponentReference>();
/**
@@ -48,4 +50,8 @@ public class CompositeReferenceImpl extends ReferenceImpl implements CompositeRe
return promotedReferences;
}
+ public List<Component> getPromotedComponents() {
+ return promotedComponents;
+ }
+
}