Methods Summary |
---|
protected void | checkConfiguration()Verifies that the options and parameters selected by the user are valid
and consistent.
log(servers.size() + " servers were found.", Project.MSG_DEBUG);
// At least one target server must be specified
if (servers.size() == 0) {
final String msg = lsm.getString("SpecifyOneServer");
throw new BuildException(msg, getLocation());
}
// Check the configuration of each target server specified
Iterator it = servers.iterator();
while (it.hasNext()) {
Server aServer = (Server)it.next();
checkConfiguration(aServer);
}
|
protected abstract void | checkConfiguration(org.apache.tools.ant.taskdefs.optional.sun.appserv.AppServerAdmin$Server aServer)Verifies that the options and parameters selected by the user are valid
and consistent for a given server.
|
public org.apache.tools.ant.taskdefs.optional.sun.appserv.AppServerAdmin$Server | createServer()Creates a nested server element.
log("createServer", Project.MSG_DEBUG);
Server aNestedServer = getNewServer();
servers.add(aNestedServer);
return aNestedServer;
|
protected void | execAdminCommand(java.lang.String command)Executes a command-string using the Sun ONE Application Server
administrative CLI infrastructure.
log("Executing: " + command, Project.MSG_INFO);
try {
if (invokeCLI == null) {
java.lang.ClassLoader antClassLoader = new AntClassLoader(
AppservClassLoader.getClassLoader(), getProject(), null, false);
log("class = " + ((AntClassLoader)antClassLoader).getClasspath(), Project.MSG_DEBUG);
inputsAndOutputs = Class.forName(CLASS_INPUTS_AND_OUTPUTS, true, antClassLoader);
adminMain = Class.forName(CLASS_ADMIN_MAIN, true, antClassLoader);
systemPropertyConstants = Class.forName(CLASS_SYSTEM_PROPERTY_CONSTANTS, true, antClassLoader);
}
log("***** INSTALL_ROOT_PROPERTY = " + (String)systemPropertyConstants.getField("INSTALL_ROOT_PROPERTY").get(null), Project.MSG_DEBUG);
final String installRootConstant = (String)systemPropertyConstants.getField("INSTALL_ROOT_PROPERTY").get(null);
final String configRootConstant = (String)systemPropertyConstants.getField("CONFIG_ROOT_PROPERTY").get(null);
final String installRoot = getInstallRoot(installRootConstant);
log("installRoot: " + installRoot, Project.MSG_DEBUG);
final String libraryPath = (String) System.getProperty("java.library.path");
System.setProperty("java.library.path", installRoot+"/lib"+File.pathSeparator+libraryPath);
System.setProperty(installRootConstant, installRoot);
System.setProperty(configRootConstant, installRoot+"/config");
System.setProperty("java.endorsed.dirs", installRoot+"/lib/endorsed");
//debug display all system properties
/*
for (java.util.Enumeration en = System.getProperties().propertyNames(); en.hasMoreElements() ;)
{
String name = (String) en.nextElement();
String value = (String) System.getProperties().getProperty(name);
log("System.property = " + name + " " + value, Project.MSG_DEBUG);
}
*/
Class[] parameterClasses = {String.class, inputsAndOutputs};
invokeCLI = adminMain.getDeclaredMethod(METHOD_INVOKE_CLI, parameterClasses);
Object[] parameters = {command, null};
if (executeCommand) {
invokeCLI.invoke(adminMain, parameters);
}
} catch (ClassNotFoundException e) {
final String msg = lsm.getString("ClassCouldNotBeFound", new Object[] {e.getMessage()});
throw new BuildException(msg, getLocation());
} catch (NoSuchMethodException e) {
final String msg = lsm.getString("CouldNotFindInvokeCLI", new Object[] {e.getMessage()});
throw new BuildException(msg, getLocation());
} catch (InvocationTargetException e) {
final String msg = lsm.getString("ExceptionOccuredRunningTheCommand", new Object[] {e.getTargetException().getMessage()});
throw new BuildException(msg, getLocation());
} catch (IllegalAccessException e) {
final String msg = lsm.getString("ExceptionOccuredInvokeingCLI", new Object[] {e.getMessage()});
throw new BuildException(msg, getLocation());
} catch (Exception e) {
throw new BuildException(e.getMessage(), getLocation());
}
|
public void | execute()Does the work.
prepareToExecute();
checkConfiguration();
Iterator it = servers.iterator();
while (it.hasNext()) {
Server aServer = (Server)it.next();
execute(aServer);
}
|
protected abstract void | execute(org.apache.tools.ant.taskdefs.optional.sun.appserv.AppServerAdmin$Server server)Builds and executes the admin command on the server specified.
|
protected java.io.File | getAsinstalldir()Returns the asinstalldir attribute specify by in the build script.
If asinstalldir hasn't been explicitly set (using
the setAsinstalldir method), the value stored in the
sunone.home property will be returned.
if (asinstalldir == null) {
String home = getProject().getProperty("asinstall.dir");
if (home != null) {
asinstalldir = new File(home);
}
else {
home = getProject().getProperty("sunone.home");
if (home != null)
{
final String msg = lsm.getString("DeprecatedProperty", new Object[] {"sunone.home", "asinstall.dir"});
log(msg, Project.MSG_WARN);
asinstalldir = new File(home);
}
}
}
if (asinstalldir!=null) verifyAsinstalldir(asinstalldir);
return asinstalldir;
|
private java.lang.String | getInstallRoot(java.lang.String installRootConstant)returns the appserver server installation directory
first it will get asinstalldir from attribute of ant task.
if user did not specify asinstalldir, then the retrieve the install directory
from java system property using installrootConstant.
if all else fails, an ClassNotFoundException is thrown and the appropraite
msg will be displayed to bhe user.
final File installDir = getAsinstalldir();
String installRoot;
if (installDir == null) {
installRoot = System.getProperty(installRootConstant);
if (installRoot == null)
throw new ClassNotFoundException("ClassCouldNotBeFound");
} else {
installRoot = installDir.getPath();
System.setProperty(installRootConstant, installRoot);
}
return installRoot;
|
protected org.apache.tools.ant.taskdefs.optional.sun.appserv.AppServerAdmin$Server | getNewServer()Builds a new server instance. This method is intended to be overridden
by subclasses which implement their own subclass of Server.
return new Server(server);
|
protected void | prepareToExecute()Does any clean-up work required before the user configuration is checked
and the command(s) executed.
if (servers.size() == 0) {
servers.add(server);
}
|
public void | setAsinstalldir(java.io.File asinstalldir)Specifies the installation directory for the Sun ONE Application Server
8. This may be used if the application server is installed on the
local machine.
this.asinstalldir = asinstalldir;
|
public void | setExecuteCommand(boolean executeCommand)This attribute is used only for debugging and is not included in the
task documentation. When set to "true" the task behaves normally. When
set to "false", each admin command is logged but not actually executed.
this.executeCommand = executeCommand;
|
public void | setHost(java.lang.String host)Sets the hostname where the application server administration instance
is running.
server.setHost(host); // Delegates to server object
|
public void | setInstance(java.lang.String instance)Sets the application server instance name. Typically, this is the
"target" for administrative commands.
server.setInstance(instance); // Delegates to server object
|
public void | setPassword(java.lang.String password)Sets the password used when logging into the application server
administration instance.
final String msg = lsm.getString("DeprecatedAttribute", new Object[] {"password",
"passwordfile"});
log(msg, Project.MSG_WARN);
server.setPassword(password); // Delegates to server object
|
public void | setPasswordfile(java.lang.String passwordfile)Sets the passwordfile used when logging into the application server
administration instance.
server.setPasswordfile(passwordfile); // Delegates to server object
|
public void | setPort(int port)Sets the port where the application server administration instance is
running.
server.setPort(port); // Delegates to server object
|
public void | setSecure(java.lang.String secure)Sets secure option
server.setSecure(secure); // Delegates to server object
|
public void | setSunonehome(java.io.File sunonehome)Specifies the installation directory for the Sun ONE Application Server
8. This may be used if the application server is installed on the
local machine.
final String msg = lsm.getString("DeprecatedAttribute", new Object[] {"sunonehome",
"asinstalldir"});
log(msg, Project.MSG_WARN);
this.asinstalldir = sunonehome;
|
public void | setUser(java.lang.String user)Sets the username used when logging into the application server
administration instance.
server.setUser(user); // Delegates to server object
|
private boolean | verifyAsinstalldir(java.io.File home)verify if asinsatlldir attribute is valid.
asinstalldir must be a valid directory and must contain the config directory.
if (home!= null && home.isDirectory()) {
if ( new File(home, "config").isDirectory() ) {
return true;
}
}
throw new ClassNotFoundException("ClassCouldNotBeFound");
|