01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.deployment.plugin.local;
17:
18: import java.io.File;
19: import java.io.InputStream;
20:
21: import javax.enterprise.deploy.shared.CommandType;
22: import javax.enterprise.deploy.shared.ModuleType;
23: import javax.enterprise.deploy.spi.Target;
24:
25: import org.apache.geronimo.kernel.Kernel;
26:
27: /**
28: * @version $Rev: 615085 $ $Date: 2008-01-24 16:27:32 -0800 (Thu, 24 Jan 2008) $
29: */
30: public class DistributeCommand extends AbstractDeployCommand {
31: protected final Target[] targetList;
32:
33: public DistributeCommand(Kernel kernel, Target[] targetList,
34: File moduleArchive, File deploymentPlan) {
35: super (CommandType.DISTRIBUTE, kernel, moduleArchive,
36: deploymentPlan, null, null, null, false);
37: this .targetList = targetList;
38: }
39:
40: public DistributeCommand(Kernel kernel, Target[] targetList,
41: ModuleType moduleType, InputStream moduleStream,
42: InputStream deploymentStream) {
43: super (CommandType.DISTRIBUTE, kernel, null, null, moduleType,
44: moduleStream, deploymentStream, true);
45: this .targetList = targetList;
46: }
47:
48: public void run() {
49: try {
50: if (spool) {
51: if (moduleStream != null) {
52: moduleArchive = createTempFile(moduleType == null ? null
53: : moduleType.getModuleExtension());
54: copyTo(moduleArchive, moduleStream);
55: }
56: if (deploymentStream != null) {
57: deploymentPlan = createTempFile(null);
58: copyTo(deploymentPlan, deploymentStream);
59: }
60: }
61: if (deployer == null) {
62: return;
63: }
64: for (int i = 0; i < targetList.length; i++) {
65: doDeploy(targetList[i], true);
66: }
67: } catch (Throwable e) {
68: doFail(e);
69: } finally {
70: if (spool) {
71: if (moduleArchive != null) {
72: moduleArchive.delete();
73: }
74: if (deploymentPlan != null) {
75: deploymentPlan.delete();
76: }
77: }
78: }
79: }
80:
81: }
|