Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following examples demonstrate how to configure Resin 3Tomcat 9.0.15 78 to start with a standalone local configuration in target/resin3xtomcat9x and deploy a WAR located in path/to/simple.war using the Java API. The default port is 8080.

Please note that the container.start() and container.stop() methods wait until the container is fully started and fully stopped before continuing. Thus, for any action you are executing after, you are assured the container is completely operational.

...

Code Block
languagejava
Deployable war = new WAR("path/to/simple.war");

LocalConfiguration configuration =
    new Resin3xStandaloneLocalConfigurationTomcat9xStandaloneLocalConfiguration("target/myresin3xtomcat9x");
configuration.addDeployable(war);

InstalledLocalContainer container =
    new Resin3xInstalledLocalContainerTomcat9xInstalledLocalContainer(configuration);
container.setHome("c:/apps/resintomcat-39.0.1878");

container.start();
// Here you are assured the container is started.

container.stop();
// Here you are assured the container is stopped.

...

Code Block
languagejava
Deployable war = new DefaultDeployableFactory().createDeployable(
    "resin3xtomcat9x", "path/to/simple.war", DeployableType.WAR);

ConfigurationFactory configurationFactory =
    new DefaultConfigurationFactory();
LocalConfiguration configuration =
    (LocalConfiguration) configurationFactory.createConfiguration(
"resin3x        "tomcat9x", ContainerType.INSTALLED,
            ConfigurationType.STANDALONE, "target/tomcat9x");
configuration.addDeployable(war);

InstalledLocalContainer container =
    (InstalledLocalContainer) new DefaultContainerFactory().createContainer(
        "resin3xtomcat9x", ContainerType.INSTALLED, configuration);
container.setHome("c:/apps/resintomcat-39.0.1878");

container.start();
// Here you are assured the container is started.

container.stop();
// Here you are assured the container is stopped.

...

Code Block
languagejava
InstalledLocalContainer container = new Resin3xInstalledLocalContainerTomcat9xInstalledLocalContainer(
    new Resin3xStandaloneLocalConfigurationTomcat9StandaloneLocalConfiguration("target/myresin3xtomcat9x"));
container.setHome("c:/apps/resintomcat-39.0.1878");

container.start();
// Here you are assured the container is started.

Deployable war = new WAR("path/to/simple.war");
Deployer deployer = new ResinInstalledLocalDeployerTomcatCopyingInstalledLocalDeployer(container);
deployer.deploy(war);

// HereTo yoube aresure NOTthat sure the WARdeployable hasis finisheddeployed, deploying.we Tocan beuse surea youDeployableMonitor
// need to use a DeployableMonitor to monitor the deployment. For example
// the The following code deploys the WAR and waitwaits until
// it is available to // serve requests (i.e., the URL should point to a resource inside your WAR): specified returns an HTTP
// code 2xx or 3xx and, in our example, the text connection-ok in the body)
deployer.deploy(war, new URLDeployableMonitor(
    new URL("http://serverlocalhost:port8080/somesimple/urljsp-status"), "connection-ok"));

container.stop();
// Here you are assured the container is stopped.

...