このコンテンツは選択した言語では利用できません。
Chapter 4. Fabric Containers
4.1. Child Containers
Abstract
Child containers are the easiest kind of container to create. They are created on the same host as an existing container and are piggybacked on the same JBoss Fuse installation.
Overview
If you want to run multiple JBoss Fuse containers on a single physical host, typically the best approach is to create child containers. A child container is a relatively lightweight way to create a new container, because it re-uses most of the files in a JBoss Fuse installation. It is also convenient for administration, because the children are defined to have a parent container, so that the containers form an orderly hierarchy.
One container or many?
In principle, a single OSGi container can host multiple applications (even applications with different dependencies). So, why might you need to define extra child containers on the same host? One reason for using child containers is simply to provide a degree of isolation between applications or between components of an application. A child container runs in its own JVM process, so it is well insulated from other containers running on the same host. Using child containers also gives your application a coarse-grained structure that can be useful for managing the system (for example, each child container can be independently stopped and started).
Creating a child container
To create a new child container, invoke the
fabric:container-create-child
command, specifying the parent container name and the name of the new child container. For example, to create the new child container, onlychild
, with root
as its parent, enter the following command:
fabric:container-create-child root onlychild
If you want to create multiple child containers, an easy way to do this is to add an extra parameter, which specifies the number of new children. For example, to create three new child containers, enter a command like the following:
fabric:container-create-child root child 3
The preceding command would create the following new child containers:
child1 child2 child3
Stopping and starting a child container
Because each child container runs as a separate process, its lifecycle is independent of the parent container. That is, when you shut down a parent container, it does not automatically shut down the children. To shut down a child container, you must explicitly invoke the
fabric:container-stop
command. For example, to shut down the child1
container:
fabric:container-stop child1
To restart a stopped child container, invoke the
fabric:container-start
command, as follows:
fabric:container-start child1
Note
You can also stop a child container using the standard UNIX process management utilities,
ps
and kill
.
Deleting a child container
To delete a child container (that is, permanently removing all trace of the container from the fabric, including Fabric registry entries, and data stored in the local filesystem), invoke the
fabric:container-delete
command, as follows:
fabric:container-delete child1
Note
Using a wildcard, you can delete all child containers; for example,
fabric:container-delete child*
.