Special container support for the JBoss application server.
| Method from org.apache.cactus.integration.ant.container.jboss.JBoss3xContainer Detail: |
public final int getJndiPort() {
return this.jndiPort;
}
Returns the server JNDI port. |
public final String getName() {
return "JBoss " + this.version;
}
|
public final int getPort() {
return this.port;
}
|
public String getTestContext() {
return this.testContextRoot;
}
|
protected final File getTmpDir() {
return this.tmpDir;
}
|
public final void init() {
// Verify the installation directory
this.version = getVersion(this.dir);
if (this.version == null)
{
throw new BuildException(this.dir
+ " not recognized as a JBoss 3.x installation");
}
if (!this.version.startsWith("3"))
{
throw new BuildException(
"This element doesn't support version " + this.version
+ " of JBoss");
}
// Try to infer the test root context from the JBoss specific
// < code >jboss-web.xml< /code > file.
this.testContextRoot = getTestContextFromJBossWebXml();
// TODO: as long as we don't have a way to set the port on the JBoss
// instance, we'll at least need to extract the port from a config file
// in the installation directory
}
|
public final void setConfig(String theConfig) {
this.config = theConfig;
}
Sets the name of the server configuration to use for running the tests. |
public final void setConfigDir(File theConfigDir) {
this.configDir = theConfigDir;
}
Sets the location of the server configuration directory. |
public final void setDir(File theDir) throws BuildException {
// Public Methods ----------------------------------------------------------
this.dir = theDir;
}
Sets the JBoss installation directory. |
public final void setJndiPort(int theJndiPort) {
this.jndiPort = theJndiPort;
}
Specify the JNDI port to use. |
public final void setPort(int thePort) {
this.port = thePort;
}
Sets the port that will be used to poll the server to verify if
it is started. This is needed for the use case where the user
has defined his own JBoss configuration by using the
#setConfig(String) call and has defined a port other
than the default one.
Note: This value is not yet used to set the port
to which the container will listen to. The reason is that this is
hard to implement with JBoss and nobody had the courage to implement
it yet... |
public final void setTmpDir(File theTmpDir) {
this.tmpDir = theTmpDir;
}
Sets the temporary directory from which the container is run. |
public final void shutDown() {
File binDir = new File(this.dir, "bin");
Java java = createJavaForShutDown();
java.setFork(true);
Path classPath = java.createClasspath();
classPath.createPathElement().setLocation(
new File(binDir, "shutdown.jar"));
java.setClassname("org.jboss.Shutdown");
if (this.version.startsWith("3.2"))
{
java.createArg().setValue("--server=" + this.getServer() + ":"
+ this.getJndiPort());
java.createArg().setValue("--shutdown");
}
else
{
java.createArg().setValue(this.getServer());
java.createArg().setValue(String.valueOf(getPort()));
}
java.execute();
}
|
public final void startUp() {
try
{
// TODO: It seems JBoss 3.2.x does not support server
// configurations located in directories with spaces in their name.
// Thus we define the default tmp dir to default to where default
// JBoss server configurations are located. This should be removed
// once we find out how to make JBoss work when using the default
// tmp dir of System.getProperty("java.io.tmpdir")
if (getTmpDir() == null)
{
setTmpDir(new File(this.dir, "server/cactus"));
}
File customServerDir = setupTempDirectory(getTmpDir(),
"cactus/jboss3x");
cleanTempDirectory(customServerDir);
prepare("cactus/jboss3x", customServerDir);
File binDir = new File(this.dir, "bin");
Java java = createJavaForStartUp();
java.setDir(binDir);
java.addSysproperty(
createSysProperty("program.name",
new File(binDir, "run.bat")));
java.addSysproperty(
createSysProperty("jboss.server.home.dir", customServerDir));
java.addSysproperty(
createSysProperty("jboss.server.home.url",
customServerDir.toURL().toString()));
Path classpath = java.createClasspath();
classpath.createPathElement().setLocation(
new File(binDir, "run.jar"));
addToolsJarToClasspath(classpath);
java.setClassname("org.jboss.Main");
java.createArg().setValue("-c");
java.createArg().setValue(this.config);
java.execute();
}
catch (IOException ioe)
{
getLog().error("Failed to startup the container", ioe);
throw new BuildException(ioe);
}
}
|