Examples of ProgressObjectImpl


Examples of com.caucho.j2ee.deployclient.ProgressObjectImpl

  public ProgressObject distribute(TargetImpl []hostTargets,
                                   InputStream archiveIs,
                                   DeploymentPlan plan)
    throws IllegalStateException
  {
    ProgressObjectImpl progress;
   
    if (hostTargets == null || hostTargets.length != 1) {
      String msg = L.l("jsr88 can only support single-host deploy");
     
      log.warning(msg);

      progress = new ProgressObjectImpl(new TargetModuleID[0]);
   
      progress.failed(msg);

      return progress;
    }

    String hostName = hostTargets[0].getName();

    String name = plan.getName();
    String moduleID;

    ArchiveDeployMXBean mxbean = null;

    try {
      if ("ear".equals(plan.getArchiveType())) {
        moduleID = "resin:name=" + name + ",type=EApp,Host=" + hostName;
     
        String jmxName = "resin:type=EarDeploy,Host=" + hostName + ",*";
        mxbean = loadArchiveMXBean(jmxName);
      }
      else if ("war".equals(plan.getArchiveType())) {
        moduleID = "resin:name=/" + name + ",type=WebApp,Host=" + hostName;
     
        String jmxName = "resin:type=WebAppDeploy,Host=" + hostName + ",*";
        mxbean = loadArchiveMXBean(jmxName);
      }
      else if ("rar".equals(plan.getArchiveType())) {
        moduleID = "resin:name=" + name + ",type=Resource,Host=" + hostName;
     
        String jmxName = "resin:type=ResourceDeploy,Host=" + hostName + ",*";
        mxbean = loadArchiveMXBean(jmxName);
      }
      else
        throw new UnsupportedOperationException(plan.getArchiveType());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }


    boolean failed = false;
    StringBuilder message = new StringBuilder();

    Path archivePath = null;

    Throwable exception = null;

    TargetImpl childTarget = new TargetImpl(moduleID, "");
   
    TargetModuleIDImpl childModuleID
      = new TargetModuleIDImpl(childTarget, moduleID);
   
    if (mxbean != null) {
      try {
        Path deployPath = Vfs.lookup(mxbean.getArchivePath(name));

        deployPath.getParent().mkdirs();

        if (archivePath == null) {
          createArchive(deployPath, plan, archiveIs);
          archivePath = deployPath;
        }
        else {
          WriteStream deployStream = deployPath.openWrite();

          try {
            deployStream.writeFile(archivePath);
          }
          finally {
            deployStream.close();
          }
        }

        mxbean.update();

        exception = mxbean.getConfigException(name);
      }
      catch (Exception e) {
        if (log.isLoggable(Level.INFO))
          log.log(Level.INFO, e.toString(), e);

        exception = e;
      }

      if (exception != null) {
        failed = true;
        describe(message, childModuleID, false, getExceptionMessage(exception));

        /*
          if (mxbean != null) {
          try {
          mxbean.undeploy(moduleID);
          }
          catch (Throwable t) {
          log.log(Level.FINE, t.toString(), t);
          }
          }
        */
      }
      else {
        if ("ear".equals(plan.getArchiveType())) {
          try {
            EAppMXBean eApp = (EAppMXBean) Jmx.find(moduleID);

            if (eApp != null)
              childTarget.setClientRefs(eApp.getClientRefs());
          } catch (Exception e) {
            log.log(Level.FINEST, e.toString(), e);
          }
        }

        describe(message, childModuleID, true);
      }
    }
    else {
      failed = true;
      log.warning(L.l("jsr88 cannot deploy '{0}', can't find deployment resource (e.g. web-app-deploy, ear-deploy).", moduleID));
    }
   
    TargetModuleID []targetModuleIDs
      = new TargetModuleID[] { childModuleID };

    progress = new ProgressObjectImpl(targetModuleIDs);
   
    if (failed)
      progress.failed(message.toString());
    else
      progress.completed(message.toString());

    return progress;
  }
View Full Code Here

Examples of com.caucho.j2ee.deployclient.ProgressObjectImpl

    }
  }

  public ProgressObject start(TargetModuleID[] ids)
  {
    ProgressObjectImpl progress =  new ProgressObjectImpl(ids);

    boolean failed = false;
    StringBuilder message = new StringBuilder();

    for (TargetModuleID targetModuleID : ids) {
      if (log.isLoggable(Level.FINE))
        log.log(Level.FINE, L.l("jsr88 starting {0}", targetModuleID.getModuleID()));

      Throwable exception = null;
      DeployControllerMXBean mxbean = null;

      try {
        ObjectName objectName = new ObjectName(targetModuleID.getModuleID());
        mxbean = (DeployControllerMXBean) Jmx.find(objectName);
        if (mxbean != null)
          mxbean.start();
        else {
          log.finer("Jsr88[] " + objectName + " is an unknown module");
          failed = true;
        }
      }
      catch (Exception t) {
        log.log(Level.INFO, t.toString(), t);
        // XXX: need to handle depending on type
        exception = t;
      }

      /*
      if (exception == null && mxbean != null) {
        // XXX: temp for types
        exception = null;
      }
      */

      if (exception != null) {
        failed  = true;
        describe(message, targetModuleID, false, getExceptionMessage(exception));
      }
      else
        describe(message, targetModuleID, true);
    }

    if (failed)
      progress.failed(L.l("start {0}", message));
    else
      progress.completed(L.l("start {0}", message));

    return progress;
  }
View Full Code Here

Examples of com.caucho.j2ee.deployclient.ProgressObjectImpl

    return progress;
  }

  public ProgressObject stop(TargetModuleID[] ids)
  {
    ProgressObjectImpl progress =  new ProgressObjectImpl(ids);

    boolean failed = false;
    StringBuilder message = new StringBuilder();

    for (TargetModuleID targetModuleID : ids) {
      if (log.isLoggable(Level.FINE))
        log.log(Level.FINE, L.l("jsr88 stopping {0}", targetModuleID.getModuleID()));

      Throwable exception = null;
      DeployControllerMXBean mxbean = null;

      try {
        ObjectName objectName = new ObjectName(targetModuleID.getModuleID());
        mxbean = (DeployControllerMXBean) Jmx.find(objectName);
        if (mxbean != null)
          mxbean.stop();
        else {
          log.finer("Jsr88[] " + objectName + " is an unknown module");
          failed = true;
        }
      }
      catch (Exception t) {
        log.log(Level.INFO, t.toString(), t);
        // XXX: need to handle depending on type
        exception = t;
      }

      /*
      if (exception == null && mxbean != null) {
        // XXX: temp for types
        exception = null;
      }
      */

      if (exception != null) {
        failed  = true;
        describe(message, targetModuleID, false, getExceptionMessage(exception));
      }
      else
        describe(message, targetModuleID, true);
    }

    if (failed)
      progress.failed(L.l("stop {0}", message));
    else
      progress.completed(L.l("stop {0}", message));

    return progress;
  }
View Full Code Here

Examples of com.caucho.j2ee.deployclient.ProgressObjectImpl

  }

  public ProgressObject undeploy(TargetModuleID []ids)
    throws IllegalStateException
  {
    ProgressObjectImpl progress =  new ProgressObjectImpl(ids);

    boolean failed = false;
    StringBuilder message = new StringBuilder();

    for (TargetModuleID targetModuleID : ids) {
      if (log.isLoggable(Level.FINE))
        log.log(Level.FINE, L.l("undeploying {0}", targetModuleID.getModuleID()));

      ArchiveDeployMXBean mxbean = null;
      Throwable exception = null;

      try {
        ObjectName objectName
          = new ObjectName(targetModuleID.getModuleID());
        mxbean = getMXBean(objectName);
        if (mxbean != null)
          mxbean.undeploy(objectName.getKeyProperty("name"));
      }
      catch (Throwable t) {
        log.log(Level.INFO, t.toString(), t);
        exception = t;
      }

      if (exception != null) {
        failed  = true;
        describe(message, targetModuleID, false, getExceptionMessage(exception));
      }
      else
        describe(message, targetModuleID, true);
    }

    if (failed)
      progress.failed(L.l("undeploy {0}", message));
    else
      progress.completed(L.l("undeploy {0}", message));

    return progress;
  }
View Full Code Here

Examples of com.sun.enterprise.deployapi.ProgressObjectImpl

        if(!isConnected()) {
            throw new IllegalStateException(localStrings.getString("enterprise.deployment.client.disconnected_state"));
        }
       
        SunTarget[] targetList = getSunTargets(targets);
        ProgressObjectImpl progressObject = new DeployAction(targetList);
        Object args[] = new Object[8];
        args[0] = dasConnection;
        args[1] = source;
        args[2] = deploymentPlan;
        args[3] = (deploymentOptions == null) ? new HashMap() : DeploymentProperties.propsToMap((Properties)deploymentOptions);
        args[4] = targetList;
        args[5] = domain;
        args[6] = localConnection;
        args[7] = serverId;
        progressObject.setCommand(CommandType.DISTRIBUTE, args);
        Thread newThread =  new Thread(progressObject);
        newThread.start();
        return progressObject;
    }
View Full Code Here

Examples of com.sun.enterprise.deployapi.ProgressObjectImpl

    public JESProgressObject undeploy(Target[] targets, String moduleID, Map options) {
        if(!isConnected()) {
            throw new IllegalStateException(localStrings.getString("enterprise.deployment.client.disconnected_state"));
        }
        SunTarget[] targetList = getSunTargets(targets);
        ProgressObjectImpl progressObject = new UndeployAction(targetList);
        Object args[] = new Object[6];
        args[0] = dasConnection;
        args[1] = moduleID;
        args[2] = (options == null) ? new HashMap() : DeploymentProperties.propsToMap((Properties)options);
        args[3] = targetList;
        args[4] = domain;
        args[5] = localConnection;
        progressObject.setCommand(CommandType.UNDEPLOY, args);
        Thread newThread =  new Thread(progressObject);
        newThread.start();
        return progressObject;
    }
View Full Code Here

Examples of com.sun.enterprise.deployapi.ProgressObjectImpl

    private JESProgressObject changeState(Target[] targets, String moduleID, CommandType cmd) {
        if(!isConnected()) {
            throw new IllegalStateException(localStrings.getString("enterprise.deployment.client.disconnected_state"));
        }
        SunTarget[] targetList = getSunTargets(targets);
        ProgressObjectImpl progressObject = new ChangeStateAction(targetList);
        Object args[] = new Object[5];
        args[0] = dasConnection;
        args[1] = targetList;
        args[2] = moduleID;
        args[3] = cmd;
        args[4] = domain;
        progressObject.setCommand(cmd, args);
        Thread newThread =  new Thread(progressObject);
        newThread.start();
        return progressObject;       
    }
View Full Code Here

Examples of com.sun.enterprise.deployapi.ProgressObjectImpl

    private JESProgressObject doApplicationReferenceAction(Target[] targets, String moduleID, Map options, CommandType cmd) {
        if(!isConnected()) {
            throw new IllegalStateException(localStrings.getString("enterprise.deployment.client.disconnected_state"));
        }
        SunTarget[] targetList = getSunTargets(targets);
        ProgressObjectImpl progressObject = new ApplicationReferenceAction(targetList);
        Object args[] = new Object[5];
        args[0] = dasConnection;
        args[1] = targetList;
        args[2] = moduleID;
        args[3] = cmd;
        args[4] = (options == null) ? new HashMap() : DeploymentProperties.propsToMap((Properties)options);
        progressObject.setCommand(cmd, args);
        Thread newThread =  new Thread(progressObject);
        newThread.start();
        return progressObject;       
    }
View Full Code Here

Examples of org.glassfish.deployapi.ProgressObjectImpl

     * @return DFProgressObject the caller can use to monitor progress and query final status
     */
    protected DFProgressObject changeState(Target[] targets, String moduleID, String commandName, String action) {
        ensureConnected();
        targets = prepareTargets(targets);
        ProgressObjectImpl po = new ProgressObjectImpl(targets);
        List<TargetModuleIDImpl> targetModuleIDList =
            new ArrayList<TargetModuleIDImpl>();
        try {
            for (Target target : targets) {
                Map commandParams = new HashMap();
                commandParams.put(DFDeploymentProperties.TARGET, target.getName());
                DFCommandRunner commandRunner = getDFCommandRunner(commandName, commandParams, new String[]{moduleID});
                DFDeploymentStatus ds = commandRunner.run();
                DFDeploymentStatus mainStatus = ds.getMainStatus();
                if(!po.checkStatusAndAddStage((TargetImpl)target, localStrings.getLocalString("enterprise.deployment.client.change_state", "{0} of {1} in target {2}", action, moduleID, target.getName()), mainStatus)) {
                    return po;
                } else {
                    TargetModuleIDImpl targetModuleID =
                        new TargetModuleIDImpl((TargetImpl)target, moduleID);
                    targetModuleIDList.add(targetModuleID);
                }
            }
            TargetModuleIDImpl[] targetModuleIDs =
                new TargetModuleIDImpl[targetModuleIDList.size()];
            targetModuleIDs = (TargetModuleIDImpl[])targetModuleIDList.toArray(targetModuleIDs);
            po.setupForNormalExit(localStrings.getLocalString("enterprise.deployment.client.change_state_all", "{0} of application in all targets", action), (TargetImpl)targets[0],  targetModuleIDs);
            return po;
        } catch (Throwable ioex) {
            po.setupForAbnormalExit(localStrings.getLocalString("enterprise.deployment.client.state_change_failed", "Attempt to change the state of the application {0} failed - {1}", moduleID, ioex.toString()), (TargetImpl)targets[0]);
            return po;
        }
    }
View Full Code Here

Examples of org.glassfish.deployapi.ProgressObjectImpl

    protected DFProgressObject changeAppRef(Target[] targets, String moduleID, String commandName, String action, Map options) {
        ensureConnected();
        Throwable commandExecutionException = null;
        targets = prepareTargets(targets);
        ProgressObjectImpl po = new ProgressObjectImpl(targets);
        List<TargetModuleIDImpl> targetModuleIDList =
            new ArrayList<TargetModuleIDImpl>();
        try {
            for (Target target : targets) {
                options.put(DFDeploymentProperties.TARGET, target.getName());
                String[] operands = new String[] {moduleID};
                DFDeploymentStatus mainStatus = null;
                DFCommandRunner commandRunner = getDFCommandRunner(commandName, options, operands);
                DFDeploymentStatus ds = commandRunner.run();
                mainStatus = ds.getMainStatus();
                if(!po.checkStatusAndAddStage((TargetImpl)target, localStrings.getLocalString("enterprise.deployment.client.create_reference", "Creation of reference for application in target {0}", target.getName()),  mainStatus)) {
                    return po;
                } else {
                    TargetModuleIDImpl targetModuleID =
                        new TargetModuleIDImpl((TargetImpl)target, moduleID);
                    targetModuleIDList.add(targetModuleID);
                }
            }
            TargetModuleIDImpl[] targetModuleIDs =
                new TargetModuleIDImpl[targetModuleIDList.size()];
            targetModuleIDs = (TargetModuleIDImpl[])targetModuleIDList.toArray(targetModuleIDs);
            po.setupForNormalExit(localStrings.getLocalString("enterprise.deployment.client.change_reference_application", "{0} of application reference in all targets", action), (TargetImpl)targets[0], targetModuleIDs);
            return po;
        } catch (Throwable ioex) {
           po.setupForAbnormalExit(localStrings.getLocalString("enterprise.deployment.client.change_reference_application_failed", "{0} of application reference failed - {1}", action, ioex.getMessage()), (TargetImpl)targets[0]);
            return po;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.