FileDocCategorySizeDatePackage
AutoDeployer.javaAPI DocGlassfish v2 API6852Fri May 04 22:35:40 BST 2007com.sun.enterprise.server

AutoDeployer

public class AutoDeployer extends Object implements MonitorListener
This class is a listener implementation of the auto deploy callbacks. When auto deploy monitor detects a new archive under the auto deploy directory, this class handles the callback from the monitor.
author
Nazrul Islam
since
JDK1.4

Fields Summary
static Logger
_logger
logger for this auto deployer
Constructors Summary
Methods Summary
public booleandeploy(MonitorableEntry entry, java.io.File archive)
Handles the callbacks from the auto deploy monitor.

param
entry entry thats being monitored
param
archive newly detected archive under the auto deploy directory
return
true if deployed successfully


        boolean status = false;

        try {
            DeploymentRequest req = deploy(archive);

            // load/reload deployed application/stand alone module

            // update the config context in server runtime

            // notify admin server if necessary

            status = true;
        } catch (IASDeploymentException de) {
            _logger.log(Level.WARNING, "core.exception", de);
            status = false;
        }

        return status;
    
private com.sun.enterprise.deployment.backend.DeploymentRequestdeploy(java.io.File archive)
Deploys the given archive. If it is already been deployed, this redeploys the application.

param
archive archive to be deployed
return
deployment request after the deployment; this provides information about the type of deployment being executed
throws
IASDeploymentException if an error while deploying


        // instance environment for this server
        InstanceEnvironment env = 
            ApplicationServer.getServerContext().getInstanceEnvironment();

        // sets the type of the archive being deployed
        DeployableObjectType type = null;
        if ( FileUtils.isEar(archive) ) {
            type = DeployableObjectType.APP;
        } else if ( FileUtils.isJar(archive) ) {
            type = DeployableObjectType.EJB;
        } else if ( FileUtils.isWar(archive) ) {
            type = DeployableObjectType.WEB;
        } else if ( FileUtils.isRar(archive) ) {
            type = DeployableObjectType.CONN;
        }

        // constructs a deploy request with the given type
        DeploymentRequest req = 
            new DeploymentRequest(env, type, DeploymentCommand.DEPLOY);

        // sets the archive that needs to be deployed
        req.setFileSource(archive);

        // application is registered with the name of the 
        // archive without extension
        String fileName  = archive.getName();
        int dotIdx       = fileName.indexOf(fileName);
        String regName   = fileName.substring(0, dotIdx); 
        req.setName(regName);

        // sets the web context root
        if (type.isWEB()) {
            req.setContextRoot(regName);
        }

        // redeploys the app if already deployed
        req.setForced(true);

        // does the actual deployment
        Deployer deployer = DeployerFactory.getDeployer(req);
        deployer.doRequest();

        // any clean up other than cleaner thread invocation
        deployer.cleanup();

        return req;
    
public booleanreload(MonitorableEntry entry)
No-op.

param
entry monitored entry with a change in time stamp
return
no-op; returns false


    // ---- START OF MonitorListener METHOD -----------------------------------

                                 
         
        return false;