Fields Summary |
---|
LocalStringsManager | lsm |
protected Component | componentThis Component instance will store user settings from the "root" command
element. |
protected List | componentsThe list of components will store user settings from nested
<component> elements. |
private List | filesetsThe list of component archives which match a nested element. |
protected static final String | TYPE_APP |
protected static final String | TYPE_EJB |
protected static final String | TYPE_WEB |
protected static final String | TYPE_CONN |
protected static final String | TYPE_CLIENT |
protected static final Map | TYPE_MAPConstants for each of the component types. In addition, the archive file
extensions are mapped to their appropriate component types. Note that
".jar" maps only to EJB although this is a valid file extension for both
EJB JARs and application clients. |
Methods Summary |
---|
public void | addFileset(org.apache.tools.ant.types.FileSet fileset)Adds a nested fileset element.
filesets.add(fileset);
|
protected void | checkComponentConfig(Server aServer, org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentAdmin$Component comp)Verifies the options and parameters selected by the user are valid and
consistent for a given server and given component.
log("Checking config for server \"" + aServer + "\" and component \""
+ comp + "\"", Project.MSG_DEBUG);
// if specified, file must exist (either directory or file)
File theFile = comp.getFile();
log("The file for this component: " + theFile, Project.MSG_DEBUG);
if ((theFile != null) && (!theFile.exists())) {
throw new BuildException(lsm.getString("FileCouldNotBeFound",
new Object[] {theFile}),
getLocation());
}
// name must be >0 characters
String theName = comp.getName();
if ((theName == null) || (theName.length() == 0)) {
throw new BuildException(lsm.getString("CouldNotDetermineComponentName"),
getLocation());
}
// type must be valid
String theType = comp.getType();
if ((theType != null) && (!TYPE_MAP.values().contains(theType))) {
throw new BuildException(lsm.getString("TypeNotValid",
new Object[] {theType}),
getLocation());
}
|
protected void | checkConfiguration()
super.checkConfiguration();
log(components.size() + " components were found.", Project.MSG_DEBUG);
if (components.size() == 0) { // This isn't necessarily a failure
log(lsm.getString("NoComponentsSpecified"), Project.MSG_WARN);
}
|
protected void | checkConfiguration(Server aServer)Verifies that the options and parameters selected by the user are valid
and consistent for a given server.
String hostname = aServer.getHost();
if (hostname == null) {
hostname = "localhost";
}
log("Checking server config for " + hostname, Project.MSG_DEBUG);
if (!aServer.hasPassword()) {
throw new BuildException(lsm.getString("PasswordMustBeSpecified",
new Object[] {getTaskName(),
hostname}), getLocation());
}
Iterator iterator = components.iterator();
while (iterator.hasNext()) { // Check the config on each component found
Component comp = (Component)iterator.next();
checkComponentConfig(aServer, comp);
}
|
public org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentAdmin$Component | createComponent()Creates a nested component element.
Component newComponent = getNewComponent();
components.add(newComponent);
return newComponent;
|
protected void | execute(Server aServer)
Iterator iterator = components.iterator();
while (iterator.hasNext()) { // Execute command using each component
Component comp = (Component)iterator.next();
String cmdString = getCommandString(aServer, comp);
execAdminCommand(cmdString);
}
|
protected abstract java.lang.String | getCommandString(Server aServer, org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentAdmin$Component comp)Gets the Sun ONE Application Server command to be executed on the
specified server for the given component.
|
protected org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentAdmin$Component | getNewComponent()Builds a new component instance. This method is intended to be overridden
by subclasses which implement their own subclass of Component.
return new Component(component);
|
protected void | prepareToExecute()
super.prepareToExecute();
processFilesets();
if (components.size() == 0) {
components.add(component);
}
|
private void | processFilesets()Examines each nested fileset and adds the matching files and directories
to the "components" List object.
for (int i = 0; i < filesets.size(); i++) {
FileSet fileset = (FileSet) filesets.get(i);
DirectoryScanner scanner = fileset.getDirectoryScanner(project);
File baseDir = scanner.getBasedir();
String[] files = scanner.getIncludedFiles();
for (int j = 0; j < files.length; j++) {
Component archive = getNewComponent();
archive.setFile(new File(baseDir, files[j]));
components.add(archive);
}
String[] dirs = scanner.getIncludedDirectories();
for (int j = 0; j < dirs.length; j++) {
Component expandedArchive = getNewComponent();
expandedArchive.setFile(new File(baseDir, dirs[j]));
components.add(expandedArchive);
}
}
|
public void | setFile(java.io.File file)Sets the filename for the component file (or directory) which is used by
the administrative command.
component.setFile(file); // Delegates to component object
|
public void | setName(java.lang.String name)Sets the display-name for the J2EE component. This is the "friendly name"
which will appear in the admin GUI and administrative commands
component.setName(name); // Delegates to component object
|
public void | setTarget(java.lang.String target)Sets the deployment target.
component.setTarget(target); // Delegates to component object
|
public void | setType(java.lang.String type)Sets the component type. Valid types are "application", "ejb", "web",
"connector" and "client"
component.setType(type); // Delegates to component object
|