Methods Summary |
---|
protected void | addArg(java.lang.String argument)add one arg
argslist.add(argument);
|
protected void | addArg(java.lang.String argument, boolean test)add one arg
if (test) {
argslist.add(argument);
}
|
protected void | addArgs(java.lang.String argument, java.lang.String param)add an arg pair
addArg(argument);
addArg(param);
|
protected void | addArgs(java.lang.String argument, java.lang.String param, boolean test)add an arg pair if the test is true
if (test) {
addArg(argument);
addArg(param);
}
|
public org.apache.tools.ant.types.Path | createClasspath()Set the optional classpath
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
|
public void | execute()Processes a set of administration commands.
The following commands are available:
-lurl sets the AxisServlet URL
-hhostName sets the AxisServlet host
-pportNumber sets the AxisServlet port
-sservletPath sets the path to the
AxisServlet
-ffileName specifies that a simple file
protocol should be used
-uusername sets the username
-wpassword sets the password
-d sets the debug flag (for instance, -ddd would
set it to 3)
-tname sets the transport chain touse
list will list the currently deployed services
quit will quit (???)
passwd value changes the admin password
xmlConfigFile deploys or undeploys
Axis components and web services
If -l or -h -p -s are not set, the
AdminClient will invoke
http://localhost:8080/axis/servlet/AxisServlet .
outputs XML result or null in case of failure. In the case of multiple
commands, the XML results will be concatenated, separated by \n
traceParams(Project.MSG_VERBOSE);
validate();
argslist = new LinkedList();
//build an array of args
addArgs("-l", url, url != null);
addArgs("-h", hostname, hostname != null);
addArgs("-p", Integer.toString(port), port != 0);
addArgs("-s", servletPath, servletPath != null);
addArgs("-f", fileProtocol, fileProtocol != null);
addArgs("-u", username, username != null);
addArgs("-w", password, password != null);
addArgs("-t", transportChain, transportChain != null);
addArg("-d", debug);
//action
addArg(action, action != null);
//action extras
if ("passwd".equals(action)) {
if (newPassword == null) {
throw new BuildException("No newpassword set for passwd");
}
addArg(newPassword);
} else {
if (newPassword != null) {
throw new BuildException(
"newpassword is only used when action=passwd");
}
}
//final param is the xml file(s)
if (xmlFile != null) {
if (!xmlFile.exists()) {
throw new BuildException("File " + xmlFile + " no found");
}
addArg(xmlFile.toString());
}
if (srcDir != null) {
DirectoryScanner ds = super.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File srcFile = new File(srcDir, files[i]);
if (!srcFile.exists()) {
throw new BuildException("File " + srcFile + " no found");
}
addArg(srcFile.getAbsolutePath());
}
}
//turn the list into an array
int counter = 0;
String[] args = new String[argslist.size()];
Iterator it = argslist.iterator();
while (it.hasNext()) {
String arg = (String) it.next();
args[counter] = arg;
counter++;
}
if (fork) {
executeInForkedVM(args);
} else {
executeInCurrentVM(args);
}
|
private void | executeInCurrentVM(java.lang.String[] args)
//now create a client and invoke it
AdminClient admin = null;
try {
admin = new AdminClient(true);
} catch (ServiceException e) {
throw new BuildException("failed to start the axis engine", e);
}
String result = null;
try {
result = admin.process(args);
if (result != null) {
log(result);
} else {
logOrThrow(getTaskName() + " got a null response");
}
} catch (AxisFault fault) {
log(fault.dumpToString(), Project.MSG_ERR);
traceParams(Project.MSG_ERR);
logOrThrow(getTaskName()
+ " failed with "
+ fault.getFaultCode().toString()
+ " " + fault.getFaultString());
} catch (BuildException e) {
//rethrow these
throw e;
} catch (Exception e) {
throw new BuildException("Exception in " + getTaskName(), e);
}
|
private void | executeInForkedVM(java.lang.String[] args)
try {
// Create an instance of the compiler, redirecting output to
// the project log
Java java = (Java) (getProject().createTask("java"));
getProject().log("using classpath: " + classpath,
Project.MSG_DEBUG);
java.setClasspath(classpath);
java.setClassname("org.apache.axis.client.AdminClient");
for (int i = 0; i < args.length; i++) {
java.createArg().setValue(args[i]);
}
java.setFailonerror(failOnError);
//we are forking here to be sure that if AdminClient calls
//System.exit() it doesn't halt the build
java.setFork(true);
java.setTaskName("AdminClient");
java.execute();
} catch (BuildException e) {
//rethrow these
throw e;
} catch (Exception e) {
throw new BuildException("Exception in " + getTaskName(), e);
}
|
private void | logOrThrow(java.lang.String text)
if (failOnError) {
throw new BuildException(text);
} else {
log(text, Project.MSG_ERR);
}
|
public void | setClasspath(org.apache.tools.ant.types.Path classpath)Set the optional classpath
createClasspath().append(classpath);
|
public void | setClasspathRef(org.apache.tools.ant.types.Reference r)Set the reference to an optional classpath
createClasspath().setRefid(r);
|
public void | setDebug(boolean debug)set a debug flag
this.debug = debug;
|
public void | setFailOnError(boolean fail)Whether or not the build should halt if this task fails.
Defaults to true .
failOnError = fail;
|
public void | setFileProtocol(java.lang.String fileProtocol)specifies that a simple file protocol be used
this.fileProtocol = fileProtocol;
|
public void | setFork(boolean f)If true, forks the ant invocation.
fork = f;
|
public void | setHostname(java.lang.String hostname)name the host to admin
this.hostname = hostname;
|
public void | setNewPassword(java.lang.String newPassword)set a new password; only valid if action=passwd
this.newPassword = newPassword;
|
public void | setPassword(java.lang.String password)the admin password
this.password = password;
|
public void | setPort(int port)the port to connect to
this.port = port;
|
public void | setServletPath(java.lang.String servletPath)the path to the AxisAdmin servlet
this.servletPath = servletPath;
|
public void | setSrcdir(java.io.File srcDir)Set the source dir to find the source text files.
this.srcDir = srcDir;
|
public void | setTransportChain(java.lang.String transportChain)set the transport chain to use
this.transportChain = transportChain;
|
public void | setUrl(java.lang.String url)full url to the admin endpoint
this.url = url;
|
public void | setUsername(java.lang.String username)username to log in as
this.username = username;
|
public void | setXmlFile(java.io.File xmlFile)the name of the XML file containing deployment information
this.xmlFile = xmlFile;
|
public void | traceParams(int logLevel)trace out parameters
log("Running axis-admin with parameters:", logLevel);
log(" action:" + action, logLevel);
log(" url:" + url, logLevel);
log(" hostname:" + hostname, logLevel);
log(" port:" + port, logLevel);
log(" servletPath:" + servletPath, logLevel);
log(" fileProtocol:" + fileProtocol, logLevel);
log(" username:" + username, logLevel);
log(" password:" + password, logLevel);
log(" transportChain:" + transportChain, logLevel);
log(" debug:" + debug, logLevel);
|
protected void | validate()validation code
if (srcDir != null) {
if (!srcDir.exists()) {
throw new BuildException("srcdir does not exist!");
}
if (!srcDir.isDirectory()) {
throw new BuildException("srcdir is not a directory!");
}
}
|