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.Este conteúdo não está disponível no idioma selecionado.
2.4. API Bundle
Overview Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
This section explains how to set up a Maven project for a typical API bundle.
The
hello-paris bundle exemplifies an API bundle, which contains only public Java interfaces. Hence, the API bundle should export all of its own packages and associate a version number with the exported packages.
Directory structure Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The
hello-paris bundle has the following directory structure:
The Java source code is located under the
src/main/java sub-directory. The org.fusesource.example.hello.paris package is public and all of its classes and interfaces can be exported from the bundle.
There are no blueprint resources associated with this bundle.
Sample API Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The
hello-paris bundle is a pure API, which means it contains only Java interfaces. In this example, there is a single interface, HelloParis, which returns a localized greeting and a Clock object that tells the local time. The HelloParis interface is defined as follows:
Maven dependencies Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
In the Maven POM file, the
hello-paris bundle defines dependencies on the following Maven artifact:
time-util
Import and export rules Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The following import and export rules apply to the
hello-paris bundle:
- Exporting own packages—the
org.fusesource.example.hello.parispackage is public, and must be exported. - Importing own packages—none of the bundle's own packages should be imported.
- Importing dependent packages—any external package dependencies must be imported.
Maven bundle plug-in settings Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The Maven bundle plug-in is configured to export the API package,
org.fusesource.example.hello.paris (coded as ${project.groupId}.hello.paris*). The Export-Package instruction also contains entries to block the export of any packages containing .impl or .internal. In this case, the bundle plug-in instructions are as follows:
Generated MANIFEST.MF file Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
When you build the bundle using Maven, the Maven bundle plug-in automatically generates the following
MANIFEST.MF file:
The
Import-Package header lists one external package dependency, org.fusesource.example.time. None of the bundle's own packages are imported.
The
Export-Package header is used to export the API package, org.fusesource.example.hello.paris, while the uses clause declares a transitive dependency on the org.fusesource.example.time package.