KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > plugin > local > DistributeCommand


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 JavaDoc;
21 import java.io.InputStream JavaDoc;
22
23 import javax.enterprise.deploy.shared.CommandType JavaDoc;
24 import javax.enterprise.deploy.spi.Target JavaDoc;
25
26 import org.apache.geronimo.kernel.Kernel;
27
28 /**
29  * @version $Rev: 482870 $ $Date: 2006-12-05 21:50:50 -0500 (Tue, 05 Dec 2006) $
30  */

31 public class DistributeCommand extends AbstractDeployCommand {
32     protected final Target JavaDoc[] targetList;
33
34     public DistributeCommand(Kernel kernel, Target JavaDoc[] targetList, File JavaDoc moduleArchive, File JavaDoc deploymentPlan) {
35         super(CommandType.DISTRIBUTE, kernel, moduleArchive, deploymentPlan, null, null, false);
36         this.targetList = targetList;
37     }
38
39     public DistributeCommand(Kernel kernel, Target JavaDoc[] targetList, InputStream JavaDoc moduleStream, InputStream JavaDoc deploymentStream) {
40         super(CommandType.DISTRIBUTE, kernel, null, null, moduleStream, deploymentStream, true);
41         this.targetList = targetList;
42     }
43
44     public void run() {
45         try {
46             if (spool) {
47                 if (moduleStream != null) {
48                     moduleArchive = createTempFile();
49                     copyTo(moduleArchive, moduleStream);
50                 }
51                 if (deploymentStream != null) {
52                     deploymentPlan = createTempFile();
53                     copyTo(deploymentPlan, deploymentStream);
54                 }
55             }
56             if (deployer == null) {
57                 return;
58             }
59             for(int i = 0; i < targetList.length; i++) {
60                 doDeploy(targetList[i], true);
61             }
62         } catch (Exception JavaDoc e) {
63             doFail(e);
64         } finally {
65             if (spool) {
66                 if (moduleArchive != null) {
67                     moduleArchive.delete();
68                 }
69                 if (deploymentPlan != null) {
70                     deploymentPlan.delete();
71                 }
72             }
73         }
74     }
75
76 }
77
Popular Tags