ComponentTaskpublic class ComponentTask extends ComponentAdmin This task enables or disables J2EE components which have been deployed to the
Sun ONE Application Server 7. The following components may be enabled or
disabled:
- Enterprise application (EAR file)
- Web application (WAR file)
- Enterprise Java Bean (EJB-JAR file)
- Enterprise connector (RAR file)
- Application client
The archive is not required to enable or disable a component -- only the
component name is required. The component archive may be used, however, as
it implies the component name.
In addition to the server-based and component-based attributes, this task
introduces one attribute:
- action -- The command for the application server. Valid
values are "enable" and "disable"
|
Fields Summary |
---|
private String | action | LocalStringsManager | lsm | private static final String | ACTION_ENABLE | private static final String | ACTION_DISABLE | private static final Map | ACTION_MAP |
Methods Summary |
---|
protected void | checkComponentConfig(Server aServer, Component comp)
super.checkComponentConfig(aServer, comp);
if (action == null) {
final String msg = lsm.getString("ActionCommandMustBeSpecified");
throw new BuildException(msg, getLocation());
}
if (!ACTION_MAP.containsKey(action)) {
final String msg = lsm.getString("InvalidActionCommand", new Object[] {action});
throw new BuildException(msg, getLocation());
}
// name must be valid string
String theName = comp.getName();
if ((theName == null) || (theName.length() == 0)) {
final String msg = lsm.getString("InvalidComponentName", new Object[] {theName});
throw new BuildException(msg, getLocation());
}
| protected java.lang.String | getCommandString(Server server, Component comp)
StringBuffer cmdString = new StringBuffer();
cmdString.append(ACTION_MAP.get(action));
cmdString.append(server.getCommandParameters(true));
if (comp.getType() != null) {
cmdString.append(" --type ").append(comp.getType());
}
// check the value and append target
String lTarget = comp.getTarget();
if ((lTarget != null) && (lTarget.length() > 0)) {
cmdString.append(" --target ").append(lTarget);
}
cmdString.append(" ").append(comp.getName());
return cmdString.toString();
| public void | setAction(java.lang.String action)Sets the action for the component command.
ACTION_MAP.put(ACTION_ENABLE, "enable");
ACTION_MAP.put(ACTION_DISABLE, "disable");
this.action = action;
|
|