diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache')
3 files changed, 6 insertions, 43 deletions
diff --git a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java index 490e043c32..a77af71e3f 100644 --- a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java +++ b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java @@ -24,8 +24,6 @@ import java.util.List; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.transaction.TransactionPolicy; import org.apache.tuscany.sca.provider.BasePolicyProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -35,27 +33,15 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; */ public class TransactionImplementationPolicyProvider extends BasePolicyProvider<TransactionPolicy> { private TransactionManagerHelper helper; - private List<PolicySet> policySets; - private RuntimeComponent component; public TransactionImplementationPolicyProvider(TransactionManagerHelper helper, RuntimeComponent component) { super(TransactionPolicy.class, component); this.helper = helper; - this.policySets = component.getPolicySets(); } public PhasedInterceptor createInterceptor(Operation operation) { - /* TODO - 2.x better way of doing this in 2.x */ - for (PolicySet policySet : policySets) { - for (PolicyExpression p : policySet.getPolicies()) { - if (p.getPolicy() instanceof TransactionPolicy) { - TransactionInterceptor interceptor = new TransactionInterceptor(helper, false, null, (TransactionPolicy)p.getPolicy(), getPhase()); - return interceptor; - } - } - } - - return null; + List<TransactionPolicy> policies = findPolicies(); + return policies.isEmpty() ? null : new TransactionInterceptor(helper, true, null, policies.get(0), getPhase()); } public String getPhase() { diff --git a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java index a982a2ceed..1dc0feb0b5 100644 --- a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java +++ b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java @@ -25,8 +25,6 @@ import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.transaction.TransactionPolicy; import org.apache.tuscany.sca.provider.BasePolicyProvider; @@ -35,25 +33,15 @@ import org.apache.tuscany.sca.provider.BasePolicyProvider; */ public class TransactionReferencePolicyProvider extends BasePolicyProvider<TransactionPolicy> { private TransactionManagerHelper helper; - private List<PolicySet> policySets; public TransactionReferencePolicyProvider(TransactionManagerHelper helper, EndpointReference epr) { super(TransactionPolicy.class, epr); this.helper = helper; - this.policySets = epr.getPolicySets(); } public PhasedInterceptor createInterceptor(Operation operation) { - /* TODO - 2.x better way of doing this in 2.x */ - for (PolicySet policySet : policySets) { - for (PolicyExpression p : policySet.getPolicies()) { - if (p.getPolicy() instanceof TransactionPolicy) { - TransactionInterceptor interceptor = new TransactionInterceptor(helper, true, (TransactionPolicy)p.getPolicy(), null,getPhase()); - return interceptor; - } - } - } - return null; + List<TransactionPolicy> policies = findPolicies(); + return policies.isEmpty() ? null : new TransactionInterceptor(helper, true, policies.get(0), null, getPhase()); } public String getPhase() { diff --git a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java index 37f3034718..c2a7c1039b 100644 --- a/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java +++ b/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java @@ -25,8 +25,6 @@ import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.transaction.TransactionPolicy; import org.apache.tuscany.sca.provider.BasePolicyProvider; @@ -35,24 +33,15 @@ import org.apache.tuscany.sca.provider.BasePolicyProvider; */ public class TransactionServicePolicyProvider extends BasePolicyProvider<TransactionPolicy> { private TransactionManagerHelper helper; - private List<PolicySet> policySets; public TransactionServicePolicyProvider(TransactionManagerHelper helper, Endpoint ep) { super(TransactionPolicy.class, ep); this.helper = helper; - this.policySets = ep.getPolicySets(); } public PhasedInterceptor createInterceptor(Operation operation) { - for (PolicySet policySet : policySets) { - for (PolicyExpression p : policySet.getPolicies()) { - if (p.getPolicy() instanceof TransactionPolicy) { - TransactionInterceptor interceptor = new TransactionInterceptor(helper, true, (TransactionPolicy)p.getPolicy(), null, getPhase()); - return interceptor; - } - } - } - return null; + List<TransactionPolicy> policies = findPolicies(); + return policies.isEmpty() ? null : new TransactionInterceptor(helper, true, policies.get(0), null, getPhase()); } public String getPhase() { |