camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r686171 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/strategy/ camel-core/src/main/java/org/apache/camel/component/log/ camel-core/src/main/java/org/apache/camel/processor/interceptor/ camel-core/src/...
Date Fri, 15 Aug 2008 08:11:02 GMT
Author: ningjiang
Date: Fri Aug 15 01:11:01 2008
New Revision: 686171

URL: http://svn.apache.org/viewvc?rev=686171&view=rev
Log:
CAMEL-770 Patch applied with thanks to Jonathan, also Fixed some CS errors of the file component

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
Fri Aug 15 01:11:01 2008
@@ -77,13 +77,13 @@
         unlockFile(endpoint, exchange, file);
     }
 
-	public void rollback(FileEndpoint endpoint, FileExchange exchange, File file) {
+    public void rollback(FileEndpoint endpoint, FileExchange exchange, File file) {
         try {
             unlockFile(endpoint, exchange, file);
         } catch (Exception e) {
             LOG.info("Unable to unlock file: " + file + ": " + e.getMessage(), e);
         }
-	}
+    }
 
     public boolean isLockFile() {
         return lockFile;
@@ -100,7 +100,7 @@
     public void setLockFileRenamer(FileRenamer lockFileRenamer) {
         this.lockFileRenamer = lockFileRenamer;
     }
-    
+
     protected void unlockFile(FileEndpoint endpoint, FileExchange exchange, File file) throws
Exception {
         if (isLockFile()) {
             Channel channel = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.fileChannel",
Channel.class);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
Fri Aug 15 01:11:01 2008
@@ -181,7 +181,7 @@
     }
 
     protected Object getBodyTypeAsString(Message message) {
-        String answer = ObjectHelper.classCanoicalName(message.getBody());
+        String answer = ObjectHelper.classCanonicalName(message.getBody());
         if (answer != null && answer.startsWith("java.lang.")) {
             return answer.substring(10);
         }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
Fri Aug 15 01:11:01 2008
@@ -120,7 +120,7 @@
     }
 
     protected Object getBodyTypeAsString(Message message) {
-        String answer = ObjectHelper.classCanoicalName(message.getBody());
+        String answer = ObjectHelper.classCanonicalName(message.getBody());
         if (answer != null && answer.startsWith("java.lang.")) {
             return answer.substring(10);
         }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Fri Aug 15 01:11:01 2008
@@ -113,7 +113,7 @@
     }
 
     /**
-     * A helper method for performing an ordered comparsion on the objects
+     * A helper method for performing an ordered comparison on the objects
      * handling nulls and objects which do not handle sorting gracefully
      */
     public static int compare(Object a, Object b) {
@@ -320,7 +320,23 @@
             return defaultValue;
         }
     }
-
+    
+    /**
+     * A helper method to access a boolean system property, catching any security
+     * exceptions
+     *
+     * @param name the name of the system property required
+     * @param defaultValue the default value to use if the property is not
+     *                available or a security exception prevents access
+     * @return the boolean representation of the system property value 
+     *         or the default value if the property is not available or 
+     *         security does not allow its access
+     */
+    public static boolean getSystemProperty(String name, Boolean defaultValue) {
+        String result = getSystemProperty(name, defaultValue.toString());
+        return Boolean.parseBoolean(result);
+    }    
+    
     /**
      * Returns the type name of the given type or null if the type variable is
      * null
@@ -337,9 +353,9 @@
     }
 
     /**
-     * Returns the canoical type name of the given value
+     * Returns the canonical type name of the given value
      */
-    public static String classCanoicalName(Object value) {
+    public static String classCanonicalName(Object value) {
         if (value != null) {
             return value.getClass().getCanonicalName();
         } else {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
Fri Aug 15 01:11:01 2008
@@ -26,8 +26,8 @@
 public class FileDeleteRouteTest extends FileRouteTest {
     @Override
     protected void setUp() throws Exception {
-    	targetdir = "target/test-delete-inbox";
-    	params = "?consumer.delay=1000&delete=true&consumer.recursive=true";
+        targetdir = "target/test-delete-inbox";
+        params = "?consumer.delay=1000&delete=true&consumer.recursive=true";
         super.setUp();
     }
 
@@ -41,10 +41,10 @@
         Thread.sleep(4000);
 
         result.assertIsSatisfied();
-        
-        for (String lockName: recorder.getLocks()) {
-        	File lock = new File(lockName);
-        	assertFalse(lock.exists());
+
+        for (String lockName : recorder.getLocks()) {
+            File lock = new File(lockName);
+            assertFalse(lock.exists());
         }
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
Fri Aug 15 01:11:01 2008
@@ -59,14 +59,14 @@
             }
         };
     }
-    
+
     public class LockRecorderProcessor implements Processor {
         private ConcurrentLinkedQueue<String> locks = new ConcurrentLinkedQueue<String>();
-        
+
         public ConcurrentLinkedQueue<String> getLocks() {
             return locks;
         }
-    	
+
         public void process(Exchange exchange) {
             locks.add(exchange.getProperty("org.apache.camel.file.lock.name", String.class));
         }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Fri Aug 15 01:11:01 2008
@@ -222,7 +222,7 @@
 
         if (event instanceof ContextRefreshedEvent) {
             // now lets start the CamelContext so that all its possible
-            // dependencies are initailized
+            // dependencies are initialized
             try {
                 LOG.debug("Starting the context now!");
                 getContext().start();

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=686171&r1=686170&r2=686171&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Fri Aug 15 01:11:01 2008
@@ -28,6 +28,7 @@
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spring.spi.ApplicationContextRegistry;
 import org.apache.camel.spring.spi.SpringInjector;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.BeansException;
@@ -56,6 +57,8 @@
     private static final transient Log LOG = LogFactory.getLog(SpringCamelContext.class);
     private ApplicationContext applicationContext;
     private EventEndpoint eventEndpoint;
+    private boolean shouldStartContext = 
+        ObjectHelper.getSystemProperty("shouldStartContext", Boolean.TRUE); // start context
by default 
 
     public SpringCamelContext() {
     }
@@ -83,7 +86,16 @@
     }
 
     public void afterPropertiesSet() throws Exception {
-        start();
+        maybeStart();
+    }
+
+    private void maybeStart() throws Exception {
+        if (getShouldStartContext()) {     
+            LOG.debug("Starting the CamelContext now that the ApplicationContext has started");
+            start();
+        } else {
+            LOG.debug("Not starting the CamelContext since shouldStartContext property was
true.");
+        }
     }
 
     public void destroy() throws Exception {
@@ -99,8 +111,7 @@
             // now lets start the CamelContext so that all its possible
             // dependencies are initialized
             try {
-                LOG.debug("Starting the CamelContext now that the ApplicationContext has
started");
-                start();
+                maybeStart();
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -146,12 +157,18 @@
 
     @Override
     protected void doStart() throws Exception {
-        super.doStart();
-        if (eventEndpoint == null) {
-            eventEndpoint = createEventEndpoint();
-        }
+        maybeDoStart();
     }
 
+    protected void maybeDoStart() throws Exception {
+        if (getShouldStartContext()) {
+            super.doStart();
+            if (eventEndpoint == null) {
+                eventEndpoint = createEventEndpoint();
+            }
+        }
+    }   
+    
     @Override
     protected Injector createInjector() {
         if (applicationContext instanceof ConfigurableApplicationContext) {
@@ -183,4 +200,12 @@
     protected Registry createRegistry() {
         return new ApplicationContextRegistry(getApplicationContext());
     }
+
+    public void setShouldStartContext(boolean shouldStartContext) {
+        this.shouldStartContext = shouldStartContext;
+    }
+
+    public boolean getShouldStartContext() {
+        return shouldStartContext;
+    }
 }



Mime
View raw message