Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 8843c9911 -> ee232060f
  refs/heads/camel-2.17.x cee716bc6 -> cf5adb653
  refs/heads/master 42ac1d046 -> cd31f6955


CAMEL-10114: camel-spring-boot - Allow to configure stream caching using 
application.properties


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

Branch: refs/heads/master
Commit: 0e7a6b6fe397b8da3a2317580879d15601d5130d
Parents: 42ac1d0
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Jul 1 17:21:47 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Jul 1 17:21:47 2016 +0200

----------------------------------------------------------------------
 .../spring/boot/CamelAutoConfiguration.java     |  29 +++-
 .../boot/CamelConfigurationProperties.java      | 158 ++++++++++++++++++-
 2 files changed, 184 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0e7a6b6f/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index bf3058b..8b4e771 100644
--- 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -45,6 +45,7 @@ import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.RoutePolicyFactory;
 import org.apache.camel.spi.RuntimeEndpointRegistry;
 import org.apache.camel.spi.ShutdownStrategy;
+import org.apache.camel.spi.StreamCachingStrategy;
 import org.apache.camel.spi.ThreadPoolProfile;
 import org.apache.camel.spi.UnitOfWorkFactory;
 import org.apache.camel.spring.CamelBeanPostProcessor;
@@ -104,7 +105,33 @@ public class CamelAutoConfiguration {
             
camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "" + 
config.getLogDebugMaxChars());
         }
 
-        camelContext.setStreamCaching(config.isStreamCaching());
+        // stream caching
+        camelContext.setStreamCaching(config.isStreamCachingEnabled());
+        
camelContext.getStreamCachingStrategy().setAnySpoolRules(config.isStreamCachingAnySpoolRules());
+        
camelContext.getStreamCachingStrategy().setBufferSize(config.getStreamCachingBufferSize());
+        
camelContext.getStreamCachingStrategy().setRemoveSpoolDirectoryWhenStopping(config.isStreamCachingRemoveSpoolDirectoryWhenStopping());
+        
camelContext.getStreamCachingStrategy().setSpoolChiper(config.getStreamCachingSpoolChiper());
+        if (config.getStreamCachingSpoolDirectory() != null) {
+            
camelContext.getStreamCachingStrategy().setSpoolDirectory(config.getStreamCachingSpoolDirectory());
+        }
+        if (config.getStreamCachingSpoolThreshold() != 0) {
+            
camelContext.getStreamCachingStrategy().setSpoolThreshold(config.getStreamCachingSpoolThreshold());
+        }
+        if (config.getStreamCachingSpoolUsedHeapMemoryLimit() != null) {
+            StreamCachingStrategy.SpoolUsedHeapMemoryLimit limit;
+            if 
("Committed".equalsIgnoreCase(config.getStreamCachingSpoolUsedHeapMemoryLimit()))
 {
+                limit = 
StreamCachingStrategy.SpoolUsedHeapMemoryLimit.Committed;
+            } else if 
("Max".equalsIgnoreCase(config.getStreamCachingSpoolUsedHeapMemoryLimit())) {
+                limit = StreamCachingStrategy.SpoolUsedHeapMemoryLimit.Max;
+            } else {
+                throw new IllegalArgumentException("Invalid option " + 
config.getStreamCachingSpoolUsedHeapMemoryLimit() + " must either be Committed 
or Max");
+            }
+            
camelContext.getStreamCachingStrategy().setSpoolUsedHeapMemoryLimit(limit);
+        }
+        if (config.getStreamCachingSpoolUsedHeapMemoryThreshold() != 0) {
+            
camelContext.getStreamCachingStrategy().setSpoolUsedHeapMemoryThreshold(config.getStreamCachingSpoolUsedHeapMemoryThreshold());
+        }
+
         camelContext.setTracing(config.isTracing());
         camelContext.setMessageHistory(config.isMessageHistory());
         
camelContext.setLogExhaustedMessageBody(config.isLogExhaustedMessageBody());

http://git-wip-us.apache.org/repos/asf/camel/blob/0e7a6b6f/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
index e88b6e3..42c1628 100644
--- 
a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
+++ 
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -92,10 +92,82 @@ public class CamelConfigurationProperties {
      * Sets whether stream caching is enabled or not.
      *
      * Default is false.
+     *
+     * @deprecated use {@link #streamCachingEnabled}
      */
+    @Deprecated
     private boolean streamCaching;
 
     /**
+     * Sets whether stream caching is enabled or not.
+     *
+     * Default is false.
+     */
+    private boolean streamCachingEnabled;
+
+    /**
+     * Sets the stream caching spool (temporary) directory to use for overflow 
and spooling to disk.
+     * <p/>
+     * If no spool directory has been explicit configured, then a temporary 
directory
+     * is created in the <tt>java.io.tmpdir</tt> directory.
+     */
+    private String streamCachingSpoolDirectory;
+
+    /**
+     * Sets a stream caching chiper name to use when spooling to disk to write 
with encryption.
+     * <p/>
+     * By default the data is not encrypted.
+     */
+    private String streamCachingSpoolChiper;
+
+    /**
+     * Stream caching threshold in bytes when overflow to disk is activated.
+     * <p/>
+     * The default threshold is {@link 
org.apache.camel.StreamCache#DEFAULT_SPOOL_THRESHOLD} bytes (eg 128kb).
+     * Use <tt>-1</tt> to disable overflow to disk.
+     */
+    private long streamCachingSpoolThreshold;
+
+    /**
+     * Sets a percentage (1-99) of used heap memory threshold to activate 
stream caching spooling to disk.
+     */
+    private int streamCachingSpoolUsedHeapMemoryThreshold;
+
+    /**
+     * Sets what the upper bounds should be when 
streamCachingSpoolUsedHeapMemoryThreshold is in use.
+     */
+    private String streamCachingSpoolUsedHeapMemoryLimit;
+
+    /**
+     * Sets whether if just any of the {@link 
org.apache.camel.spi.StreamCachingStrategy.SpoolRule} rules
+     * returns <tt>true</tt> then shouldSpoolCache(long) returns <tt>true</tt>.
+     * If this option is <tt>false</tt>, then <b>all</b> the {@link 
org.apache.camel.spi.StreamCachingStrategy.SpoolRule} must
+     * return <tt>true</tt>.
+     * <p/>
+     * The default value is <tt>false</tt> which means that all the rules must 
return <tt>true</tt>.
+     */
+    private boolean streamCachingAnySpoolRules;
+
+    /**
+     * Sets the stream caching buffer size to use when allocating in-memory 
buffers used for in-memory stream caches.
+     * <p/>
+     * The default size is {@link 
org.apache.camel.util.IOHelper#DEFAULT_BUFFER_SIZE}
+     */
+    private int streamCachingBufferSize;
+
+    /**
+     * Whether to remove stream caching temporary directory when stopping.
+     * <p/>
+     * This option is default <tt>true</tt>
+     */
+    private boolean streamCachingRemoveSpoolDirectoryWhenStopping = true;
+
+    /**
+     * Sets whether stream caching statistics is enabled.
+     */
+    private boolean streamCachingStatisticsEnabled;
+
+    /**
      * Sets whether tracing is enabled or not.
      *
      * Default is false.
@@ -247,12 +319,94 @@ public class CamelConfigurationProperties {
         this.logDebugMaxChars = logDebugMaxChars;
     }
 
+    @Deprecated
     public boolean isStreamCaching() {
-        return streamCaching;
+        return streamCachingEnabled;
     }
 
+    @Deprecated
     public void setStreamCaching(boolean streamCaching) {
-        this.streamCaching = streamCaching;
+        this.streamCachingEnabled = streamCaching;
+    }
+
+    public boolean isStreamCachingEnabled() {
+        return streamCachingEnabled;
+    }
+
+    public void setStreamCachingEnabled(boolean streamCachingEnabled) {
+        this.streamCachingEnabled = streamCachingEnabled;
+    }
+
+    public String getStreamCachingSpoolDirectory() {
+        return streamCachingSpoolDirectory;
+    }
+
+    public void setStreamCachingSpoolDirectory(String 
streamCachingSpoolDirectory) {
+        this.streamCachingSpoolDirectory = streamCachingSpoolDirectory;
+    }
+
+    public String getStreamCachingSpoolChiper() {
+        return streamCachingSpoolChiper;
+    }
+
+    public void setStreamCachingSpoolChiper(String streamCachingSpoolChiper) {
+        this.streamCachingSpoolChiper = streamCachingSpoolChiper;
+    }
+
+    public long getStreamCachingSpoolThreshold() {
+        return streamCachingSpoolThreshold;
+    }
+
+    public void setStreamCachingSpoolThreshold(long 
streamCachingSpoolThreshold) {
+        this.streamCachingSpoolThreshold = streamCachingSpoolThreshold;
+    }
+
+    public int getStreamCachingSpoolUsedHeapMemoryThreshold() {
+        return streamCachingSpoolUsedHeapMemoryThreshold;
+    }
+
+    public void setStreamCachingSpoolUsedHeapMemoryThreshold(int 
streamCachingSpoolUsedHeapMemoryThreshold) {
+        this.streamCachingSpoolUsedHeapMemoryThreshold = 
streamCachingSpoolUsedHeapMemoryThreshold;
+    }
+
+    public String getStreamCachingSpoolUsedHeapMemoryLimit() {
+        return streamCachingSpoolUsedHeapMemoryLimit;
+    }
+
+    public void setStreamCachingSpoolUsedHeapMemoryLimit(String 
streamCachingSpoolUsedHeapMemoryLimit) {
+        this.streamCachingSpoolUsedHeapMemoryLimit = 
streamCachingSpoolUsedHeapMemoryLimit;
+    }
+
+    public boolean isStreamCachingAnySpoolRules() {
+        return streamCachingAnySpoolRules;
+    }
+
+    public void setStreamCachingAnySpoolRules(boolean 
streamCachingAnySpoolRules) {
+        this.streamCachingAnySpoolRules = streamCachingAnySpoolRules;
+    }
+
+    public int getStreamCachingBufferSize() {
+        return streamCachingBufferSize;
+    }
+
+    public void setStreamCachingBufferSize(int streamCachingBufferSize) {
+        this.streamCachingBufferSize = streamCachingBufferSize;
+    }
+
+    public boolean isStreamCachingRemoveSpoolDirectoryWhenStopping() {
+        return streamCachingRemoveSpoolDirectoryWhenStopping;
+    }
+
+    public void setStreamCachingRemoveSpoolDirectoryWhenStopping(boolean 
streamCachingRemoveSpoolDirectoryWhenStopping) {
+        this.streamCachingRemoveSpoolDirectoryWhenStopping = 
streamCachingRemoveSpoolDirectoryWhenStopping;
+    }
+
+    public boolean isStreamCachingStatisticsEnabled() {
+        return streamCachingStatisticsEnabled;
+    }
+
+    public void setStreamCachingStatisticsEnabled(boolean 
streamCachingStatisticsEnabled) {
+        this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled;
     }
 
     public boolean isTracing() {

Reply via email to