Source Code Cross Referenced for RunBuilder.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » deployer » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.common.deployer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp.common.deployer;
024:
025:        // Toolbox
026:        import org.enhydra.tool.common.ToolException;
027:        import org.enhydra.tool.common.FileUtil;
028:        import org.enhydra.tool.common.PathHandle;
029:
030:        // AddinCore
031:        import org.enhydra.kelp.common.AbstractEchoBuilder;
032:        import org.enhydra.kelp.common.Constants;
033:        import org.enhydra.kelp.common.PathUtil;
034:        import org.enhydra.kelp.common.node.OtterNodeFactory;
035:        import org.enhydra.kelp.common.node.OtterTextFileNode;
036:        import org.enhydra.kelp.common.event.WriteListener;
037:
038:        // JDK
039:        import java.io.File;
040:        import java.io.FileWriter;
041:        import java.io.PrintWriter;
042:        import java.util.ResourceBundle;
043:
044:        //
045:        public class RunBuilder extends AbstractEchoBuilder {
046:            static ResourceBundle res = ResourceBundle
047:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
048:
049:            /**
050:             * Method declaration
051:             *
052:             *
053:             * @param in
054:             *
055:             * @return
056:             */
057:            public static File createPolicyFile(String path) {
058:
059:                // strings not to be resourced
060:                final String POLICY_LINE1 = "grant {"; // nores
061:                final String POLICY_LINE2 = "permission java.security.AllPermission;"; // nores
062:                final String POLICY_LINE3 = "};"; // nores
063:                File in = new File(path);
064:                File out = null;
065:
066:                if (in.exists()) {
067:                    in.delete();
068:                    in = null;
069:                }
070:                try {
071:                    out = new File(path);
072:                    out.getParentFile().mkdirs();
073:                    out.createNewFile();
074:                    PrintWriter writer = new PrintWriter(new FileWriter(out));
075:
076:                    writer.println(POLICY_LINE1);
077:                    writer.println(POLICY_LINE2);
078:                    writer.println(POLICY_LINE3);
079:                    writer.flush();
080:                    writer.close();
081:                    out = null;
082:                    out = new File(path);
083:                } catch (java.io.IOException e) {
084:                    e.printStackTrace();
085:                }
086:                return out;
087:            }
088:
089:            /**
090:             *
091:             * @param listeners
092:             */
093:            public RunBuilder(WriteListener listener) {
094:                super (listener);
095:            }
096:
097:            /**
098:             * Make content, policy file, process templates, configure project for
099:             * running enhydra and create archive.
100:             */
101:            public void buildImpl() {
102:                PathHandle ph = null;
103:
104:                if (getProject().isDeployRun()) {
105:                    echo(new String());
106:                    ph = PathHandle.createPathHandle(getProject()
107:                            .getDeployBootstrapPath());
108:                    if (ph.isFile()) {
109:
110:                        // setup IDE for run
111:                        if (isFresh()) {
112:                            if (getProject().isDeployStartupJava()
113:                                    || getProject().isDeployStartupRun()) {
114:                                refreshProgress(65, res
115:                                        .getString("Configuring_project"));
116:                                echo(res.getString("Configuring_project"));
117:                                makeStartup();
118:                            }
119:                        }
120:                    } else if (ph.isDirectory()) {
121:
122:                        // auto-deploy archive
123:                        ph = PathHandle.createPathHandle(getProject()
124:                                .getAutoDeployFilePath());
125:                        if (ph.isEmpty()) {
126:                            echo("No archive to deploy");
127:                        } else if (ph.getFile().isFile()) {
128:                            File out = null;
129:
130:                            out = new File(getProject()
131:                                    .getDeployBootstrapPath());
132:                            out = new File(out, ph.getFile().getName());
133:                            try {
134:                                FileUtil.copy(ph.getFile(), out);
135:                            } catch (ToolException e) {
136:                                echo(e);
137:                            }
138:                        } else {
139:                            echo("Deployment archive not found: "
140:                                    + ph.getPath());
141:                        }
142:                    }
143:                }
144:                refreshProgress(100, new String());
145:            }
146:
147:            //
148:            //
149:            //
150:
151:            /**
152:             * Create policy file for security manager
153:             */
154:            private File createPolicy() {
155:                StringBuffer policyPath = new StringBuffer();
156:                File policy = null;
157:
158:                policyPath.append(PathUtil.getDeployConfPath(getProject()));
159:                policyPath.append(File.separator);
160:                policyPath.append(Constants.FILE_JAVA_POLICY);
161:                policy = RunBuilder.createPolicyFile(policyPath.toString()
162:                        .replace('\\', '/'));
163:                return policy;
164:            }
165:
166:            /**
167:             * Copy or create policy file as needed.
168:             */
169:            private void makePolicy() {
170:
171:                // Find all images in project and copy using
172:                // the mapping table.
173:                OtterTextFileNode node = getProject().getFirstPolicy();
174:
175:                if (node == null) {
176:                    File file = null;
177:
178:                    file = createPolicy();
179:                    echo(res.getString("Creating_policy_file")
180:                            + PathHandle.createPathString(file));
181:                } else {
182:                    File source = null;
183:                    File dest = null;
184:
185:                    source = new File(node.getFilePath());
186:                    dest = new File(PathUtil.getDeployConfPath(getProject()),
187:                            source.getName());
188:                    try {
189:                        FileUtil.copy(source, dest);
190:                    } catch (ToolException e) {
191:                        echo(e);
192:                        e.printStackTrace();
193:                    }
194:                }
195:            }
196:
197:            /**
198:             * Configure project for starting server
199:             */
200:            private void makeStartup() {
201:                if (getProject().isDeployStartupJava()) {
202:                    OtterNodeFactory factory = null;
203:                    StartServerGenerator start = null;
204:                    PathHandle startPath = null;
205:
206:                    factory = getProject().getNodeFactory();
207:                    start = new StartServerGenerator(getProject());
208:                    try {
209:                        start.create();
210:                        startPath = PathHandle
211:                                .createPathHandle(start.getFile());
212:                        factory.createJavaFileNode(getProject(), startPath
213:                                .getPath());
214:                        echo(res.getString("Creating_startup")
215:                                + startPath.getPath());
216:                    } catch (java.io.IOException e) {
217:                        echo(e);
218:                        e.printStackTrace();
219:                    }
220:                }
221:                if (getProject().isDeployStartupRun()) {
222:                    getProject().configureRunClass();
223:                }
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.