本文整理汇总了Java中org.apache.camel.component.file.GenericFileEndpoint类的典型用法代码示例。如果您正苦于以下问题:Java GenericFileEndpoint类的具体用法?Java GenericFileEndpoint怎么用?Java GenericFileEndpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenericFileEndpoint类属于org.apache.camel.component.file包,在下文中一共展示了GenericFileEndpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: begin
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
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) {
return false;
}
// okay we got the file then execute the begin renamer
if (beginRenamer != null) {
GenericFile<T> newName = beginRenamer.renameFile(exchange, file);
GenericFile<T> to = renameFile(operations, file, newName);
if (to != null) {
to.bindToExchange(exchange);
}
}
return true;
}
示例2: rollback
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
public void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
try {
deleteLocalWorkFile(exchange);
operations.releaseRetreivedFileResources(exchange);
// moved the failed file if specifying the moveFailed option
if (failureRenamer != null) {
// create a copy and bind the file to the exchange to be used by the renamer to evaluate the file name
Exchange copy = exchange.copy();
file.bindToExchange(copy);
// must preserve message id
copy.getIn().setMessageId(exchange.getIn().getMessageId());
copy.setExchangeId(exchange.getExchangeId());
GenericFile<T> newName = failureRenamer.renameFile(copy, file);
renameFile(operations, file, newName);
}
} finally {
// must release lock last
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLockOnRollback(operations, file, exchange);
}
}
}
示例3: begin
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
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) {
return false;
}
// okay we got the file then execute the begin renamer
if (beginRenamer != null) {
GenericFile<T> newName = beginRenamer.renameFile(exchange, file);
GenericFile<T> to = renameFile(operations, file, newName);
if (to != null) {
to.bindToExchange(exchange);
}
}
return true;
}
示例4: rollback
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
public void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
try {
operations.releaseRetreivedFileResources(exchange);
if (failureRenamer != null) {
// create a copy and bind the file to the exchange to be used by the renamer to evaluate the file name
Exchange copy = exchange.copy();
file.bindToExchange(copy);
// must preserve message id
copy.getIn().setMessageId(exchange.getIn().getMessageId());
copy.setExchangeId(exchange.getExchangeId());
GenericFile<T> newName = failureRenamer.renameFile(copy, file);
renameFile(operations, file, newName);
}
} finally {
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLockOnRollback(operations, file, exchange);
}
deleteLocalWorkFile(exchange);
}
}
示例5: commit
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
try {
if (commitRenamer != null) {
// create a copy and bind the file to the exchange to be used by the renamer to evaluate the file name
Exchange copy = exchange.copy();
file.bindToExchange(copy);
// must preserve message id
copy.getIn().setMessageId(exchange.getIn().getMessageId());
copy.setExchangeId(exchange.getExchangeId());
GenericFile<T> newName = commitRenamer.renameFile(copy, file);
renameFile(operations, file, newName);
}
} finally {
// must invoke super
super.commit(operations, endpoint, exchange, file);
}
}
示例6: prepareOnStartup
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
public void prepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) {
if (deleteOrphanLockFiles) {
String dir = endpoint.getConfiguration().getDirectory();
File file = new File(dir);
LOG.debug("Prepare on startup by deleting orphaned lock files from: {}", dir);
Pattern excludePattern = endpoint.getExclude() != null ? Pattern.compile(endpoint.getExclude()) : null;
Pattern includePattern = endpoint.getInclude() != null ? Pattern.compile(endpoint.getInclude()) : null;
String endpointPath = endpoint.getConfiguration().getDirectory();
StopWatch watch = new StopWatch();
deleteLockFiles(file, endpoint.isRecursive(), endpointPath, endpoint.getFilter(), endpoint.getAntFilter(), excludePattern, includePattern);
// log anything that takes more than a second
if (watch.taken() > 1000) {
LOG.info("Prepared on startup by deleting orphaned lock files from: {} took {} millis to complete.", dir, watch.taken());
}
}
}
示例7: testTroubleDeletingFile
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
public void testTroubleDeletingFile() throws Exception {
deleteCounter = 0;
existsCounter = 0;
@SuppressWarnings("unchecked")
GenericFileEndpoint<Object> endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
Exchange exchange = endpoint.createExchange();
GenericFile<Object> file = new GenericFile<Object>();
file.setAbsoluteFilePath("target/foo/me.txt");
GenericFileDeleteProcessStrategy<Object> strategy = new GenericFileDeleteProcessStrategy<Object>();
strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);
assertEquals("Should have tried to delete file 2 times", 2, deleteCounter);
assertEquals("Should have tried to delete file 2 times", 2, existsCounter);
}
示例8: testCannotDeleteFile
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
public void testCannotDeleteFile() throws Exception {
deleteCounter = 0;
existsCounter = 0;
@SuppressWarnings("unchecked")
GenericFileEndpoint<Object> endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
Exchange exchange = endpoint.createExchange();
GenericFile<Object> file = new GenericFile<Object>();
file.setAbsoluteFilePath("target/foo/boom.txt");
GenericFileDeleteProcessStrategy<Object> strategy = new GenericFileDeleteProcessStrategy<Object>();
try {
strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);
fail("Should have thrown an exception");
} catch (GenericFileOperationFailedException e) {
// expected
}
assertEquals("Should have tried to delete file 3 times", 3, deleteCounter);
assertEquals("Should have tried to delete file 3 times", 3, existsCounter);
}
示例9: buildFileEndpoint
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
protected GenericFileEndpoint<ChannelSftp.LsEntry> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// get the base uri part before the options as they can be non URI valid such as the expression using $ chars
// and the URI constructor will regard $ as an illegal character and we dont want to enforce end users to
// to escape the $ for the expression (file language)
String baseUri = uri;
if (uri.indexOf("?") != -1) {
baseUri = uri.substring(0, uri.indexOf("?"));
}
// lets make sure we create a new configuration as each endpoint can
// customize its own version
SftpConfiguration config = new SftpConfiguration(new URI(baseUri));
FtpUtils.ensureRelativeFtpDirectory(this, config);
return new SftpEndpoint(uri, this, config);
}
示例10: buildFileEndpoint
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
String baseUri = getBaseUri(uri);
// lets make sure we create a new configuration as each endpoint can customize its own version
// must pass on baseUri to the configuration (see above)
FtpConfiguration config = new FtpConfiguration(new URI(baseUri));
FtpUtils.ensureRelativeFtpDirectory(this, config);
FtpEndpoint<FTPFile> answer = new FtpEndpoint<FTPFile>(uri, this, config);
extractAndSetFtpClientConfigParameters(parameters, answer);
extractAndSetFtpClientParameters(parameters, answer);
return answer;
}
示例11: buildFileEndpoint
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
String baseUri = getBaseUri(uri);
// lets make sure we create a new configuration as each endpoint can customize its own version
// must pass on baseUri to the configuration (see above)
FtpsConfiguration config = new FtpsConfiguration(new URI(baseUri));
FtpUtils.ensureRelativeFtpDirectory(this, config);
FtpsEndpoint endpoint = new FtpsEndpoint(uri, this, config);
extractAndSetFtpClientKeyStoreParameters(parameters, endpoint);
extractAndSetFtpClientTrustStoreParameters(parameters, endpoint);
extractAndSetFtpClientConfigParameters(parameters, endpoint);
extractAndSetFtpClientParameters(parameters, endpoint);
return endpoint;
}
示例12: afterPropertiesSet
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
@Override
protected void afterPropertiesSet(GenericFileEndpoint<File> endpoint) throws Exception {
super.afterPropertiesSet(endpoint);
if (endpoint instanceof LoadBalancedFileEndpoint) {
LoadBalancedFileEndpoint lbEndpoint = (LoadBalancedFileEndpoint)endpoint;
PriorityFileFilterFactory factory = lbEndpoint.getPriorityFileFilterFactory();
if (factory == null) {
throw new ResolveEndpointFailedException(lbEndpoint.getEndpointUri(), "PriorityFileFilterFactory is null");
}
updateFilter(lbEndpoint, factory);
updateMaxMessagesPerPoll(lbEndpoint, factory);
updateMove(lbEndpoint);
}
}
示例13: begin
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
// if we use exclusive read then acquire the exclusive read (waiting until we got it)
if (exclusiveReadLockStrategy != null) {
boolean lock = exclusiveReadLockStrategy.acquireExclusiveReadLock(operations, file, exchange);
if (!lock) {
// do not begin since we could not get the exclusive read lock
return false;
}
}
return true;
}
示例14: abort
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
public void abort(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
deleteLocalWorkFile(exchange);
operations.releaseRetreivedFileResources(exchange);
// must release lock last
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLockOnAbort(operations, file, exchange);
}
}
示例15: commit
import org.apache.camel.component.file.GenericFileEndpoint; //导入依赖的package包/类
public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
deleteLocalWorkFile(exchange);
operations.releaseRetreivedFileResources(exchange);
// must release lock last
if (exclusiveReadLockStrategy != null) {
exclusiveReadLockStrategy.releaseExclusiveReadLockOnCommit(operations, file, exchange);
}
}