Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 55. Configuring the API Component Maven Plug-In
Abstract
						This chapter provides a reference for all of the configuration options available on the API component Maven plug-in.
					
55.1. Overview of the Plug-In Configuration
Copier lienLien copié sur presse-papiers!
Overview
Copier lienLien copié sur presse-papiers!
					The main purpose of the API component Maven plug-in, 
camel-api-component-maven-plugin, is to generate the API mapping classes, which implement the mapping between endpoint URIs and API method invocations. By editing the configuration of the API component Maven plug-in, you can customize various aspects of the API mapping.
				Location of the generated code
Copier lienLien copié sur presse-papiers!
					The API mapping classes generated by the API component Maven plug-in are placed in the following location, by default:
				
ProjectName-component/target/generated-sources/camel-component
ProjectName-component/target/generated-sources/camel-componentPrerequisites
Copier lienLien copié sur presse-papiers!
					The main inputs to the API component Maven plug-in are the Java API classes and the Javadoc metadata. These are made available to the plug-in by declaring them as regular Maven dependencies (where the Javadoc Maven dependencies should be declared with 
provided scope).
				Setting up the plug-in
Copier lienLien copié sur presse-papiers!
					The recommended way to set up the API component Maven plug-in is to generate starting point code using the API component archetype. This generates the default plug-in configuration in the 
ProjectName-component/pom.xml file, which you can then customize for your project. The main aspects of the plug-in set-up are, as follows:
				- Maven dependencies must be declared for the requisite Java API and for the Javadoc metadata.
- The plug-in's base configuration is declared in thepluginManagementscope (which also defines the version of the plug-in to use).
- The plug-in instance itself is declared and configured.
- Thebuild-helper-mavenplug-in is configured to pick up the generated sources from thetarget/generated-sources/camel-componentdirectory and include them in the Maven build.
Example base configuration
Copier lienLien copié sur presse-papiers!
					The following POM file extract shows the base configuration of the API component Maven plug-in, as defined in the Maven 
pluginManagement scope when the code has been generated using the API component archetype:
				
					The configuration specified in the 
pluginManagement scope provides default settings for the plug-in. It does not actually create an instance of a plug-in, but its default settings will be used by any API component plug-in instance.
				Base configuration
Copier lienLien copié sur presse-papiers!
					In addition to specifying the plug-in version (in the 
version element), the preceding base configuration specifies the following configuration properties:
				- scheme
- The URI scheme for this API component.
- componentName
- The name of this API component (which is also used as a prefix for generated class names).
- componentPackage
- Specifies the Java package containing the classes generated by the API component Maven archetype. This package is also exported by the defaultmaven-bundle-pluginconfiguration. Hence, if you want a class to be publicly visible, you should place it in this Java package.
- outPackage
- Specifies the Java package where the generated API mapping classes are placed (when they are generated by the API component Maven plug-in). By default, this has the value of thecomponentNameproperty, with the addition of the.internalsuffix. This package is declared as private by the defaultmaven-bundle-pluginconfiguration. Hence, if you want a class to be private, you should place it in this Java package.
Example instance configuration
Copier lienLien copié sur presse-papiers!
					The following POM file extract shows a sample instance of the API component Maven plug-in, which is configured to generate an API mapping during the Maven build:
				
Basic mapping configuration
Copier lienLien copié sur presse-papiers!
					The plug-in is configured by the 
configuration element, which contains a single apis child element to configure the classes of the Java API. Each API class is configured by an api element, as follows:
				- apiName
- The API name is a short name for the API class and is used as theendpoint-prefixpart of an endpoint URI.NoteIf the API consists of just a single Java class, you can leave theapiNameelement empty, so that theendpoint-prefixbecomes redundant, and you can then specify the endpoint URI using the format shown in the section called “URI format for a single API class”.
- proxyClass
- This element specifies the fully-qualified name of the API class.
- fromJavadoc
- If the API class is accompanied by Javadoc metadata, you must indicate this by including thefromJavadocelement and the Javadoc itself must also be specified in the Maven file, as aprovideddependency.
- fromSignatureFile
- If the API class is accompanied by signature file metadata, you must indicate this by including thefromSignatureFileelement, where the content of this element specifies the location of the signature file.NoteThe signature files do not get included in the final package built by Maven, because these files are needed only at build time, not at run time.
Customizing the API mapping
Copier lienLien copié sur presse-papiers!
					The following aspects of the API mapping can be customized by configuring the plug-in:
				
- Method aliases—you can define additional names (aliases) for an API method using thealiasesconfiguration element. For details, see Section 55.3, “Method Aliases”.
- Nullable options—you can use thenullableOptionsconfiguration element to declare method arguments that default tonull. For details, see Section 55.4, “Nullable Options”.
- Argument name substitution—due to the way the API mapping is implemented, the arguments from all of the methods in a particular API class belong to the same namespace. If two arguments with the same name are declared to be of different type, this leads to a clash. To avoid such name clashes, you can use thesubstitutionsconfiguration element to rename method arguments (as they would appear in a URI). For details, see Section 55.5, “Argument Name Substitution”.
- Excluding arguments—when it comes to mapping Java arguments to URI options, you might sometimes want to exclude certain arguments from the mapping. You can filter out unwanted arguments by specifying either theexcludeConfigNameselement or theexcludeConfigTypeselement. For details, see Section 55.6, “Excluded Arguments”.
- Extra options—sometimes you might want to define extra options, which are not part of the Java API. You can do this using theextraOptionsconfiguration element.
Configuring Javadoc metadata
Copier lienLien copié sur presse-papiers!
					It is possible to filter the Javadoc metadata to ignore or explicitly include certain content. For details of how to do this, see Section 55.2, “Javadoc Options”.
				
Configuring signature file metadata
Copier lienLien copié sur presse-papiers!
					In cases where no Javadoc is available, you can resort to signature files to supply the needed mapping metadata. The 
fromSignatureFile is used to specify the location of the corresponding signature file. It has no special options.