camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r737635 - in /camel/trunk/camel-core/src/main: java/org/apache/camel/component/file/ java/org/apache/camel/component/file/strategy/ resources/META-INF/services/org/apache/camel/component/
Date Mon, 26 Jan 2009 05:18:25 GMT
Author: davsclaus
Date: Mon Jan 26 05:18:23 2009
New Revision: 737635

URL: http://svn.apache.org/viewvc?rev=737635&view=rev
Log:
CAMEL-1241: java.io.File based component on the new generic VFS stuff (work in progress)

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
  (with props)
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
  (with props)
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
  (with props)
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
  (contents, props changed)
      - copied, changed from r737493, camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
  (contents, props changed)
      - copied, changed from r737485, camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategyFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExclusiveReadLockStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/newfile

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Mon Jan 26 05:18:23 2009
@@ -31,6 +31,7 @@
     private long lastModified;
     private T file;
     private Object body;
+    private GenericFileBinding<T> binding = new GenericFileDefaultBinding();
 
     @Override
     public GenericFile<T> clone() {
@@ -57,6 +58,7 @@
         result.setLastModified(source.getLastModified());
         result.setFile(source.getFile());
         result.setBody(source.getBody());
+        result.setBinding(source.getBinding());
         return result;
     }
 
@@ -136,17 +138,25 @@
     }
 
     public Object getBody() {
-        return body;
+        return binding.getBody(this);
     }
 
     public void setBody(Object os) {
-        this.body = os;
+        binding.setBody(this, os);
     }
 
     public String getParent() {
         return getAbsoluteFileName().substring(0, getAbsoluteFileName().lastIndexOf("/"));
     }
 
+    public GenericFileBinding<T> getBinding() {
+        return binding;
+    }
+
+    public void setBinding(GenericFileBinding<T> binding) {
+        this.binding = binding;
+    }
+
     @Override
     public String toString() {
         return getAbsoluteFileName();

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java?rev=737635&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
Mon Jan 26 05:18:23 2009
@@ -0,0 +1,27 @@
+/**
+ * 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;
+
+/**
+ * Binding between the generic file and the body content.
+ */
+public interface GenericFileBinding<T> {
+
+    public Object getBody(GenericFile<T> file);
+
+    public void setBody(GenericFile<T> file, Object body);
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java?rev=737635&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
Mon Jan 26 05:18:23 2009
@@ -0,0 +1,17 @@
+package org.apache.camel.component.file;
+
+/**
+ *
+ */
+public class GenericFileDefaultBinding implements GenericFileBinding {
+
+    private Object body;
+
+    public Object getBody(GenericFile genericFile) {
+        return body;
+    }
+
+    public void setBody(GenericFile genericFile, Object body) {
+        this.body = body;
+    }
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExclusiveReadLockStrategy.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExclusiveReadLockStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExclusiveReadLockStrategy.java
Mon Jan 26 05:18:23 2009
@@ -28,15 +28,34 @@
  * rename the file.</li>
  * </ul>
  */
-public interface GenericFileExclusiveReadLockStrategy {
+public interface GenericFileExclusiveReadLockStrategy<T> {
 
     /**
      * Acquires exclusive read lock to the file.
      *
      * @param operations generic file operations
-     * @param file       the remote file
+     * @param file       the file
      * @return <tt>true</tt> if read lock was acquired. If <tt>false</tt>
Camel
      *         will skip the file and try it on the next poll
      */
-    boolean acquireExclusiveReadLock(GenericFileOperations operations, GenericFile file);
+    boolean acquireExclusiveReadLock(GenericFileOperations<T> operations, GenericFile<T>
file);
+
+    /**
+     * Releases the exclusive read lock granted by the <tt>acquireExclusiveReadLock</tt>
method.
+     *
+     * @param operations generic file operations
+     * @param file       the file
+     */
+    void releaseExclusiveReadLock(GenericFileOperations<T> operations, GenericFile<T>
file);
+
+    /**
+     * Sets an optional timeout period.
+     * <p/>
+     * If the readlock could not be granted within the timeperiod then the wait is stopped
and the
+     * <tt>acquireExclusiveReadLock</tt> method returns <tt>false</tt>.
+     *
+     * @param timeout period in millis
+     */
+    void setTimeout(long timeout);
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
Mon Jan 26 05:18:23 2009
@@ -105,7 +105,7 @@
         if (lastPathIndex != -1) {
             String directory = fileName.substring(0, lastPathIndex);
             if (!operations.buildDirectory(directory)) {
-                log.warn("Can not build directory: " + directory + " (could be because of
denied permissions)");
+                log.debug("Can not build directory: " + directory + " (could be because of
denied permissions)");
             }
         }
         boolean success = operations.storeFile(fileName, exchange);
@@ -152,6 +152,7 @@
                 answer = baseDir + name;
             } else {
                 // use a generated filename if no name provided
+                // TODO: Consider to require end user to always provide a filename instead
of generating a new name
                 answer = baseDir + getGenericFileEndpoint().getGeneratedFileName(exchange.getIn());
             }
         } else {

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java?rev=737635&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
Mon Jan 26 05:18:23 2009
@@ -0,0 +1,23 @@
+package org.apache.camel.component.file;
+
+import java.io.File;
+
+/**
+ *
+ */
+public class NewFileBinding implements GenericFileBinding<File> {
+
+    private File body;
+
+    public Object getBody(GenericFile<File> file) {
+        // TODO: comment why I do this
+        // TODO: consider storing object and only create new if changed
+        // TODO: Consider callback from changeName to binding so we change
+        // change it at that time
+        return new File(file.getAbsoluteFileName());
+    }
+
+    public void setBody(GenericFile<File> GenericFile, Object body) {
+        // noop
+    }
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileConsumer.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileConsumer.java
Mon Jan 26 05:18:23 2009
@@ -81,6 +81,8 @@
 
     protected GenericFile<File> asGenericFile(File file) {
         GenericFile<File> answer = new GenericFile<File>();
+        // use file specific binding
+        answer.setBinding(new NewFileBinding());
         answer.setFile(file);
         answer.setFileLength(file.length());
         answer.setFileName(file.getName());

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategyFactory.java
Mon Jan 26 05:18:23 2009
@@ -107,6 +107,7 @@
                 if (timeout != null) {
                     readLockStrategy.setTimeout(timeout);
                 }
+                return readLockStrategy;
             } else if ("rename".equals(readLock)) {
                 FileRenameExclusiveReadLockStrategy readLockStrategy = new FileRenameExclusiveReadLockStrategy();
                 Long timeout = (Long) params.get("readLockTimeout");

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileProcessStrategySupport.java
Mon Jan 26 05:18:23 2009
@@ -37,6 +37,9 @@
  * @version $Revision$
  */
 public abstract class FileProcessStrategySupport implements FileProcessStrategy {
+
+    // TODO: Should be suppored by NewFile
+
     private static final transient Log LOG = LogFactory.getLog(FileProcessStrategySupport.class);
     private boolean lockFile;
     private FileRenamer lockFileRenamer;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
Mon Jan 26 05:18:23 2009
@@ -40,11 +40,15 @@
     }
 
     public void commit(GenericFileOperations operations, GenericFileEndpoint endpoint, GenericFileExchange
exchange, GenericFile file) throws Exception {
-        // nothing
+        if (exclusiveReadLockStrategy != null) {
+            exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file);
+        }
     }
 
     public void rollback(GenericFileOperations operations, GenericFileEndpoint endpoint,
GenericFileExchange exchange, GenericFile file) {
-        // nothing
+        if (exclusiveReadLockStrategy != null) {
+            exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file);
+        }
     }
 
     public GenericFileExclusiveReadLockStrategy getExclusiveReadLockStrategy() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
Mon Jan 26 05:18:23 2009
@@ -73,6 +73,10 @@
         return true;
     }
 
+    public void releaseExclusiveReadLock(GenericFileOperations genericFileOperations, GenericFile
genericFile) {
+        // noop
+    }
+
     private void sleep() {
         LOG.trace("Exclusive read lock not granted. Sleeping for 1000 millis.");
         try {

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
(from r737493, camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java&r1=737493&r2=737635&rev=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
Mon Jan 26 05:18:23 2009
@@ -23,7 +23,9 @@
 import java.nio.channels.FileLock;
 
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.file.ExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileOperations;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,22 +35,22 @@
  * After granting the read lock it is released, we just want to make sure that when we start
  * consuming the file its not currently in progress of being written by third party.
  */
-public class FileLockExclusiveReadLockStrategy implements ExclusiveReadLockStrategy {
-    private static final transient Log LOG = LogFactory.getLog(FileLockExclusiveReadLockStrategy.class);
+public class NewFileLockExclusiveReadLockStrategy implements GenericFileExclusiveReadLockStrategy<File>
{
+    private static final transient Log LOG = LogFactory.getLog(NewFileLockExclusiveReadLockStrategy.class);
     private long timeout;
 
-    // TODO: We shall keep this with the GenericFileXX to support FileLock for java.io.File
-    
-    public boolean acquireExclusiveReadLock(File file) {
+    public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations,
GenericFile<File> file) {
+        File target = new File(file.getAbsoluteFileName());
+
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Waiting for exclusive read lock to file: " + file);
+            LOG.trace("Waiting for exclusive read lock to file: " + target);
         }
 
         FileChannel channel = null;
         try {
             // try to acquire rw lock on the file before we can consume it
-            channel = new RandomAccessFile(file, "rw").getChannel();
-    
+            channel = new RandomAccessFile(target, "rw").getChannel();
+
             long start = System.currentTimeMillis();
             boolean exclusive = false;
 
@@ -57,14 +59,14 @@
                 if (timeout > 0) {
                     long delta = System.currentTimeMillis() - start;
                     if (delta > timeout) {
-                        LOG.debug("Could not acquire read lock within " + timeout + " millis.
Will skip the file: " + file);
+                        LOG.debug("Could not acquire read lock within " + timeout + " millis.
Will skip the file: " + target);
                         // we could not get the lock within the timeout period, so return
false
                         return false;
                     }
                 }
 
                 // get the lock using either try lock or not depending on if we are using
timeout or not
-                FileLock lock = null; 
+                FileLock lock = null;
                 try {
                     lock = timeout > 0 ? channel.tryLock() : channel.lock();
                 } catch (IllegalStateException ex) {
@@ -73,7 +75,7 @@
                 }
                 if (lock != null) {
                     if (LOG.isTraceEnabled()) {
-                        LOG.trace("Acquired exclusive read lock: " + lock + " to file: "
+ file);
+                        LOG.trace("Acquired exclusive read lock: " + lock + " to file: "
+ target);
                     }
                     // just release it now we dont want to hold it during the rest of the
processing
                     lock.release();
@@ -95,12 +97,16 @@
             sleep();
         } finally {
             // must close channel
-            ObjectHelper.close(channel, "while acquiring exclusive read lock for file: "
+ file, LOG);
+            ObjectHelper.close(channel, "while acquiring exclusive read lock for file: "
+ target, LOG);
         }
 
         return true;
     }
-    
+
+    public void releaseExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations,
GenericFile<File> fileGenericFile) {
+        // TODO: release read lock from above, as we should hold id during processing
+    }
+
     private void sleep() {
         LOG.trace("Exclusive read lock not granted. Sleeping for 1000 millis.");
         try {
@@ -118,7 +124,7 @@
      * Sets an optional timeout period.
      * <p/>
      * If the readlock could not be granted within the timeperiod then the wait is stopped
and the
-     * {@link #acquireExclusiveReadLock(java.io.File)} returns <tt>false</tt>.
+     * acquireReadLock returns <tt>false</tt>.
      *
      * @param timeout period in millis
      */
@@ -126,4 +132,4 @@
         this.timeout = timeout;
     }
 
-}
+ }
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
(from r737485, camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategyFactory.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategyFactory.java&r1=737485&r2=737635&rev=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategyFactory.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
Mon Jan 26 05:18:23 2009
@@ -23,9 +23,9 @@
 import org.apache.camel.component.file.GenericFileProcessStrategy;
 import org.apache.camel.util.ObjectHelper;
 
-public final class GenericFileProcessStrategyFactory {
+public final class NewFileProcessStrategyFactory {
 
-    private GenericFileProcessStrategyFactory() {
+    private NewFileProcessStrategyFactory() {
     }
 
     public static GenericFileProcessStrategy createGenericFileProcessStrategy(Map<String,
Object> params) {
@@ -93,16 +93,27 @@
         if (ObjectHelper.isNotEmpty(readLock)) {
             if ("none".equals(readLock) || "false".equals(readLock)) {
                 return null;
+            } else if ("fileLock".equals(readLock)) {
+                GenericFileExclusiveReadLockStrategy readLockStrategy = new NewFileLockExclusiveReadLockStrategy();
+                Long timeout = (Long) params.get("readLockTimeout");
+                if (timeout != null) {
+                    readLockStrategy.setTimeout(timeout);
+                }
+                return readLockStrategy;
             } else if ("rename".equals(readLock)) {
-                GenericFileRenameExclusiveReadLockStrategy readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy();
+                GenericFileExclusiveReadLockStrategy readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy();
                 Long timeout = (Long) params.get("readLockTimeout");
                 if (timeout != null) {
                     readLockStrategy.setTimeout(timeout);
                 }
                 return readLockStrategy;
+            } else if ("markerFile".equals(readLock)) {
+                // TODO: marker file that is the stuff with the .camel file
+                GenericFileExclusiveReadLockStrategy readLockStrategy = new NewMarkerFileExclusiveReadLockStrategy();
+                return readLockStrategy;
             }
         }
 
         return null;
     }
-}
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileProcessStrategyFactory.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java?rev=737635&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
Mon Jan 26 05:18:23 2009
@@ -0,0 +1,27 @@
+package org.apache.camel.component.file.strategy;
+
+import java.io.File;
+
+import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileOperations;
+import org.apache.camel.component.file.GenericFile;
+
+/**
+ *
+ */
+public class NewMarkerFileExclusiveReadLockStrategy implements GenericFileExclusiveReadLockStrategy<File>
{
+
+    public boolean acquireExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations,
GenericFile<File> fileGenericFile) {
+        // create the .camelFile
+        return false;
+    }
+
+    public void releaseExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations,
GenericFile<File> fileGenericFile) {
+        // delete the .camelFile
+    }
+
+    public void setTimeout(long timeout) {
+        // noop
+    }
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/newfile
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/newfile?rev=737635&r1=737634&r2=737635&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/newfile
(original)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/newfile
Mon Jan 26 05:18:23 2009
@@ -16,4 +16,4 @@
 #
 
 class=org.apache.camel.component.file.NewFileComponent
-strategy.factory.class=org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory
\ No newline at end of file
+strategy.factory.class=org.apache.camel.component.file.strategy.NewFileProcessStrategyFactory
\ No newline at end of file



Mime
View raw message