1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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.cli;
19
20 import org.apache.geronimo.common.DeploymentException;
21
22 import javax.enterprise.deploy.spi.DeploymentManager;
23 import javax.enterprise.deploy.spi.Target;
24 import javax.enterprise.deploy.spi.status.ProgressObject;
25 import java.io.File;
26 import java.io.PrintWriter;
27
28 /**
29 * The CLI deployer logic to deploy (distribute plus start).
30 *
31 * @version $Rev: 398160 $ $Date: 2006-04-29 07:33:58 -0700 (Sat, 29 Apr 2006) $
32 */
33 public class CommandDeploy extends CommandDistribute {
34 public CommandDeploy() {
35 super("deploy", "1. Common Commands", "[--inPlace] [--targets target;target;...] [module] [plan]",
36 "Normally both a module and plan are passed to the deployer. " +
37 "Sometimes the module contains a plan, or requires no plan, in which case " +
38 "the plan may be omitted. Sometimes the plan references a module already " +
39 "deployed in the Geronimo server environment, in which case a module does " +
40 "not need to be provided.\n" +
41 "If no targets are provided, the module is deployed to all available " +
42 "targets. Geronimo only provides one target (ever), so this is primarily " +
43 "useful when using a different driver.");
44 }
45
46 protected String getAction() {
47 return "Deployed";
48 }
49
50 protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
51 ProgressObject po = super.runCommand(mgr, out, inPlace, tlist, module, plan);
52 waitForProgress(out, po);
53 if(po.getDeploymentStatus().isFailed()) {
54 throw new DeploymentException("Unable to distribute "+(module == null ? plan.getName() : module.getName())+": "+po.getDeploymentStatus().getMessage());
55 }
56 return mgr.start(po.getResultTargetModuleIDs());
57 }
58
59 public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
60 super.execute(out, connection, args);
61 }
62 }