Package com.sun.enterprise.deployment.backend

Examples of com.sun.enterprise.deployment.backend.DeploymentRequest


            final DeploymentTarget target =
                DeploymentServiceUtils.getDeploymentTarget(targetName);
           
            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);

            int actionCode;
            if(type.isAPP()) {
                actionCode = BaseDeployEvent.APPLICATION_DEPLOYED;
            }
            else {
                actionCode = BaseDeployEvent.MODULE_DEPLOYED;
            }
   
            req.setName(moduleID);
            req.setActionCode(actionCode);
            req.setTarget(target);

            DeploymentProperties dProps = new DeploymentProperties(options);
            req.setForced(dProps.getForce());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            return start(req, createAuditInfoIfOn(req, AuditInfo.Operation.start, startTime));
       } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
View Full Code Here


            final DeploymentTarget target =
                DeploymentServiceUtils.getDeploymentTarget(targetName);
       
            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.UNDEPLOY);
               
            int actionCode;
            if(type.isAPP()) {
                actionCode = BaseDeployEvent.APPLICATION_UNDEPLOYED;
            }  
            else {
                actionCode = BaseDeployEvent.MODULE_UNDEPLOYED;
            }                      
                                   
            req.setName(moduleID);
            req.setActionCode(actionCode);
            req.setTarget(target);

            DeploymentProperties dProps = new DeploymentProperties(options);
            req.setCascade(dProps.getCascade());
            req.setForced(dProps.getForce());
            req.setExternallyManagedPath(dProps.getExternallyManaged());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            return stop(req, createAuditInfoIfOn(req, AuditInfo.Operation.stop, startTime));
        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
View Full Code Here

                            moduleID, deployFile.getAbsolutePath());
            }       

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);
   
            DeploymentRequestRegistry.getRegistry().addDeploymentRequest(
                moduleID, req);

            req.setName(moduleID);
            boolean isRegistered = false;
            isRegistered = DeploymentServiceUtils.isRegistered(moduleID, type);
            // FIXME validation for new REDEPLOY property

            if (isRegistered) {
                DeploymentServiceUtils.validate(moduleID,type,REDEPLOY_ACTION, req);
            }

            req.setFileSource(deployFile);
            req.setDeploymentPlan(planFile);
            req.setForced(dProps.getForce());
            // Set the context Root for extension modules
            if(type.isWEB() || req.isExtensionModule()) {
                req.setDefaultContextRoot(dProps.getDefaultContextRoot(
                    archiveName));
                req.setContextRoot(dProps.getContextRoot());
            }
            req.setVerifying(dProps.getVerify());
            req.setPrecompileJSP(dProps.getPrecompileJSP());
            req.setGenerateRMIStubs(dProps.getGenerateRMIStubs());
            req.setAvailabilityEnabled(dProps.getAvailabilityEnabled());
            req.setStartOnDeploy(dProps.getEnable());
            req.setDescription(dProps.getDescription());
            req.setLibraries(dProps.getLibraries());
            req.setJavaWebStartEnabled(dProps.getJavaWebStartEnabled());
            req.setExternallyManagedPath(dProps.getExternallyManaged());
            req.setDeploymentCallback(callback);
            req.setIsRedeployInProgress(dProps.getRedeploy());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            /*
             * The property option (name=value)[:name=value]* pair
             * is sent as String which is read here and converted to a Map.
             * The Map is sent in the request
             */
            Properties propOption= new Properties();
            Map<String, String> propMap = new HashMap();
            if(dProps != null)
            {
                for (Iterator itr = dProps.keySet().iterator(); itr.hasNext();) {
                    String propKey = (String) itr.next();
                    if(propKey.equals(PROPERTY)) {
                        String propValue = (String) dProps.get(propKey);
                        StringTokenizer tok = new StringTokenizer(propValue, ":");
                        while(tok.hasMoreElements()) {
                            StringTokenizer token = new StringTokenizer(tok.nextToken(), "=");
                               String key = token.nextToken();
                               String val = token.nextToken();
                               propMap.put(key, val);
                            
                        }
                    }
                }
            }
            propOption.put(PROPERTY, propMap);

            Properties optionalAttributes = new Properties();
            String virtualServers = dProps.getVirtualServers();
            if(virtualServers!=null) {
                optionalAttributes.put(ServerTags.VIRTUAL_SERVERS,
                    virtualServers);
            }
            req.setOptionalAttributes(optionalAttributes);

            req.addOptionalArguments(dProps.prune());
            req.addOptionalArguments(propOption);
            DeploymentServiceUtils.setHostAndPort(req);
            return deploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.deploy, startTime));
        } catch(Exception e) {
            sLogger.log(Level.WARNING, "mbean.deploy_failed", e);
View Full Code Here

                DeploymentServiceUtils.checkWebModuleReferences(mModuleID);
            }

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(env,
                objectType, DeploymentCommand.UNDEPLOY);

            DeploymentRequestRegistry.getRegistry().addDeploymentRequest(
                mModuleID, req);

            DeploymentProperties dProps =
                new DeploymentProperties(mParams);
            req.setName(mModuleID);
            req.setCascade(dProps.getCascade());
            req.setExternallyManagedPath(dProps.getExternallyManaged());

            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            req.addOptionalArguments(dProps.prune());
            return undeploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.undeploy, startTime));
        }
        catch(Exception e) {
            String msg = localStrings.getString(
            "enterprise.deployment.phasing.deploymentservice.undeploy.failed",
View Full Code Here

            }
        }
    }

    public boolean quit(String moduleID) {
        DeploymentRequest request = DeploymentRequestRegistry.getRegistry().getDeploymentRequest(moduleID);
        if (request != null) {
            request.setAbort(true);
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

        boolean   isApp    = false;
        boolean  isRedeploy  = false;
        int    actionCode  = -1;
        String  targetName  = null;
        DeploymentTarget target = null;
        DeploymentRequest req = phaseCtx.getDeploymentRequest();
        DeploymentStatus status = phaseCtx.getDeploymentStatus();

        Deployer deployer = null;
        ExtensionModuleDeployer extDeployer = null;

        try {
            DeploymentCallback callback = req.getDeploymentCallback();
            if (callback != null) {
                int percent = 0;
                DeploymentProgress progress = new DeploymentProgressImpl(
                    (byte)percent, "deployment started", null);
                callback.deploymentProgress(progress);
            }
       
            // set the current deployment status in deployment request
            // to J2EECPhase deployment status
            req.setCurrentDeploymentStatus(status);

            req.setDescriptor(deploymentCtx.getApplication(req.getName()));

            if (DeploymentServiceUtils.isRegistered(req.getName(),
                req.getType()) && req.isForced()) {

                isRedeploy = true;

                //Re-record instrospect/instrument/verifier data if
                //any of the application is re-deployed
                if (AppVerification.doInstrument()) {
                    AppVerification.getInstrumentLogger().handleChangeInDeployment();
                }
            }

            if(req.isApplication())
                isApp = true;
           
            if (!req.isExtensionModule()) {
                deployer = DeployerFactory.getDeployer(req);
                deployer.doRequestPrepare();
            }

            if(isRedeploy) {
                // clear the deploymentCtx cache now
                deploymentCtx.removeApplication(req.getName());              
                req.setDescriptor(null);

                target = (DeploymentTarget)req.getTarget();
               
                // In the case of redeploy to domain,
                // no stop event will be sent.
                if(target != null && ! target.getName().equals("domain")) {
                    targetName = target.getName();
               
                    if(isApp) {
                        type = null;
                        actionCode  = BaseDeployEvent.APPLICATION_UNDEPLOYED;
                    }
                    else {
                        type = DeploymentServiceUtils.getModuleTypeString(req.getType());
                        actionCode  = BaseDeployEvent.MODULE_UNDEPLOYED;
                    }
                    DeploymentServiceUtils.multicastEvent(actionCode, req.getName(), type, req.getCascade(), req.isForced(),  targetName);
                    wasUnRegistered = true;
                }
            }
           
            if (req.isExtensionModule()) {
                ModuleType moduleType = req.getType().getModuleType();
                extDeployer =
                    PluggableDeploymentInfo.getExtensionModuleDeployer(
                        moduleType);  
                if (isRedeploy) {
                    extDeployer.redeployToDomain(req);
                } else {
                    extDeployer.deployToDomain(req);
                }
            } else {
                deployer.doRequestFinish();
                // cache the updated application object in deployment context
                deploymentCtx.addApplication(req.getName(), req.getDescriptor());
                parseAndValidateSunResourcesXMLFiles(req);
                deployer.cleanup();
            }
           
            // check if an abort operation has been issued
            // throw exception if true
            DeploymentServiceUtils.checkAbort(req.getName());

            // do all the config update at the end for easy rollback
            if(isRedeploy) {
                DeploymentServiceUtils.updateConfig(req);
            } else {
                DeploymentServiceUtils.addToConfig(req);
            }
            // set context roots on config bean
            ApplicationConfigHelper.resetAppContextRoots(
                DeploymentServiceUtils.getConfigContext(), req.getName(),
                true);

            wasUnRegistered = false// addToConfig re-registered it...

            // everything went fine
            status.setStageStatus(DeploymentStatus.SUCCESS);           
           
            // some useful information for clients...
            sLogger.log(Level.INFO, "deployed with " + DeploymentProperties.MODULE_ID + " = " + req.getName());
            populateStatusProperties(status, req);
            if (callback != null) {
                int percent = 100;
                DeploymentProgress progress2 = new DeploymentProgressImpl(
                    (byte)percent, "deployment finished", null);
                callback.deploymentProgress(progress2);
            }
        
        } catch(Throwable t) {
            String msg =
            localStrings.getString("enterprise.deployment.phasing.j2eec.error" );
            if (t.getCause()!= null)
                msg += t.getCause().toString();

            // For any failure during the J2EEC phase (during fresh deploy or redeploy), cleanup the domain.xml
            // so that the config is left in a clean state without any hanging j2ee-app/module elements without
            // any app-refs;
            // the target==null check ensures that this code is done for 8.1 only thereby preserving same
            // behavior for 8.0 apps
            try {
                if (target == null) {
                    if (deployer != null) {
                        deployer.removePolicy();
                    }
                    DeploymentServiceUtils.removeFromConfig(req.getName(),
                        req.getType());
                }
            } catch (Exception eee){}

            if(isRedeploy && wasUnRegistered && t instanceof IASDeploymentException && req.getReRegisterOnFailure()) {
                // DBE rollback re-registered.  We need to notify to get it reloaded now.
                if(isApp)
                    actionCode = BaseDeployEvent.APPLICATION_DEPLOYED;
                else
                    actionCode = BaseDeployEvent.MODULE_DEPLOYED;
               
                try {
                    DeploymentServiceUtils.multicastEvent(actionCode, req.getName(), type, req.getCascade(), req.isForced(), targetName);
                }
                catch(Throwable t2) {
                    msg += t2;
                }
            }
View Full Code Here

    public void runPhase(DeploymentPhaseContext phaseCtx)
    {
        DeploymentStatus status = phaseCtx.getDeploymentStatus();

        try {
            DeploymentRequest req = phaseCtx.getDeploymentRequest();
                                                                     
            prePhaseNotify(getPrePhaseEvent(req));
            doResourceOperation(req);
            postPhaseNotify(getPostPhaseEvent(req));
                                                                     
View Full Code Here

     * @param phaseCtx the DeploymentPhaseContext object    
     */
    public void runPhase(DeploymentPhaseContext phaseCtx) {
        String type = null;
       
        DeploymentRequest req = phaseCtx.getDeploymentRequest();

        DeploymentStatus status = phaseCtx.getDeploymentStatus();
       
        DeploymentTarget target = (DeploymentTarget)req.getTarget();
        if(target == null) {
            String msg = localStrings.getString("enterprise.deployment.phasing.start.targetnotspecified");
            sLogger.log(Level.FINEST, msg);
            status.setStageStatus(DeploymentStatus.SUCCESS);           
            return;
        }
       
        if (!DeploymentServiceUtils.containsResourceAdapter(req)) {
            status.setStageStatus(DeploymentStatus.SUCCESS);
            return;
        }

        if (!req.isApplication()) {
            type = DeploymentServiceUtils.getModuleTypeString(req.getType());
        }

        prePhaseNotify(getPrePhaseEvent(req));
        int actionCode = req.getActionCode();
       
        boolean success;
        try {
           // send this event to load standalone rar
           // or the rar part of the embedded rar
           success = target.sendStartEvent(actionCode, req.getName(), type,
                                           req.isForced(), Constants.LOAD_RAR);
        } catch(DeploymentTargetException dte) {
            status.setStageStatus(DeploymentStatus.WARNING);
            if (dte.getCause()!=null) {
                status.setStageStatusMessage(dte.getMessage());
            }
View Full Code Here

        }
    }

    public static void checkAbort(String moduleID)
        throws IASDeploymentException {
        DeploymentRequest request =
            DeploymentRequestRegistry.getRegistry().getDeploymentRequest(
                moduleID);
        if (request != null && request.isAborted()) {
            DeploymentRequestRegistry.getRegistry().removeDeploymentRequest(
                moduleID);
            String msg = localStrings.getString(
                "enterprise.deployment.phasing.operation.abort",
                new Object[]{ moduleID });
View Full Code Here

     */
    public void runPhase(DeploymentPhaseContext phaseCtx)
    {
        String type = null;
       
        DeploymentRequest req = phaseCtx.getDeploymentRequest();

        DeploymentTarget target = (DeploymentTarget)req.getTarget();
        DeploymentStatus status = phaseCtx.getDeploymentStatus();

        int loadUnloadAction = Constants.UNLOAD_ALL;

        Application app = DeploymentServiceUtils.getInstanceManager(
               req.getType()).getRegisteredDescriptor(req.getName());

        // store the application object in DeploymentContext before it's
        // removed from instance manager cache
        deploymentCtx.addApplication(req.getName(), app);
       
        if(!req.isApplication())
        {        
            type = DeploymentServiceUtils.getModuleTypeString(req.getType());
        } else {
            if ( (app != null) && (app.getRarComponentCount() != 0) ) {
                loadUnloadAction = Constants.UNLOAD_REST;
            }
        }
       
        prePhaseNotify(getPrePhaseEvent(req));
 
        boolean success;
        try {
            // send this event to unload non-rar standalone module
            // or to unload the non-rar submodules of embedded rar
            if (! req.isConnectorModule()) {
                success = target.sendStopEvent(req.getActionCode(), req.getName(), type, req.getCascade(), req.isForced(), loadUnloadAction);
            } else {
                status.setStageStatus(DeploymentStatus.SUCCESS);
                return;
            }
        } catch(DeploymentTargetException dte) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.backend.DeploymentRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.