Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.plugin.local » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   package org.apache.geronimo.deployment.plugin.local;
   19   
   20   import java.io.File;
   21   import java.io.InputStream;
   22   
   23   import javax.enterprise.deploy.shared.CommandType;
   24   import javax.enterprise.deploy.shared.ModuleType;
   25   import javax.enterprise.deploy.spi.Target;
   26   
   27   import org.apache.geronimo.kernel.Kernel;
   28   
   29   /**
   30    * @version $Rev: 615085 $ $Date: 2008-01-24 16:27:32 -0800 (Thu, 24 Jan 2008) $
   31    */
   32   public class DistributeCommand extends AbstractDeployCommand {
   33       protected final Target[] targetList;
   34   
   35       public DistributeCommand(Kernel kernel, Target[] targetList, File moduleArchive, File deploymentPlan) {
   36           super(CommandType.DISTRIBUTE, kernel, moduleArchive, deploymentPlan, null, null, null, false);
   37           this.targetList = targetList;
   38       }
   39   
   40       public DistributeCommand(Kernel kernel, Target[] targetList, ModuleType moduleType, InputStream moduleStream, InputStream deploymentStream) {
   41           super(CommandType.DISTRIBUTE, kernel, null, null, moduleType, moduleStream, deploymentStream, true);    
   42           this.targetList = targetList;
   43       }
   44   
   45       public void run() {
   46           try {
   47               if (spool) {
   48                   if (moduleStream != null) {
   49                       moduleArchive = createTempFile(moduleType == null? null: moduleType.getModuleExtension());
   50                       copyTo(moduleArchive, moduleStream);
   51                   }
   52                   if (deploymentStream != null) {
   53                       deploymentPlan = createTempFile(null);
   54                       copyTo(deploymentPlan, deploymentStream);
   55                   }
   56               }
   57               if (deployer == null) {
   58                   return;
   59               }
   60               for(int i = 0; i < targetList.length; i++) {
   61               	doDeploy(targetList[i], true);
   62               }
   63           } catch (Throwable e) {
   64               doFail(e);
   65           } finally {
   66               if (spool) {
   67                   if (moduleArchive != null) {
   68                       moduleArchive.delete();
   69                   }
   70                   if (deploymentPlan != null) {
   71                       deploymentPlan.delete();
   72                   }
   73               }
   74           }
   75       }
   76   
   77   }

Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.plugin.local » [javadoc | source]