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

ComponentAdmin

public abstract class ComponentAdmin extends IasAdmin

Fields Summary
private Component
component
private List
components
private List
filesets
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_MAP
Constructors Summary
Methods Summary
public voidaddFileset(org.apache.tools.ant.types.FileSet fileset)

        filesets.add(fileset);
    
protected voidcheckComponentConfig(org.apache.tools.ant.taskdefs.optional.iplanet.ComponentAdmin$Component comp)

		log("Checking configuration for " + comp.getName(), Project.MSG_DEBUG);

		// if specified, file must exist (either directory or file)
		File theFile = comp.getFile();
		if ((theFile != null) && (!theFile.exists())) {
			String msg = "The file specified (" + theFile + ") could not be found.";
			throw new BuildException(msg, getLocation());
		}

		// name must be >0 characters
		String theName = comp.getName();
		if ((theName == null) || (theName.length() == 0)) {
			String msg = "A valid name for the component could not be determined.";
			throw new BuildException(msg, getLocation());
		}

		// type must be valid
		String theType = comp.getType();
		if ((theType != null) && (!TYPE_MAP.values().contains(theType))) {
			String msg = "The type specified (" + theType + ") is not valid.";
			throw new BuildException(msg, getLocation());
		}
	
protected voidcheckConfiguration()

		super.checkConfiguration();

		if (components.size() == 0) {
			log("WARNING!  No components were specified.", Project.MSG_WARN);
		}

		log(components.size() + " components were found.", Project.MSG_DEBUG);

		Iterator iterator = components.iterator();
		while (iterator.hasNext()) {
			Component comp = (Component)iterator.next();
			checkComponentConfig(comp);
		}
	
public org.apache.tools.ant.taskdefs.optional.iplanet.ComponentAdmin$ComponentcreateComponent()

		log("createComponent", Project.MSG_DEBUG);
		Component newComponent = new Component(component);
		components.add(newComponent);
		return newComponent;
	
protected voidexecute(Server server)

		Iterator iterator = components.iterator();
		while (iterator.hasNext()) {
			Component comp = (Component)iterator.next();
			String cmdString = getCommandString(server, comp);
			execIasCommand(cmdString);
		}
	
protected abstract java.lang.StringgetCommandString(Server server, org.apache.tools.ant.taskdefs.optional.iplanet.ComponentAdmin$Component comp)

private org.apache.tools.ant.taskdefs.optional.iplanet.ComponentAdmin$ComponentgetComponent()

		if (component == null) {
			component = new Component();
			Iterator it = components.iterator();
			while (it.hasNext()) {
				Component aComponent = (Component)it.next();
				aComponent.setParent(component);
			}
			components.add(0, component);
		}

		return component;
	
protected voidprepareToExecute()

		super.prepareToExecute();
		processFilesets();
	
private voidprocessFilesets()

		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 = new Component();
				archive.setFile(new File(baseDir, files[j]));
				components.add(archive);
			}

			String[] dirs = scanner.getIncludedDirectories();
			for (int j = 0; j < dirs.length; j++) {
				Component expandedArchive = new Component();
				expandedArchive.setFile(new File(baseDir, dirs[j]));
				components.add(expandedArchive);
			}
		}
	
public voidsetContextroot(java.lang.String contextroot)

		getComponent().setContextroot(contextroot);
	
public voidsetFile(java.io.File file)

 // FIXME (4 or 5 elements?)
	 
		TYPE_MAP.put("ear", TYPE_APP);
		TYPE_MAP.put("jar", TYPE_EJB);
		TYPE_MAP.put("war", TYPE_WEB);
		TYPE_MAP.put("rar", TYPE_CONN);
//		TYPE_MAP.put("???", TYPE_CLIENT);  // FIXME
	
		getComponent().setFile(file);
	
public voidsetForce(boolean force)

		getComponent().setForce(force);
	
public voidsetName(java.lang.String name)

		getComponent().setName(name);
	
public voidsetType(java.lang.String type)

		getComponent().setType(type);
	
public voidsetUpload(boolean upload)

		getComponent().setUpload(upload);