FileDocCategorySizeDatePackage
DeployTask.javaAPI DocGlassfish v2 API32219Fri May 04 22:32:42 BST 2007org.apache.tools.ant.taskdefs.optional.sun.appserv

DeployTask

public class DeployTask extends ComponentAdmin
This task deploys J2EE components to the Sun ONE Application Server 7. The following components may be deployed:
  • Enterprise application (EAR file)
  • Web application (WAR file)
  • Enterprise Java Bean (EJB-JAR file)
  • Enterprise connector (RAR file)
  • Application client
see
AppServerAdmin
see
ComponentAdmin
author
Greg Nelson gn@sun.com

Fields Summary
private static final String
DEPLOY_COMMAND
private static final String
DEPLOY_DIR_COMMAND
LocalStringsManager
lsm
Constructors Summary
Methods Summary
private voidCheckForMutuallyExclusiveAttribute(org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask$DeployComponent deployComp)
This private class checks for any mutually exclusive attributes. If mutually exclusive attributes that are specified, then a BuildException is thrown.

        if (deployComp.createtablesIsSet &&
            deployComp.dropandcreatetablesIsSet ) {
            final String msg = lsm.getString("MutuallyExclusivelyAttribute",
                                             new Object[] {"createtables",
                                                           "dropandcreatetables"});
            throw new BuildException(msg, getLocation());
        }
    
protected voidcheckComponentConfig(Server aServer, Component comp)

		log("Checking component and server config in DeployTask", Project.MSG_DEBUG);

		DeployServer deployServer = (DeployServer) aServer;
		DeployComponent deployComp = (DeployComponent) comp;

		// file must be specified
		File theFile = comp.getFile();
		if (theFile == null) {
			throw new BuildException(lsm.getString("ComponentFileMustBeSpecified",
						 new Object[] {getTaskName()}), getLocation());
		}

		/*
		 * The file attribute is checked before the superclass implementation.
		 * If the superclass is called first and no file is specified, a 
		 * somewhat misleading error message is provided complaining the 
		 * component name couldn't be determined.
		 */
		super.checkComponentConfig(aServer, comp);

		// if an "exploded" archive is being deployed, --upload is not allowed
		if (theFile.isDirectory() && deployServer.getUpload()) {
			String hostname = aServer.getHost();
			if (hostname == null) {
				hostname = "localhost";
			}
			throw new BuildException(lsm.getString("UploadMayNotBeSetToTrue",
						 new Object[] {theFile.getAbsolutePath()}), 
						 getLocation());
		}

		// retrievestubs (if specified) must be a directory
		File theDir = deployComp.getRetrieveStubs();
		if (theDir != null) {
			if (!theDir.exists()) {
				throw new BuildException(lsm.getString(
							 "RetrieveStubsDirectoryDoesNotExist",
							 new Object[] {theDir}), getLocation());
			}
			if (!theDir.isDirectory()) {
			    throw new BuildException(lsm.getString(
                                                         "RetrievesStbusDoesNotReferToADirectory", 
							 new Object[] {theDir}), getLocation());
			}
		}
	
public ServercreateServer()
Creates a nested server element.

return
Server which has been added

		log("createServer using DeployServer object", Project.MSG_DEBUG);
		Server aNestedServer = new DeployServer(server);
		servers.add(aNestedServer);
		return aNestedServer;
	
protected java.lang.StringgetCommandString(Server aServer, Component comp)

		DeployServer deployServer = (DeployServer) aServer;
		DeployComponent deployComp = (DeployComponent) comp;

        CheckForMutuallyExclusiveAttribute(deployComp);

		StringBuffer cmdString;
		boolean isFile = comp.getFile().isFile();
		
		cmdString = new StringBuffer(isFile ? DEPLOY_COMMAND : DEPLOY_DIR_COMMAND);
		cmdString.append(aServer.getCommandParameters(true));
		if (comp.getType() != null) {
  		    log(lsm.getString("DeprecatedTypeAttribute"), Project.MSG_WARN);
		}
		cmdString.append(" --force=").append(deployComp.isForce());
        cmdString.append(" --enabled=").append(deployComp.isEnabled());
		cmdString.append(" --name ").append(comp.getName());
		cmdString.append(" --verify=").append(deployComp.isVerify());
        cmdString.append(" --precompilejsp=").append(deployComp.isPrecompileJsp());
		if (isFile) {
			cmdString.append(" --upload=").append(deployServer.getUpload());
		}
        if (deployServer.getVirtualServers() != null) {
			cmdString.append(" --virtualservers ");
            cmdString.append(deployServer.getVirtualServers());
		}

		if (deployComp.getRetrieveStubs() != null) {
			cmdString.append(" --retrieve ");
			cmdString.append("\""+deployComp.getRetrieveStubs()+"\"");
		}
        if (deployComp.getDeploymentplan() != null) {
			cmdString.append(" --deploymentplan ");
			cmdString.append("\""+deployComp.getDeploymentplan()+"\"");
		}

		if (deployComp.contextRootIsSet()) {
            cmdString.append(" --contextroot ").append(deployComp.getContextroot());
		}
        if (deployComp.getDbvendorname() != null) {
            cmdString.append(" --dbvendorname ").append(deployComp.getDbvendorname());
		}
        if (deployComp.createtablesIsSet) {
            cmdString.append(" --createtables=").append(deployComp.getCreatetables());
            deployComp.createtablesIsSet = false;  // set it back to false
		}
        if (deployComp.dropandcreatetablesIsSet) {
            cmdString.append(" --dropandcreatetables=").append(deployComp.getDropandcreatetables());
            deployComp.dropandcreatetablesIsSet = false; // set it back to false
		}
        if (deployComp.uniquetablenamesIsSet) {
            cmdString.append(" --uniquetablenames=").append(deployComp.getUniquetablenames());
            deployComp.uniquetablenamesIsSet = false;  // set it back to false
		}
        if (deployComp.availabilityenabledIsSet) {
            cmdString.append(" --availabilityenabled=").append(deployComp.getAvailabilityenabled());
            deployComp.availabilityenabledIsSet = false;   // set it back to false
		}
        if (deployComp.generatermistubsIsSet) {
            cmdString.append(" --generatermistubs=").append(deployComp.getGeneratermistubs());
            deployComp.generatermistubsIsSet = false;   // set it back to false
		}

		// check the value and append target
		String lTarget = deployComp.getTarget();
		if ((lTarget != null) && (lTarget.length() > 0)) {
	    		cmdString.append(" --target ").append(lTarget);
		}

		cmdString.append(" ").append("\""+comp.getFile().getPath()+"\"");

		return cmdString.toString();
	
protected ComponentgetNewComponent()

		return new DeployComponent(component);
	
protected ServergetNewServer()


	   
		return new DeployServer(server);
	
public voidsetAvailabilityenabled(boolean availabilityenabled)
Sets availabilityenabled option. If false then all SFSB checkpointing is disabled for either the given j2ee app or the given ejb module. If it is true then the j2ee app or stand-alone ejb modules may be ha enabled.

param
availabilityenabled

		((DeployComponent)component).setAvailabilityenabled(availabilityenabled);  // Delegates to component object
	
public voidsetContextroot(java.lang.String contextroot)
Sets the context root for a web module (WAR file). This attribute is only used when deploying WAR files to the application server.

param
contextroot The contextroot for the web application.

		((DeployComponent)component).setContextroot(contextroot); // Delegates to component obj
	
public voidsetCreatetables(boolean createtables)
Sets if creates tables at deploy of an application with unmapped CMP beans.

param
createtables

		((DeployComponent)component).setCreatetables(createtables);  // Delegates to component object
	
public voidsetDbvendorname(java.lang.String dbvendorname)
Sets the dbvendorname - the name of database vendor being used.

param
dbvendorname

		((DeployComponent)component).setDbvendorname(dbvendorname); // Delegates to component obj
	
public voidsetDeploymentplan(java.io.File deploymentplan)
Sets the deploymentplan, a jar containing the sun-specifi descriptors which should be passed along when deploying a pure ear.

param
deploymentplan

		((DeployComponent)component).setDeploymentplan(deploymentplan); // Delegates to component obj
	
public voidsetDropandcreatetables(boolean dropandcreatetables)
Sets if drops tables at undeploy of an already deployed application with unmapped CMP beans.

param
dropandcreatetables

		((DeployComponent)component).setDropandcreatetables(dropandcreatetables);  // Delegates to component object
	
public voidsetEnabled(boolean enabled)
Sets if the command is enabled or disabled.

param
enabled If set to true, component is enabled. If set to false, component is disabled.

		((DeployComponent)component).setEnabled(enabled);  // Delegates to component object
	
public voidsetForce(boolean force)
Sets if the command should overwrite existing values or components.

param
force If set to true, components are automatically overwritten. If set to false, administrative commands will fail if the component already exists.

		((DeployComponent)component).setForce(force);  // Delegates to component object
	
public voidsetGeneratermistubs(boolean generatermistubs)
Sets generatermistubs option. If true then generate the static RMI-IIOP stubs and put it in the client.jar.

param
generatermistubs

		((DeployComponent)component).setGeneratermistubs(generatermistubs);  // Delegates to component object
	
public voidsetPrecompileJsp(boolean precompile)
Sets if the command should precompile JSPs when deploying them to the server.

param
precompile If set to true, JSPs are automatically compiled.

		((DeployComponent)component).setPrecompileJsp(precompile);  // Delegates to component object
	
public voidsetRetrieveStubs(java.io.File stubsDir)
Sets the directory where the JAR file with client stubs will be saved.

param
dir The directory where client stubs will be saved.

		((DeployComponent)component).setRetrieveStubs(stubsDir);  // Delegates to component object
	
public voidsetUniquetablenames(boolean uniquetablenames)
Sets the unique table names for all the beans and results in a hascode added to the table names.

param
uniquetablenames

		((DeployComponent)component).setUniquetablenames(uniquetablenames);  // Delegates to component object
	
public voidsetUpload(boolean upload)
Set if the component should be transferred to the (potentially) remote server before executing the command. Defaults to true.

param
upload If set to true, components are transferred to the server before the command is executed.

		((DeployServer)server).setUpload(upload);  // Delegates to server object
	
public voidsetVerify(boolean verify)
Sets if the deployment descriptors should be verified as part of the deployment process.

param
verify If set to true, the deployment descriptors will be verified.

		((DeployComponent)component).setVerify(verify);
	
public voidsetVirtualServers(java.lang.String virtualServers)
Specifies the virtual server (or servers) where the component will be deployed. This applies to only EAR and WAR files.

param
virtualServers The name of the virtual server or the names of multiple virtual servers separated by commas (',')

		((DeployServer)server).setVirtualServers(virtualServers);