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

IasAdmin

public abstract class IasAdmin extends org.apache.tools.ant.Task

Fields Summary
private Server
server
private List
servers
private File
ias7home
private static final boolean
ACTUALLY_EXEC_COMMAND
private static final String[]
CLASSPATH_ELEMENTS
private static final String
CLASS_INPUTS_AND_OUTPUTS
private static final String
CLASS_IAS_ADMIN_MAIN
private static final String
METHOD_INVOKE_CLI
Constructors Summary
Methods Summary
protected voidcheckConfiguration()


		if (servers.size() == 0) {
			String msg = "At least one server must be specified.";
			throw new BuildException(msg, getLocation());
		}

		Iterator it = servers.iterator();
		while (it.hasNext()) {
			Server aServer = (Server)it.next();
			checkConfiguration(server);
		}
	
protected voidcheckConfiguration(org.apache.tools.ant.taskdefs.optional.iplanet.IasAdmin$Server aServer)

		if (aServer.getPassword() == null) {
			String msg = "A password must be specified for each server.  A "
							+ "password for " + aServer.getHost() + " was "
							+ "not specified.";
			throw new BuildException(msg, getLocation());
		}
	
public org.apache.tools.ant.taskdefs.optional.iplanet.IasAdmin$ServercreateServer()

		log("createServer", Project.MSG_DEBUG);
		Server aServer = new Server(server);
		servers.add(aServer);
		return aServer;
	
protected voidexecIasCommand(java.lang.String command)

		log("Executing: " + command, Project.MSG_INFO);

		try {
			Path iasClasspath = new Path(getProject(), getIasClasspath());
			iasClasspath.append(Path.systemClasspath);
			log("Using classpath: " + iasClasspath.toString(), Project.MSG_DEBUG);

			ClassLoader antClassLoader = new AntClassLoader(getProject(), iasClasspath);

			Class inputsAndOutputs = 
						Class.forName(CLASS_INPUTS_AND_OUTPUTS, true, antClassLoader);
			Class iasAdminMain = 
						Class.forName(CLASS_IAS_ADMIN_MAIN, true, antClassLoader);

			Class[] parameterClasses = {String.class, inputsAndOutputs};
			Method invokeCLI =  
					iasAdminMain.getDeclaredMethod(METHOD_INVOKE_CLI, parameterClasses);

			Object[] parameters = {command, null};

			if (ACTUALLY_EXEC_COMMAND) {
				invokeCLI.invoke(iasAdminMain, parameters);
			}
		} catch (ClassNotFoundException e) {
			String msg = "An iPlanet Application Server 7.0 admin CLI "
							+ "class could not be found (" + e.getMessage()
							+ ").  Use the ias7home attribute, set the "
							+ "ias7.home property, or add the appropriate "
							+ "JARs to the classpath.";
			throw new BuildException(msg, getLocation());
		} catch (NoSuchMethodException e) {
			String msg = "The \"invokeCLI\" method couldn't be found on the "
							+ "IasAdminMain class.  The exception message "
							+ "is:  " + e.getMessage();
			throw new BuildException(msg, getLocation());
		} catch (InvocationTargetException e) {
			String msg = "An exception occurred while running the command.  The "
							+ "exception message is: "
							+ e.getTargetException().getMessage();
			throw new BuildException(msg, getLocation());
		} catch (IllegalAccessException e) {
			String msg = "An exception occurred while trying to invoke the "
							+ "\"invokeCLI\" method.  The exception message "
							+ "is: " + e.getMessage();
			throw new BuildException(msg, getLocation());
		}
	
public voidexecute()

		prepareToExecute();
		checkConfiguration();

		Iterator it = servers.iterator();
		while (it.hasNext()) {
			Server aServer = (Server)it.next();
			execute(aServer);
		}
	
protected abstract voidexecute(org.apache.tools.ant.taskdefs.optional.iplanet.IasAdmin$Server server)

protected java.lang.String[]getClasspathElements()
Returns the JARs and directories that should be added to the classpath when calling the IasAdminMain class. All elements are relative to the iPlanet Application Server 7.0 installation directory.

		return CLASSPATH_ELEMENTS;
	
protected java.io.FilegetIas7home()
Returns null if iashome hasn't been explicitly set and the property ias7.home isn't set.

		if (ias7home == null) {
			String home = getProject().getProperty("ias7.home");
			if (home != null) {
				ias7home = new File(home);
			}
		}
		
		return ias7home;
	
private java.lang.StringgetIasClasspath()

		StringBuffer classpath = new StringBuffer();
		String[] elements = getClasspathElements();
		for (int i = 0; i < elements.length; i++ ) {
			classpath.append(new File(getIas7home(), elements[i]).getPath());
			classpath.append(':");
		}

		return classpath.toString();
	
private org.apache.tools.ant.taskdefs.optional.iplanet.IasAdmin$ServergetServer()

		if (server == null) {
			server = new Server();
			Iterator it = servers.iterator();
			while (it.hasNext()) {
				Server aServer = (Server)it.next();
				aServer.setParent(server);
			}
		}
		return server;
	
protected voidprepareToExecute()

		if ((servers.size() == 0) && (server != null)) {
			servers.add(server);
		}
	
public voidsetHost(java.lang.String host)

		getServer().setHost(host);
	
public voidsetIas7home(java.io.File iashome)

		this.ias7home = ias7home;
	
public voidsetInstance(java.lang.String instance)

		getServer().setInstance(instance);
	
public voidsetInstanceport(int instanceport)

		getServer().setInstanceport(instanceport);
	
public voidsetPassword(java.lang.String password)

		log("setPassword:  " + password, Project.MSG_DEBUG);
		getServer().setPassword(password);
	
public voidsetPort(int port)

		getServer().setPort(port);
	
public voidsetUser(java.lang.String user)


	    
		getServer().setUser(user);