You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/08/04 16:09:58 UTC
[07/19] camel git commit: CAMEL-11550: Component extensions
CAMEL-11550: Component extensions
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/42529399
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/42529399
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/42529399
Branch: refs/heads/master
Commit: 4252939938f6603080fb8adda750872a8001a74b
Parents: f347292
Author: lburgazzoli <lb...@gmail.com>
Authored: Tue Jul 18 18:47:28 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Fri Aug 4 18:09:04 2017 +0200
----------------------------------------------------------------------
.../main/java/org/apache/camel/Component.java | 25 ++
.../java/org/apache/camel/ComponentAware.java | 61 +++
.../org/apache/camel/ComponentVerifier.java | 361 +----------------
.../camel/ComponentVerifierException.java | 34 --
.../apache/camel/ComponentVerifierHelper.java | 140 -------
.../apache/camel/IllegalOptionException.java | 39 --
.../org/apache/camel/NoSuchOptionException.java | 29 --
.../org/apache/camel/VerifiableComponent.java | 3 +
.../component/extension/ComponentExtension.java | 26 ++
.../extension/ComponentExtensionHelper.java | 43 +++
.../extension/ComponentVerifierExtension.java | 385 +++++++++++++++++++
.../component/extension/MetaDataExtension.java | 74 ++++
.../metadata/AbstractMetaDataExtension.java | 65 ++++
.../extension/metadata/DefaultMetaData.java | 63 +++
.../extension/metadata/MetaDataBuilder.java | 64 +++
.../component/extension/metadata/package.html | 25 ++
.../camel/component/extension/package.html | 25 ++
.../verifier/CatalogVerifierCustomizer.java | 104 +++++
.../verifier/ComponentVerifierException.java | 36 ++
.../ComponentVerifierExtensionHelper.java | 145 +++++++
.../DefaultComponentVerifierExtension.java | 214 +++++++++++
.../extension/verifier/DefaultResult.java | 57 +++
.../DefaultResultVerificationError.java | 66 ++++
.../verifier/IllegalOptionException.java | 39 ++
.../verifier/NoSuchOptionException.java | 29 ++
.../extension/verifier/OptionsGroup.java | 142 +++++++
.../extension/verifier/ResultBuilder.java | 141 +++++++
.../extension/verifier/ResultErrorBuilder.java | 213 ++++++++++
.../extension/verifier/ResultErrorHelper.java | 164 ++++++++
.../component/extension/verifier/package.html | 25 ++
.../camel/component/rest/RestComponent.java | 12 +-
.../component/rest/RestComponentVerifier.java | 152 --------
.../rest/RestComponentVerifierExtension.java | 151 ++++++++
.../org/apache/camel/impl/DefaultComponent.java | 36 ++
.../verifier/CatalogVerifierCustomizer.java | 104 -----
.../impl/verifier/DefaultComponentVerifier.java | 202 ----------
.../camel/impl/verifier/DefaultResult.java | 57 ---
.../DefaultResultVerificationError.java | 66 ----
.../camel/impl/verifier/OptionsGroup.java | 142 -------
.../camel/impl/verifier/ResultBuilder.java | 143 -------
.../camel/impl/verifier/ResultErrorBuilder.java | 213 ----------
.../camel/impl/verifier/ResultErrorHelper.java | 164 --------
.../management/mbean/ManagedComponent.java | 5 +-
.../apache/camel/util/CamelContextHelper.java | 2 +-
.../org/apache/camel/ComponentVerifierTest.java | 66 ----
.../verifier/ComponentVerifierTest.java | 66 ++++
.../RestComponentVerifierExtensionTest.java | 141 +++++++
.../rest/RestComponentVerifierTest.java | 32 +-
.../verifier/DefaultComponentVerifierTest.java | 23 +-
.../impl/verifier/ResultErrorHelperTest.java | 9 +-
.../camel/management/ManagedComponentTest.java | 6 +-
.../camel/component/http/HttpComponent.java | 11 +-
.../component/http/HttpComponentVerifier.java | 250 ------------
.../http/HttpComponentVerifierExtension.java | 246 ++++++++++++
.../http/CamelComponentVerifierTest.java | 192 ---------
.../HttpComponentVerifierExtensionTest.java | 151 ++++++++
.../http/HttpComponentVerifierTest.java | 150 ++++++++
.../camel/component/http4/HttpComponent.java | 11 +-
.../component/http4/HttpComponentVerifier.java | 250 ------------
.../http4/HttpComponentVerifierExtension.java | 248 ++++++++++++
.../CamelComponentVerifierExtensionTest.java | 263 +++++++++++++
.../http4/CamelComponentVerifierTest.java | 43 ++-
.../salesforce/SalesforceComponent.java | 7 +-
.../salesforce/SalesforceComponentVerifier.java | 204 ----------
.../SalesforceComponentVerifierExtension.java | 205 ++++++++++
...alesforceComponentVerifierExtensionTest.java | 183 +++++++++
.../SalesforceComponentVerifierTest.java | 27 +-
.../servicenow/ServiceNowComponent.java | 37 +-
.../servicenow/ServiceNowComponentVerifier.java | 113 ------
.../ServiceNowComponentVerifierExtension.java | 112 ++++++
...erviceNowComponentVerifierExtensionTest.java | 151 ++++++++
.../ServiceNowComponentVerifierTest.java | 32 +-
.../twitter/AbstractTwitterComponent.java | 17 +-
.../DefaultTwitterComponentVerifier.java | 95 -----
.../component/twitter/TwitterComponent.java | 18 +-
.../TwitterComponentVerifierExtension.java | 94 +++++
.../TwitterDirectMessageComponent.java | 19 +-
.../twitter/search/TwitterSearchComponent.java | 20 +-
.../streaming/TwitterStreamingComponent.java | 19 +-
.../timeline/TwitterTimelineComponent.java | 18 +-
.../AbstractComponentVerifierExtensionTest.java | 82 ++++
.../twitter/AbstractComponentVerifierTest.java | 81 ++++
.../twitter/CamelComponentVerifierTest.java | 123 ------
.../TwitterComponentVerifierExtensionTest.java | 24 ++
.../twitter/TwitterComponentVerifierTest.java | 24 ++
...ctmessageComponentVerifierExtensionTest.java | 26 ++
...itterDirectmessageComponentVerifierTest.java | 26 ++
...terSearchComponentVerifierExtensionTest.java | 72 ++++
.../TwitterSearchComponentVerifierTest.java | 72 ++++
...StreamingComponentVerifierExtensionTest.java | 26 ++
.../TwitterStreamingComponentVerifierTest.java | 26 ++
...rTimelineComponentVerifierExtensionTest.java | 26 ++
.../TwitterTimelineComponentVerifierTest.java | 26 ++
.../component/undertow/UndertowComponent.java | 10 +-
.../undertow/UndertowComponentVerifier.java | 239 ------------
.../UndertowComponentVerifierExtension.java | 236 ++++++++++++
.../UndertowComponentVerifierExtensionTest.java | 104 +++++
.../SpringBootAutoConfigurationMojo.java | 2 +-
.../connector/DefaultConnectorComponent.java | 28 +-
99 files changed, 5515 insertions(+), 3553 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/Component.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/Component.java b/camel-core/src/main/java/org/apache/camel/Component.java
index d873470..b21e7a4 100644
--- a/camel-core/src/main/java/org/apache/camel/Component.java
+++ b/camel-core/src/main/java/org/apache/camel/Component.java
@@ -16,6 +16,12 @@
*/
package org.apache.camel;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+
+import org.apache.camel.component.extension.ComponentExtension;
+
/**
* A <a href="http://camel.apache.org/component.html">component</a> is
* a factory of {@link Endpoint} objects.
@@ -73,4 +79,23 @@ public interface Component extends CamelContextAware {
*/
@Deprecated
ComponentConfiguration createComponentConfiguration();
+
+ /**
+ * Gets a list of supported extensions.
+ *
+ * @return the list of extensions.
+ */
+ default Collection<Class<? extends ComponentExtension>> getSupportedExtensions() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Gets the extension of the given type.
+ *
+ * @param extensionType tye type of the extensions
+ * @return an optional extension
+ */
+ default <T extends ComponentExtension> Optional<T> getExtension(Class<T> extensionType) {
+ return Optional.empty();
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/ComponentAware.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentAware.java b/camel-core/src/main/java/org/apache/camel/ComponentAware.java
new file mode 100644
index 0000000..88f7a31
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/ComponentAware.java
@@ -0,0 +1,61 @@
+/**
+ * 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;
+
+/**
+ * An interface to represent an object which wishes to be injected with
+ * a {@link Component}.
+ */
+public interface ComponentAware {
+
+ /**
+ * Injects the {@link Component}
+ *
+ * @param component the component
+ */
+ void setComponent(Component component);
+
+ /**
+ * Get the {@link Component}
+ *
+ * @return the component
+ */
+ Component getComponent();
+
+ /**
+ * Get the {@link Component} as the specified type.
+ *
+ * @param type the proprietary class or interface of the underlying concrete Component.
+ * @return an instance of the underlying concrete Component as the required type.
+ * @throws IllegalArgumentException if the component class can't be cast to required type,
+ */
+ default <T extends Component> T getComponent(Class<T> type) {
+ final Component component = getComponent();
+
+ if (component == null) {
+ return null;
+ }
+
+ if (Component.class.isAssignableFrom(type)) {
+ return type.cast(component);
+ }
+
+ throw new IllegalArgumentException(
+ "Unable to unwrap the Component type (" + component.getClass() + ") to the required type (" + type + ")"
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/ComponentVerifier.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentVerifier.java b/camel-core/src/main/java/org/apache/camel/ComponentVerifier.java
index bcbda7c..d95a7e7 100644
--- a/camel-core/src/main/java/org/apache/camel/ComponentVerifier.java
+++ b/camel-core/src/main/java/org/apache/camel/ComponentVerifier.java
@@ -16,14 +16,9 @@
*/
package org.apache.camel;
-import java.io.Serializable;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.camel.ComponentVerifierHelper.ExceptionErrorAttribute;
-import org.apache.camel.impl.verifier.ResultErrorBuilder;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.component.extension.ComponentVerifierExtension;
/**
* Defines the interface used for validating component/endpoint parameters. The central method of this
@@ -31,356 +26,8 @@ import org.apache.camel.util.ObjectHelper;
* <p/>
* The return value is a {@link Result} of the verification
*
+ * @deprecated use {@link ComponentVerifierExtension}
*/
-public interface ComponentVerifier {
-
- /**
- * Verify the given parameters against a provided scope.
- *
- * <p>
- * The supported scopes are:
- * <ul>
- * <li><strong>{@link Scope#PARAMETERS}</strong>: to validate that all the mandatory options are provided and syntactically correct.</li>
- * <li><strong>{@link Scope#CONNECTIVITY}</strong>: to validate that the given options (i.e. credentials, addresses) are correct. Verifying with this
- * scope typically implies reaching out to the backend via some sort of network connection.</li>
- * </ul>
- *
- * @param scope the scope of the verification
- * @param parameters the parameters to verify which are interpreted individually by each component verifier
- * @return the verification result
- */
- Result verify(Scope scope, Map<String, Object> parameters);
-
- /**
- * The result of a verification
- */
- interface Result extends Serializable {
-
- /**
- * Status of the verification
- */
- enum Status {
- /**
- * Verification succeeded
- */
- OK,
- /**
- * Error occurred during the verification
- */
- ERROR,
- /**
- * Verification is not supported. This can depend on the given scope.
- */
- UNSUPPORTED
- }
-
- /**
- * Scope of the verification. This is the scope given to the call to {@link #verify(Scope, Map)} and
- * can be used for correlation.
- *
- * @return the scope against which the parameters have been validated.
- */
- Scope getScope();
-
- /**
- * Result of the validation as status. This should be the first datum to check after a verification
- * happened.
- *
- * @return the status
- */
- Status getStatus();
-
- /**
- * Collection of errors happened for the verification. This list is empty (but non null) if the verification
- * succeeded.
- *
- * @return a list of errors. Can be empty when verification was successful
- */
- List<VerificationError> getErrors();
- }
-
- /**
- * The scope defines how the parameters should be verified.
- */
- enum Scope {
- /**
- * Only validate the parameters for their <em>syntactic</em> soundness. Verifications in this scope should
- * be as fast as possible
- */
- PARAMETERS,
-
- /**
- * Reach out to the backend and verify that a connection can be established. This means, if the verification
- * in this scope succeeds, then it can safely be assumed that the component can be used.
- */
- CONNECTIVITY;
-
- private static final Scope[] VALUES = values();
-
- /**
- * Get an instance of this scope from a string representation
- *
- * @param scope the scope as string, which can be in any case
- * @return the scope enum represented by this string
- */
- public static Scope fromString(String scope) {
- for (Scope value : VALUES) {
- if (ObjectHelper.equal(scope, value.name(), true)) {
- return value;
- }
- }
- throw new IllegalArgumentException("Unknown scope <" + scope + ">");
- }
- }
-
- // =============================================================================================
-
- /**
- * This interface represents a detailed error in case when the verification fails.
- */
- interface VerificationError extends Serializable {
-
- /**
- * The overall error code, which can be either a {@link StandardCode} or a custom code. It is
- * recommended to stick to the predefined standard codes
- *
- * @return the general error code.
- */
- Code getCode();
-
- /**
- * A human readable description of the error in plain english
- *
- * @return the error description (if available)
- */
- String getDescription();
-
- /**
- * A set of input parameter names which fails the verification. These are keys to the parameter provided
- * to {@link #verify(Scope, Map)}.
- *
- * @return the parameter names which are malformed and caused the failure of the validation
- */
- Set<String> getParameterKeys();
-
- /**
- * Details about the failed verification. The keys can be either predefined values
- * ({@link ExceptionAttribute}, {@link HttpAttribute}, {@link GroupAttribute}) or it can be free-form
- * custom keys specific to a component. The standard attributes are defined as enums in all uppercase (with
- * underscore as separator), custom attributes are supposed to be in all lower case (also with underscores
- * as separators)
- *
- * @return a number of key/value pair with additional information related to the verification.
- */
- Map<Attribute, Object> getDetails();
-
- /**
- * 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(Attribute attribute) {
- Map<Attribute, Object> 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 ComponentVerifierHelper.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 {@link ExceptionAttribute},
- * {@link HttpAttribute} or {@link GroupAttribute}
- * @return generated attribute
- */
- static Attribute asAttribute(String attribute) {
- return new ComponentVerifierHelper.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 ComponentVerifierHelper.StandardErrorCode("AUTHENTICATION");
- /**
- * An exception occurred
- */
- StandardCode EXCEPTION = new ComponentVerifierHelper.StandardErrorCode("EXCEPTION");
- /**
- * Internal error while performing the verification
- */
- StandardCode INTERNAL = new ComponentVerifierHelper.StandardErrorCode("INTERNAL");
- /**
- * A mandatory parameter is missing
- */
- StandardCode MISSING_PARAMETER = new ComponentVerifierHelper.StandardErrorCode("MISSING_PARAMETER");
- /**
- * A given parameter is not known to the component
- */
- StandardCode UNKNOWN_PARAMETER = new ComponentVerifierHelper.StandardErrorCode("UNKNOWN_PARAMETER");
- /**
- * A given parameter is illegal
- */
- StandardCode ILLEGAL_PARAMETER = new ComponentVerifierHelper.StandardErrorCode("ILLEGAL_PARAMETER");
- /**
- * A combination of parameters is illegal. See {@link VerificationError#getParameterKeys()} for the set
- * of affected parameters
- */
- StandardCode ILLEGAL_PARAMETER_GROUP_COMBINATION = new ComponentVerifierHelper.StandardErrorCode("ILLEGAL_PARAMETER_GROUP_COMBINATION");
- /**
- * A parameter <em>value</em> is not valid
- */
- StandardCode ILLEGAL_PARAMETER_VALUE = new ComponentVerifierHelper.StandardErrorCode("ILLEGAL_PARAMETER_VALUE");
- /**
- * A group of parameters is not complete in order to be valid
- */
- StandardCode INCOMPLETE_PARAMETER_GROUP = new ComponentVerifierHelper.StandardErrorCode("INCOMPLETE_PARAMETER_GROUP");
- /**
- * The verification is not supported
- */
- StandardCode UNSUPPORTED = new ComponentVerifierHelper.StandardErrorCode("UNSUPPORTED");
- /**
- * The requested {@link Scope} is not supported
- */
- StandardCode UNSUPPORTED_SCOPE = new ComponentVerifierHelper.StandardErrorCode("UNSUPPORTED_SCOPE");
- /**
- * The requested {@link Component} is not supported
- */
- StandardCode UNSUPPORTED_COMPONENT = new ComponentVerifierHelper.StandardErrorCode("UNSUPPORTED_COMPONENT");
- /**
- * Generic error which is explained in more details with {@link VerificationError#getDetails()}
- */
- StandardCode GENERIC = new ComponentVerifierHelper.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)}
- * <p>
- * 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 ExceptionErrorAttribute("EXCEPTION_INSTANCE");
- /**
- * The exception class
- */
- ExceptionAttribute EXCEPTION_CLASS = new ExceptionErrorAttribute("EXCEPTION_CLASS");
- }
-
- /**
- * HTTP related error details
- */
- interface HttpAttribute extends Attribute {
- /**
- * The erroneous HTTP code that occurred
- */
- HttpAttribute HTTP_CODE = new ComponentVerifierHelper.HttpErrorAttribute("HTTP_CODE");
- /**
- * HTTP response's body
- */
- HttpAttribute HTTP_TEXT = new ComponentVerifierHelper.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 ComponentVerifierHelper.HttpErrorAttribute("HTTP_REDIRECT");
- }
-
- /**
- * Group related details
- */
- interface GroupAttribute extends Attribute {
- /**
- * Group name
- */
- GroupAttribute GROUP_NAME = new ComponentVerifierHelper.GroupErrorAttribute("GROUP_NAME");
- /**
- * Options for the group
- */
- GroupAttribute GROUP_OPTIONS = new ComponentVerifierHelper.GroupErrorAttribute("GROUP_OPTIONS");
- }
- }
-
+@Deprecated
+public interface ComponentVerifier extends ComponentVerifierExtension {
}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java b/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java
deleted file mode 100644
index 358498b..0000000
--- a/camel-core/src/main/java/org/apache/camel/ComponentVerifierException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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;
-
-public class ComponentVerifierException extends CamelException {
- public ComponentVerifierException() {
- }
-
- public ComponentVerifierException(String message) {
- super(message);
- }
-
- public ComponentVerifierException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ComponentVerifierException(Throwable cause) {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java b/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java
deleted file mode 100644
index 7fc8115..0000000
--- a/camel-core/src/main/java/org/apache/camel/ComponentVerifierHelper.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * 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;
-
-import org.apache.camel.ComponentVerifier.VerificationError.Attribute;
-import org.apache.camel.ComponentVerifier.VerificationError.Code;
-
-/**
- * Package visible helper class holding implementation classes for
- * constant like error code and attributes in {@link ComponentVerifier.VerificationError}
- */
-class ComponentVerifierHelper {
-
- /**
- * Custom class for error codes
- */
- static class ErrorCode implements Code {
-
- private final String name;
-
- ErrorCode(String name) {
- if (name == null) {
- throw new IllegalArgumentException("Name of an error code must not be null");
- }
- this.name = name;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof Code)) {
- return false;
- }
-
- Code errorCode = (Code) o;
-
- return name.equals(errorCode.name());
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
- @Override
- public String toString() {
- return name();
- }
- }
-
- static class ErrorAttribute implements Attribute {
-
- private final String name;
-
- ErrorAttribute(String name) {
- if (name == null) {
- throw new IllegalArgumentException("Name of an error attribute must not be null");
- }
- this.name = name;
- }
-
- @Override
- public String name() {
- return name;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof Attribute)) {
- return false;
- }
-
- Attribute that = (Attribute) o;
-
- return name.equals(that.name());
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
- @Override
- public String toString() {
- return name();
- }
- }
-
- // ===========================================================================================================
- // Helper classes for implementing the constants in ComponentVerifier:
-
- static class StandardErrorCode extends ErrorCode implements ComponentVerifier.VerificationError.StandardCode {
- StandardErrorCode(String name) {
- super(name);
- }
- }
-
- static class ExceptionErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.ExceptionAttribute {
- ExceptionErrorAttribute(String name) {
- super(name);
- }
- }
-
- static class HttpErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.HttpAttribute {
- HttpErrorAttribute(String name) {
- super(name);
- }
- }
-
- static class GroupErrorAttribute extends ErrorAttribute implements ComponentVerifier.VerificationError.GroupAttribute {
- GroupErrorAttribute(String name) {
- super(name);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java b/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java
deleted file mode 100644
index 527eb9d..0000000
--- a/camel-core/src/main/java/org/apache/camel/IllegalOptionException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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;
-
-public class IllegalOptionException extends ComponentVerifierException {
- private final String optionName;
- private final String optionValue;
-
- public IllegalOptionException(String optionName) {
- this(optionName, null);
- }
-
- public IllegalOptionException(String optionName, String optionValue) {
- this.optionName = optionName;
- this.optionValue = optionValue;
- }
-
- public String getOptionName() {
- return optionName;
- }
-
- public String getOptionValue() {
- return optionValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java b/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java
deleted file mode 100644
index 3f1d561..0000000
--- a/camel-core/src/main/java/org/apache/camel/NoSuchOptionException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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;
-
-public class NoSuchOptionException extends ComponentVerifierException {
- private final String optionName;
-
- public NoSuchOptionException(String optionName) {
- this.optionName = optionName;
- }
-
- public String getOptionName() {
- return optionName;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/VerifiableComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/VerifiableComponent.java b/camel-core/src/main/java/org/apache/camel/VerifiableComponent.java
index 2b95404..2e2b6f6 100644
--- a/camel-core/src/main/java/org/apache/camel/VerifiableComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/VerifiableComponent.java
@@ -18,7 +18,10 @@ package org.apache.camel;
/**
* An interface to represent an object which support validation
+ *
+ * @deprecated see {@link org.apache.camel.extension.ComponentExtension}
*/
+@Deprecated
public interface VerifiableComponent {
/**
* Get the {@link ComponentVerifier}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
new file mode 100644
index 0000000..8d90d31
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
@@ -0,0 +1,26 @@
+/**
+ * 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;
+
+/**
+ * Marker interface for component extensions.
+ * <p/>
+ * An extension is a feature provided by the component such as ComponentVerifier,
+ * ServiceMetaData.
+ */
+public interface ComponentExtension {
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtensionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtensionHelper.java b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtensionHelper.java
new file mode 100644
index 0000000..3487b3c
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtensionHelper.java
@@ -0,0 +1,43 @@
+/**
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Component;
+import org.apache.camel.ComponentAware;
+
+public final class ComponentExtensionHelper {
+ private ComponentExtensionHelper() {
+ }
+
+ public static <T> T trySetCamelContext(T object, CamelContext camelContext) {
+ if (object instanceof CamelContextAware) {
+ ((CamelContextAware) object).setCamelContext(camelContext);
+ }
+
+ return object;
+ }
+
+ public static <T> T trySetComponent(T object, Component component) {
+ if (object instanceof ComponentAware) {
+ ((ComponentAware) object).setComponent(component);
+ }
+
+ return object;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java
new file mode 100644
index 0000000..f9acf0e
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java
@@ -0,0 +1,385 @@
+/**
+ * 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.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.Component;
+import org.apache.camel.component.extension.verifier.ComponentVerifierExtensionHelper;
+import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
+import org.apache.camel.util.ObjectHelper;
+/**
+ * Defines the interface used for validating component/endpoint parameters. The central method of this
+ * interface is {@link #verify(ComponentVerifierExtension.Scope, Map)} which takes a scope and a set of parameters which should be verified.
+ * <p/>
+ * The return value is a {@link ComponentVerifierExtension.Result} of the verification
+ *
+ */
+public interface ComponentVerifierExtension extends ComponentExtension {
+
+ /**
+ * Verify the given parameters against a provided scope.
+ *
+ * <p>
+ * The supported scopes are:
+ * <ul>
+ * <li><strong>{@link ComponentVerifierExtension.Scope#PARAMETERS}</strong>: to validate that all the mandatory options are provided and syntactically correct.</li>
+ * <li><strong>{@link ComponentVerifierExtension.Scope#CONNECTIVITY}</strong>: to validate that the given options (i.e. credentials, addresses) are correct. Verifying with this
+ * scope typically implies reaching out to the backend via some sort of network connection.</li>
+ * </ul>
+ *
+ * @param scope the scope of the verification
+ * @param parameters the parameters to verify which are interpreted individually by each component verifier
+ * @return the verification result
+ */
+ ComponentVerifierExtension.Result verify(ComponentVerifierExtension.Scope scope, Map<String, Object> parameters);
+
+ /**
+ * The result of a verification
+ */
+ interface Result extends Serializable {
+
+ /**
+ * Status of the verification
+ */
+ enum Status {
+ /**
+ * Verification succeeded
+ */
+ OK,
+ /**
+ * Error occurred during the verification
+ */
+ ERROR,
+ /**
+ * Verification is not supported. This can depend on the given scope.
+ */
+ UNSUPPORTED
+ }
+
+ /**
+ * Scope of the verification. This is the scope given to the call to {@link #verify(ComponentVerifierExtension.Scope, Map)} and
+ * can be used for correlation.
+ *
+ * @return the scope against which the parameters have been validated.
+ */
+ ComponentVerifierExtension.Scope getScope();
+
+ /**
+ * Result of the validation as status. This should be the first datum to check after a verification
+ * happened.
+ *
+ * @return the status
+ */
+ ComponentVerifierExtension.Result.Status getStatus();
+
+ /**
+ * Collection of errors happened for the verification. This list is empty (but non null) if the verification
+ * succeeded.
+ *
+ * @return a list of errors. Can be empty when verification was successful
+ */
+ List<ComponentVerifierExtension.VerificationError> getErrors();
+ }
+
+ /**
+ * The scope defines how the parameters should be verified.
+ */
+ enum Scope {
+ /**
+ * Only validate the parameters for their <em>syntactic</em> soundness. Verifications in this scope should
+ * be as fast as possible
+ */
+ PARAMETERS,
+
+ /**
+ * Reach out to the backend and verify that a connection can be established. This means, if the verification
+ * in this scope succeeds, then it can safely be assumed that the component can be used.
+ */
+ CONNECTIVITY;
+
+ private static final ComponentVerifierExtension.Scope[] VALUES = values();
+
+ /**
+ * Get an instance of this scope from a string representation
+ *
+ * @param scope the scope as string, which can be in any case
+ * @return the scope enum represented by this string
+ */
+ public static ComponentVerifierExtension.Scope fromString(String scope) {
+ for (ComponentVerifierExtension.Scope value : VALUES) {
+ if (ObjectHelper.equal(scope, value.name(), true)) {
+ return value;
+ }
+ }
+ throw new IllegalArgumentException("Unknown scope <" + scope + ">");
+ }
+ }
+
+ // =============================================================================================
+
+ /**
+ * This interface represents a detailed error in case when the verification fails.
+ */
+ interface VerificationError extends Serializable {
+
+ /**
+ * The overall error code, which can be either a {@link StandardCode} or a custom code. It is
+ * recommended to stick to the predefined standard codes
+ *
+ * @return the general error code.
+ */
+ Code getCode();
+
+ /**
+ * A human readable description of the error in plain english
+ *
+ * @return the error description (if available)
+ */
+ String getDescription();
+
+ /**
+ * A set of input parameter names which fails the verification. These are keys to the parameter provided
+ * to {@link #verify(ComponentVerifierExtension.Scope, Map)}.
+ *
+ * @return the parameter names which are malformed and caused the failure of the validation
+ */
+ Set<String> getParameterKeys();
+
+ /**
+ * Details about the failed verification. The keys can be either predefined values
+ * ({@link ExceptionAttribute}, {@link HttpAttribute}, {@link GroupAttribute}) or it can be free-form
+ * custom keys specific to a component. The standard attributes are defined as enums in all uppercase (with
+ * underscore as separator), custom attributes are supposed to be in all lower case (also with underscores
+ * as separators)
+ *
+ * @return a number of key/value pair with additional information related to the verification.
+ */
+ Map<ComponentVerifierExtension.VerificationError.Attribute, Object> getDetails();
+
+ /**
+ * 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(ComponentVerifierExtension.VerificationError.Attribute attribute) {
+ Map<ComponentVerifierExtension.VerificationError.Attribute, Object> 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 <em>value</em> 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)}
+ * <p>
+ * 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
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java
----------------------------------------------------------------------
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 0000000..9361e66
--- /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<MetaData> meta(Map<String, Object> 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 <tt>null</tt> if there is no attribute for the given name
+ * @throws TypeConversionException is thrown if error during type conversion
+ */
+ <T> T getAttribute(String name, Class<T> type);
+
+ /**
+ * Returns the payload of the meta data as a POJO.
+ *
+ * @return the body, can be <tt>null</tt>
+ */
+ 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> T getPayload(Class<T> type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/metadata/AbstractMetaDataExtension.java
----------------------------------------------------------------------
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 0000000..c8bd577
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/metadata/DefaultMetaData.java
----------------------------------------------------------------------
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 0000000..b1e2df4
--- /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<String, Object> attributes;
+ private final Object payload;
+ private CamelContext camelContext;
+
+ public DefaultMetaData(CamelContext camelContext, Map<String, Object> 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> T getAttribute(String name, Class<T> 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> T getPayload(Class<T> type) {
+ if (camelContext != null) {
+ return camelContext.getTypeConverter().convertTo(type, payload);
+ }
+
+ throw new IllegalStateException("Unable to perform conversion as CamelContext is not set");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/metadata/MetaDataBuilder.java
----------------------------------------------------------------------
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 0000000..0957c64
--- /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<String, Object> 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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/metadata/package.html
----------------------------------------------------------------------
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 0000000..6687307
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/metadata/package.html
@@ -0,0 +1,25 @@
+<!--
+ ~ 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.
+ -->
+<html>
+<head>
+</head>
+<body>
+
+MetaData component extension
+
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/package.html
----------------------------------------------------------------------
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 0000000..be2383a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/package.html
@@ -0,0 +1,25 @@
+<!--
+ ~ 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.
+ -->
+<html>
+<head>
+</head>
+<body>
+
+Component extension
+
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
new file mode 100644
index 0000000..e8d256a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/CatalogVerifierCustomizer.java
@@ -0,0 +1,104 @@
+/**
+ * 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.verifier;
+
+public class CatalogVerifierCustomizer {
+ private boolean includeUnknown = true;
+ private boolean includeRequired = true;
+ private boolean includeInvalidBoolean = true;
+ private boolean includeInvalidInteger = true;
+ private boolean includeInvalidNumber = true;
+ private boolean includeInvalidEnum = true;
+
+ public boolean isIncludeUnknown() {
+ return includeUnknown;
+ }
+
+ public void setIncludeUnknown(boolean includeUnknown) {
+ this.includeUnknown = includeUnknown;
+ }
+
+ public boolean isIncludeRequired() {
+ return includeRequired;
+ }
+
+ public void setIncludeRequired(boolean includeRequired) {
+ this.includeRequired = includeRequired;
+ }
+
+ public boolean isIncludeInvalidBoolean() {
+ return includeInvalidBoolean;
+ }
+
+ public void setIncludeInvalidBoolean(boolean includeInvalidBoolean) {
+ this.includeInvalidBoolean = includeInvalidBoolean;
+ }
+
+ public boolean isIncludeInvalidInteger() {
+ return includeInvalidInteger;
+ }
+
+ public void setIncludeInvalidInteger(boolean includeInvalidInteger) {
+ this.includeInvalidInteger = includeInvalidInteger;
+ }
+
+ public boolean isIncludeInvalidNumber() {
+ return includeInvalidNumber;
+ }
+
+ public void setIncludeInvalidNumber(boolean includeInvalidNumber) {
+ this.includeInvalidNumber = includeInvalidNumber;
+ }
+
+ public boolean isIncludeInvalidEnum() {
+ return includeInvalidEnum;
+ }
+
+ public void setIncludeInvalidEnum(boolean includeInvalidEnum) {
+ this.includeInvalidEnum = includeInvalidEnum;
+ }
+
+ public CatalogVerifierCustomizer excludeUnknown() {
+ this.includeUnknown = false;
+ return this;
+ }
+
+ public CatalogVerifierCustomizer excludeRequired() {
+ this.includeRequired = false;
+ return this;
+ }
+
+ public CatalogVerifierCustomizer excludeInvalidBoolean() {
+ this.includeInvalidBoolean = false;
+ return this;
+ }
+
+ public CatalogVerifierCustomizer excludeInvalidInteger() {
+ this.includeInvalidInteger = false;
+ return this;
+ }
+
+ public CatalogVerifierCustomizer excludeInvalidNumber() {
+ this.includeInvalidNumber = false;
+ return this;
+ }
+
+ public CatalogVerifierCustomizer excludeInvalidEnum() {
+ this.includeInvalidEnum = false;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
new file mode 100644
index 0000000..690a571
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierException.java
@@ -0,0 +1,36 @@
+/**
+ * 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.verifier;
+
+import org.apache.camel.CamelException;
+
+public class ComponentVerifierException extends CamelException {
+ public ComponentVerifierException() {
+ }
+
+ public ComponentVerifierException(String message) {
+ super(message);
+ }
+
+ public ComponentVerifierException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentVerifierException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/42529399/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
new file mode 100644
index 0000000..583ccf7
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/verifier/ComponentVerifierExtensionHelper.java
@@ -0,0 +1,145 @@
+/**
+ * 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.verifier;
+
+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 ComponentVerifierExtension.VerificationError}
+ */
+public final class ComponentVerifierExtensionHelper {
+
+ /**
+ * Custom class for error codes
+ */
+ public static class ErrorCode implements Code {
+
+ private final String name;
+
+ public ErrorCode(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name of an error code must not be null");
+ }
+ this.name = name;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Code)) {
+ return false;
+ }
+
+ Code errorCode = (Code) o;
+
+ return name.equals(errorCode.name());
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+ }
+
+ public static class ErrorAttribute implements Attribute {
+
+ private final String name;
+
+ public ErrorAttribute(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name of an error attribute must not be null");
+ }
+ this.name = name;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Attribute)) {
+ return false;
+ }
+
+ Attribute that = (Attribute) o;
+
+ return name.equals(that.name());
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+ }
+
+ // ===========================================================================================================
+ // Helper classes for implementing the constants in ComponentVerifier:
+
+ public static class StandardErrorCode extends ErrorCode implements StandardCode {
+ public StandardErrorCode(String name) {
+ super(name);
+ }
+ }
+
+ public static class ExceptionErrorAttribute extends ErrorAttribute implements ExceptionAttribute {
+ public ExceptionErrorAttribute(String name) {
+ super(name);
+ }
+ }
+
+ public static class HttpErrorAttribute extends ErrorAttribute implements HttpAttribute {
+ public HttpErrorAttribute(String name) {
+ super(name);
+ }
+ }
+
+ public static class GroupErrorAttribute extends ErrorAttribute implements GroupAttribute {
+ public GroupErrorAttribute(String name) {
+ super(name);
+ }
+ }
+}