当前位置: 首页>>代码示例>>Java>>正文


Java GenericFileEndpoint类代码示例

本文整理汇总了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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:GenericFileDeleteProcessStrategy.java

示例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);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:GenericFileDeleteProcessStrategy.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:GenericFileRenameProcessStrategy.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:GenericFileRenameProcessStrategy.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:GenericFileRenameProcessStrategy.java

示例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());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:MarkerFileExclusiveReadLockStrategy.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:GenericFileDeleteProcessStrategyTest.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:GenericFileDeleteProcessStrategyTest.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:SftpComponent.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FtpComponent.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FtpsComponent.java

示例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);
    }
}
 
开发者ID:garethahealy,项目名称:camel-file-loadbalancer,代码行数:18,代码来源:LoadBalancedFileComponent.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:GenericFileProcessStrategySupport.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:GenericFileProcessStrategySupport.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:GenericFileProcessStrategySupport.java


注:本文中的org.apache.camel.component.file.GenericFileEndpoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。