You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2018/10/03 15:05:04 UTC

[camel] 16/32: [CAMEL-12818] Remove useDom, handled(), add rethrow()

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch sandbox/camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0bc6e1eb704069320f3af572c59df5c83c7a9f4d
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Sep 25 20:40:14 2018 +0200

    [CAMEL-12818] Remove useDom, handled(), add rethrow()
---
 camel-core/src/main/docs/validator-component.adoc  |  3 +-
 .../component/validator/ValidatorEndpoint.java     | 14 -----
 .../org/apache/camel/model/RethrowDefinition.java  | 66 ++++++++++++++++++++++
 .../java/org/apache/camel/model/TryDefinition.java | 45 ++-------------
 .../processor/validation/ValidatingProcessor.java  | 21 -------
 .../java/org/apache/camel/util/ResourceHelper.java | 22 --------
 .../resources/org/apache/camel/model/jaxb.index    |  1 +
 .../TryCatchWithSplitNotHandledIssueTest.java      |  3 +-
 .../camel/processor/TryProcessorHandledTest.java   |  5 +-
 .../processor/ValidatingDomProcessorTest.java      |  6 +-
 .../camel-ejb/src/main/docs/ejb-component.adoc     |  3 +-
 .../camel/component/validator/msv/MsvEndpoint.java |  2 -
 .../src/main/docs/restlet-component.adoc           |  3 +-
 .../ssh/ResourceHelperKeyPairProvider.java         | 34 +++++------
 .../org/apache/camel/component/ssh/SshHelper.java  |  2 +-
 15 files changed, 98 insertions(+), 132 deletions(-)

diff --git a/camel-core/src/main/docs/validator-component.adoc b/camel-core/src/main/docs/validator-component.adoc
index c32f2bd..41004cf 100644
--- a/camel-core/src/main/docs/validator-component.adoc
+++ b/camel-core/src/main/docs/validator-component.adoc
@@ -85,7 +85,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (11 parameters):
+==== Query Parameters (10 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -100,7 +100,6 @@ with the following path and query parameters:
 | *schemaFactory* (advanced) | To use a custom javax.xml.validation.SchemaFactory |  | SchemaFactory
 | *schemaLanguage* (advanced) | Configures the W3C XML Schema Namespace URI. | http://www.w3.org/2001/XMLSchema | String
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
-| *useDom* (advanced) | Whether DOMSource/DOMResult or SaxSource/SaxResult should be used by the validator. | false | boolean
 | *useSharedSchema* (advanced) | Whether the Schema instance should be shared or not. This option is introduced to work around a JDK 1.6.x bug. Xerces should not have this issue. | true | boolean
 |===
 // endpoint options: END
diff --git a/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
index 124e1a9..941e57f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
@@ -56,8 +56,6 @@ public class ValidatorEndpoint extends DefaultEndpoint {
     private SchemaFactory schemaFactory;
     @UriParam(label = "advanced", description = "To use a custom org.apache.camel.processor.validation.ValidatorErrorHandler. The default error handler captures the errors and throws an exception.")
     private ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
-    @UriParam(label = "advanced", description = "Whether DOMSource/DOMResult or SaxSource/SaxResult should be used by the validator.")
-    private boolean useDom;
     @UriParam(defaultValue = "true", label = "advanced",
             description = "Whether the Schema instance should be shared or not. This option is introduced to work around a JDK 1.6.x bug. Xerces should not have this issue.")
     private boolean useSharedSchema = true;
@@ -140,7 +138,6 @@ public class ValidatorEndpoint extends DefaultEndpoint {
 
     protected void configureValidator(ValidatingProcessor validator) throws Exception {
         validator.setErrorHandler(getErrorHandler());
-        validator.setUseDom(isUseDom());
         validator.setUseSharedSchema(isUseSharedSchema());
         validator.setFailOnNullBody(isFailOnNullBody());
         validator.setFailOnNullHeader(isFailOnNullHeader());
@@ -194,17 +191,6 @@ public class ValidatorEndpoint extends DefaultEndpoint {
         this.errorHandler = errorHandler;
     }
 
-    public boolean isUseDom() {
-        return useDom;
-    }
-
-    /**
-     * Whether DOMSource/DOMResult or SaxSource/SaxResult should be used by the validator.
-     */
-    public void setUseDom(boolean useDom) {
-        this.useDom = useDom;
-    }
-
     public boolean isUseSharedSchema() {
         return useSharedSchema;
     }
diff --git a/camel-core/src/main/java/org/apache/camel/model/RethrowDefinition.java b/camel-core/src/main/java/org/apache/camel/model/RethrowDefinition.java
new file mode 100644
index 0000000..13d06e5
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/RethrowDefinition.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.RouteContext;
+
+/**
+ * Rethrow an exception inside a catch block
+ *
+ * @version 
+ */
+@Metadata(label = "error")
+@XmlRootElement(name = "rethrow")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RethrowDefinition extends NoOutputDefinition<RethrowDefinition> {
+
+    public RethrowDefinition() {
+    }
+
+    @Override
+    public String toString() {
+        return "Rethrow[]";
+    }
+
+    @Override
+    public String getShortName() {
+        return "rethrow";
+    }
+
+    @Override
+    public String getLabel() {
+        return "rethrow[]";
+    }
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws Exception {
+        return exchange -> {
+            Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
+            if (e != null) {
+                throw e;
+            }
+        };
+    }
+
+}
diff --git a/camel-core/src/main/java/org/apache/camel/model/TryDefinition.java b/camel-core/src/main/java/org/apache/camel/model/TryDefinition.java
index 7c7589f..9e5a12e 100644
--- a/camel-core/src/main/java/org/apache/camel/model/TryDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/TryDefinition.java
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
@@ -168,53 +169,15 @@ public class TryDefinition extends OutputDefinition<TryDefinition> {
     }
 
     /**
-     * Sets whether the exchange should be marked as handled or not.
+     * Rethrow the exception that has been caught by Camel.
      *
-     * @param handled  handled or not
      * @return the builder
-     * @deprecated will be removed in Camel 3.0. Instead of using handled(false) you can re-throw the exception
-     * from a {@link Processor} or use the {@link ProcessorDefinition#throwException(Exception)}
      */
-    @Deprecated
-    public TryDefinition handled(boolean handled) {
-        Expression expression = ExpressionBuilder.constantExpression(Boolean.toString(handled));
-        return handled(expression);
-    }
-
-    /**
-     * Sets whether the exchange should be marked as handled or not.
-     *
-     * @param handled  predicate that determines true or false
-     * @return the builder
-     * @deprecated will be removed in Camel 3.0. Instead of using handled(false) you can re-throw the exception
-     * from a {@link Processor} or use the {@link ProcessorDefinition#throwException(Exception)}
-     */
-    @Deprecated
-    public TryDefinition handled(@AsPredicate Predicate handled) {
-        // we must use a delegate so we can use the fluent builder based on TryDefinition
-        // to configure all with try .. catch .. finally
-        // set the handled on all the catch definitions
-        Iterator<CatchDefinition> it = ProcessorDefinitionHelper.filterTypeInOutputs(getOutputs(), CatchDefinition.class);
-        while (it.hasNext()) {
-            CatchDefinition doCatch = it.next();
-            doCatch.setHandledPolicy(handled);
-        }
+    public TryDefinition rethrow() {
+        addOutput(new RethrowDefinition());
         return this;
     }
 
-    /**
-     * Sets whether the exchange should be marked as handled or not.
-     *
-     * @param handled  expression that determines true or false
-     * @return the builder
-     * @deprecated will be removed in Camel 3.0. Instead of using handled(false) you can re-throw the exception
-     * from a {@link Processor} or use the {@link ProcessorDefinition#throwException(Exception)}
-     */
-    @Deprecated
-    public TryDefinition handled(@AsPredicate Expression handled) {
-        return handled(ExpressionToPredicateAdapter.toPredicate(handled));
-    }
-
     // Properties
     // -------------------------------------------------------------------------
 
diff --git a/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
index 8bba7e7..bf8db68 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
@@ -65,7 +65,6 @@ public class ValidatingProcessor implements AsyncProcessor {
     private final SchemaReader schemaReader;
     private ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
     private final XmlConverter converter = new XmlConverter();
-    private boolean useDom;
     private boolean useSharedSchema = true;
     private boolean failOnNullBody = true;
     private boolean failOnNullHeader = true;
@@ -265,21 +264,6 @@ public class ValidatingProcessor implements AsyncProcessor {
         this.errorHandler = errorHandler;
     }
 
-    @Deprecated
-    public boolean isUseDom() {
-        return useDom;
-    }
-
-    /**
-     * Sets whether DOMSource and DOMResult should be used.
-     *
-     * @param useDom true to use DOM otherwise
-     */
-    @Deprecated
-    public void setUseDom(boolean useDom) {
-        this.useDom = useDom;
-    }
-
     public boolean isUseSharedSchema() {
         return useSharedSchema;
     }
@@ -380,11 +364,6 @@ public class ValidatingProcessor implements AsyncProcessor {
      * </ul>
      */
     protected Source getSource(Exchange exchange, Object content) {
-        if (isUseDom()) {
-            // force DOM
-            return exchange.getContext().getTypeConverter().tryConvertTo(DOMSource.class, exchange, content);
-        }
-
         // body or header may already be a source
         if (content instanceof Source) {
             return (Source) content;
diff --git a/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java b/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java
index 72d6648..ec30baf 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java
@@ -200,28 +200,6 @@ public final class ResourceHelper {
     }
 
     /**
-     * Resolves the mandatory resource.
-     * <p/>
-     * If possible recommended to use {@link #resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)}
-     *
-     * @param classResolver the class resolver to load the resource from the classpath
-     * @param uri URI of the resource
-     * @return the resource as an {@link InputStream}.  Remember to close this stream after usage.
-     * @throws java.io.IOException is thrown if the resource file could not be found or loaded as {@link InputStream}
-     * @deprecated use {@link #resolveMandatoryResourceAsInputStream(CamelContext, String)}
-     */
-    @Deprecated
-    public static InputStream resolveMandatoryResourceAsInputStream(ClassResolver classResolver, String uri) throws IOException {
-        InputStream is = resolveResourceAsInputStream(classResolver, uri);
-        if (is == null) {
-            String resolvedName = resolveUriPath(uri);
-            throw new FileNotFoundException("Cannot find resource: " + resolvedName + " in classpath for URI: " + uri);
-        } else {
-            return is;
-        }
-    }
-
-    /**
      * Resolves the resource.
      * <p/>
      * If possible recommended to use {@link #resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)}
diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
index cb929cf..a879745 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
@@ -70,6 +70,7 @@ RemovePropertyDefinition
 RemovePropertiesDefinition
 ResequenceDefinition
 RestContextRefDefinition
+RethrowDefinition
 RollbackDefinition
 RouteBuilderDefinition
 RouteDefinition
diff --git a/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitNotHandledIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitNotHandledIssueTest.java
index 25d4927..7f05a11 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitNotHandledIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitNotHandledIssueTest.java
@@ -63,8 +63,9 @@ public class TryCatchWithSplitNotHandledIssueTest extends ContextTestSupport {
                     .doTry()
                         .to("bean:error")
                         .to("mock:result")
-                    .doCatch(Exception.class).handled(false)
+                    .doCatch(Exception.class)
                         .to("mock:error")
+                        .rethrow()
                     .end();
             }
 
diff --git a/camel-core/src/test/java/org/apache/camel/processor/TryProcessorHandledTest.java b/camel-core/src/test/java/org/apache/camel/processor/TryProcessorHandledTest.java
index 513dbb6..2629c6d 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/TryProcessorHandledTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/TryProcessorHandledTest.java
@@ -77,11 +77,10 @@ public class TryProcessorHandledTest extends ContextTestSupport {
                     .doTry()
                         .process(new ProcessorFail())
                         .to("mock:result")
-                    // catch IOExcption that we do not want to handle, eg the caller should get the error back
+                    // catch IOException that we do not want to handle, eg the caller should get the error back
                     .doCatch(IOException.class)
-                        // mark this as NOT handled, eg the caller will also get the exception
-                        .handled(false)
                         .to("mock:io")
+                        .rethrow()
                     .doCatch(Exception.class)
                         // and catch all other exceptions
                         // they are handled by default (ie handled = true)
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ValidatingDomProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/ValidatingDomProcessorTest.java
index 8334ffa..3ce5e4c 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ValidatingDomProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ValidatingDomProcessorTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.processor;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.validation.NoXmlBodyValidationException;
+import org.apache.camel.processor.validation.SchemaValidationException;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -30,8 +31,6 @@ public class ValidatingDomProcessorTest extends ValidatingProcessorTest {
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        validating.setUseDom(true);
-        assertEquals(true, validating.isUseDom());
     }
 
     @Test
@@ -48,8 +47,7 @@ public class ValidatingDomProcessorTest extends ValidatingProcessorTest {
             template.sendBody("direct:start", xml);
             fail("Should have thrown a RuntimeCamelException");
         } catch (CamelExecutionException e) {
-            // cannot be converted to DOM
-            assertIsInstanceOf(NoXmlBodyValidationException.class, e.getCause());
+            assertIsInstanceOf(SchemaValidationException.class, e.getCause());
         }
 
         assertMockEndpointsSatisfied();
diff --git a/components/camel-ejb/src/main/docs/ejb-component.adoc b/components/camel-ejb/src/main/docs/ejb-component.adoc
index a734448..77694e1 100644
--- a/components/camel-ejb/src/main/docs/ejb-component.adoc
+++ b/components/camel-ejb/src/main/docs/ejb-component.adoc
@@ -69,7 +69,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (5 parameters):
+==== Query Parameters (4 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -77,7 +77,6 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *method* (producer) | Sets the name of the method to invoke on the bean |  | String
 | *cache* (advanced) | If enabled, Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. |  | Boolean
-| *multiParameterArray* (advanced) | *Deprecated* How to treat the parameters which are passed from the message body.true means the message body should be an array of parameters.. Deprecation note: This option is used internally by Camel, and is not intended for end users to use. Deprecation note: This option is used internally by Camel, and is not intended for end users to use. | false | boolean
 | *parameters* (advanced) | Used for configuring additional properties on the bean |  | Map
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 |===
diff --git a/components/camel-msv/src/main/java/org/apache/camel/component/validator/msv/MsvEndpoint.java b/components/camel-msv/src/main/java/org/apache/camel/component/validator/msv/MsvEndpoint.java
index 45efa6b..be933ec 100644
--- a/components/camel-msv/src/main/java/org/apache/camel/component/validator/msv/MsvEndpoint.java
+++ b/components/camel-msv/src/main/java/org/apache/camel/component/validator/msv/MsvEndpoint.java
@@ -38,8 +38,6 @@ public class MsvEndpoint extends ValidatorEndpoint {
     protected void configureValidator(ValidatingProcessor validator) throws Exception {
         super.configureValidator(validator);
         validator.setSchemaLanguage(XMLConstants.RELAXNG_NS_URI);
-        // must use Dom for Msv to work
-        validator.setUseDom(true);
     }
 
     @Override
diff --git a/components/camel-restlet/src/main/docs/restlet-component.adoc b/components/camel-restlet/src/main/docs/restlet-component.adoc
index 5a3aa99..2cc003a 100644
--- a/components/camel-restlet/src/main/docs/restlet-component.adoc
+++ b/components/camel-restlet/src/main/docs/restlet-component.adoc
@@ -121,7 +121,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (18 parameters):
+==== Query Parameters (17 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -133,7 +133,6 @@ with the following path and query parameters:
 | *disableStreamCache* (consumer) | Determines whether or not the raw input stream from Restlet is cached or not (Camel will read the stream into a in memory/overflow to file, Stream caching) cache. By default Camel will cache the Restlet input stream to support reading it multiple times to ensure Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persist [...]
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
-| *restletUriPatterns* (consumer) | *Deprecated* Specify one ore more URI templates to be serviced by a restlet consumer endpoint, using the # notation to reference a List in the Camel Registry. If a URI pattern has been defined in the endpoint URI, both the URI pattern defined in the endpoint and the restletUriPatterns option will be honored. |  | List
 | *connectTimeout* (producer) | The Client will give up connection if the connection is timeout, 0 for unlimited wait. | 30000 | int
 | *cookieHandler* (producer) | Configure a cookie handler to maintain a HTTP session |  | CookieHandler
 | *socketTimeout* (producer) | The Client socket receive timeout, 0 for unlimited wait. | 30000 | int
diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceHelperKeyPairProvider.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceHelperKeyPairProvider.java
index 60062c1..4fa7f9a 100644
--- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceHelperKeyPairProvider.java
+++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceHelperKeyPairProvider.java
@@ -22,8 +22,9 @@ import java.io.InputStreamReader;
 import java.security.KeyPair;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.function.Supplier;
 
-import org.apache.camel.spi.ClassResolver;
+import org.apache.camel.CamelContext;
 import org.apache.camel.util.ResourceHelper;
 import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider;
 import org.apache.sshd.common.util.io.IoUtils;
@@ -32,7 +33,6 @@ import org.bouncycastle.openssl.PEMDecryptorProvider;
 import org.bouncycastle.openssl.PEMEncryptedKeyPair;
 import org.bouncycastle.openssl.PEMKeyPair;
 import org.bouncycastle.openssl.PEMParser;
-import org.bouncycastle.openssl.PasswordFinder;
 import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
 import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
 import org.slf4j.Logger;
@@ -49,33 +49,33 @@ import org.slf4j.LoggerFactory;
 public class ResourceHelperKeyPairProvider extends AbstractKeyPairProvider {
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
-    private ClassResolver classResolver;
+    private CamelContext camelContext;
     private String[] resources;
-    private PasswordFinder passwordFinder;
+    private Supplier<char[]> passwordFinder;
 
     public ResourceHelperKeyPairProvider() {
     }
 
     public ResourceHelperKeyPairProvider(String[] resources,
-                                         ClassResolver classResolver) {
-        this.classResolver = classResolver;
+                                         CamelContext camelContext) {
+        this.camelContext = camelContext;
         this.resources = resources;
     }
 
     public ResourceHelperKeyPairProvider(String[] resources,
-                                         PasswordFinder passwordFinder,
-                                         ClassResolver classResolver) {
-        this.classResolver = classResolver;
+                                         Supplier<char[]> passwordFinder,
+                                         CamelContext camelContext) {
+        this.camelContext = camelContext;
         this.resources = resources;
         this.passwordFinder = passwordFinder;
     }
 
-    public ClassResolver getClassResolver() {
-        return classResolver;
+    public CamelContext getCamelContext() {
+        return camelContext;
     }
 
-    public void setClassResolver(ClassResolver classResolver) {
-        this.classResolver = classResolver;
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
     }
 
     public String[] getResources() {
@@ -86,11 +86,11 @@ public class ResourceHelperKeyPairProvider extends AbstractKeyPairProvider {
         this.resources = resources;
     }
 
-    public PasswordFinder getPasswordFinder() {
+    public Supplier<char[]> getPasswordFinder() {
         return passwordFinder;
     }
 
-    public void setPasswordFinder(PasswordFinder passwordFinder) {
+    public void setPasswordFinder(Supplier<char[]> passwordFinder) {
         this.passwordFinder = passwordFinder;
     }
 
@@ -108,7 +108,7 @@ public class ResourceHelperKeyPairProvider extends AbstractKeyPairProvider {
             InputStreamReader isr = null;
             InputStream is = null;
             try {
-                is = ResourceHelper.resolveMandatoryResourceAsInputStream(classResolver, resource);
+                is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, resource);
                 isr = new InputStreamReader(is);
                 r = new PEMParser(isr);
 
@@ -118,7 +118,7 @@ public class ResourceHelperKeyPairProvider extends AbstractKeyPairProvider {
                 pemConverter.setProvider("BC");
                 if (passwordFinder != null && o instanceof PEMEncryptedKeyPair) {
                     JcePEMDecryptorProviderBuilder decryptorBuilder = new JcePEMDecryptorProviderBuilder();
-                    PEMDecryptorProvider pemDecryptor = decryptorBuilder.build(passwordFinder.getPassword());
+                    PEMDecryptorProvider pemDecryptor = decryptorBuilder.build(passwordFinder.get());
                     o = pemConverter.getKeyPair(((PEMEncryptedKeyPair) o).decryptKeyPair(pemDecryptor));
                 }
                 
diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshHelper.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshHelper.java
index 02082c0..8aa3f2f 100644
--- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshHelper.java
+++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshHelper.java
@@ -82,7 +82,7 @@ public final class SshHelper {
             final String certResource = configuration.getCertResource();
             if (certResource != null) {
                 LOG.debug("Attempting to authenticate using ResourceKey '{}'...", certResource);
-                keyPairProvider = new ResourceHelperKeyPairProvider(new String[]{certResource}, endpoint.getCamelContext().getClassResolver());
+                keyPairProvider = new ResourceHelperKeyPairProvider(new String[]{certResource}, endpoint.getCamelContext());
             } else {
                 keyPairProvider = configuration.getKeyPairProvider();
             }