001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel; 018 019import java.util.Collection; 020import java.util.Collections; 021import java.util.Optional; 022 023import org.apache.camel.component.extension.ComponentExtension; 024 025/** 026 * A <a href="http://camel.apache.org/component.html">component</a> is 027 * a factory of {@link Endpoint} objects. 028 * 029 * @version 030 */ 031public interface Component extends CamelContextAware { 032 033 /** 034 * Attempt to resolve an endpoint for the given URI if the component is 035 * capable of handling the URI. 036 * <p/> 037 * See {@link #useRawUri()} for controlling whether the passed in uri 038 * should be as-is (raw), or encoded (default). 039 * 040 * @param uri the URI to create; either raw or encoded (default) 041 * @return a newly created {@link Endpoint} or null if this component cannot create 042 * {@link Endpoint} instances using the given uri 043 * @throws Exception is thrown if error creating the endpoint 044 * @see #useRawUri() 045 */ 046 Endpoint createEndpoint(String uri) throws Exception; 047 048 /** 049 * Whether to use raw or encoded uri, when creating endpoints. 050 * <p/> 051 * <b>Notice:</b> When using raw uris, then the parameter values is raw as well. 052 * 053 * @return <tt>true</tt> to use raw uris, <tt>false</tt> to use encoded uris (default). 054 * 055 * @since Camel 2.11.0 056 */ 057 boolean useRawUri(); 058 059 /** 060 * Attempt to create a configuration object from the given uri 061 * 062 * @param uri the configuration URI 063 * @return a newly created {@link EndpointConfiguration} 064 * @throws Exception is thrown if the configuration URI is invalid 065 * 066 * @since Camel 2.9.0 067 */ 068 @Deprecated 069 EndpointConfiguration createConfiguration(String uri) throws Exception; 070 071 /** 072 * Creates a configuration helper object for a component that lets you configure the various 073 * URI and parameter values; then create the full URI for it, create a new Endpoint from it 074 * or configure an existing Endpoint from the values. 075 * 076 * This method is intended to be used in cases where there is not yet a full URI to 077 * configure an endpoint yet; but rather there are a number of parameters to configure 078 * to then build up a new URI or directly create an Endpoint from the parameter values. 079 */ 080 @Deprecated 081 ComponentConfiguration createComponentConfiguration(); 082 083 /** 084 * Gets a list of supported extensions. 085 * 086 * @return the list of extensions. 087 */ 088 default Collection<Class<? extends ComponentExtension>> getSupportedExtensions() { 089 return Collections.emptyList(); 090 } 091 092 /** 093 * Gets the extension of the given type. 094 * 095 * @param extensionType tye type of the extensions 096 * @return an optional extension 097 */ 098 default <T extends ComponentExtension> Optional<T> getExtension(Class<T> extensionType) { 099 return Optional.empty(); 100 } 101}