camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r961439 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/spi/ camel-core/src/test/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processor/async/ compo...
Date Wed, 07 Jul 2010 17:46:51 GMT
Author: hadrian
Date: Wed Jul  7 17:46:50 2010
New Revision: 961439

URL: http://svn.apache.org/viewvc?rev=961439&view=rev
Log:
CAMEL-2914. Move beforeWrap() to Policy

Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/DefinitionAwarePolicy.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefinitionPolicyPerProcessorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerProcessorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointPolicyTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
    camel/trunk/components/camel-spring-security/src/main/java/org/apache/camel/component/spring/security/SpringSecurityAuthorizationPolicy.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java Wed
Jul  7 17:46:50 2010
@@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlTran
 
 import org.apache.camel.Processor;
 import org.apache.camel.processor.WrapProcessor;
-import org.apache.camel.spi.DefinitionAwarePolicy;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.TransactedPolicy;
@@ -125,10 +124,7 @@ public class PolicyDefinition extends Ou
         ObjectHelper.notNull(policy, "policy", this);
 
         // before wrap
-        if (policy instanceof DefinitionAwarePolicy) {
-            DefinitionAwarePolicy aware = (DefinitionAwarePolicy) policy;
-            aware.beforeWrap(routeContext, this);
-        }
+        policy.beforeWrap(routeContext, this);
 
         // create processor after the before wrap
         Processor childProcessor = this.createChildProcessor(routeContext, true);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
Wed Jul  7 17:46:50 2010
@@ -18,6 +18,7 @@ package org.apache.camel.model;
 
 import java.lang.reflect.Method;
 import java.util.Map;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -27,7 +28,6 @@ import javax.xml.bind.annotation.XmlTran
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.processor.WrapProcessor;
-import org.apache.camel.spi.DefinitionAwarePolicy;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.TransactedPolicy;
@@ -135,10 +135,7 @@ public class TransactedDefinition extend
         ObjectHelper.notNull(policy, "policy", this);
 
         // before wrap
-        if (policy instanceof DefinitionAwarePolicy) {
-            DefinitionAwarePolicy aware = (DefinitionAwarePolicy) policy;
-            aware.beforeWrap(routeContext, this);
-        }
+        policy.beforeWrap(routeContext, this);
 
         // create processor after the before wrap
         Processor childProcessor = this.createChildProcessor(routeContext, true);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java Wed Jul  7 17:46:50
2010
@@ -17,6 +17,7 @@
 package org.apache.camel.spi;
 
 import org.apache.camel.Processor;
+import org.apache.camel.model.ProcessorDefinition;
 
 /**
  * A strategy capable of applying interceptors to a processor
@@ -37,6 +38,17 @@ import org.apache.camel.Processor;
 public interface Policy {
 
     /**
+     * Hook invoked before the wrap.
+     * <p/>
+     * This allows you to do any custom logic before the processor is wrapped. For example
to
+     * manipulate the {@link org.apache.camel.model.ProcessorDefinition definiton}
+     *
+     * @param routeContext   the route context
+     * @param definition     the processor definition
+     */
+    void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition);
+
+    /**
      * Wraps any applicable interceptors around the given processor.
      *
      * @param routeContext the route context

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefinitionPolicyPerProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefinitionPolicyPerProcessorTest.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefinitionPolicyPerProcessorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefinitionPolicyPerProcessorTest.java
Wed Jul  7 17:46:50 2010
@@ -24,7 +24,7 @@ import org.apache.camel.impl.JndiRegistr
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.SetBodyDefinition;
 import org.apache.camel.model.language.ConstantExpression;
-import org.apache.camel.spi.DefinitionAwarePolicy;
+import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 
 /**
@@ -65,7 +65,7 @@ public class DefinitionPolicyPerProcesso
         };
     }
 
-    public static class MyPolicy implements DefinitionAwarePolicy {
+    public static class MyPolicy implements Policy {
 
         private final String name;
         private int invoked;
@@ -92,6 +92,5 @@ public class DefinitionPolicyPerProcesso
                 }
             };
         }
-
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerProcessorTest.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerProcessorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerProcessorTest.java
Wed Jul  7 17:46:50 2010
@@ -21,6 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 
@@ -85,6 +86,11 @@ public class PolicyPerProcessorTest exte
             this.name = name;
         }
 
+        public void beforeWrap(RouteContext routeContext,
+                ProcessorDefinition<?> definition) {
+            // no need to modify the route
+        }
+
         public Processor wrap(RouteContext routeContext, final Processor processor) {
             return new Processor() {
                 public void process(Exchange exchange) throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerRouteTest.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerRouteTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PolicyPerRouteTest.java
Wed Jul  7 17:46:50 2010
@@ -21,6 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 
@@ -85,6 +86,11 @@ public class PolicyPerRouteTest extends 
             this.name = name;
         }
 
+        public void beforeWrap(RouteContext routeContext,
+                ProcessorDefinition<?> definition) {
+            // no need to modify the route
+        }
+
         public Processor wrap(RouteContext routeContext, final Processor processor) {
             return new Processor() {
                 public void process(Exchange exchange) throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointPolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointPolicyTest.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointPolicyTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointPolicyTest.java
Wed Jul  7 17:46:50 2010
@@ -24,6 +24,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.AsyncProcessorHelper;
@@ -109,6 +110,11 @@ public class AsyncEndpointPolicyTest ext
             this.name = name;
         }
 
+        public void beforeWrap(RouteContext routeContext,
+                ProcessorDefinition<?> definition) {
+            // no need to modify the route
+        }
+
         public Processor wrap(RouteContext routeContext, final Processor processor) {
             return new AsyncProcessor() {
                 public boolean process(final Exchange exchange, final AsyncCallback callback)
{

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/TransactedJmsRouteTest.java
Wed Jul  7 17:46:50 2010
@@ -27,6 +27,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.processor.DelegateProcessor;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
@@ -68,6 +69,9 @@ public class TransactedJmsRouteTest exte
                 SpringTransactionPolicy requirenew = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRES_NEW",
TransactionTemplate.class));
 
                 Policy rollback = new Policy() {
+                    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?>
definition) {
+                    }
+
                     public Processor wrap(RouteContext routeContext, Processor processor)
{
                         return new DelegateProcessor(processor) {
                             @Override
@@ -85,6 +89,9 @@ public class TransactedJmsRouteTest exte
                 };
 
                 Policy catchRollback = new Policy() {
+                    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?>
definition) {
+                    }
+
                     public Processor wrap(RouteContext routeContext, Processor processor)
{
                         return new DelegateProcessor(processor) {
                             @Override
@@ -305,5 +312,4 @@ public class TransactedJmsRouteTest exte
 
         assertIsSatisfied(mockEndpointA, mockEndpointB);
     }
-
 }

Modified: camel/trunk/components/camel-spring-security/src/main/java/org/apache/camel/component/spring/security/SpringSecurityAuthorizationPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-security/src/main/java/org/apache/camel/component/spring/security/SpringSecurityAuthorizationPolicy.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-security/src/main/java/org/apache/camel/component/spring/security/SpringSecurityAuthorizationPolicy.java
(original)
+++ camel/trunk/components/camel-spring-security/src/main/java/org/apache/camel/component/spring/security/SpringSecurityAuthorizationPolicy.java
Wed Jul  7 17:46:50 2010
@@ -23,6 +23,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.model.IdentifiedType;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.processor.DelegateProcessor;
 import org.apache.camel.spi.AuthorizationPolicy;
 import org.apache.camel.spi.RouteContext;
@@ -53,6 +54,9 @@ public class SpringSecurityAuthorization
     private boolean alwaysReauthenticate;
     private boolean useThreadSecurityContext = true;
 
+    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition)
{
+    }
+
     public Processor wrap(RouteContext routeContext, Processor processor) {
         // wrap the processor with authorizeDelegateProcessor
         return new AuthorizeDelegateProcess(processor);
@@ -206,5 +210,4 @@ public class SpringSecurityAuthorization
     public void setAccessDecisionManager(AccessDecisionManager accessDecisionManager) {
         this.accessDecisionManager = accessDecisionManager;
     }
-
 }

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java?rev=961439&r1=961438&r2=961439&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
Wed Jul  7 17:46:50 2010
@@ -19,6 +19,7 @@ package org.apache.camel.spring.spi;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderRef;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.TransactedPolicy;
 import org.apache.camel.util.ObjectHelper;
@@ -52,6 +53,9 @@ public class SpringTransactionPolicy imp
         this.transactionManager = transactionManager;
     }
 
+    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition)
{
+    }
+
     public Processor wrap(RouteContext routeContext, Processor processor) {
         TransactionErrorHandler answer;
 



Mime
View raw message