tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r918589 - /tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/
Date Wed, 03 Mar 2010 17:16:50 GMT
Author: lresende
Date: Wed Mar  3 17:16:49 2010
New Revision: 918589

URL: http://svn.apache.org/viewvc?rev=918589&view=rev
Log:
Updating/Cleaning up policyProvider code that creates intercetor to better utilize base class

Modified:
    tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
    tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
    tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java

Modified: tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java?rev=918589&r1=918588&r2=918589&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
Wed Mar  3 17:16:49 2010
@@ -24,8 +24,6 @@
 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 @@
  */
 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() {

Modified: tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java?rev=918589&r1=918588&r2=918589&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
Wed Mar  3 17:16:49 2010
@@ -25,8 +25,6 @@
 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 @@
  */
 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() {

Modified: tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java?rev=918589&r1=918588&r2=918589&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java
Wed Mar  3 17:16:49 2010
@@ -25,8 +25,6 @@
 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 @@
  */
 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() {



Mime
View raw message