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


Java GenericFile.getAbsoluteFilePath方法代码示例

本文整理汇总了Java中org.apache.camel.component.file.GenericFile.getAbsoluteFilePath方法的典型用法代码示例。如果您正苦于以下问题:Java GenericFile.getAbsoluteFilePath方法的具体用法?Java GenericFile.getAbsoluteFilePath怎么用?Java GenericFile.getAbsoluteFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.component.file.GenericFile的用法示例。


在下文中一共展示了GenericFile.getAbsoluteFilePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asReadLockKey

import org.apache.camel.component.file.GenericFile; //导入方法依赖的package包/类
private static String asReadLockKey(GenericFile file, String key) {
    // use the copy from absolute path as that was the original path of the file when the lock was acquired
    // for example if the file consumer uses preMove then the file is moved and therefore has another name
    // that would no longer match
    String path = file.getCopyFromAbsoluteFilePath() != null ? file.getCopyFromAbsoluteFilePath() : file.getAbsoluteFilePath();
    return path + "-" + key;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:FileLockExclusiveReadLockStrategy.java

示例2: asKey

import org.apache.camel.component.file.GenericFile; //导入方法依赖的package包/类
protected String asKey(GenericFile<File> file) {
    // use absolute file path as default key, but evaluate if an expression key was configured
    String key = file.getAbsoluteFilePath();
    if (endpoint.getIdempotentKey() != null) {
        Exchange dummy = endpoint.createExchange(file);
        key = endpoint.getIdempotentKey().evaluate(dummy, String.class);
    }
    return key;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:FileIdempotentRepositoryReadLockStrategy.java

示例3: acquireExclusiveReadLock

import org.apache.camel.component.file.GenericFile; //导入方法依赖的package包/类
@Override
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception {
    // must call super
    if (!super.acquireExclusiveReadLock(operations, file, exchange)) {
        return false;
    }

    File target = new File(file.getAbsoluteFilePath());
    boolean exclusive = false;

    LOG.trace("Waiting for exclusive read lock to file: {}", file);

    long lastModified = Long.MIN_VALUE;
    long length = Long.MIN_VALUE;
    StopWatch watch = new StopWatch();
    long startTime = (new Date()).getTime();

    while (!exclusive) {
        // timeout check
        if (timeout > 0) {
            long delta = watch.taken();
            if (delta > timeout) {
                CamelLogger.log(LOG, readLockLoggingLevel,
                        "Cannot acquire read lock within " + timeout + " millis. Will skip the file: " + file);
                // we could not get the lock within the timeout period, so return false
                return false;
            }
        }

        long newLastModified = target.lastModified();
        long newLength = target.length();
        long newOlderThan = startTime + watch.taken() - minAge;

        LOG.trace("Previous last modified: {}, new last modified: {}", lastModified, newLastModified);
        LOG.trace("Previous length: {}, new length: {}", length, newLength);
        LOG.trace("New older than threshold: {}", newOlderThan);

        if (newLength >= minLength && ((minAge == 0 && newLastModified == lastModified && newLength == length) || (minAge != 0 && newLastModified < newOlderThan))) {
            LOG.trace("Read lock acquired.");
            exclusive = true;
        } else {
            // set new base file change information
            lastModified = newLastModified;
            length = newLength;

            boolean interrupted = sleep();
            if (interrupted) {
                // we were interrupted while sleeping, we are likely being shutdown so return false
                return false;
            }
        }
    }

    return exclusive;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:56,代码来源:FileChangedExclusiveReadLockStrategy.java

示例4: getLockFileName

import org.apache.camel.component.file.GenericFile; //导入方法依赖的package包/类
private static String getLockFileName(GenericFile<File> file) {
    return file.getAbsoluteFilePath() + FileComponent.DEFAULT_LOCK_FILE_POSTFIX;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:MarkerFileExclusiveReadLockStrategy.java


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