Source Code Cross Referenced for WebPackager.java in  » Installer » IzPack » com » izforge » izpack » compiler » 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 » Installer » IzPack » com.izforge.izpack.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Id: WebPackager.java 628 2004-04-15 20:20:15Z mchenryc $
003:         *  IzPack
004:         *  Copyright (C) 2001-2004 Julien Ponge
005:         *
006:         *  File :               WebPackager.java
007:         *  Description :        The web installer packager class.
008:         *  Author's email :     julien@izforge.com
009:         *  Author's Website :   http://www.izforge.com
010:         *
011:         *  This program is free software; you can redistribute it and/or
012:         *  modify it under the terms of the GNU General Public License
013:         *  as published by the Free Software Foundation; either version 2
014:         *  of the License, or any later version.
015:         *
016:         *  This program is distributed in the hope that it will be useful,
017:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019:         *  GNU General Public License for more details.
020:         *
021:         *  You should have received a copy of the GNU General Public License
022:         *  along with this program; if not, write to the Free Software
023:         *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
024:         */
025:        package com.izforge.izpack.compiler;
026:
027:        import java.io.DataOutputStream;
028:        import java.io.FileOutputStream;
029:        import java.io.InputStream;
030:        import java.io.ObjectOutputStream;
031:        import java.util.ArrayList;
032:        import java.util.Enumeration;
033:        import java.util.List;
034:        import java.util.Properties;
035:        import java.util.jar.JarFile;
036:        import java.util.jar.JarOutputStream;
037:        import java.util.zip.ZipEntry;
038:        import java.util.zip.ZipException;
039:        import java.util.zip.ZipOutputStream;
040:
041:        import com.izforge.izpack.GUIPrefs;
042:        import com.izforge.izpack.Info;
043:        import com.izforge.izpack.Pack;
044:
045:        /**
046:         *  Web packager class.
047:         *
048:         * @author     Julien Ponge
049:         */
050:        public class WebPackager extends Packager {
051:            /**  The zipped output stream. */
052:            protected JarOutputStream outJar;
053:
054:            /**  The web jar file output stream. */
055:            protected JarOutputStream webJar;
056:
057:            /**
058:             *  The constructor.
059:             *
060:             * @param  outputFilename  The output filename.
061:             * @param  plistener       The packager listener.
062:             * @exception  Exception   Description of the Exception
063:             */
064:            public WebPackager(String outputFilename, PackagerListener plistener)
065:                    throws Exception {
066:                packs = new ArrayList();
067:                langpacks = new ArrayList();
068:                setPackagerListener(plistener);
069:
070:                sendStart();
071:
072:                // Sets up the zipped output stream
073:                FileOutputStream outFile = new FileOutputStream(outputFilename);
074:                outJar = new JarOutputStream(outFile);
075:                outJar.setLevel(9);
076:
077:                // Sets up the web output jar stream
078:                outputFilename = outputFilename.substring(0, outputFilename
079:                        .length() - 4)
080:                        + "_web.jar";
081:                outFile = new FileOutputStream(outputFilename);
082:                webJar = new JarOutputStream(outFile);
083:                webJar.setLevel(9);
084:
085:                // Copies the skeleton installer
086:                sendMsg("Copying the skeleton installer ...");
087:                writeSkeletonInstaller(outJar);
088:            }
089:
090:            public boolean allowPackFileBackReferences() {
091:                return false;
092:            }
093:
094:            /**
095:             *  Adds a pack (the compiler sends the merged data).
096:             *
097:             * @param  packNumber     The pack number.
098:             * @param  name           The pack name.
099:             * @param  osConstraints  The target operation system(s) of this pack.
100:             * @param  required       Is the pack required ?
101:             * @param  description    The pack description.
102:             * @return                Description of the Return Value
103:             * @exception  Exception  Description of the Exception
104:             */
105:            public ZipOutputStream addPack(int packNumber, String name,
106:                    List osConstraints, boolean required, String description,
107:                    boolean preselected) throws Exception {
108:                sendMsg("Adding pack #" + packNumber + " : " + name + " ...");
109:
110:                // Adds it in the packs array
111:                Pack pack = new Pack(name, description, osConstraints,
112:                        required, preselected);
113:                packs.add(packNumber, pack);
114:
115:                // Returns the suiting output stream
116:                String entryName = "packs/pack" + packNumber;
117:                ZipEntry entry = new ZipEntry(entryName);
118:                webJar.putNextEntry(entry);
119:                return webJar;
120:            }
121:
122:            /**
123:             *  Sets the GUI preferences.
124:             *
125:             * @param  prefs          The new gUIPrefs value
126:             * @exception  Exception  Description of the Exception
127:             */
128:            public void setGUIPrefs(GUIPrefs prefs) throws Exception {
129:                sendMsg("Setting the GUI preferences ...");
130:
131:                outJar.putNextEntry(new ZipEntry("GUIPrefs"));
132:                ObjectOutputStream objOut = new ObjectOutputStream(outJar);
133:                objOut.writeObject(prefs);
134:                objOut.flush();
135:                outJar.closeEntry();
136:            }
137:
138:            /**
139:             *  Adds a panel.
140:             *
141:             * @param  classFilename  The class filename.
142:             * @param  input          The stream to get the file data from.
143:             * @exception  Exception  Description of the Exception
144:             */
145:            public void addPanelClass(String classFilename, InputStream input)
146:                    throws Exception {
147:                sendMsg("Adding the (sub)classes for " + classFilename + " ...");
148:
149:                outJar.putNextEntry(new ZipEntry("com/izforge/izpack/panels/"
150:                        + classFilename));
151:                copyStream(input, outJar);
152:                outJar.closeEntry();
153:            }
154:
155:            /**
156:             *  Sets the panels order.
157:             *
158:             * @param  order          The ordered list of the panels.
159:             * @exception  Exception  Description of the Exception
160:             */
161:            public void setPanelsOrder(ArrayList order) throws Exception {
162:                sendMsg("Setting the panels order ...");
163:
164:                outJar.putNextEntry(new ZipEntry("panelsOrder"));
165:                ObjectOutputStream objOut = new ObjectOutputStream(outJar);
166:                objOut.writeObject(order);
167:                objOut.flush();
168:                outJar.closeEntry();
169:            }
170:
171:            /**
172:             *  Sets the informations related to this installation.
173:             *
174:             * @param  info           The info section.
175:             * @exception  Exception  Description of the Exception
176:             */
177:            public void setInfo(Info info) throws Exception {
178:                sendMsg("Setting the installer informations ...");
179:
180:                outJar.putNextEntry(new ZipEntry("info"));
181:                ObjectOutputStream objOut = new ObjectOutputStream(outJar);
182:                objOut.writeObject(info);
183:                objOut.flush();
184:                outJar.closeEntry();
185:            }
186:
187:            /**
188:             *  Adds Variable Declaration.
189:             *
190:             * @param  varDef         The variables definitions.
191:             * @exception  Exception  Description of the Exception
192:             */
193:            public void setVariables(Properties varDef) throws Exception {
194:                sendMsg("Setting  the variables ...");
195:                outJar.putNextEntry(new ZipEntry("vars"));
196:                ObjectOutputStream objOut = new ObjectOutputStream(outJar);
197:                objOut.writeObject(varDef);
198:                objOut.flush();
199:                outJar.closeEntry();
200:            }
201:
202:            /**
203:             *  Adds a resource.
204:             *
205:             * @param  resId          The resource Id.
206:             * @param  input          The stream to get the data from.
207:             * @exception  Exception  Description of the Exception
208:             */
209:            public void addResource(String resId, InputStream input)
210:                    throws Exception {
211:                sendMsg("Adding resource : " + resId + " ...");
212:
213:                outJar.putNextEntry(new ZipEntry("res/" + resId));
214:                copyStream(input, outJar);
215:                outJar.closeEntry();
216:                input.close();
217:            }
218:
219:            /**
220:             *  Adds a native library.
221:             *
222:             * @param  name           The native library name.
223:             * @param  input          The stream to get the data from.
224:             * @exception  Exception  Description of the Exception
225:             */
226:            public void addNativeLibrary(String name, InputStream input)
227:                    throws Exception {
228:                sendMsg("Adding native library : " + name + " ...");
229:
230:                outJar.putNextEntry(new ZipEntry("native/" + name));
231:                copyStream(input, outJar);
232:                outJar.closeEntry();
233:                input.close();
234:            }
235:
236:            /**
237:             *  Adds a language pack.
238:             *
239:             * @param  iso3           The ISO3 code.
240:             * @param  input          The stream to get the data from.
241:             * @exception  Exception  Description of the Exception
242:             */
243:            public void addLangPack(String iso3, InputStream input)
244:                    throws Exception {
245:                sendMsg("Adding langpack : " + iso3 + " ...");
246:
247:                langpacks.add(iso3);
248:                outJar.putNextEntry(new ZipEntry("langpacks/" + iso3 + ".xml"));
249:                copyStream(input, outJar);
250:                outJar.closeEntry();
251:                input.close();
252:            }
253:
254:            /**
255:             *  Adds a jar file content to the installer.
256:             *
257:             * @param  file           The jar filename.
258:             * @exception  Exception  Description of the Exception
259:             */
260:            public void addJarContent(String file) throws Exception {
261:                sendMsg("Adding a jar file content ...");
262:
263:                JarFile jar = new JarFile(file);
264:                Enumeration entries = jar.entries();
265:                while (entries.hasMoreElements()) {
266:                    // Puts a new entry
267:                    ZipEntry zentry = (ZipEntry) entries.nextElement();
268:                    try {
269:                        InputStream zin = jar.getInputStream(zentry);
270:                        outJar.putNextEntry(new ZipEntry(zentry.getName()));
271:
272:                        // Copy the data
273:                        copyStream(zin, outJar);
274:                        outJar.closeEntry();
275:                        zin.close();
276:                    } catch (ZipException zerr) {
277:                    }
278:                }
279:            }
280:
281:            /**
282:             *  Tells the packager to finish the job (misc writings, cleanups, closings ,
283:             *  ...).
284:             *
285:             * @exception  Exception  Description of the Exception
286:             */
287:            public void finish() throws Exception {
288:                // Usefull stuff
289:                DataOutputStream datOut;
290:                ObjectOutputStream objOut;
291:                int size;
292:                int i;
293:
294:                sendMsg("Finishing the enpacking ...");
295:
296:                // Writes the installation kind information
297:                outJar.putNextEntry(new ZipEntry("kind"));
298:                datOut = new DataOutputStream(outJar);
299:                datOut.writeUTF("web");
300:                datOut.flush();
301:                outJar.closeEntry();
302:
303:                // Writes the packs informations
304:                outJar.putNextEntry(new ZipEntry("packs.info"));
305:                objOut = new ObjectOutputStream(outJar);
306:                size = packs.size();
307:                objOut.writeInt(size);
308:                for (i = 0; i < size; i++)
309:                    objOut.writeObject(packs.get(i));
310:                objOut.flush();
311:                outJar.closeEntry();
312:
313:                // Writes the langpacks informations
314:                outJar.putNextEntry(new ZipEntry("langpacks.info"));
315:                datOut = new DataOutputStream(outJar);
316:                size = langpacks.size();
317:                datOut.writeInt(size);
318:                for (i = 0; i < size; i++)
319:                    datOut.writeUTF((String) langpacks.get(i));
320:                datOut.flush();
321:                outJar.closeEntry();
322:
323:                // Closes the stream
324:                outJar.flush();
325:                outJar.close();
326:                webJar.flush();
327:                webJar.close();
328:
329:                sendStop();
330:            }
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.