use of org.apache.camel.LoggingLevel in project camel by apache.
the class FileProcessStrategyFactory method getExclusiveReadLockStrategy.
@SuppressWarnings("unchecked")
private static GenericFileExclusiveReadLockStrategy<File> getExclusiveReadLockStrategy(Map<String, Object> params) {
GenericFileExclusiveReadLockStrategy<File> strategy = (GenericFileExclusiveReadLockStrategy<File>) 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 ("markerFile".equals(readLock)) {
strategy = new MarkerFileExclusiveReadLockStrategy();
} else if ("fileLock".equals(readLock)) {
strategy = new FileLockExclusiveReadLockStrategy();
} else if ("rename".equals(readLock)) {
strategy = new FileRenameExclusiveReadLockStrategy();
} else if ("changed".equals(readLock)) {
FileChangedExclusiveReadLockStrategy readLockStrategy = new FileChangedExclusiveReadLockStrategy();
Long minLength = (Long) params.get("readLockMinLength");
if (minLength != null) {
readLockStrategy.setMinLength(minLength);
}
Long minAge = (Long) params.get("readLockMinAge");
if (null != minAge) {
readLockStrategy.setMinAge(minAge);
}
strategy = readLockStrategy;
} else if ("idempotent".equals(readLock)) {
FileIdempotentRepositoryReadLockStrategy readLockStrategy = new FileIdempotentRepositoryReadLockStrategy();
Boolean readLockRemoveOnRollback = (Boolean) params.get("readLockRemoveOnRollback");
if (readLockRemoveOnRollback != null) {
readLockStrategy.setRemoveOnRollback(readLockRemoveOnRollback);
}
Boolean readLockRemoveOnCommit = (Boolean) params.get("readLockRemoveOnCommit");
if (readLockRemoveOnCommit != null) {
readLockStrategy.setRemoveOnCommit(readLockRemoveOnCommit);
}
IdempotentRepository repo = (IdempotentRepository) params.get("readLockIdempotentRepository");
if (repo != null) {
readLockStrategy.setIdempotentRepository(repo);
}
strategy = readLockStrategy;
} else if ("idempotent-changed".equals(readLock)) {
FileIdempotentChangedRepositoryReadLockStrategy readLockStrategy = new FileIdempotentChangedRepositoryReadLockStrategy();
Boolean readLockRemoveOnRollback = (Boolean) params.get("readLockRemoveOnRollback");
if (readLockRemoveOnRollback != null) {
readLockStrategy.setRemoveOnRollback(readLockRemoveOnRollback);
}
Boolean readLockRemoveOnCommit = (Boolean) params.get("readLockRemoveOnCommit");
if (readLockRemoveOnCommit != null) {
readLockStrategy.setRemoveOnCommit(readLockRemoveOnCommit);
}
IdempotentRepository repo = (IdempotentRepository) params.get("readLockIdempotentRepository");
if (repo != null) {
readLockStrategy.setIdempotentRepository(repo);
}
Long minLength = (Long) params.get("readLockMinLength");
if (minLength != null) {
readLockStrategy.setMinLength(minLength);
}
Long minAge = (Long) params.get("readLockMinAge");
if (null != minAge) {
readLockStrategy.setMinAge(minAge);
}
strategy = readLockStrategy;
} else if ("idempotent-rename".equals(readLock)) {
FileIdempotentRenameRepositoryReadLockStrategy readLockStrategy = new FileIdempotentRenameRepositoryReadLockStrategy();
Boolean readLockRemoveOnRollback = (Boolean) params.get("readLockRemoveOnRollback");
if (readLockRemoveOnRollback != null) {
readLockStrategy.setRemoveOnRollback(readLockRemoveOnRollback);
}
Boolean readLockRemoveOnCommit = (Boolean) params.get("readLockRemoveOnCommit");
if (readLockRemoveOnCommit != null) {
readLockStrategy.setRemoveOnCommit(readLockRemoveOnCommit);
}
IdempotentRepository repo = (IdempotentRepository) params.get("readLockIdempotentRepository");
if (repo != null) {
readLockStrategy.setIdempotentRepository(repo);
}
strategy = readLockStrategy;
}
if (strategy != null) {
Long timeout = (Long) params.get("readLockTimeout");
if (timeout != null) {
strategy.setTimeout(timeout);
}
Long checkInterval = (Long) params.get("readLockCheckInterval");
if (checkInterval != null) {
strategy.setCheckInterval(checkInterval);
}
LoggingLevel readLockLoggingLevel = (LoggingLevel) params.get("readLockLoggingLevel");
if (readLockLoggingLevel != null) {
strategy.setReadLockLoggingLevel(readLockLoggingLevel);
}
Boolean readLockMarkerFile = (Boolean) params.get("readLockMarkerFile");
if (readLockMarkerFile != null) {
strategy.setMarkerFiler(readLockMarkerFile);
}
Boolean readLockDeleteOrphanLockFiles = (Boolean) params.get("readLockDeleteOrphanLockFiles");
if (readLockDeleteOrphanLockFiles != null) {
strategy.setDeleteOrphanLockFiles(readLockDeleteOrphanLockFiles);
}
}
}
return strategy;
}
use of org.apache.camel.LoggingLevel in project camel by apache.
the class CamelLogger method log.
public void log(String message, LoggingLevel loggingLevel) {
LoggingLevel oldLogLevel = getLevel();
setLevel(loggingLevel);
log(message);
setLevel(oldLogLevel);
}
use of org.apache.camel.LoggingLevel in project camel by apache.
the class EnumConverterTest method testMandatoryConvertWithExchangeEnum.
public void testMandatoryConvertWithExchangeEnum() throws Exception {
Exchange exchange = new DefaultExchange(context);
LoggingLevel level = context.getTypeConverter().mandatoryConvertTo(LoggingLevel.class, exchange, "WARN");
assertEquals(LoggingLevel.WARN, level);
}
use of org.apache.camel.LoggingLevel in project camel by apache.
the class EnumConverterTest method testCaseInsensitive.
public void testCaseInsensitive() throws Exception {
Exchange exchange = new DefaultExchange(context);
LoggingLevel level = context.getTypeConverter().mandatoryConvertTo(LoggingLevel.class, exchange, "Warn");
assertEquals(LoggingLevel.WARN, level);
level = context.getTypeConverter().mandatoryConvertTo(LoggingLevel.class, exchange, "warn");
assertEquals(LoggingLevel.WARN, level);
level = context.getTypeConverter().mandatoryConvertTo(LoggingLevel.class, exchange, "wARn");
assertEquals(LoggingLevel.WARN, level);
level = context.getTypeConverter().mandatoryConvertTo(LoggingLevel.class, exchange, "inFO");
assertEquals(LoggingLevel.INFO, level);
}
use of org.apache.camel.LoggingLevel in project camel by apache.
the class LogComponent method createEndpoint.
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
LoggingLevel level = getLoggingLevel(parameters);
Logger providedLogger = getLogger(parameters);
if (providedLogger == null) {
// try to look up the logger in registry
Map<String, Logger> availableLoggers = getCamelContext().getRegistry().findByTypeWithName(Logger.class);
if (availableLoggers.size() == 1) {
providedLogger = availableLoggers.values().iterator().next();
LOG.info("Using custom Logger: {}", providedLogger);
} else if (availableLoggers.size() > 1) {
LOG.info("More than one {} instance found in the registry. Falling back to creating logger from URI {}.", Logger.class.getName(), uri);
}
}
LogEndpoint endpoint = new LogEndpoint(uri, this);
endpoint.setLevel(level.name());
setProperties(endpoint, parameters);
if (providedLogger == null) {
endpoint.setLoggerName(remaining);
} else {
endpoint.setProvidedLogger(providedLogger);
}
// first, try to pick up the ExchangeFormatter from the registry
ExchangeFormatter localFormatter = getCamelContext().getRegistry().lookupByNameAndType("logFormatter", ExchangeFormatter.class);
if (localFormatter != null) {
setProperties(localFormatter, parameters);
} else if (localFormatter == null && exchangeFormatter != null) {
// do not set properties, the exchangeFormatter is explicitly set, therefore the
// user would have set its properties explicitly too
localFormatter = exchangeFormatter;
} else {
// if no formatter is available in the Registry, create a local one of the default type, for a single use
localFormatter = new DefaultExchangeFormatter();
setProperties(localFormatter, parameters);
}
endpoint.setLocalFormatter(localFormatter);
return endpoint;
}
Aggregations