This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 566132c08d5110a1c0dc901c0c1a6b2c54c0efe0 Author: Claus Ibsen <[email protected]> AuthorDate: Tue Apr 21 12:15:32 2020 +0200 CAMEL-14936: camel-core - Remove optional prefix in FactoryFinder --- .../services/org/apache/camel/component/scp | 1 - .../apache/camel/component/scp/ScpComponent.java | 2 - .../apache/camel/component/scp/ScpEndpoint.java | 6 +++ .../component/scp/ScpProcessStrategyFactory.java | 55 ++++------------------ 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/components/camel-jsch/src/generated/resources/META-INF/services/org/apache/camel/component/scp b/components/camel-jsch/src/generated/resources/META-INF/services/org/apache/camel/component/scp index 45a1126..906c818 100644 --- a/components/camel-jsch/src/generated/resources/META-INF/services/org/apache/camel/component/scp +++ b/components/camel-jsch/src/generated/resources/META-INF/services/org/apache/camel/component/scp @@ -1,3 +1,2 @@ # Generated by camel build tools - do NOT edit this file! class=org.apache.camel.component.scp.ScpComponent -strategy.factory.class=org.apache.camel.component.scp.ScpProcessStrategyFactory diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java index f1fc631..b84269b 100644 --- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java +++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java @@ -21,7 +21,6 @@ import java.util.Map; import com.jcraft.jsch.JSch; import org.apache.camel.CamelContext; -import org.apache.camel.component.file.FileProcessStrategy; import org.apache.camel.component.file.GenericFileEndpoint; import org.apache.camel.component.file.remote.RemoteFileComponent; import org.apache.camel.spi.annotations.Component; @@ -30,7 +29,6 @@ import org.apache.camel.spi.annotations.Component; * Component providing secure messaging using JSch */ @Component("scp") -@FileProcessStrategy(ScpProcessStrategyFactory.class) public class ScpComponent extends RemoteFileComponent<ScpFile> { private boolean verboseLogging; diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpEndpoint.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpEndpoint.java index 9a71b0c..37f5f42 100644 --- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpEndpoint.java +++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpEndpoint.java @@ -18,6 +18,7 @@ package org.apache.camel.component.scp; import org.apache.camel.Expression; import org.apache.camel.Processor; +import org.apache.camel.component.file.GenericFileProcessStrategy; import org.apache.camel.component.file.GenericFileProducer; import org.apache.camel.component.file.remote.RemoteFileConsumer; import org.apache.camel.component.file.remote.RemoteFileEndpoint; @@ -73,6 +74,11 @@ public class ScpEndpoint extends RemoteFileEndpoint<ScpFile> { } @Override + protected GenericFileProcessStrategy<ScpFile> createGenericFileStrategy() { + return new ScpProcessStrategyFactory().createGenericFileProcessStrategy(getCamelContext(), getParamsAsMap()); + } + + @Override public String getScheme() { return "scp"; } diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpProcessStrategyFactory.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpProcessStrategyFactory.java index 117a4ef..7688392 100644 --- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpProcessStrategyFactory.java +++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpProcessStrategyFactory.java @@ -21,65 +21,26 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy; import org.apache.camel.component.file.GenericFileProcessStrategy; +import org.apache.camel.component.file.GenericFileProcessStrategyFactory; import org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy; -public final class ScpProcessStrategyFactory { - - private ScpProcessStrategyFactory() { - } +public class ScpProcessStrategyFactory implements GenericFileProcessStrategyFactory<ScpFile> { @SuppressWarnings("unchecked") - public static <LsEntry> GenericFileProcessStrategy<LsEntry> createGenericFileProcessStrategy(CamelContext context, Map<String, Object> params) { - - /* - // We assume a value is present only if its value not null for String and 'true' for boolean - Expression moveExpression = (Expression) params.get("move"); - Expression moveFailedExpression = (Expression) params.get("moveFailed"); - Expression preMoveExpression = (Expression) params.get("preMove"); - boolean isNoop = params.get("noop") != null; - boolean isDelete = params.get("delete") != null; - boolean isMove = moveExpression != null || preMoveExpression != null || moveFailedExpression != null; - */ - + public GenericFileProcessStrategy<ScpFile> createGenericFileProcessStrategy(CamelContext context, Map<String, Object> params) { // default strategy will do nothing - GenericFileNoOpProcessStrategy<LsEntry> strategy = new GenericFileNoOpProcessStrategy<>(); - strategy.setExclusiveReadLockStrategy((GenericFileExclusiveReadLockStrategy<LsEntry>) getExclusiveReadLockStrategy(params)); + GenericFileNoOpProcessStrategy<ScpFile> strategy = new GenericFileNoOpProcessStrategy<>(); + strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params)); return strategy; } @SuppressWarnings({"unchecked"}) - private static <LsEntry> GenericFileExclusiveReadLockStrategy<LsEntry> getExclusiveReadLockStrategy(Map<String, Object> params) { - GenericFileExclusiveReadLockStrategy<LsEntry> strategy = (GenericFileExclusiveReadLockStrategy<LsEntry>) params.get("exclusiveReadLockStrategy"); + private static GenericFileExclusiveReadLockStrategy<ScpFile> getExclusiveReadLockStrategy(Map<String, Object> params) { + GenericFileExclusiveReadLockStrategy<ScpFile> strategy = (GenericFileExclusiveReadLockStrategy<ScpFile>) 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 ("rename".equals(readLock)) { - GenericFileRenameExclusiveReadLockStrategy<LsEntry> readLockStrategy = new GenericFileRenameExclusiveReadLockStrategy<LsEntry>(); - Long timeout = (Long) params.get("readLockTimeout"); - if (timeout != null) { - readLockStrategy.setTimeout(timeout); - } - return readLockStrategy; - } else if ("changed".equals(readLock)) { - GenericFileExclusiveReadLockStrategy readLockStrategy = new SftpChangedExclusiveReadLockStrategy(); - 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; - } - } -*/ return null; } + }
