camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-6476: Introducing StreamCachingStrategy SPI to make it easier to configure and allow 3rd party to plugin custom strategies. Work in progress.
Date Thu, 18 Jul 2013 10:02:18 GMT
Updated Branches:
  refs/heads/master 739a589e3 -> 25612791c


CAMEL-6476: Introducing StreamCachingStrategy SPI to make it easier to configure and allow
3rd party to plugin custom strategies. Work in progress.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/25612791
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/25612791
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/25612791

Branch: refs/heads/master
Commit: 25612791c9c3833f9ec4b2ce8a1fc33416ec8092
Parents: 739a589
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jul 18 11:59:33 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jul 18 12:02:04 2013 +0200

----------------------------------------------------------------------
 .../blueprint/CamelContextFactoryBean.java      |  11 ++
 .../xml/AbstractCamelContextFactoryBean.java    |  87 +++++++++++-----
 .../camel/core/xml/CamelJMXAgentDefinition.java |  26 ++---
 .../CamelStreamCachingStrategyDefinition.java   | 101 +++++++++++++++++++
 .../org/apache/camel/core/xml/jaxb.index        |   1 +
 .../camel/spring/CamelContextFactoryBean.java   |  11 ++
 .../spring/handler/CamelNamespaceHandler.java   |   5 +-
 .../SpringStreamCachingStrategyTest.java        |  42 ++++++++
 .../SpringStreamCachingStrategyTest.xml         |  36 +++++++
 .../BlueprintStreamCachingStrategyTest.java     |  39 +++++++
 .../BlueprintStreamCachingStrategyTest.xml      |  36 +++++++
 11 files changed, 354 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 8818c85..027cc83 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -40,6 +40,7 @@ import org.apache.camel.core.xml.AbstractCamelContextFactoryBean;
 import org.apache.camel.core.xml.CamelJMXAgentDefinition;
 import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
 import org.apache.camel.core.xml.CamelServiceExporterDefinition;
+import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
 import org.apache.camel.model.ContextScanDefinition;
 import org.apache.camel.model.InterceptDefinition;
 import org.apache.camel.model.InterceptFromDefinition;
@@ -121,6 +122,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
     private ContextScanDefinition contextScan;
     @XmlElement(name = "jmxAgent", type = CamelJMXAgentDefinition.class, required = false)
     private CamelJMXAgentDefinition camelJMXAgent;
+    @XmlElement(name = "streamCaching", type = CamelStreamCachingStrategyDefinition.class,
required = false)
+    private CamelStreamCachingStrategyDefinition camelStreamCachingStrategy;
     @XmlElements({
         @XmlElement(name = "template", type = CamelProducerTemplateFactoryBean.class, required
= false),
         @XmlElement(name = "consumerTemplate", type = CamelConsumerTemplateFactoryBean.class,
required = false),
@@ -507,6 +510,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
         this.camelJMXAgent = camelJMXAgent;
     }
 
+    public CamelStreamCachingStrategyDefinition getCamelStreamCachingStrategy() {
+        return camelStreamCachingStrategy;
+    }
+
+    public void setCamelStreamCachingStrategy(CamelStreamCachingStrategyDefinition camelStreamCachingStrategy)
{
+        this.camelStreamCachingStrategy = camelStreamCachingStrategy;
+    }
+
     public List<?> getBeans() {
         return beans;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 1454233..15b1c2d 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -138,7 +138,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         // set the package scan resolver as soon as possible
         PackageScanClassResolver packageResolver = getBeanForType(PackageScanClassResolver.class);
         if (packageResolver != null) {
-            LOG.info("Using custom PackageScanClassResolver: " + packageResolver);
+            LOG.info("Using custom PackageScanClassResolver: {}", packageResolver);
             getContext().setPackageScanClassResolver(packageResolver);
         }
 
@@ -147,7 +147,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
             getContext().setProperties(getProperties().asMap());
         }
         // and enable lazy loading of type converters if applicable
-        initLazyLoadTypeConverteres();
+        initLazyLoadTypeConverters();
 
         setupCustomServices();
 
@@ -167,42 +167,42 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
             if (formatter != null) {
                 tracer.setFormatter(formatter);
             }
-            LOG.info("Using custom Tracer: " + tracer);
+            LOG.info("Using custom Tracer: {}", tracer);
             getContext().addInterceptStrategy(tracer);
         }
         BacklogTracer backlogTracer = getBeanForType(BacklogTracer.class);
         if (backlogTracer != null) {
-            LOG.info("Using custom BacklogTracer: " + backlogTracer);
+            LOG.info("Using custom BacklogTracer: {}", backlogTracer);
             getContext().addInterceptStrategy(backlogTracer);
         }
         HandleFault handleFault = getBeanForType(HandleFault.class);
         if (handleFault != null) {
-            LOG.info("Using custom HandleFault: " + handleFault);
+            LOG.info("Using custom HandleFault: {}", handleFault);
             getContext().addInterceptStrategy(handleFault);
         }
         Delayer delayer = getBeanForType(Delayer.class);
         if (delayer != null) {
-            LOG.info("Using custom Delayer: " + delayer);
+            LOG.info("Using custom Delayer: {}", delayer);
             getContext().addInterceptStrategy(delayer);
         }
         InflightRepository inflightRepository = getBeanForType(InflightRepository.class);
         if (inflightRepository != null) {
-            LOG.info("Using custom InflightRepository: " + inflightRepository);
+            LOG.info("Using custom InflightRepository: {}", inflightRepository);
             getContext().setInflightRepository(inflightRepository);
         }
         ManagementStrategy managementStrategy = getBeanForType(ManagementStrategy.class);
         if (managementStrategy != null) {
-            LOG.info("Using custom ManagementStrategy: " + managementStrategy);
+            LOG.info("Using custom ManagementStrategy: {}", managementStrategy);
             getContext().setManagementStrategy(managementStrategy);
         }
         ManagementNamingStrategy managementNamingStrategy = getBeanForType(ManagementNamingStrategy.class);
         if (managementNamingStrategy != null) {
-            LOG.info("Using custom ManagementNamingStrategy: " + managementNamingStrategy);
+            LOG.info("Using custom ManagementNamingStrategy: {}", managementNamingStrategy);
             getContext().getManagementStrategy().setManagementNamingStrategy(managementNamingStrategy);
         }
         EventFactory eventFactory = getBeanForType(EventFactory.class);
         if (eventFactory != null) {
-            LOG.info("Using custom EventFactory: " + eventFactory);
+            LOG.info("Using custom EventFactory: {}", eventFactory);
             getContext().getManagementStrategy().setEventFactory(eventFactory);
         }
         // set the event notifier strategies if defined
@@ -212,7 +212,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 EventNotifier notifier = entry.getValue();
                 // do not add if already added, for instance a tracer that is also an InterceptStrategy
class
                 if (!getContext().getManagementStrategy().getEventNotifiers().contains(notifier))
{
-                    LOG.info("Using custom EventNotifier with id: " + entry.getKey() + "
and implementation: " + notifier);
+                    LOG.info("Using custom EventNotifier with id: {} and implementation:
{}", entry.getKey(), notifier);
                     getContext().getManagementStrategy().addEventNotifier(notifier);
                 }
             }
@@ -222,7 +222,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (endpointStrategies != null && !endpointStrategies.isEmpty()) {
             for (Entry<String, EndpointStrategy> entry : endpointStrategies.entrySet())
{
                 EndpointStrategy strategy = entry.getValue();
-                LOG.info("Using custom EndpointStrategy with id: " + entry.getKey() + " and
implementation: " + strategy);
+                LOG.info("Using custom EndpointStrategy with id: {} and implementation: {}",
entry.getKey(), strategy);
                 getContext().addRegisterEndpointCallback(strategy);
             }
         }
@@ -239,7 +239,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 InterceptStrategy strategy = entry.getValue();
                 // do not add if already added, for instance a tracer that is also an InterceptStrategy
class
                 if (!getContext().getInterceptStrategies().contains(strategy)) {
-                    LOG.info("Using custom InterceptStrategy with id: " + entry.getKey()
+ " and implementation: " + strategy);
+                    LOG.info("Using custom InterceptStrategy with id: {} and implementation:
{}", entry.getKey(), strategy);
                     getContext().addInterceptStrategy(strategy);
                 }
             }
@@ -251,7 +251,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 LifecycleStrategy strategy = entry.getValue();
                 // do not add if already added, for instance a tracer that is also an InterceptStrategy
class
                 if (!getContext().getLifecycleStrategies().contains(strategy)) {
-                    LOG.info("Using custom LifecycleStrategy with id: " + entry.getKey()
+ " and implementation: " + strategy);
+                    LOG.info("Using custom LifecycleStrategy with id: {} and implementation:
{}", entry.getKey(), strategy);
                     getContext().addLifecycleStrategy(strategy);
                 }
             }
@@ -266,6 +266,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         // init camel context
         initCamelContext(getContext());
 
+        // init stream caching strategy
+        initStreamCachingStrategy();
+
         // must init route refs before we prepare the routes below
         initRouteRefs();
 
@@ -305,7 +308,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
     protected abstract void initCustomRegistry(T context);
     
     @SuppressWarnings("deprecation")
-    protected void initLazyLoadTypeConverteres() {
+    protected void initLazyLoadTypeConverters() {
         if (getLazyLoadTypeConverters() != null) {
             getContext().setLazyLoadTypeConverters(getLazyLoadTypeConverters());
         } else if (System.getProperty(LAZY_LOAD_TYPE_CONVERTERS) != null) {
@@ -337,7 +340,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
             // no need to add a lifecycle strategy as we do not need one as JMX is disabled
             getContext().setManagementStrategy(new DefaultManagementStrategy());
         } else if (camelJMXAgent != null) {
-            LOG.info("JMXAgent enabled: " + camelJMXAgent);
+            LOG.info("JMXAgent enabled: {}", camelJMXAgent);
             DefaultManagementAgent agent = new DefaultManagementAgent(getContext());
             agent.setConnectorPort(CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getConnectorPort()));
             agent.setCreateConnector(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getCreateConnector()));
@@ -368,6 +371,34 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         }
     }
 
+    protected void initStreamCachingStrategy() throws Exception {
+        CamelStreamCachingStrategyDefinition streamCaching = getCamelStreamCachingStrategy();
+        if (streamCaching == null) {
+            return;
+        }
+
+        Boolean enabled = CamelContextHelper.parseBoolean(getContext(), streamCaching.getEnabled());
+        if (enabled != null) {
+            getContext().getStreamCachingStrategy().setEnabled(enabled);
+        }
+        String spoolDirectory = CamelContextHelper.parseText(getContext(), streamCaching.getSpoolDirectory());
+        if (spoolDirectory != null) {
+            getContext().getStreamCachingStrategy().setSpoolDirectory(spoolDirectory);
+        }
+        Long spoolThreshold = CamelContextHelper.parseLong(getContext(), streamCaching.getSpoolThreshold());
+        if (spoolThreshold != null) {
+            getContext().getStreamCachingStrategy().setSpoolThreshold(spoolThreshold);
+        }
+        String spoolChiper = CamelContextHelper.parseText(getContext(), streamCaching.getSpoolChiper());
+        if (spoolChiper != null) {
+            getContext().getStreamCachingStrategy().setSpoolChiper(spoolChiper);
+        }
+        Boolean remove = CamelContextHelper.parseBoolean(getContext(), streamCaching.getRemoveSpoolDirectoryWhenStopping());
+        if (remove != null) {
+            getContext().getStreamCachingStrategy().setRemoveSpoolDirectoryWhenStopping(remove);
+        }
+    }
+
     protected void initPropertyPlaceholder() throws Exception {
         if (getCamelPropertyPlaceholder() != null) {
             CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder();
@@ -497,6 +528,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
     public abstract CamelJMXAgentDefinition getCamelJMXAgent();
 
+    public abstract CamelStreamCachingStrategyDefinition getCamelStreamCachingStrategy();
+
     public abstract List<RouteBuilderDefinition> getBuilderRefs();
 
     public abstract List<RouteContextRefDefinition> getRouteRefs();
@@ -584,7 +617,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 ThreadPoolProfile profile = entry.getValue();
                 // do not add if already added, for instance a tracer that is also an InterceptStrategy
class
                 if (profile.isDefaultProfile()) {
-                    LOG.info("Using custom default ThreadPoolProfile with id: " + entry.getKey()
+ " and implementation: " + profile);
+                    LOG.info("Using custom default ThreadPoolProfile with id: {} and implementation:
{}", entry.getKey(), profile);
                     context.getExecutorServiceManager().setDefaultThreadPoolProfile(profile);
                     defaultIds.add(entry.getKey());
                 } else {
@@ -597,7 +630,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (getThreadPoolProfiles() != null && !getThreadPoolProfiles().isEmpty())
{
             for (ThreadPoolProfileDefinition definition : getThreadPoolProfiles()) {
                 if (definition.isDefaultProfile()) {
-                    LOG.info("Using custom default ThreadPoolProfile with id: " + definition.getId()
+ " and implementation: " + definition);
+                    LOG.info("Using custom default ThreadPoolProfile with id: {} and implementation:
{}", definition.getId(), definition);
                     context.getExecutorServiceManager().setDefaultThreadPoolProfile(asThreadPoolProfile(context,
definition));
                     defaultIds.add(definition.getId());
                 } else {
@@ -752,47 +785,47 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
     private void setupCustomServices() {
         ClassResolver classResolver = getBeanForType(ClassResolver.class);
         if (classResolver != null) {
-            LOG.info("Using custom ClassResolver: " + classResolver);
+            LOG.info("Using custom ClassResolver: {}", classResolver);
             getContext().setClassResolver(classResolver);
         }
         FactoryFinderResolver factoryFinderResolver = getBeanForType(FactoryFinderResolver.class);
         if (factoryFinderResolver != null) {
-            LOG.info("Using custom FactoryFinderResolver: " + factoryFinderResolver);
+            LOG.info("Using custom FactoryFinderResolver: {}", factoryFinderResolver);
             getContext().setFactoryFinderResolver(factoryFinderResolver);
         }
         ExecutorServiceManager executorServiceStrategy = getBeanForType(ExecutorServiceManager.class);
         if (executorServiceStrategy != null) {
-            LOG.info("Using custom ExecutorServiceStrategy: " + executorServiceStrategy);
+            LOG.info("Using custom ExecutorServiceStrategy: {}", executorServiceStrategy);
             getContext().setExecutorServiceManager(executorServiceStrategy);
         }
         ThreadPoolFactory threadPoolFactory = getBeanForType(ThreadPoolFactory.class);
         if (threadPoolFactory != null) {
-            LOG.info("Using custom ThreadPoolFactory: " + threadPoolFactory);
+            LOG.info("Using custom ThreadPoolFactory: {}", threadPoolFactory);
             getContext().getExecutorServiceManager().setThreadPoolFactory(threadPoolFactory);
         }
         ProcessorFactory processorFactory = getBeanForType(ProcessorFactory.class);
         if (processorFactory != null) {
-            LOG.info("Using custom ProcessorFactory: " + processorFactory);
+            LOG.info("Using custom ProcessorFactory: {}", processorFactory);
             getContext().setProcessorFactory(processorFactory);
         }
         Debugger debugger = getBeanForType(Debugger.class);
         if (debugger != null) {
-            LOG.info("Using custom Debugger: " + debugger);
+            LOG.info("Using custom Debugger: {}", debugger);
             getContext().setDebugger(debugger);
         }
         UuidGenerator uuidGenerator = getBeanForType(UuidGenerator.class);
         if (uuidGenerator != null) {
-            LOG.info("Using custom UuidGenerator: " + uuidGenerator);
+            LOG.info("Using custom UuidGenerator: {}", uuidGenerator);
             getContext().setUuidGenerator(uuidGenerator);
         }
         NodeIdFactory nodeIdFactory = getBeanForType(NodeIdFactory.class);
         if (nodeIdFactory != null) {
-            LOG.info("Using custom NodeIdFactory: " + nodeIdFactory);
+            LOG.info("Using custom NodeIdFactory: {}", nodeIdFactory);
             getContext().setNodeIdFactory(nodeIdFactory);
         }
         StreamCachingStrategy streamCachingStrategy = getBeanForType(StreamCachingStrategy.class);
         if (streamCachingStrategy != null) {
-            LOG.info("Using custom StreamCachingStrategy: " + streamCachingStrategy);
+            LOG.info("Using custom StreamCachingStrategy: {}", streamCachingStrategy);
             getContext().setStreamCachingStrategy(streamCachingStrategy);
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
index 72ebbb2..bde0ec6 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
@@ -36,79 +36,79 @@ public class CamelJMXAgentDefinition extends IdentifiedType {
     /**
      * Disable JMI (default false)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String disabled = "false";
 
     /**
      * Only register processor if a custom id was defined for it.
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String onlyRegisterProcessorWithCustomId = "false";
 
     /**
      * RMI connector registry port (default 1099)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String registryPort;
 
     /**
      * RMI connector server port (default -1 not used)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String connectorPort;
 
     /**
      * MBean server default domain name (default org.apache.camel)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String mbeanServerDefaultDomain;
 
     /**
      * MBean object domain name (default org.apache.camel)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String mbeanObjectDomainName;
 
     /**
      * JMX Service URL path (default /jmxrmi)
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String serviceUrlPath;
 
     /**
      * A flag that indicates whether the agent should be created
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String createConnector = "true";
 
     /**
      * A flag that indicates whether the platform mbean server should be used
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String usePlatformMBeanServer = "true";
 
     /**
      * A flag that indicates whether to register mbeans always
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String registerAlways;
 
     /**
      * A flag that indicates whether to register mbeans when starting new routes
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String registerNewRoutes = "true";
 
     /**
      * Level of granularity for performance statistics enabled
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private ManagementStatisticsLevel statisticsLevel = ManagementStatisticsLevel.All;
 
     /**
      * A flag that indicates whether Load statistics is enabled
      */
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String loadStatisticsEnabled;
 
     public String getDisabled() {

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelStreamCachingStrategyDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelStreamCachingStrategyDefinition.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelStreamCachingStrategyDefinition.java
new file mode 100644
index 0000000..4a526d5
--- /dev/null
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelStreamCachingStrategyDefinition.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.core.xml;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.model.IdentifiedType;
+
+/**
+ * The JAXB type class for the configuration of stream caching
+ *
+ * @version 
+ */
+@XmlRootElement(name = "streamCaching")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CamelStreamCachingStrategyDefinition extends IdentifiedType {
+
+    @XmlAttribute
+    private String enabled;
+
+    @XmlAttribute
+    private String spoolDirectory;
+
+    @XmlAttribute
+    private String spoolThreshold;
+
+    @XmlAttribute
+    private String spoolChiper;
+
+    @XmlAttribute
+    private String bufferSize;
+
+    @XmlAttribute
+    private String removeSpoolDirectoryWhenStopping;
+
+    public String getEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(String enabled) {
+        this.enabled = enabled;
+    }
+
+    public String getSpoolDirectory() {
+        return spoolDirectory;
+    }
+
+    public void setSpoolDirectory(String spoolDirectory) {
+        this.spoolDirectory = spoolDirectory;
+    }
+
+    public String getSpoolThreshold() {
+        return spoolThreshold;
+    }
+
+    public void setSpoolThreshold(String spoolThreshold) {
+        this.spoolThreshold = spoolThreshold;
+    }
+
+    public String getSpoolChiper() {
+        return spoolChiper;
+    }
+
+    public void setSpoolChiper(String spoolChiper) {
+        this.spoolChiper = spoolChiper;
+    }
+
+    public String getBufferSize() {
+        return bufferSize;
+    }
+
+    public void setBufferSize(String bufferSize) {
+        this.bufferSize = bufferSize;
+    }
+
+    public String getRemoveSpoolDirectoryWhenStopping() {
+        return removeSpoolDirectoryWhenStopping;
+    }
+
+    public void setRemoveSpoolDirectoryWhenStopping(String removeSpoolDirectoryWhenStopping)
{
+        this.removeSpoolDirectoryWhenStopping = removeSpoolDirectoryWhenStopping;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-core-xml/src/main/resources/org/apache/camel/core/xml/jaxb.index
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/resources/org/apache/camel/core/xml/jaxb.index
b/components/camel-core-xml/src/main/resources/org/apache/camel/core/xml/jaxb.index
index 63fff2a..c2ef941 100644
--- a/components/camel-core-xml/src/main/resources/org/apache/camel/core/xml/jaxb.index
+++ b/components/camel-core-xml/src/main/resources/org/apache/camel/core/xml/jaxb.index
@@ -18,3 +18,4 @@ CamelJMXAgentDefinition
 CamelPropertyPlaceholderDefinition
 CamelProxyFactoryDefinition
 CamelServiceExporterDefinition
+CamelStreamCachingStrategyDefinition

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index 9fb2a91..b25b329 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -38,6 +38,7 @@ import org.apache.camel.core.xml.CamelJMXAgentDefinition;
 import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
 import org.apache.camel.core.xml.CamelProxyFactoryDefinition;
 import org.apache.camel.core.xml.CamelServiceExporterDefinition;
+import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
 import org.apache.camel.model.ContextScanDefinition;
 import org.apache.camel.model.InterceptDefinition;
 import org.apache.camel.model.InterceptFromDefinition;
@@ -126,6 +127,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
     private PackageScanDefinition packageScan;
     @XmlElement(name = "contextScan", type = ContextScanDefinition.class, required = false)
     private ContextScanDefinition contextScan;
+    @XmlElement(name = "streamCaching", type = CamelStreamCachingStrategyDefinition.class,
required = false)
+    private CamelStreamCachingStrategyDefinition camelStreamCachingStrategy;
     @XmlElement(name = "jmxAgent", type = CamelJMXAgentDefinition.class, required = false)
     private CamelJMXAgentDefinition camelJMXAgent;
     @XmlElements({
@@ -457,6 +460,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
         this.camelPropertyPlaceholder = camelPropertyPlaceholder;
     }
 
+    public CamelStreamCachingStrategyDefinition getCamelStreamCachingStrategy() {
+        return camelStreamCachingStrategy;
+    }
+
+    public void setCamelStreamCachingStrategy(CamelStreamCachingStrategyDefinition camelStreamCachingStrategy)
{
+        this.camelStreamCachingStrategy = camelStreamCachingStrategy;
+    }
+
     public void setCamelJMXAgent(CamelJMXAgentDefinition agent) {
         camelJMXAgent = agent;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
index f050d5d..837c365 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
@@ -34,6 +34,7 @@ import org.w3c.dom.NodeList;
 import org.apache.camel.builder.xml.Namespaces;
 import org.apache.camel.core.xml.CamelJMXAgentDefinition;
 import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
+import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
 import org.apache.camel.impl.DefaultCamelContextNameStrategy;
 import org.apache.camel.model.FromDefinition;
 import org.apache.camel.model.SendDefinition;
@@ -113,8 +114,9 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport {
         addBeanDefinitionParser("threadPool", CamelThreadPoolFactoryBean.class, true, true);
         addBeanDefinitionParser("redeliveryPolicyProfile", CamelRedeliveryPolicyFactoryBean.class,
true, true);
 
-        // jmx agent and property placeholder cannot be used outside of the camel context
+        // jmx agent, stream caching, and property placeholder cannot be used outside of
the camel context
         addBeanDefinitionParser("jmxAgent", CamelJMXAgentDefinition.class, false, false);
+        addBeanDefinitionParser("streamCaching", CamelStreamCachingStrategyDefinition.class,
false, false);
         addBeanDefinitionParser("propertyPlaceholder", CamelPropertyPlaceholderDefinition.class,
false, false);
 
         // errorhandler could be the sub element of camelContext or defined outside camelContext
@@ -327,6 +329,7 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport {
                 }
                 builder.addPropertyValue("camelPropertyPlaceholder", factoryBean.getCamelPropertyPlaceholder());
                 builder.addPropertyValue("camelJMXAgent", factoryBean.getCamelJMXAgent());
+                builder.addPropertyValue("camelStreamCachingStrategy", factoryBean.getCamelStreamCachingStrategy());
                 builder.addPropertyValue("threadPoolProfiles", factoryBean.getThreadPoolProfiles());
                 // add any depends-on
                 addDependsOn(factoryBean, builder);

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
new file mode 100644
index 0000000..d452a81
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringStreamCachingStrategyTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.xml");
+    }
+
+    @Test
+    public void testStreamCaching() {
+        assertTrue(context.getStreamCachingStrategy().isEnabled());
+        assertEquals("target/cachedir", context.getStreamCachingStrategy().getSpoolDirectory().toString());
+        assertEquals(Integer.valueOf(4096).intValue(), context.getStreamCachingStrategy().getBufferSize());
+        assertEquals(Long.valueOf(8192).longValue(), context.getStreamCachingStrategy().getSpoolThreshold());
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.xml
new file mode 100644
index 0000000..9d03a65
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringStreamCachingStrategyTest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext streamCache="true" xmlns="http://camel.apache.org/schema/spring">
+
+    <streamCaching id="myCacheConfig" bufferSize="2048" spoolDirectory="target/cachedir"
spoolThreshold="8192"/>
+
+    <route>
+      <from uri="direct:c"/>
+      <to uri="mock:c"/>
+    </route>
+
+  </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.java
new file mode 100644
index 0000000..2a37974
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.blueprint;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class BlueprintStreamCachingStrategyTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.xml";
+    }
+
+    @Test
+    public void testStreamCaching() {
+        assertTrue(context.getStreamCachingStrategy().isEnabled());
+        assertEquals("target/cachedir", context.getStreamCachingStrategy().getSpoolDirectory().toString());
+        assertEquals(Integer.valueOf(4096).intValue(), context.getStreamCachingStrategy().getBufferSize());
+        assertEquals(Long.valueOf(8192).longValue(), context.getStreamCachingStrategy().getSpoolThreshold());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/25612791/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.xml
new file mode 100644
index 0000000..7a7caa6
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/BlueprintStreamCachingStrategyTest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<!-- START SNIPPET: example -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <camelContext streamCache="true" xmlns="http://camel.apache.org/schema/blueprint">
+
+    <streamCaching id="myCacheConfig" bufferSize="2048" spoolDirectory="target/cachedir"
spoolThreshold="8192"/>
+
+    <route>
+      <from uri="direct:c"/>
+      <to uri="mock:c"/>
+    </route>
+
+  </camelContext>
+
+</blueprint>
+<!-- END SNIPPET: example -->


Mime
View raw message