Container Instantiation
Definition
Create a container instanceSupport Matrix
Java | Ant | Maven 3 |
---|---|---|
Java API
If you're using the Java API there are 2 solutions to instantiate a container:
- by instantiating the Java object implementing the container and passing a Configuration object to it. For example:
Container container = new Orion2xLocalContainer(configuration); [...] Container container = new Resin3xLocalContainer(configuration); [...] Container container = new Weblogic8xLocalContainer(configuration); [...] Container container = new TomcatRemoteContainer(configuration);
- by using the
DefaultContainerFactory
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 installed local container:
ContainerFactory factory = new DefaultContainerFactory(); Container container = factory.createContainer("resin3x", ContainerType.INSTALLED, configuration);
In general we recommend that you use the factory method to instantiate a container as this makes your code more flexible.
The class or container id to use for instantiating a container can be found on each container's documentation page:
- Geronimo 1.x
- Geronimo 2.x
- Geronimo 3.x
- GlassFish 2.x
- GlassFish 3.x
- GlassFish 4.x
- GlassFish 5.x
- GlassFish 6.x
- GlassFish 7.x
- GlassFish 8.x
- JBoss 3.x
- JBoss 4.x
- JBoss 4.2.x
- JBoss 5.x
- JBoss 5.1.x
- JBoss 6.x
- JBoss 6.1.x
- JBoss 7.x
- JBoss 7.1.x
- JBoss 7.2.x
- JBoss 7.3.x
- JBoss 7.4.x
- JBoss 7.5.x
- Jetty 5.x
- Jetty 6.x
- Jetty 7.x
- Jetty 8.x
- Jetty 9.x
- Jetty 10.x
- Jetty 11.x
- Jetty 12.x
- jo! 1.x
- JOnAS 4.x
- JOnAS 5.x
- JRun 4.x
- OC4J 10.x
- OC4J 9.x
- Payara
- Resin 3.x
- Resin 3.1.x
- Resin 4.x
- Tomcat 4.x
- Tomcat 5.x
- Tomcat 6.x
- Tomcat 7.x
- Tomcat 8.x
- Tomcat 9.x
- Tomcat 10.x
- Tomcat 11.x
- TomEE 1.x
- TomEE 7.x
- TomEE 8.x
- TomEE 9.x
- TomEE 10.x
- WebLogic 8.x
- WebLogic 9.x
- WebLogic 10.x
- WebLogic 10.3.x
- WebLogic 12.x
- WebLogic 12.1.x
- WebLogic 12.2.x
- WebLogic 14.x
- WebSphere 8.5.x
- WebSphere 9.x
- WebSphere Liberty
- WildFly 8.x
- WildFly 9.x
- WildFly 10.x
- WildFly 11.x
- WildFly 12.x
- WildFly 13.x
- WildFly 14.x
- WildFly 15.x
- WildFly 16.x
- WildFly 17.x
- WildFly 18.x
- WildFly 19.x
- WildFly 20.x
- WildFly 21.x
- WildFly 22.x
- WildFly 23.x
- WildFly 24.x
- WildFly 25.x
- WildFly 26.x
- WildFly 27.x
- WildFly 28.x
- WildFly 29.x
- WildFly 30.x
- WildFly 31.x
- WildFly 32.x
- WildFly 33.x
- WildFly 34.x
- WildFly 35.x
- WildFly Swarm
Example using Cargo extensions
If you're using a Cargo extension you'll use the way defined by the extension to instantiate a container. Underneath, all extensions use the factory method to instantiate containers.