All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.camel.Component Maven / Gradle / Ivy

The newest version!
/*
 * 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 java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;

import org.apache.camel.component.extension.ComponentExtension;
import org.apache.camel.spi.PropertyConfigurer;

/**
 * A component is a factory of {@link Endpoint} objects.
 */
public interface Component extends CamelContextAware, Service {

    /**
     * Attempt to resolve an endpoint for the given URI if the component is capable of handling the URI.
     * 

* See {@link #useRawUri()} for controlling whether the passed in uri should be as-is (raw), or encoded (default). * * @param uri the URI to create; either raw or encoded (default) * @return a newly created {@link Endpoint} or null if this component cannot create {@link Endpoint} * instances using the given uri * @throws Exception is thrown if error creating the endpoint * @see #useRawUri() */ Endpoint createEndpoint(String uri) throws Exception; /** * Attempt to resolve an endpoint for the given URI if the component is capable of handling the URI. *

* See {@link #useRawUri()} for controlling whether the passed in uri should be as-is (raw), or encoded (default). * * @param uri the URI to create; either raw or encoded (default) * @param parameters the parameters for the endpoint * @return a newly created {@link Endpoint} or null if this component cannot create {@link Endpoint} * instances using the given uri * @throws Exception is thrown if error creating the endpoint * @see #useRawUri() */ Endpoint createEndpoint(String uri, Map parameters) throws Exception; /** * Whether to use raw or encoded uri, when creating endpoints. *

* Notice: When using raw uris, then the parameter values is raw as well. * * @return true to use raw uris, false to use encoded uris (default). */ boolean useRawUri(); /** * Gets the component {@link PropertyConfigurer}. * * @return the configurer, or null if the component does not support using property configurer. */ default PropertyConfigurer getComponentPropertyConfigurer() { return null; } /** * Gets the endpoint {@link PropertyConfigurer}. * * @return the configurer, or null if the endpoint does not support using property configurer. */ default PropertyConfigurer getEndpointPropertyConfigurer() { return null; } /** * Gets a list of supported extensions. * * @return the list of extensions. */ default Collection> getSupportedExtensions() { return Collections.emptyList(); } /** * Gets the extension of the given type. * * @param extensionType tye type of the extensions * @return an optional extension */ default Optional getExtension(Class extensionType) { return Optional.empty(); } /** * Set the {@link Component} context if the component is an instance of {@link ComponentAware}. */ static T trySetComponent(T object, Component component) { if (object instanceof ComponentAware componentAware) { componentAware.setComponent(component); } return object; } /** * Gets the default name of the component. */ default String getDefaultName() { return null; } /** * Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as * autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets * configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection * factories, AWS Clients, etc. */ default boolean isAutowiredEnabled() { return true; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy