You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2009/06/30 07:11:49 UTC
svn commit: r789563 - in
/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file: ./
strategy/
Author: hadrian
Date: Tue Jun 30 05:11:49 2009
New Revision: 789563
URL: http://svn.apache.org/viewvc?rev=789563&view=rev
Log:
CAMEL-1078. More changes in preparation of removal of GenericFileExchange.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
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/GenericFileEndpoint.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProcessStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileExpressionRenamer.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/GenericFileRenameProcessStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenamer.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java Tue Jun 30 05:11:49 2009
@@ -83,7 +83,9 @@
public GenericFileExchange<File> createExchange(GenericFile<File> file) {
GenericFileExchange<File> exchange = new GenericFileExchange<File>(this);
- exchange.setGenericFile(file);
+ if (file != null) {
+ file.bindToExchange(exchange);
+ }
return exchange;
}
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=789563&r1=789562&r2=789563&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 Tue Jun 30 05:11:49 2009
@@ -83,6 +83,16 @@
}
/**
+ * Bind this GenericFile to an Exchange
+ */
+ public void bindToExchange(Exchange exchange) {
+ exchange.setProperty(FileComponent.FILE_EXCHANGE_FILE, this);
+ GenericFileMessage<T> in = new GenericFileMessage<T>(this);
+ exchange.setIn(in);
+ populateHeaders(in);
+ }
+
+ /**
* Populates the {@link GenericFileMessage} relevant headers
*
* @param message the message to populate with headers
@@ -307,5 +317,4 @@
public String toString() {
return "GenericFile[" + (absolute ? absoluteFilePath : relativeFilePath) + "]";
}
-
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java Tue Jun 30 05:11:49 2009
@@ -487,5 +487,4 @@
Language language = getCamelContext().resolveLanguage("file");
return language.createExpression(expression);
}
-
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java Tue Jun 30 05:11:49 2009
@@ -31,22 +31,15 @@
public GenericFileExchange(DefaultExchange parent, GenericFile<T> file) {
super(parent);
- setGenericFile(file);
+ if (file != null) {
+ file.bindToExchange(this);
+ }
}
public GenericFile<T> getGenericFile() {
return (GenericFile<T>) getProperty(FileComponent.FILE_EXCHANGE_FILE);
}
- public void setGenericFile(GenericFile<T> file) {
- setProperty(FileComponent.FILE_EXCHANGE_FILE, file);
- GenericFileMessage<T> in = new GenericFileMessage<T>(file);
- setIn(in);
- if (file != null) {
- file.populateHeaders(in);
- }
- }
-
public Exchange newInstance() {
return new GenericFileExchange<T>(this, getGenericFile());
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProcessStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProcessStrategy.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProcessStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProcessStrategy.java Tue Jun 30 05:11:49 2009
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.file;
+import org.apache.camel.Exchange;
+
/**
* Represents a pluggable strategy when processing files.
*/
@@ -35,7 +37,7 @@
* @throws Exception can be thrown in case of errors
*/
boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
- GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
+ Exchange exchange, GenericFile<T> file) throws Exception;
/**
* Releases any file locks and possibly deletes or moves the file after
@@ -48,7 +50,7 @@
* @throws Exception can be thrown in case of errors
*/
void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
- GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
+ Exchange exchange, GenericFile<T> file) throws Exception;
/**
* Releases any file locks and possibly deletes or moves the file after
@@ -61,6 +63,6 @@
* @throws Exception can be thrown in case of errors
*/
void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint,
- GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception;
+ Exchange exchange, GenericFile<T> file) throws Exception;
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java Tue Jun 30 05:11:49 2009
@@ -16,16 +16,16 @@
*/
package org.apache.camel.component.file.strategy;
+import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
-import org.apache.camel.component.file.GenericFileExchange;
import org.apache.camel.component.file.GenericFileOperationFailedException;
import org.apache.camel.component.file.GenericFileOperations;
public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrategySupport<T> {
@Override
- public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
// must invoke super
super.commit(operations, endpoint, exchange, file);
@@ -34,5 +34,4 @@
throw new GenericFileOperationFailedException("Cannot delete file: " + file);
}
}
-
}
\ No newline at end of file
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileExpressionRenamer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileExpressionRenamer.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileExpressionRenamer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileExpressionRenamer.java Tue Jun 30 05:11:49 2009
@@ -16,9 +16,9 @@
*/
package org.apache.camel.component.file.strategy;
+import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.component.file.GenericFileExchange;
import org.apache.camel.util.ObjectHelper;
public class GenericFileExpressionRenamer<T> implements GenericFileRenamer<T> {
@@ -31,7 +31,7 @@
this.expression = expression;
}
- public GenericFile<T> renameFile(GenericFileExchange<T> exchange, GenericFile<T> file) {
+ public GenericFile<T> renameFile(Exchange exchange, GenericFile<T> file) {
ObjectHelper.notNull(expression, "expression");
String newName = expression.evaluate(exchange, String.class);
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=789563&r1=789562&r2=789563&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 Tue Jun 30 05:11:49 2009
@@ -21,7 +21,6 @@
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
-import org.apache.camel.component.file.GenericFileExchange;
import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
import org.apache.camel.component.file.GenericFileOperations;
import org.apache.camel.component.file.GenericFileProcessStrategy;
@@ -32,7 +31,7 @@
protected final transient Log log = LogFactory.getLog(getClass());
protected GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy;
- public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
// is we use excluse read then acquire the exclusive read (waiting until we got it)
if (exclusiveReadLockStrategy != null) {
boolean lock = exclusiveReadLockStrategy.acquireExclusiveReadLock(operations, file, exchange);
@@ -45,7 +44,7 @@
return true;
}
- public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange);
}
@@ -53,7 +52,7 @@
deleteLocalWorkFile(exchange);
}
- public void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange);
}
@@ -69,7 +68,7 @@
this.exclusiveReadLockStrategy = exclusiveReadLockStrategy;
}
- private void deleteLocalWorkFile(GenericFileExchange<T> exchange) {
+ private void deleteLocalWorkFile(Exchange exchange) {
// delete local work file, if it was used (eg by ftp component)
File local = exchange.getIn().getHeader(Exchange.FILE_LOCAL_WORK_PATH, File.class);
if (local != null && local.exists()) {
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java Tue Jun 30 05:11:49 2009
@@ -18,9 +18,9 @@
import java.io.IOException;
+import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
-import org.apache.camel.component.file.GenericFileExchange;
import org.apache.camel.component.file.GenericFileOperationFailedException;
import org.apache.camel.component.file.GenericFileOperations;
@@ -32,7 +32,7 @@
}
@Override
- public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
// must invoke super
boolean result = super.begin(operations, endpoint, exchange, file);
if (!result) {
@@ -42,14 +42,16 @@
if (beginRenamer != null) {
GenericFile<T> newName = beginRenamer.renameFile(exchange, file);
GenericFile<T> to = renameFile(operations, file, newName);
- exchange.setGenericFile(to);
+ if (to != null) {
+ to.bindToExchange(exchange);
+ }
}
return true;
}
@Override
- public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, GenericFileExchange<T> exchange, GenericFile<T> file) throws Exception {
+ public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
// must invoke super
super.commit(operations, endpoint, exchange, file);
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenamer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenamer.java?rev=789563&r1=789562&r2=789563&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenamer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenamer.java Tue Jun 30 05:11:49 2009
@@ -16,8 +16,8 @@
*/
package org.apache.camel.component.file.strategy;
+import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.component.file.GenericFileExchange;
/**
* Used for renaming files.
@@ -31,6 +31,5 @@
* @param file the original file.
* @return the renamed file name.
*/
- GenericFile<T> renameFile(GenericFileExchange<T> exchange, GenericFile<T> file);
-
+ GenericFile<T> renameFile(Exchange exchange, GenericFile<T> file);
}