Task to start/stop a Resin instance.
| Method from org.apache.cactus.integration.ant.container.resin.AbstractResinTask Detail: |
public Path createContainerClasspath() {
if (this.containerClasspath == null)
{
this.containerClasspath = new Path(this.project);
}
return this.containerClasspath.createPath();
}
Adds container classpath to the classpath that will be used for starting
the container. |
public void execute() {
// Resin container that prepares, starts and stops a Resin
// instance.
AbstractResinContainer container = getResinContainer();
// Sets the file to be deployed in the container.
if (getWarFile() != null)
{
container.setDeployableFile(
WarParser.parse(getWarFile()));
}
else if (getEarFile() != null)
{
container.setDeployableFile(
EarParser.parse(getEarFile()));
}
container.setDir(getDir());
container.setAntTaskFactory(new DefaultAntTaskFactory(
getProject(), getTaskName(), getLocation(), getOwningTarget()));
container.setPort(getPort());
// Add specific additional user-defined classpath
container.setContainerClasspath(this.containerClasspath);
if (getResinConf() != null)
{
container.setResinConf(getResinConf());
}
if (getTmpDir() != null)
{
container.setTmpDir(getTmpDir());
}
if (getOutput() != null)
{
container.setOutput(getOutput());
}
if (getAppend())
{
container.setAppend(getAppend());
}
// Verify that the task is correctly set up.
verify(container);
// If the user has provided a test URL, we use a ContainerRunner
// that continuously polls this test URL to verify if the container
// is started. In that case, this task will only return when the
// container is up and running. If no test URL has been started
// we simply start the container and give back the control to the user
// without waiting for container to be up and running.
ContainerRunner runner = null;
if (getTestURL() != null)
{
runner = new ContainerRunner(container);
runner.setURL(getTestURL());
}
// Decide whether to start or stop the container
if (getAction().equalsIgnoreCase("start"))
{
if (getTestURL() != null)
{
runner.startUpContainer();
}
else
{
container.startUp();
}
}
else if (getAction().equalsIgnoreCase("stop"))
{
if (getTestURL() != null)
{
runner.shutDownContainer();
}
else
{
container.shutDown();
}
}
}
Start or stop the container depending on the action asked by the user.
When starting the container, also prepare a valid container
configuration and optionally deploy a war or ear in it. |
protected final String getAction() {
return this.action;
}
|
protected final boolean getAppend() {
return this.append;
}
|
protected final File getDir() {
return this.dir;
}
|
protected final File getEarFile() {
return this.earFile;
}
|
protected final File getOutput() {
return this.output;
}
|
protected final int getPort() {
return this.port;
}
|
protected final File getResinConf() {
return this.resinConf;
}
|
abstract protected AbstractResinContainer getResinContainer()
|
protected final URL getTestURL() {
return this.testURL;
}
|
protected final File getTmpDir() {
return this.tmpDir;
}
|
protected final File getWarFile() {
return this.warFile;
}
|
public void setAction(String theAction) {
this.action = theAction;
}
Sets the action to execute (either "start" or "stop"). |
public final void setAppend(boolean isAppend) {
this.append = isAppend;
}
Sets whether output of the container should be appended to an existing
file, or the existing file should be truncated. |
public final void setDir(File theDir) {
this.dir = theDir;
}
Sets the Resin installation directory. |
public final void setEarFile(File theEarFile) {
if (getWarFile() != null)
{
throw new BuildException(
"You may only specify one of [earfile] and [warfile]");
}
this.earFile = theEarFile;
}
Sets an enterprise application aarchive to deploy. |
public final void setOutput(File theOutput) {
this.output = theOutput;
}
Sets the file to which output of the container should be written. |
public final void setPort(int thePort) {
this.port = thePort;
}
Sets the port to which the container should listen. |
public final void setResinConf(File theResinConf) {
this.resinConf = theResinConf;
}
Sets the configuration file to use for the test installation of Resin |
public void setTestURL(URL theTestURL) {
this.testURL = theTestURL;
}
Sets the URL to call for testing if the server is running. |
public final void setTmpDir(File theTmpDir) {
this.tmpDir = theTmpDir;
}
Sets the temporary directory from which the container is run. |
public final void setWarFile(File theWarFile) {
if (getEarFile() != null)
{
throw new BuildException(
"You may only specify one of [earfile] and [warfile]");
}
this.warFile = theWarFile;
}
Sets a web application archive to deploy in the container. |