details = getDetails();
+ if (details != null) {
+ return details.get(attribute);
+ }
+ return null;
+ }
+
+ /**
+ * Get a single detail for a given attribute
+ *
+ * @param attribute the attribute to lookup
+ * @return the detail value or null if no such attribute exists
+ */
+ default Object getDetail(String attribute) {
+ return getDetail(asAttribute(attribute));
+ }
+
+ /**
+ * Convert a string to an {@link Code}
+ *
+ * @param code the code to convert. It should be in all lower case (with
+ * underscore as a separator) to avoid overlap with {@link StandardCode}
+ * @return error code
+ */
+ static Code asCode(String code) {
+ return new ComponentVerifierExtensionHelper.ErrorCode(code);
+ }
+
+ /**
+ * Convert a string to an {@link Attribute}
+ *
+ * @param attribute the string representation of an attribute to convert. It should be in all lower case (with
+ * underscore as a separator) to avoid overlap with standard attributes like {@linkExceptionAttribute},
+ * {@linkHttpAttribute} or {@link GroupAttribute}
+ * @return generated attribute
+ */
+ static Attribute asAttribute(String attribute) {
+ return new ComponentVerifierExtensionHelper.ErrorAttribute(attribute);
+ }
+
+ /**
+ * Interface defining an error code. This is implemented by the {@link StandardCode} but also
+ * own code can be generated by implementing this interface. This is best done via {@link #asCode(String)}
+ * If possible, the standard codes should be reused
+ */
+ interface Code extends Serializable {
+ /**
+ * Name of the code. All uppercase for standard codes, all lower case for custom codes.
+ * Separator between two words is an underscore.
+ *
+ * @return code name
+ */
+ String name();
+
+ /**
+ * Bean style accessor to name.
+ * This is required for framework like Jackson using bean convention for object serialization.
+ *
+ * @return code name
+ */
+ default String getName() {
+ return name();
+ }
+ }
+
+ /**
+ * Standard set of error codes
+ */
+ interface StandardCode extends Code {
+ /**
+ * Authentication failed
+ */
+ StandardCode AUTHENTICATION = new ComponentVerifierExtensionHelper.StandardErrorCode("AUTHENTICATION");
+ /**
+ * An exception occurred
+ */
+ StandardCode EXCEPTION = new ComponentVerifierExtensionHelper.StandardErrorCode("EXCEPTION");
+ /**
+ * Internal error while performing the verification
+ */
+ StandardCode INTERNAL = new ComponentVerifierExtensionHelper.StandardErrorCode("INTERNAL");
+ /**
+ * A mandatory parameter is missing
+ */
+ StandardCode MISSING_PARAMETER = new ComponentVerifierExtensionHelper.StandardErrorCode("MISSING_PARAMETER");
+ /**
+ * A given parameter is not known to the component
+ */
+ StandardCode UNKNOWN_PARAMETER = new ComponentVerifierExtensionHelper.StandardErrorCode("UNKNOWN_PARAMETER");
+ /**
+ * A given parameter is illegal
+ */
+ StandardCode ILLEGAL_PARAMETER = new ComponentVerifierExtensionHelper.StandardErrorCode("ILLEGAL_PARAMETER");
+ /**
+ * A combination of parameters is illegal. See {@link ComponentVerifierExtension.VerificationError#getParameterKeys()} for the set
+ * of affected parameters
+ */
+ StandardCode ILLEGAL_PARAMETER_GROUP_COMBINATION = new ComponentVerifierExtensionHelper.StandardErrorCode("ILLEGAL_PARAMETER_GROUP_COMBINATION");
+ /**
+ * A parameter value is not valid
+ */
+ StandardCode ILLEGAL_PARAMETER_VALUE = new ComponentVerifierExtensionHelper.StandardErrorCode("ILLEGAL_PARAMETER_VALUE");
+ /**
+ * A group of parameters is not complete in order to be valid
+ */
+ StandardCode INCOMPLETE_PARAMETER_GROUP = new ComponentVerifierExtensionHelper.StandardErrorCode("INCOMPLETE_PARAMETER_GROUP");
+ /**
+ * The verification is not supported
+ */
+ StandardCode UNSUPPORTED = new ComponentVerifierExtensionHelper.StandardErrorCode("UNSUPPORTED");
+ /**
+ * The requested {@link ComponentVerifierExtension.Scope} is not supported
+ */
+ StandardCode UNSUPPORTED_SCOPE = new ComponentVerifierExtensionHelper.StandardErrorCode("UNSUPPORTED_SCOPE");
+ /**
+ * The requested {@link Component} is not supported
+ */
+ StandardCode UNSUPPORTED_COMPONENT = new ComponentVerifierExtensionHelper.StandardErrorCode("UNSUPPORTED_COMPONENT");
+ /**
+ * Generic error which is explained in more details with {@link ComponentVerifierExtension.VerificationError#getDetails()}
+ */
+ StandardCode GENERIC = new ComponentVerifierExtensionHelper.StandardErrorCode("GENERIC");
+ }
+
+ /**
+ * Interface defining an attribute which is a key for the detailed error messages. This is implemented by several
+ * standard enums like {@link ExceptionAttribute}, {@link HttpAttribute} or {@link GroupAttribute} but can also
+ * implemented for component specific details. This is best done via {@link #asAttribute(String)}
+ * or using one of the other builder method in this error builder (like {@link ResultErrorBuilder#detail(String, Object)}
+ *
+ * With respecting to name, the same rules as for {@link Code} apply: Standard attributes are all upper case with _
+ * as separators, whereas custom attributes are lower case with underscore separators.
+ */
+ interface Attribute extends Serializable {
+ /**
+ * Name of the attribute. All uppercase for standard attributes and all lower case for custom attributes.
+ * Separator between words is an underscore.
+ *
+ * @return attribute name
+ */
+ String name();
+
+ /**
+ * Bean style accessor to name;
+ * This is required for framework like Jackson using bean convention for object serialization.
+ *
+ * @return attribute name
+ */
+ default String getName() {
+ return name();
+ }
+ }
+
+ /**
+ * Attributes for details about an exception that was raised
+ */
+ interface ExceptionAttribute extends Attribute {
+ /**
+ * The exception object that has been thrown. Note that this can be a complex
+ * object and can cause large content when e.g. serialized as JSON
+ */
+ ExceptionAttribute EXCEPTION_INSTANCE = new ComponentVerifierExtensionHelper.ExceptionErrorAttribute("EXCEPTION_INSTANCE");
+ /**
+ * The exception class
+ */
+ ExceptionAttribute EXCEPTION_CLASS = new ComponentVerifierExtensionHelper.ExceptionErrorAttribute("EXCEPTION_CLASS");
+ }
+
+ /**
+ * HTTP related error details
+ */
+ interface HttpAttribute extends Attribute {
+ /**
+ * The erroneous HTTP code that occurred
+ */
+ HttpAttribute HTTP_CODE = new ComponentVerifierExtensionHelper.HttpErrorAttribute("HTTP_CODE");
+ /**
+ * HTTP response's body
+ */
+ HttpAttribute HTTP_TEXT = new ComponentVerifierExtensionHelper.HttpErrorAttribute("HTTP_TEXT");
+ /**
+ * If given as details, specifies that a redirect happened and the
+ * content of this detail is the redirect URL
+ */
+ HttpAttribute HTTP_REDIRECT = new ComponentVerifierExtensionHelper.HttpErrorAttribute("HTTP_REDIRECT");
+ }
+
+ /**
+ * Group related details
+ */
+ interface GroupAttribute extends Attribute {
+ /**
+ * Group name
+ */
+ GroupAttribute GROUP_NAME = new ComponentVerifierExtensionHelper.GroupErrorAttribute("GROUP_NAME");
+ /**
+ * Options for the group
+ */
+ GroupAttribute GROUP_OPTIONS = new ComponentVerifierExtensionHelper.GroupErrorAttribute("GROUP_OPTIONS");
+ }
+ }
+}
\ No newline at end of file
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java b/camel-core/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java
new file mode 100644
index 0000000000000..9361e6650f12b
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java
@@ -0,0 +1,74 @@
+/**
+ * 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.component.extension;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConversionException;
+
+public interface MetaDataExtension extends ComponentExtension {
+ /**
+ * @param parameters
+ * @return the {@link MetaData}
+ */
+ Optional meta(Map parameters);
+
+ interface MetaData {
+ // Common meta-data attributes
+ String CONTENT_TYPE = Exchange.CONTENT_TYPE;
+ String JAVA_TYPE = "Java-Type";
+
+ /**
+ *
+ * Returns an attribute associated with this meta data by name.
+ *
+ * @param name the attribute name
+ * @return the attribute
+ */
+ Object getAttribute(String name);
+
+ /**
+ *
+ * Returns an attribute associated with this meta data by name and
+ * specifying the type required.
+ *
+ * @param name the attribute name
+ * @param type the type of the attribute
+ * @return the value of the given attribute or null if there is no attribute for the given name
+ * @throws TypeConversionException is thrown if error during type conversion
+ */
+ T getAttribute(String name, Class type);
+
+ /**
+ * Returns the payload of the meta data as a POJO.
+ *
+ * @return the body, can be null
+ */
+ Object getPayload();
+
+ /**
+ * Returns the payload of the meta data as specified type.
+ *
+ * @param type the type that the payload should be converted yo.
+ * @return the payload of the meta data as the specified type.
+ * @throws TypeConversionException is thrown if error during type conversion
+ */
+ T getPayload(Class type);
+ }
+}
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/metadata/AbstractMetaDataExtension.java b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/AbstractMetaDataExtension.java
new file mode 100644
index 0000000000000..c8bd5779f39e8
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/AbstractMetaDataExtension.java
@@ -0,0 +1,65 @@
+/**
+ * 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.component.extension.metadata;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Component;
+import org.apache.camel.ComponentAware;
+import org.apache.camel.component.extension.MetaDataExtension;
+
+public abstract class AbstractMetaDataExtension implements MetaDataExtension, ComponentAware, CamelContextAware {
+ private CamelContext camelContext;
+ private Component component;
+
+ protected AbstractMetaDataExtension() {
+ this(null, null);
+ }
+
+ protected AbstractMetaDataExtension(Component component) {
+ this(component, component.getCamelContext());
+ }
+
+ protected AbstractMetaDataExtension(CamelContext camelContext) {
+ this(null, camelContext);
+ }
+
+ protected AbstractMetaDataExtension(Component component, CamelContext camelContext) {
+ this.component = component;
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public void setComponent(Component component) {
+ this.component = component;
+ }
+
+ @Override
+ public Component getComponent() {
+ return component;
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+}
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/metadata/DefaultMetaData.java b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/DefaultMetaData.java
new file mode 100644
index 0000000000000..b1e2df4b5f5d9
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/DefaultMetaData.java
@@ -0,0 +1,63 @@
+/**
+ * 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.component.extension.metadata;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.extension.MetaDataExtension;
+
+public class DefaultMetaData implements MetaDataExtension.MetaData {
+ private final Map attributes;
+ private final Object payload;
+ private CamelContext camelContext;
+
+ public DefaultMetaData(CamelContext camelContext, Map attributes, Object payload) {
+ this.camelContext = camelContext;
+ this.attributes = attributes;
+ this.payload = payload;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ @Override
+ public T getAttribute(String name, Class type) {
+ Object value = attributes.get(name);
+ if (camelContext != null) {
+ return camelContext.getTypeConverter().convertTo(type, value);
+ }
+
+ throw new IllegalStateException("Unable to perform conversion as CamelContext is not set");
+ }
+
+ @Override
+ public Object getPayload() {
+ return payload;
+ }
+
+ @Override
+ public T getPayload(Class type) {
+ if (camelContext != null) {
+ return camelContext.getTypeConverter().convertTo(type, payload);
+ }
+
+ throw new IllegalStateException("Unable to perform conversion as CamelContext is not set");
+ }
+}
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/metadata/MetaDataBuilder.java b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/MetaDataBuilder.java
new file mode 100644
index 0000000000000..0957c64cb9b5c
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/MetaDataBuilder.java
@@ -0,0 +1,64 @@
+/**
+ * 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.component.extension.metadata;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.extension.MetaDataExtension;
+
+public final class MetaDataBuilder {
+ private final CamelContext camelContext;
+ private Object payload;
+ private Map attributes;
+
+ private MetaDataBuilder(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ public MetaDataBuilder withPayload(Object payload) {
+ this.payload = payload;
+ return this;
+ }
+
+ public MetaDataBuilder withAttribute(String name, Object value) {
+ if (this.attributes == null) {
+ this.attributes = new HashMap<>();
+ }
+
+ this.attributes.put(name, value);
+ return this;
+ }
+
+ public MetaDataExtension.MetaData build() {
+ return new DefaultMetaData(
+ camelContext,
+ attributes == null ? Collections.emptyMap() : attributes,
+ payload
+ );
+ }
+
+ // *****************************
+ //
+ // *****************************
+
+ public static MetaDataBuilder on(CamelContext camelContext) {
+ return new MetaDataBuilder(camelContext);
+ }
+}
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/metadata/package.html b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/package.html
new file mode 100644
index 0000000000000..66873076800ca
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/package.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+MetaData component extension
+
+
+
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/package.html b/camel-core/src/main/java/org/apache/camel/component/extension/package.html
new file mode 100644
index 0000000000000..be2383ac3d9ff
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/package.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+Component extension
+
+
+
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/CatalogVerifierCustomizer.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
similarity index 98%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/CatalogVerifierCustomizer.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
index 43d69935d9836..e8d256a1a8002 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/CatalogVerifierCustomizer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
public class CatalogVerifierCustomizer {
private boolean includeUnknown = true;
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
similarity index 92%
rename from camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
index 358498b90eb6e..690a5715a5d14 100644
--- a/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+package org.apache.camel.component.extension.verifier;
+
+import org.apache.camel.CamelException;
public class ComponentVerifierException extends CamelException {
public ComponentVerifierException() {
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
similarity index 63%
rename from camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
index 7fc811502ff6a..583ccf714e06a 100644
--- a/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
@@ -14,25 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+package org.apache.camel.component.extension.verifier;
-import org.apache.camel.ComponentVerifier.VerificationError.Attribute;
-import org.apache.camel.ComponentVerifier.VerificationError.Code;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.Attribute;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.Code;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.ExceptionAttribute;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.GroupAttribute;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.HttpAttribute;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError.StandardCode;
/**
* Package visible helper class holding implementation classes for
- * constant like error code and attributes in {@link ComponentVerifier.VerificationError}
+ * constant like error code and attributes in {@link ComponentVerifierExtension.VerificationError}
*/
-class ComponentVerifierHelper {
+public final class ComponentVerifierExtensionHelper {
/**
* Custom class for error codes
*/
- static class ErrorCode implements Code {
+ public static class ErrorCode implements Code {
private final String name;
- ErrorCode(String name) {
+ public ErrorCode(String name) {
if (name == null) {
throw new IllegalArgumentException("Name of an error code must not be null");
}
@@ -69,11 +74,11 @@ public String toString() {
}
}
- static class ErrorAttribute implements Attribute {
+ public static class ErrorAttribute implements Attribute {
private final String name;
- ErrorAttribute(String name) {
+ public ErrorAttribute(String name) {
if (name == null) {
throw new IllegalArgumentException("Name of an error attribute must not be null");
}
@@ -114,26 +119,26 @@ public String toString() {
// ===========================================================================================================
// Helper classes for implementing the constants in ComponentVerifier:
- static class StandardErrorCode extends ErrorCode implements ComponentVerifier.VerificationError.StandardCode {
- StandardErrorCode(String name) {
+ public static class StandardErrorCode extends ErrorCode implements StandardCode {
+ public StandardErrorCode(String name) {
super(name);
}
}
- static class ExceptionErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.ExceptionAttribute {
- ExceptionErrorAttribute(String name) {
+ public static class ExceptionErrorAttribute extends ErrorAttribute implements ExceptionAttribute {
+ public ExceptionErrorAttribute(String name) {
super(name);
}
}
- static class HttpErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.HttpAttribute {
- HttpErrorAttribute(String name) {
+ public static class HttpErrorAttribute extends ErrorAttribute implements HttpAttribute {
+ public HttpErrorAttribute(String name) {
super(name);
}
}
- static class GroupErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.GroupAttribute {
- GroupErrorAttribute(String name) {
+ public static class GroupErrorAttribute extends ErrorAttribute implements GroupAttribute {
+ public GroupErrorAttribute(String name) {
super(name);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultComponentVerifier.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java
similarity index 91%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultComponentVerifier.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java
index f05cdb1a2c957..a5495cae1bbf7 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultComponentVerifier.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultComponentVerifierExtension.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.Map;
import java.util.Optional;
@@ -22,9 +22,10 @@
import java.util.stream.Collectors;
import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
import org.apache.camel.ComponentVerifier;
-import org.apache.camel.NoSuchOptionException;
import org.apache.camel.TypeConverter;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
import org.apache.camel.runtimecatalog.EndpointValidationResult;
import org.apache.camel.runtimecatalog.RuntimeCamelCatalog;
import org.apache.camel.util.CamelContextHelper;
@@ -33,11 +34,15 @@
import static org.apache.camel.util.StreamUtils.stream;
-public class DefaultComponentVerifier implements ComponentVerifier {
+public class DefaultComponentVerifierExtension implements ComponentVerifierExtension, ComponentVerifier, CamelContextAware {
private final String defaultScheme;
- private final CamelContext camelContext;
+ private CamelContext camelContext;
- public DefaultComponentVerifier(String defaultScheme, CamelContext camelContext) {
+ public DefaultComponentVerifierExtension(String defaultScheme) {
+ this(defaultScheme, null);
+ }
+
+ public DefaultComponentVerifierExtension(String defaultScheme, CamelContext camelContext) {
this.defaultScheme = defaultScheme;
this.camelContext = camelContext;
}
@@ -46,6 +51,16 @@ public DefaultComponentVerifier(String defaultScheme, CamelContext camelContext)
//
// *************************************
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
@Override
public Result verify(Scope scope, Map parameters) {
// Camel context is mandatory
@@ -149,9 +164,6 @@ protected void verifyParametersAgainstCatalog(ResultBuilder builder, Map T setProperties(T instance, Map properties) throws Exception {
if (camelContext == null) {
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResult.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResult.java
similarity index 68%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResult.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResult.java
index ad36d5f056abd..17a82c055d5b4 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResult.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResult.java
@@ -14,25 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.List;
-import org.apache.camel.ComponentVerifier;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
-public class DefaultResult implements ComponentVerifier.Result {
- private final ComponentVerifier.Scope scope;
+public class DefaultResult implements ComponentVerifierExtension.Result {
+ private final ComponentVerifierExtension.Scope scope;
private final Status status;
- private final List verificationErrors;
+ private final List verificationErrors;
- public DefaultResult(ComponentVerifier.Scope scope, Status status, List verificationErrors) {
+ public DefaultResult(ComponentVerifierExtension.Scope scope, Status status, List verificationErrors) {
this.scope = scope;
this.status = status;
this.verificationErrors = verificationErrors;
}
@Override
- public ComponentVerifier.Scope getScope() {
+ public ComponentVerifierExtension.Scope getScope() {
return scope;
}
@@ -42,7 +42,7 @@ public Status getStatus() {
}
@Override
- public List getErrors() {
+ public List getErrors() {
return verificationErrors;
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResultVerificationError.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResultVerificationError.java
similarity index 93%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResultVerificationError.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResultVerificationError.java
index 8bc872773816b..2255dc1baa2dc 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/DefaultResultVerificationError.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/DefaultResultVerificationError.java
@@ -14,12 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.Map;
import java.util.Set;
-import org.apache.camel.ComponentVerifier.VerificationError;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError;
public class DefaultResultVerificationError implements VerificationError {
private final Code code;
diff --git a/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/IllegalOptionException.java
similarity index 96%
rename from camel-core/src/main/java/org/apache/camel/IllegalOptionException.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/IllegalOptionException.java
index 527eb9dc7b4d4..a8d717db2e0c6 100644
--- a/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/IllegalOptionException.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+package org.apache.camel.component.extension.verifier;
public class IllegalOptionException extends ComponentVerifierException {
private final String optionName;
diff --git a/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/NoSuchOptionException.java
similarity index 95%
rename from camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/NoSuchOptionException.java
index 3f1d561a9f697..a03d9f02b96d9 100644
--- a/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/NoSuchOptionException.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+package org.apache.camel.component.extension.verifier;
public class NoSuchOptionException extends ComponentVerifierException {
private final String optionName;
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/OptionsGroup.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/OptionsGroup.java
similarity index 98%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/OptionsGroup.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/OptionsGroup.java
index 1df438335519d..62f81c4217f38 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/OptionsGroup.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/OptionsGroup.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.io.Serializable;
import java.util.Arrays;
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultBuilder.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultBuilder.java
similarity index 69%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/ResultBuilder.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultBuilder.java
index 5e8ddae9d234c..637bd08fd2b47 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.ArrayList;
import java.util.Collections;
@@ -22,16 +22,14 @@
import java.util.Optional;
import java.util.function.Supplier;
-import org.apache.camel.ComponentVerifier;
-import org.apache.camel.IllegalOptionException;
-import org.apache.camel.NoSuchOptionException;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
import org.apache.camel.util.function.ThrowingBiConsumer;
import org.apache.camel.util.function.ThrowingConsumer;
public final class ResultBuilder {
- private Optional scope;
- private Optional status;
- private List verificationErrors;
+ private Optional scope;
+ private Optional status;
+ private List verificationErrors;
public ResultBuilder() {
this.scope = Optional.empty();
@@ -42,33 +40,33 @@ public ResultBuilder() {
// Accessors
// **********************************
- public ResultBuilder scope(ComponentVerifier.Scope scope) {
+ public ResultBuilder scope(ComponentVerifierExtension.Scope scope) {
this.scope = Optional.of(scope);
return this;
}
- public ResultBuilder status(ComponentVerifier.Result.Status status) {
+ public ResultBuilder status(ComponentVerifierExtension.Result.Status status) {
this.status = Optional.of(status);
return this;
}
- public ResultBuilder error(ComponentVerifier.VerificationError verificationError) {
+ public ResultBuilder error(ComponentVerifierExtension.VerificationError verificationError) {
if (this.verificationErrors == null) {
this.verificationErrors = new ArrayList<>();
}
this.verificationErrors.add(verificationError);
- this.status = Optional.of(ComponentVerifier.Result.Status.ERROR);
+ this.status = Optional.of(ComponentVerifierExtension.Result.Status.ERROR);
return this;
}
- public ResultBuilder error(Optional error) {
+ public ResultBuilder error(Optional error) {
error.ifPresent(e -> error(e));
return this;
}
- public ResultBuilder error(Supplier> supplier) {
+ public ResultBuilder error(Supplier> supplier) {
return error(supplier.get());
}
@@ -100,7 +98,7 @@ public ResultBuilder error(T data, ThrowingBiConsumer verificationErrors) {
+ public ResultBuilder errors(List verificationErrors) {
verificationErrors.forEach(this::error);
return this;
}
@@ -109,10 +107,10 @@ public ResultBuilder errors(List verificati
// Build
// **********************************
- public ComponentVerifier.Result build() {
+ public ComponentVerifierExtension.Result build() {
return new DefaultResult(
- scope.orElse(ComponentVerifier.Scope.PARAMETERS),
- status.orElse(ComponentVerifier.Result.Status.UNSUPPORTED),
+ scope.orElse(ComponentVerifierExtension.Scope.PARAMETERS),
+ status.orElse(ComponentVerifierExtension.Result.Status.UNSUPPORTED),
verificationErrors != null ? Collections.unmodifiableList(verificationErrors) : Collections.emptyList()
);
}
@@ -121,23 +119,23 @@ public ComponentVerifier.Result build() {
// Helpers
// **********************************
- public static ResultBuilder withStatus(ComponentVerifier.Result.Status status) {
+ public static ResultBuilder withStatus(ComponentVerifierExtension.Result.Status status) {
return new ResultBuilder().status(status);
}
- public static ResultBuilder withStatusAndScope(ComponentVerifier.Result.Status status, ComponentVerifier.Scope scope) {
+ public static ResultBuilder withStatusAndScope(ComponentVerifierExtension.Result.Status status, ComponentVerifierExtension.Scope scope) {
return new ResultBuilder().status(status).scope(scope);
}
- public static ResultBuilder withScope(ComponentVerifier.Scope scope) {
+ public static ResultBuilder withScope(ComponentVerifierExtension.Scope scope) {
return new ResultBuilder().scope(scope);
}
public static ResultBuilder unsupported() {
- return withStatusAndScope(ComponentVerifier.Result.Status.UNSUPPORTED, ComponentVerifier.Scope.PARAMETERS);
+ return withStatusAndScope(ComponentVerifierExtension.Result.Status.UNSUPPORTED, ComponentVerifierExtension.Scope.PARAMETERS);
}
- public static ResultBuilder unsupportedScope(ComponentVerifier.Scope scope) {
- return withStatusAndScope(ComponentVerifier.Result.Status.UNSUPPORTED, scope);
+ public static ResultBuilder unsupportedScope(ComponentVerifierExtension.Scope scope) {
+ return withStatusAndScope(ComponentVerifierExtension.Result.Status.UNSUPPORTED, scope);
}
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorBuilder.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorBuilder.java
similarity index 98%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorBuilder.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorBuilder.java
index daadb48509d9b..313e9c2b70c43 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.Collection;
import java.util.Collections;
@@ -25,7 +25,7 @@
import java.util.Set;
import java.util.function.Supplier;
-import org.apache.camel.ComponentVerifier.VerificationError;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError;
import org.apache.camel.util.ObjectHelper;
public final class ResultErrorBuilder {
diff --git a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorHelper.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorHelper.java
similarity index 97%
rename from camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorHelper.java
rename to camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorHelper.java
index fb0dfc0c64de1..d03307e590ccf 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/verifier/ResultErrorHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ResultErrorHelper.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.impl.verifier;
+package org.apache.camel.component.extension.verifier;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,7 +28,7 @@
import java.util.TreeSet;
import java.util.stream.Collectors;
-import org.apache.camel.ComponentVerifier.VerificationError;
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError;
import org.apache.camel.util.ObjectHelper;
/**
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/verifier/package.html b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/package.html
new file mode 100644
index 0000000000000..cfeb0f5e5a496
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/package.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+Verifier component extension
+
+
+
diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/RestComponent.java b/camel-core/src/main/java/org/apache/camel/component/rest/RestComponent.java
index 264750cdede7d..e2651a2d20ded 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestComponent.java
@@ -27,6 +27,7 @@
import org.apache.camel.ComponentVerifier;
import org.apache.camel.Endpoint;
import org.apache.camel.VerifiableComponent;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.model.rest.RestConstants;
import org.apache.camel.spi.Metadata;
@@ -50,6 +51,10 @@ public class RestComponent extends DefaultComponent implements VerifiableCompone
@Metadata(label = "producer")
private String host;
+ public RestComponent() {
+ registerExtension(RestComponentVerifierExtension::new);
+ }
+
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
String restConfigurationName = getAndRemoveParameter(parameters, "componentName", String.class, componentName);
@@ -235,13 +240,8 @@ private void mergeProperties(Supplier