本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}