Source Code Cross Referenced for DeploymentPlan.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » j2ee » deployserver » 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 resin 3.1.5 » resin » com.caucho.j2ee.deployserver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.j2ee.deployserver;
031:
032:        import com.caucho.config.ConfigException;
033:        import com.caucho.config.types.RawString;
034:        import com.caucho.util.L10N;
035:        import com.caucho.vfs.Vfs;
036:        import com.caucho.vfs.WriteStream;
037:        import com.caucho.xml.XmlPrinter;
038:
039:        import org.w3c.dom.Node;
040:
041:        import javax.annotation.PostConstruct;
042:        import java.io.IOException;
043:        import java.io.OutputStream;
044:        import java.util.ArrayList;
045:
046:        /**
047:         * Plan for the deployment.
048:         */
049:        public class DeploymentPlan {
050:            private static final L10N L = new L10N(DeploymentPlan.class);
051:
052:            private String _archiveType;
053:            private String _name;
054:            private String _metaInf;
055:
056:            private ArrayList<PlanFile> _fileList = new ArrayList<PlanFile>();
057:
058:            /**
059:             * Sets the deployment type.
060:             */
061:            public void setArchiveType(String type) throws ConfigException {
062:                if (type.equals("war")) {
063:                    _metaInf = "WEB-INF/";
064:                } else if (type.equals("ear")) {
065:                    _metaInf = "META-INF/";
066:                } else if (type.equals("rar")) {
067:                    _metaInf = "META-INF/";
068:                } else
069:                    throw new ConfigException(L.l(
070:                            "'{0}' is an unknown archive type.", type));
071:
072:                _archiveType = type;
073:            }
074:
075:            /**
076:             * Gets the deployment type.
077:             */
078:            public String getArchiveType() {
079:                return _archiveType;
080:            }
081:
082:            /**
083:             * Sets the name
084:             */
085:            public void setName(String name) {
086:                _name = name;
087:            }
088:
089:            /**
090:             * Gets the name
091:             */
092:            public String getName() {
093:                return _name;
094:            }
095:
096:            @PostConstruct
097:            public void init() {
098:                if (_archiveType == null)
099:                    throw new ConfigException(L.l("`{0}' is required",
100:                            "archive-type"));
101:
102:                if (_name == null)
103:                    throw new ConfigException(L.l("`{0}' is required", "name"));
104:            }
105:
106:            /**
107:             * An ExtFile is an Xml file that is written into the META-INF
108:             * (or WEB-INF for a war) * directory.
109:             */
110:            public ExtFile createExtFile() {
111:                return new ExtFile();
112:            }
113:
114:            public void addExtFile(ExtFile extFile) {
115:                _fileList.add(extFile);
116:            }
117:
118:            /**
119:             * A RawFile is any format file that is written into a file
120:             * specified by the path, relative to the root of the deployed archive.
121:             */
122:            public RawFile createRawFile() {
123:                return new RawFile();
124:            }
125:
126:            public void addRawFile(RawFile rawFile) {
127:                _fileList.add(rawFile);
128:            }
129:
130:            /**
131:             * Returns the list of ext and raw files.
132:             */
133:            public ArrayList<PlanFile> getFileList() {
134:                return _fileList;
135:            }
136:
137:            abstract public class PlanFile {
138:                abstract public String getPath();
139:
140:                abstract public void writeToStream(OutputStream os)
141:                        throws IOException;
142:
143:                public String toString() {
144:                    return "DeploymentPlan$" + getClass().getSimpleName() + "["
145:                            + getPath() + "]";
146:                }
147:
148:            }
149:
150:            public class ExtFile extends PlanFile {
151:                private String _name;
152:                private Node _data;
153:
154:                /**
155:                 * Sets the file name.
156:                 */
157:                public void setName(String name) {
158:                    if (name.startsWith("/"))
159:                        throw new ConfigException(L.l(
160:                                "name `{0}' cannot start with /", name));
161:
162:                    _name = name;
163:                }
164:
165:                public void setData(Node data) {
166:                    _data = data.getFirstChild();
167:                }
168:
169:                @PostConstruct
170:                public void init() {
171:                    if (_name == null)
172:                        throw new ConfigException(L.l("`{0}' is required",
173:                                "name"));
174:
175:                    if (_data == null)
176:                        throw new ConfigException(L.l("`{0}' is required",
177:                                "data"));
178:                }
179:
180:                public String getPath() {
181:                    return _metaInf + _name;
182:                }
183:
184:                public void writeToStream(OutputStream os) throws IOException {
185:                    XmlPrinter xmlPrinter = new XmlPrinter(os);
186:                    xmlPrinter.setPretty(true);
187:                    xmlPrinter.printXml(_data);
188:                }
189:            }
190:
191:            public class RawFile extends PlanFile {
192:                private String _path;
193:                private String _data;
194:
195:                /**
196:                 * Sets the file name.
197:                 */
198:                public void setPath(String path) {
199:                    if (path.startsWith("/"))
200:                        throw new ConfigException(L.l(
201:                                "path `{0}' cannot start with /", path));
202:
203:                    _path = path;
204:                }
205:
206:                public void setData(RawString data) {
207:                    _data = data.getValue();
208:                }
209:
210:                @PostConstruct
211:                public void init() {
212:                    if (_path == null)
213:                        throw new ConfigException(L.l("`{0}' is required",
214:                                "path"));
215:
216:                    if (_data == null)
217:                        throw new ConfigException(L.l("`{0}' is required",
218:                                "data"));
219:                }
220:
221:                public String getPath() {
222:                    return _path;
223:                }
224:
225:                public void writeToStream(OutputStream os) throws IOException {
226:                    WriteStream writeStream = Vfs.openWrite(os);
227:
228:                    try {
229:                        writeStream.print(_data);
230:                    } finally {
231:                        writeStream.close();
232:                    }
233:                }
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.