This page last changed on Apr 25, 2005 by vmassol.

Definition

Instantiate a container by name

Explanation

There are 2 solutions to instantiate a container:
  • by explicitely creating a new instance of the container itself (see the Container Instantiation page for more details on creating a container's instance). For example to instantiate a Resin 3.x container:
    Container container = new Resin3xContainer();
  • by using the ContainerFactory class. The advantage is that you can instantiate the container by name and thus your code can be generic which is nice if you plan to run the same code with different containers. For example, to instantiate a Resin 3.x container:
    ContainerFactory factory = new ContainerFactory();
    Container container = factory.createContainer("resin3x");

Note: You can also pass the full container class name (that's useful if you wish to instantiate a custom container you have developed):
Container container = factory.createContainer("org.codehaus.cargo.container.resin.Resin3xContainer");
Document generated by Confluence on Apr 30, 2005 12:52