Source Code Cross Referenced for CommandInstallCAR.java in  » EJB-Server-geronimo » deploy-tool » org » apache » geronimo » deployment » cli » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server geronimo » deploy tool » org.apache.geronimo.deployment.cli 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.deployment.cli;
017:
018:        import java.io.File;
019:        import java.io.IOException;
020:
021:        import javax.enterprise.deploy.spi.DeploymentManager;
022:
023:        import org.apache.geronimo.cli.deployer.BaseCommandArgs;
024:        import org.apache.geronimo.cli.deployer.CommandArgs;
025:        import org.apache.geronimo.common.DeploymentException;
026:        import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
027:        import org.apache.geronimo.kernel.repository.Artifact;
028:        import org.apache.geronimo.kernel.repository.MissingDependencyException;
029:        import org.apache.geronimo.system.plugin.DownloadResults;
030:        import jline.ConsoleReader;
031:
032:        /**
033:         * The CLI deployer logic to start.
034:         *
035:         * @version $Rev: 615705 $ $Date: 2008-01-27 18:11:26 -0800 (Sun, 27 Jan 2008) $
036:         */
037:        public class CommandInstallCAR extends AbstractCommand {
038:
039:            //todo: provide a way to handle a username and password for the remote repo?
040:
041:            public void execute(ConsoleReader consoleReader,
042:                    ServerConnection connection, CommandArgs commandArgs)
043:                    throws DeploymentException {
044:                DeploymentManager dmgr = connection.getDeploymentManager();
045:                if (dmgr instanceof  GeronimoDeploymentManager) {
046:                    try {
047:                        GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
048:                        if (commandArgs.getArgs().length == 0) {
049:                            throw new DeploymentException(
050:                                    "Must specify Plugin CAR file");
051:                        }
052:                        File carFile = new File(commandArgs.getArgs()[0]);
053:                        carFile = carFile.getAbsoluteFile();
054:                        if (!carFile.exists() || !carFile.canRead()) {
055:                            throw new DeploymentException(
056:                                    "CAR file cannot be read: "
057:                                            + carFile.getAbsolutePath());
058:                        }
059:                        //TODO figure out if there is a plausible default repo
060:                        Object key = mgr.startInstall(carFile, null, false,
061:                                null, null);
062:                        long start = System.currentTimeMillis();
063:                        DownloadResults results = showProgress(consoleReader,
064:                                mgr, key);
065:                        int time = (int) (System.currentTimeMillis() - start) / 1000;
066:                        printResults(consoleReader, results, time);
067:                        if (results.isFinished() && !results.isFailed()
068:                                && results.getInstalledConfigIDs().size() == 1) {
069:                            Artifact target = results.getInstalledConfigIDs()
070:                                    .get(0);
071:                            consoleReader.printString(DeployUtils.reformat(
072:                                    "Now starting " + target + "...", 4, 72));
073:                            consoleReader.flushConsole();
074:                            new CommandStart()
075:                                    .execute(consoleReader, connection,
076:                                            new BaseCommandArgs(
077:                                                    new String[] { target
078:                                                            .toString() }));
079:                        }
080:                    } catch (IOException e) {
081:                        throw new DeploymentException("Cannot install plugin",
082:                                e);
083:                    }
084:                } else {
085:                    throw new DeploymentException(
086:                            "Cannot install plugins when connected to "
087:                                    + connection.getServerURI());
088:                }
089:            }
090:
091:            static DownloadResults showProgress(ConsoleReader consoleReader,
092:                    GeronimoDeploymentManager mgr, Object key)
093:                    throws IOException {
094:                DeployUtils.println("Checking for status every 1000ms:", 0,
095:                        consoleReader);
096:                String last = null, status;
097:                while (true) {
098:                    DownloadResults results = mgr.checkOnInstall(key);
099:                    if (results.getCurrentFile() != null) {
100:                        if (results.getCurrentFilePercent() > -1) {
101:                            status = results.getCurrentMessage() + " ("
102:                                    + results.getCurrentFilePercent() + "%)";
103:                        } else {
104:                            status = results.getCurrentMessage();
105:                        }
106:                        if (last == null || !last.equals(status)) {
107:                            last = status;
108:                            DeployUtils.println(status, 0, consoleReader);
109:                            consoleReader.flushConsole();
110:                        }
111:                    }
112:                    if (results.isFinished()) {
113:                        if (results.isFailed()) {
114:                            DeployUtils.println("Installation FAILED: "
115:                                    + results.getFailure().getMessage(), 0,
116:                                    consoleReader);
117:                        }
118:                        return results;
119:                    }
120:                    try {
121:                        Thread.sleep(1000);
122:                    } catch (InterruptedException e) {
123:                        return results;
124:                    }
125:                }
126:            }
127:
128:            static void printResults(ConsoleReader consoleReader,
129:                    DownloadResults results, int time) throws IOException,
130:                    DeploymentException {
131:                consoleReader.printNewline();
132:                if (!results.isFailed()) {
133:                    DeployUtils.println("**** Installation Complete!", 0,
134:                            consoleReader);
135:                    for (MissingDependencyException e : results
136:                            .getSkippedPlugins()) {
137:                        DeployUtils.println(e.getMessage(), 0, consoleReader);
138:                    }
139:                    for (Artifact uri : results.getDependenciesPresent()) {
140:                        DeployUtils.println("Used existing: " + uri, 0,
141:                                consoleReader);
142:                    }
143:                    for (Artifact uri : results.getDependenciesInstalled()) {
144:                        DeployUtils.println("Installed new: " + uri, 0,
145:                                consoleReader);
146:                    }
147:                    consoleReader.printNewline();
148:                    if (results.getTotalDownloadBytes() > 0 && time > 0) {
149:                        DeployUtils.println("Downloaded "
150:                                + (results.getTotalDownloadBytes() / 1024)
151:                                + " kB in " + time + "s ("
152:                                + results.getTotalDownloadBytes()
153:                                / (1024 * time) + " kB/s)", 0, consoleReader);
154:                    }
155:                }
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.