You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2007/12/17 19:58:21 UTC

svn commit: r604966 - in /activemq/camel/trunk: ./ camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/component/file/strategy/ camel-core/src/main/java/org/apac...

Author: gnodet
Date: Mon Dec 17 10:58:20 2007
New Revision: 604966

URL: http://svn.apache.org/viewvc?rev=604966&view=rev
Log:
CAMEL-262: maven-remote-resources-plugin, patch provided by Christian Schneider

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProcessStrategy.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
Removed:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategy.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    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/impl/DefaultComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java Mon Dec 17 10:58:20 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.camel;
 
+import java.util.Map;
+
 /**
  * An <a href="http://activemq.apache.org/camel/endpoint.html">endpoint</a>
  * implements the <a
@@ -100,4 +102,6 @@
      * @throws Exception if the pull consumer could not be created
      */
     PollingConsumer<E> createPollingConsumer() throws Exception;
+    
+    void configureProperties(Map options);
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java Mon Dec 17 10:58:20 2007
@@ -19,7 +19,6 @@
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.component.file.strategy.FileProcessStrategy;
 import org.apache.camel.impl.ScheduledPollConsumer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Mon Dec 17 10:58:20 2007
@@ -16,23 +16,21 @@
  */
 package org.apache.camel.component.file;
 
+import java.io.File;
+
 import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
 import org.apache.camel.component.file.strategy.DefaultFileRenamer;
-import org.apache.camel.component.file.strategy.DeleteFileProcessStrategy;
-import org.apache.camel.component.file.strategy.FileProcessStrategy;
+import org.apache.camel.component.file.strategy.FileProcessStrategyFactory;
 import org.apache.camel.component.file.strategy.FileProcessStrategySupport;
 import org.apache.camel.component.file.strategy.NoOpFileProcessStrategy;
-import org.apache.camel.component.file.strategy.RenameFileProcessStrategy;
 import org.apache.camel.impl.ScheduledPollEndpoint;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.File;
-
 /**
  * A <a href="http://activemq.apache.org/camel/file.html">File Endpoint</a> for
  * working with file systems
@@ -285,18 +283,6 @@
      * A strategy method to lazily create the file strategy
      */
     protected FileProcessStrategy createFileStrategy() {
-        if (isNoop()) {
-            return new NoOpFileProcessStrategy();
-        } else if (moveNamePostfix != null || moveNamePrefix != null) {
-            if (isDelete()) {
-                throw new IllegalArgumentException(
-                                                   "You cannot set the deleteFiles property and a moveFilenamePostfix or moveFilenamePrefix");
-            }
-            return new RenameFileProcessStrategy(isLock(), moveNamePrefix, moveNamePostfix);
-        } else if (isDelete()) {
-            return new DeleteFileProcessStrategy(isLock());
-        } else {
-            return new RenameFileProcessStrategy(isLock());
-        }
+    	return FileProcessStrategyFactory.createFileProcessStrategy(isNoop(), isDelete(), isLock(), moveNamePrefix, moveNamePostfix);
     }
 }

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProcessStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProcessStrategy.java?rev=604966&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProcessStrategy.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileProcessStrategy.java Mon Dec 17 10:58:20 2007
@@ -0,0 +1,41 @@
+/**
+ * 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.component.file;
+
+import java.io.File;
+
+import org.apache.camel.Endpoint;
+
+/**
+ * Represents a strategy for marking that a file is processed.
+ *
+ * @version $Revision: 1.1 $
+ */
+public interface FileProcessStrategy {
+    /**
+     * Called when work is about to begin on this file. This method may attempt to acquire some file lock before
+     * returning true; returning false if the file lock could not be obtained so that the file should be ignored.
+     *
+     * @return true if the file can be processed (such as if a file lock could be obtained)
+     */
+    boolean begin(Endpoint endpoint, FileExchange exchange, File file) throws Exception;
+
+    /**
+     * Releases any file locks and possibly deletes or moves the file
+     */
+    void commit(Endpoint endpoint, FileExchange exchange, File file) throws Exception;
+}

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java?rev=604966&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java Mon Dec 17 10:58:20 2007
@@ -0,0 +1,40 @@
+/**
+ * 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.component.file.strategy;
+
+import org.apache.camel.component.file.FileProcessStrategy;
+
+public class FileProcessStrategyFactory {
+	/**
+     * A strategy method to lazily create the file strategy
+     */
+    public static FileProcessStrategy createFileProcessStrategy(boolean isNoop, boolean isDelete, boolean isLock, String moveNamePrefix, String moveNamePostfix) {
+        if (isNoop) {
+            return new NoOpFileProcessStrategy();
+        } else if (moveNamePostfix != null || moveNamePrefix != null) {
+            if (isDelete) {
+                throw new IllegalArgumentException(
+                                                   "You cannot set the deleteFiles property and a moveFilenamePostfix or moveFilenamePrefix");
+            }
+            return new RenameFileProcessStrategy(isLock, moveNamePrefix, moveNamePostfix);
+        } else if (isDelete) {
+            return new DeleteFileProcessStrategy(isLock);
+        } else {
+            return new RenameFileProcessStrategy(isLock);
+        }
+    }
+}

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=604966&r1=604965&r2=604966&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 Mon Dec 17 10:58:20 2007
@@ -22,8 +22,9 @@
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 
-import org.apache.camel.component.file.FileEndpoint;
+import org.apache.camel.Endpoint;
 import org.apache.camel.component.file.FileExchange;
+import org.apache.camel.component.file.FileProcessStrategy;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -51,7 +52,7 @@
         this.lockFileRenamer = lockFileRenamer;
     }
 
-    public boolean begin(FileEndpoint endpoint, FileExchange exchange, File file) throws Exception {
+    public boolean begin(Endpoint endpoint, FileExchange exchange, File file) throws Exception {
         if (isLockFile()) {
             File newFile = lockFileRenamer.renameFile(file);
             String lockFileName = newFile.getAbsolutePath();
@@ -72,7 +73,7 @@
         return true;
     }
 
-    public void commit(FileEndpoint endpoint, FileExchange exchange, File file) throws Exception {
+    public void commit(Endpoint endpoint, FileExchange exchange, File file) throws Exception {
         if (isLockFile()) {
             Channel channel = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.fileChannel", Channel.class);
             String lockfile = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.file.lock.name", String.class);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java Mon Dec 17 10:58:20 2007
@@ -72,12 +72,9 @@
             return null;
         }
         if (parameters != null) {
-            if (endpoint instanceof ScheduledPollEndpoint) {
-                ScheduledPollEndpoint scheduledPollEndpoint = (ScheduledPollEndpoint)endpoint;
-                scheduledPollEndpoint.configureProperties(parameters);
-            }
+            endpoint.configureProperties(parameters);
             if (useIntrospectionOnEndpoint()) {
-            setProperties(endpoint, parameters);
+                setProperties(endpoint, parameters);
             }
         }
         return endpoint;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java Mon Dec 17 10:58:20 2007
@@ -26,6 +26,7 @@
 
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
@@ -169,4 +170,7 @@
     protected ScheduledThreadPoolExecutor createExecutorService() {
         return new ScheduledThreadPoolExecutor(10);
     }
+
+	public void configureProperties(Map options) {
+	}
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java Mon Dec 17 10:58:20 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.Map;
+
 import org.apache.camel.*;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -87,7 +89,10 @@
     public PollingConsumer createPollingConsumer() throws Exception {
         throw new UnsupportedOperationException();
     }
-    
+
+    public void configureProperties(Map options) {
+    }
+
     public Resource getWsdl() {
         return wsdl;
     }

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=604966&r1=604965&r2=604966&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Mon Dec 17 10:58:20 2007
@@ -49,7 +49,7 @@
     <slf4j-version>1.3.0</slf4j-version>
     <snapshot-repo-url>scpexe://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</snapshot-repo-url>
     <commons-io-version>1.3.1</commons-io-version>
-    <felix-version>1.0.0</felix-version>
+    <felix-version>1.1.0-SNAPSHOT</felix-version>
     <!-- OSGi bundles properties -->
     <camel.osgi.import.pkg>!javax.xml.bind.annotation.adapters,*</camel.osgi.import.pkg>
     <camel.osgi.private.pkg>!*</camel.osgi.private.pkg>