FileDocCategorySizeDatePackage
InstanceTask.javaAPI DocGlassfish v2 API4269Fri May 04 22:32:42 BST 2007org.apache.tools.ant.taskdefs.optional.iplanet

InstanceTask

public class InstanceTask extends IasAdmin

Fields Summary
private String
action
private static final String
ACTION_START
private static final String
ACTION_STOP
private static final String
ACTION_RESTART
private static final String
ACTION_CREATE
private static final String
ACTION_DESTROY
private static final Map
ACTION_MAP
Constructors Summary
Methods Summary
protected voidcheckConfiguration()

		super.checkConfiguration();
	
		if (action == null) {
			String msg = "The action command must be specified.";
			throw new BuildException(msg, getLocation());
		}

		if (!ACTION_MAP.containsKey(action)) {

			String msg = "The action command (\"" + action + "\") is invalid.";
			throw new BuildException(msg, getLocation());
		}
	
protected voidcheckConfiguration(Server aServer)

		super.checkConfiguration(aServer);
		if ((action.equals(ACTION_CREATE) || action.equals(ACTION_DESTROY)) &&
				(aServer.getInstance() == null)) {
			String msg = "When creating or destroying an application server "
							+ "instance, the \"instance\" attribute is required.";
			throw new BuildException(msg, getLocation());
		}
	
protected voidexecute(Server aServer)

		if (action.equals(ACTION_RESTART)) {
			execute(ACTION_STOP, aServer);
			execute(ACTION_START, aServer);
		} else {
			execute(action, aServer);
		}
	
private voidexecute(java.lang.String anAction, Server aServer)

		String cmdString = (String) ACTION_MAP.get(anAction);
		cmdString +=aServer.getCommandParameters(false);
		if (anAction.equals(ACTION_CREATE)) {
			cmdString += " --instanceport " + aServer.getInstanceport();
		}
		if (aServer.getInstance() != null) {
			cmdString += " " + aServer.getInstance();
		}
		execIasCommand(cmdString);
	
public voidsetAction(java.lang.String action)

	 
		ACTION_MAP.put(ACTION_START, "start-instance");
		ACTION_MAP.put(ACTION_STOP, "stop-instance");
		ACTION_MAP.put(ACTION_RESTART, null);
		ACTION_MAP.put(ACTION_CREATE, "create-instance");
		ACTION_MAP.put(ACTION_DESTROY, "delete-instance");
	
		this.action = action;