diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-17 19:29:34 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-17 19:29:34 +0000 |
commit | 16b8b195e6e48294b7d651aba6fa9f47c9d277aa (patch) | |
tree | 3362471b556516127ab4b9ce46dfe2d8a515a63b | |
parent | 507f857a0035626365dde283e2cb7fb1c63ed37e (diff) |
TUSCANY-3256 - Applying Greg's patch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@816346 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 63 insertions, 19 deletions
diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java index 8832597343..1cf94ff527 100644 --- a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java @@ -18,6 +18,10 @@ */
package org.apache.tuscany.sca.assembly;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
@@ -27,7 +31,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint; *
* @version $Rev$ $Date$
*/
-public interface ConfiguredOperation extends Base, PolicySetAttachPoint {
+public interface ConfiguredOperation extends Base, Cloneable, PolicySetAttachPoint {
/**
* Returns the name of the operation.
*
@@ -58,4 +62,26 @@ public interface ConfiguredOperation extends Base, PolicySetAttachPoint { * @param contractName the name of the contract to which this operation belongs
*/
void setContractName(String contractName);
+
+
+ /**
+ * Sets a list of policy sets.
+ *
+ * @param policySets
+ */
+ public void setPolicySets(List<PolicySet> policySets);
+
+ /**
+ * Sets a list of required intents.
+ *
+ * @param intents
+ */
+ public void setRequiredIntents(List<Intent> intents);
+
+ /**
+ * Clone the ConfiguredOperation
+ *
+ * @return
+ */
+ Object clone() throws CloneNotSupportedException;
}
diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java index 5061ac6bac..5f4f42bb15 100644 --- a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java @@ -558,30 +558,45 @@ abstract class PolicyConfigurationUtil { private static void addInheritedOpConfOnBindings(OperationsConfigurator source,
OperationsConfigurator target,
PolicySetAttachPoint attachPoint) throws PolicyValidationException {
- boolean found = false;
-
+
List<ConfiguredOperation> additionalOperations = new ArrayList<ConfiguredOperation>();
for ( ConfiguredOperation sourceConfOp : source.getConfiguredOperations() ) {
- for ( ConfiguredOperation targetConfOp : target.getConfiguredOperations() ) {
- if ( sourceConfOp.getName().equals(targetConfOp.getName())) {
- List<Intent> prunedIntents = computeInheritableIntents(attachPoint.getType(),
- sourceConfOp.getRequiredIntents());
- PolicyComputationUtils.addInheritedIntents(prunedIntents,
- targetConfOp.getRequiredIntents());
-
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(sourceConfOp.getPolicySets(),
- attachPoint.getApplicablePolicySets());
- PolicyComputationUtils.addInheritedPolicySets(prunedPolicySets, targetConfOp.getPolicySets(), true);
+ boolean found = false;
+ ConfiguredOperation targetConfOp = null;
+ for ( ConfiguredOperation confOp : target.getConfiguredOperations() ) {
+ if ( sourceConfOp.getName().equals(confOp.getName())) {
+ targetConfOp = confOp;
found = true;
break;
}
- }
-
+ }
if ( !found ) {
- additionalOperations.add(sourceConfOp);
+ // Create a new target configured operation and copy everything from the source
+ // except the intents and policy sets (which must be computed below).
+ try {
+ targetConfOp = (ConfiguredOperation)sourceConfOp.clone();
+ targetConfOp.setRequiredIntents(new ArrayList<Intent>());
+ targetConfOp.setPolicySets(new ArrayList<PolicySet>());
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ }
+
+ List<Intent> prunedIntents =
+ computeInheritableIntents(attachPoint.getType(), sourceConfOp.getRequiredIntents());
+ PolicyComputationUtils.addInheritedIntents(prunedIntents, targetConfOp.getRequiredIntents());
+
+ List<PolicySet> prunedPolicySets =
+ computeInheritablePolicySets(sourceConfOp.getPolicySets(), attachPoint.getApplicablePolicySets());
+ PolicyComputationUtils.addInheritedPolicySets(prunedPolicySets, targetConfOp.getPolicySets(), true);
+
+ // If this is a new target configured operation, we will add it to the target list
+ // if it has required intents or policy sets.
+ if (!found && (!targetConfOp.getRequiredIntents().isEmpty() || !targetConfOp.getPolicySets().isEmpty())) {
+ additionalOperations.add(targetConfOp);
}
}
-
+
if ( !additionalOperations.isEmpty() ) {
target.getConfiguredOperations().addAll(additionalOperations);
}
diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java index 1373ce511b..6d8f986051 100644 --- a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java @@ -88,6 +88,9 @@ public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOpera public List<PolicySet> getApplicablePolicySets() {
return applicablePolicySets;
}
-
-
+
+ public Object clone() throws CloneNotSupportedException {
+ // Note this is a shallow copy.
+ return super.clone();
+ }
}
|