001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.component.file;
018
019 /**
020 * Represents a strategy for marking that a remote file is processed.
021 */
022 public interface GenericFileProcessStrategy<T> {
023
024 /**
025 * Called when work is about to begin on this file. This method may attempt
026 * to acquire some file lock before returning true; returning false if the
027 * file lock could not be obtained so that the file should be ignored.
028 *
029 * @param operations ftp operations
030 * @param endpoint the endpoint
031 * @param exchange the exchange
032 * @param file the remote file
033 * @return true if the file can be processed (such as if a file lock could
034 * be obtained)
035 * @throws Exception can be thrown in case of errors
036 */
037 boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
038 GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
039
040 /**
041 * Releases any file locks and possibly deletes or moves the file after
042 * successful processing
043 *
044 * @param operations ftp operations
045 * @param endpoint the endpoint
046 * @param exchange the exchange
047 * @param file the remote file
048 * @throws Exception can be thrown in case of errors
049 */
050 void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
051 GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
052
053 /**
054 * Releases any file locks and possibly deletes or moves the file after
055 * unsuccessful processing
056 *
057 * @param operations ftp operations
058 * @param endpoint the endpoint
059 * @param exchange the exchange
060 * @param file the remote file
061 * @throws Exception can be thrown in case of errors
062 */
063 void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
064 GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
065
066 }