return new GenericFileExpressionRenamer<File>(expression);
}
@SuppressWarnings("unchecked")
private static GenericFileExclusiveReadLockStrategy<File> getExclusiveReadLockStrategy(Map<String, Object> params) {
GenericFileExclusiveReadLockStrategy strategy = (GenericFileExclusiveReadLockStrategy) params.get("exclusiveReadLockStrategy");
if (strategy != null) {
return strategy;
}
// no explicit strategy set then fallback to readLock option
String readLock = (String) params.get("readLock");
if (ObjectHelper.isNotEmpty(readLock)) {
if ("none".equals(readLock) || "false".equals(readLock)) {
return null;
} else if ("fileLock".equals(readLock)) {
GenericFileExclusiveReadLockStrategy<File> readLockStrategy = new FileLockExclusiveReadLockStrategy();
Long timeout = (Long) params.get("readLockTimeout");
if (timeout != null) {
readLockStrategy.setTimeout(timeout);
}
Long checkInterval = (Long) params.get("readLockCheckInterval");
if (checkInterval != null) {
readLockStrategy.setCheckInterval(checkInterval);
}
return readLockStrategy;
} else if ("rename".equals(readLock)) {
GenericFileExclusiveReadLockStrategy<File> readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy<File>();
Long timeout = (Long) params.get("readLockTimeout");
if (timeout != null) {
readLockStrategy.setTimeout(timeout);
}
Long checkInterval = (Long) params.get("readLockCheckInterval");
if (checkInterval != null) {
readLockStrategy.setCheckInterval(checkInterval);
}
return readLockStrategy;
} else if ("changed".equals(readLock)) {
GenericFileExclusiveReadLockStrategy readLockStrategy = new FileChangedExclusiveReadLockStrategy();
Long timeout = (Long) params.get("readLockTimeout");
if (timeout != null) {
readLockStrategy.setTimeout(timeout);
}
Long checkInterval = (Long) params.get("readLockCheckInterval");
if (checkInterval != null) {
readLockStrategy.setCheckInterval(checkInterval);
}
return readLockStrategy;
} else if ("markerFile".equals(readLock)) {
return new MarkerFileExclusiveReadLockStrategy();
}