geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx JMXDeploymentManager.java
Date Tue, 06 Jul 2004 05:36:12 GMT
jboynes     2004/07/05 22:36:12

  Modified:    modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local
                        DistributeCommand.java
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx
                        JMXDeploymentManager.java
  Log:
  Support distribute with InputStream params
  
  Revision  Changes    Path
  1.12      +54 -3     incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
  
  Index: DistributeCommand.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DistributeCommand.java	23 Jun 2004 22:44:49 -0000	1.11
  +++ DistributeCommand.java	6 Jul 2004 05:36:12 -0000	1.12
  @@ -18,6 +18,10 @@
   package org.apache.geronimo.deployment.plugin.local;
   
   import java.io.File;
  +import java.io.InputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.FileOutputStream;
   import java.util.Iterator;
   import java.util.Set;
   import java.net.URI;
  @@ -36,8 +40,11 @@
       private static final String[] DEPLOY_SIG = {File.class.getName(), File.class.getName()};
       private final KernelMBean kernel;
       private final Target[] targetList;
  -    private final File moduleArchive;
  -    private final File deploymentPlan;
  +    private final boolean spool;
  +    private File moduleArchive;
  +    private File deploymentPlan;
  +    private InputStream moduleStream;
  +    private InputStream deploymentStream;
   
       public DistributeCommand(KernelMBean kernel, Target[] targetList, File moduleArchive,
File deploymentPlan) {
           super(CommandType.DISTRIBUTE);
  @@ -45,10 +52,32 @@
           this.targetList = targetList;
           this.moduleArchive = moduleArchive;
           this.deploymentPlan = deploymentPlan;
  +        spool = false;
  +    }
  +
  +    public DistributeCommand(KernelMBean kernel, Target[] targetList, InputStream moduleStream,
InputStream deploymentStream) {
  +        super(CommandType.DISTRIBUTE);
  +        this.kernel = kernel;
  +        this.targetList = targetList;
  +        this.moduleArchive = null ;
  +        this.deploymentPlan = null;
  +        this.moduleStream = moduleStream;
  +        this.deploymentStream = deploymentStream;
  +        spool = true;
       }
   
       public void run() {
           try {
  +            if (spool) {
  +                if (moduleStream != null) {
  +                    moduleArchive = File.createTempFile("deployer", ".tmp");
  +                    copyTo(moduleArchive, moduleStream);
  +                }
  +                if (deploymentStream != null) {
  +                    deploymentPlan = File.createTempFile("deployer", ".tmp");
  +                    copyTo(deploymentPlan, deploymentStream);
  +                }
  +            }
               Set deployers = kernel.listGBeans(new ObjectName("geronimo.deployment:role=Deployer,*"));
               if (deployers.isEmpty()) {
                   fail("No deployer present in kernel");
  @@ -67,6 +96,28 @@
               complete("Completed");
           } catch (Exception e) {
               fail(e.getMessage());
  +        } finally {
  +            if (spool) {
  +                if (moduleArchive != null) {
  +                    moduleArchive.delete();
  +                }
  +                if (deploymentPlan != null) {
  +                    deploymentPlan.delete();
  +                }
  +            }
  +        }
  +    }
  +
  +    private void copyTo(File outfile, InputStream is) throws IOException {
  +        byte[] buffer = new byte[4096];
  +        int count;
  +        OutputStream os = new FileOutputStream(outfile);
  +        try {
  +            while ((count = is.read(buffer)) > 0) {
  +                os.write(buffer, 0, count);
  +            }
  +        } finally {
  +            os.close();
           }
       }
   }
  
  
  
  1.7       +9 -4      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
  
  Index: JMXDeploymentManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JMXDeploymentManager.java	24 Jun 2004 02:50:13 -0000	1.6
  +++ JMXDeploymentManager.java	6 Jul 2004 05:36:12 -0000	1.7
  @@ -39,11 +39,11 @@
   
   import org.apache.geronimo.deployment.plugin.TargetImpl;
   import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
  +import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
  +import org.apache.geronimo.deployment.plugin.local.RedeployCommand;
   import org.apache.geronimo.deployment.plugin.local.StartCommand;
   import org.apache.geronimo.deployment.plugin.local.StopCommand;
  -import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
   import org.apache.geronimo.deployment.plugin.local.UndeployCommand;
  -import org.apache.geronimo.deployment.plugin.local.RedeployCommand;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.KernelMBean;
   import org.apache.geronimo.kernel.config.ConfigurationInfo;
  @@ -161,7 +161,12 @@
       }
   
       public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) {
  -        throw new UnsupportedOperationException();
  +        if (kernel == null) {
  +            throw new IllegalStateException("Disconnected");
  +        }
  +        DistributeCommand command = new DistributeCommand(kernel, targetList, moduleArchive,
deploymentPlan);
  +        new Thread(command).start();
  +        return command;
       }
   
       public ProgressObject start(TargetModuleID[] moduleIDList) {
  
  
  

Mime
View raw message