Source Code Cross Referenced for AbstractDeployCommand.java in  » EJB-Server-geronimo » deploy-jsr88 » org » apache » geronimo » deployment » plugin » local » 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 jsr88 » org.apache.geronimo.deployment.plugin.local 
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.plugin.local;
017:
018:        import java.io.File;
019:        import java.io.FileOutputStream;
020:        import java.io.IOException;
021:        import java.io.InputStream;
022:        import java.io.OutputStream;
023:        import java.net.URL;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Set;
027:        import javax.enterprise.deploy.shared.CommandType;
028:        import javax.enterprise.deploy.shared.ModuleType;
029:        import javax.enterprise.deploy.spi.Target;
030:
031:        import org.apache.geronimo.common.DeploymentException;
032:        import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
033:        import org.apache.geronimo.gbean.AbstractName;
034:        import org.apache.geronimo.gbean.AbstractNameQuery;
035:        import org.apache.geronimo.kernel.Kernel;
036:
037:        /**
038:         * @version $Rev: 512979 $ $Date: 2007-02-28 13:28:28 -0800 (Wed, 28 Feb 2007) $
039:         */
040:        public abstract class AbstractDeployCommand extends CommandSupport {
041:            protected final Kernel kernel;
042:            private static final String[] DEPLOY_SIG = {
043:                    boolean.class.getName(), File.class.getName(),
044:                    File.class.getName(), String.class.getName() };
045:            protected final boolean spool;
046:            protected File moduleArchive;
047:            protected File deploymentPlan;
048:            protected final ModuleType moduleType;
049:            protected InputStream moduleStream;
050:            protected InputStream deploymentStream;
051:            protected AbstractName deployer;
052:
053:            public AbstractDeployCommand(CommandType command, Kernel kernel,
054:                    File moduleArchive, File deploymentPlan,
055:                    ModuleType moduleType, InputStream moduleStream,
056:                    InputStream deploymentStream, boolean spool) {
057:                super (command);
058:                this .kernel = kernel;
059:                this .moduleArchive = moduleArchive;
060:                this .deploymentPlan = deploymentPlan;
061:                this .moduleType = moduleType;
062:                this .moduleStream = moduleStream;
063:                this .deploymentStream = deploymentStream;
064:                this .spool = spool;
065:                deployer = getDeployerName();
066:            }
067:
068:            private AbstractName getDeployerName() {
069:                Set deployers = kernel.listGBeans(new AbstractNameQuery(
070:                        "org.apache.geronimo.deployment.Deployer"));
071:                if (deployers.isEmpty()) {
072:                    fail("No Deployer GBean present in running Geronimo server. "
073:                            + "This usually indicates a serious problem with the configuration of "
074:                            + "your running Geronimo server.  If "
075:                            + "the deployer is present but not started, the workaround is to run "
076:                            + "a deploy command like 'start geronimo/geronimo-gbean-deployer/1.0/car'.  "
077:                            + "If the deployer service is not present at all (it was undeployed) then "
078:                            + "you need to either re-install Geronimo or get a deployment plan for the "
079:                            + "runtime deployer and distribute it while the server is not running and "
080:                            + "then start the server with a command like the above.  For help on this, "
081:                            + "write to user@geronimo.apache.org and include the contents of your "
082:                            + "var/config/config.xml file.");
083:                    return null;
084:                }
085:                Iterator j = deployers.iterator();
086:                AbstractName deployer = (AbstractName) j.next();
087:                if (j.hasNext()) {
088:                    fail("More than one deployer found");
089:                    return null;
090:                }
091:                return deployer;
092:
093:            }
094:
095:            // be careful to clean up the temp file... we tell the vm to delete this on exit
096:            // but VMs can't be trusted to acutally delete the file
097:            // Copied from DeploymentUtil
098:            protected static File createTempFile(String extension)
099:                    throws IOException {
100:                File tempFile = File.createTempFile("geronimo-deploymentUtil",
101:                        extension == null ? ".tmpdir" : extension);
102:                tempFile.deleteOnExit();
103:                return tempFile;
104:            }
105:
106:            protected void copyTo(File outfile, InputStream is)
107:                    throws IOException {
108:                byte[] buffer = new byte[4096];
109:                int count;
110:                OutputStream os = new FileOutputStream(outfile);
111:                try {
112:                    while ((count = is.read(buffer)) > 0) {
113:                        os.write(buffer, 0, count);
114:                    }
115:                } finally {
116:                    os.close();
117:                }
118:            }
119:
120:            protected void doDeploy(Target target, boolean finished)
121:                    throws Exception {
122:                File[] args = { moduleArchive, deploymentPlan };
123:                massageFileNames(args);
124:                Object deployParams[] = new Object[] {
125:                        Boolean.valueOf(commandContext.isInPlace()), args[0],
126:                        args[1], target.getName() };
127:                List objectNames = (List) kernel.invoke(deployer, "deploy",
128:                        deployParams, DEPLOY_SIG);
129:                if (objectNames == null || objectNames.isEmpty()) {
130:                    throw new DeploymentException(
131:                            "Server didn't deploy anything");
132:                }
133:                String parentName = (String) objectNames.get(0);
134:                String[] childIDs = new String[objectNames.size() - 1];
135:                for (int j = 0; j < childIDs.length; j++) {
136:                    childIDs[j] = (String) objectNames.get(j + 1);
137:                }
138:
139:                TargetModuleIDImpl moduleID = new TargetModuleIDImpl(target,
140:                        parentName, childIDs);
141:                if (isWebApp(kernel, parentName)) {
142:                    moduleID.setType(ModuleType.WAR);
143:                }
144:                if (moduleID.getChildTargetModuleID() != null) {
145:                    for (int i = 0; i < moduleID.getChildTargetModuleID().length; i++) {
146:                        TargetModuleIDImpl id = (TargetModuleIDImpl) moduleID
147:                                .getChildTargetModuleID()[i];
148:                        if (isWebApp(kernel, id.getModuleID())) {
149:                            id.setType(ModuleType.WAR);
150:                        }
151:                    }
152:                }
153:                addModule(moduleID);
154:                if (finished) {
155:                    addWebURLs(kernel);
156:                    complete("Completed with id " + parentName);
157:                }
158:            }
159:
160:            protected void massageFileNames(File[] inputs) {
161:            }
162:
163:            public URL getRemoteDeployUploadURL() throws Exception {
164:                return new URL((String) kernel.getAttribute(deployer,
165:                        "remoteDeployUploadURL"));
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.