4.4. Locating Artifacts in a Fabric
Overview
Fabric containers also use Maven to locate artifacts, however they do so in a more constrained manner than a standalone container. Fabric containers use Maven through the fabric's Maven proxy and never search the local repository of the system on which it is running.
The Maven proxy attempts to strike a similar balance between accessing artifacts locally and accessing artifacts from remote repositories, however it changes the scope of local and remote. For default features, the artifacts are always stored in the fabric's system repository which is maintained by the fabric's ensemble servers. For non-default features, third party bundles, or customer developed bundles, it is likely that Maven will need to search remote repositories that are outside of the fabric to locate the artifacts.
Procedure for locating artifacts
Figure 4.3, “How Containers Locate Artifacts in a Fabric” shows an overview of the procedure that a fabric container follows when a feature or bundle is installed.
Figure 4.3. How Containers Locate Artifacts in a Fabric
The steps followed to locate the required Maven artifacts are:
- The container contacts the fabric Maven proxy to search for the artifacts.
- The proxy searches for the artifacts in the fabric's system repository.This repository contains all of the artifacts provided with the Red Hat JBoss Fuse installation.
- If the artifacts are not available in system repository, the proxy searches the remote repositories specified in its configuration.See chapter "Configuring a Fabric's Maven Proxy" in "Configuring and Running JBoss Fuse" for details on how to configure a fabric's Maven proxy.
- The Maven proxy downloads the artifacts to the container.
Loading artifacts into the fabric's repository
Because fabric containers generally do not check a repository local to the machine on which it is running, you must load all of an application's artifacts into a repository that the fabric's Maven proxy knows about. There are two ways to do this:
- load the application's artifacts into the fabric's system repositoryMaven can upload artifacts directly to the fabric's system repository by adding a
repository
element defining the Maven proxy's repository to the POM'sdistributionManagement
element. Example 4.3, “Adding a Fabric Maven Proxy to a POM” shows a POM entry for connecting to a fabric's repository when one of the Fabric Servers is running on the local machine.Example 4.3. Adding a Fabric Maven Proxy to a POM
<distributionManagement> <repository> <id>fabric-maven-proxy</id> <name>FMC Maven Proxy</name> <url>http://username:password@localhost:8107/maven/upload/</url> </repository> </distributionManagement>
You will need to modify theurl
element to include the connection details for your environment:- The username and password are the credentials used access the Fabric Server to which you are trying to connect.
- The hostname,
localhost
in Example 4.3, “Adding a Fabric Maven Proxy to a POM”, is the address of the machine hosting the Fabric Server. - The port number,
8107
in Example 4.3, “Adding a Fabric Maven Proxy to a POM”, is the port number exposed by the Fabric Server.8107
is the default setting. - The path,
/maven/upload/
in Example 4.3, “Adding a Fabric Maven Proxy to a POM”, is the same for all Fabric Servers.
NoteThe Red Hat JBoss Fuse Plugins for Eclipse can also be used to upload artifacts to a fabric's system repository. Red Hat JBoss Fuse Plugins for Eclipse will also generate a profile for deploying the application to a container. - load the application's artifacts to a custom repository and configure the fabric's Maven proxy to include the custom repositoryThis is a good option if an application is going to be used in multiple fabrics because you will not need to install the application into a separate repository for each fabric used. All of the fabrics will use a single, centrally located version of the application.To configure the fabric's Maven proxy see chapter "Configuring a Fabric's Maven Proxy" in "Configuring and Running JBoss Fuse".