diff options
Diffstat (limited to 'java/sca')
-rw-r--r-- | java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java index 1a45366d72..389f163a95 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java @@ -58,29 +58,33 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon public Object clone() throws CloneNotSupportedException { CompositeImpl clone = (CompositeImpl)super.clone(); + // clone the child components clone.components = new ArrayList<Component>(); for (Component component : getComponents()) { Component clonedComponent = (Component)component.clone(); - for (Service service : clone.getServices()) { - CompositeService compositeService = (CompositeService)service; - // Force the promoted component/service to be rebuilt against the clone - if (compositeService.getPromotedComponent() != null) { - compositeService.getPromotedComponent().setUnresolved(true); - } - if (compositeService.getPromotedService() != null) { - compositeService.getPromotedService().setUnresolved(true); - } + clone.components.add(clonedComponent); + } + + // reset the references and services so the get re-resolved + for (Service service : clone.getServices()) { + CompositeService compositeService = (CompositeService)service; + // Force the promoted component/service to be rebuilt against the clone + if (compositeService.getPromotedComponent() != null) { + compositeService.getPromotedComponent().setUnresolved(true); } - for (Reference reference : clone.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - for (ComponentReference ref : compositeReference.getPromotedReferences()) { - // Force the promoted reference to be rebuilt against the clone - ref.setUnresolved(true); - } + if (compositeService.getPromotedService() != null) { + compositeService.getPromotedService().setUnresolved(true); + } + } + for (Reference reference : clone.getReferences()) { + CompositeReference compositeReference = (CompositeReference)reference; + for (ComponentReference ref : compositeReference.getPromotedReferences()) { + // Force the promoted reference to be rebuilt against the clone + ref.setUnresolved(true); } - - clone.components.add(clonedComponent); } + + // clone the wires clone.wires = new ArrayList<Wire>(); for (Wire wire : getWires()) { clone.wires.add((Wire)wire.clone()); |