Source Code Cross Referenced for EarFile.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » ant » archive » file » 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 » ow2 easybeans » org.ow2.easybeans.ant.archive.file 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2007 Bull S.A.S.
004:         * Contact: easybeans@ow2.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: EarFile.java 1970 2007-10-16 11:49:25Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.ant.archive.file;
025:
026:        import java.io.File;
027:        import java.io.IOException;
028:        import java.util.ArrayList;
029:        import java.util.List;
030:
031:        import org.apache.tools.ant.BuildException;
032:        import org.apache.tools.ant.Project;
033:        import org.apache.tools.ant.taskdefs.Jar;
034:        import org.apache.tools.ant.types.FileSet;
035:        import org.apache.tools.ant.types.ZipFileSet;
036:        import org.ow2.easybeans.ant.archive.AbsArchive;
037:        import org.ow2.easybeans.ant.archive.Ejb;
038:        import org.ow2.easybeans.ant.archive.War;
039:        import org.ow2.easybeans.ant.archive.api.IEar;
040:        import org.ow2.easybeans.ant.archive.info.ArchiveInfo;
041:        import org.ow2.easybeans.ant.archive.info.EarInfo;
042:
043:        /**
044:         * Creates an EAR file.
045:         * @author Florent Benoit
046:         */
047:        public class EarFile extends Jar implements  IEar {
048:
049:            /**
050:             * Path to the Standard deployment descriptor.
051:             */
052:            private static final String DEPLOYMENT_DESCRIPTOR = "META-INF/application.xml";
053:
054:            /**
055:             * Ear info object.
056:             */
057:            private EarInfo earInfo = null;
058:
059:            /**
060:             * Creates an archive for the given project.
061:             * @param p the given project
062:             */
063:            public EarFile(final Project p) {
064:                super ();
065:                setProject(p);
066:            }
067:
068:            /**
069:             * Sets the information about an EAR archive.
070:             * @param earInfo the object that holds data information.
071:             */
072:            public void setEarInfo(final EarInfo earInfo) {
073:                this .earInfo = earInfo;
074:            }
075:
076:            /**
077:             * Execute the task.
078:             */
079:            @Override
080:            public void execute() {
081:
082:                // First, package each ejb, war, etc. (sub modules)
083:                // Execute children by changing the destination directory
084:                List<Ejb> ejbs = earInfo.getEjbs();
085:                List<War> wars = earInfo.getWars();
086:
087:                // Add all archives
088:                List<AbsArchive> archives = new ArrayList<AbsArchive>();
089:                if (ejbs != null) {
090:                    for (Ejb ejb : ejbs) {
091:                        archives.add(ejb);
092:                    }
093:                }
094:                if (wars != null) {
095:                    for (War war : wars) {
096:                        archives.add(war);
097:                    }
098:                }
099:
100:                // Update archives
101:                for (AbsArchive archive : archives) {
102:                    // Update path
103:                    updateArchive(archive);
104:
105:                    // Build the file
106:                    archive.execute();
107:
108:                    // Now, add each archive built in the fileset of the Ear
109:                    addArchiveInFileSet(archive);
110:                }
111:
112:                // Deployment descriptor
113:                if (earInfo.getDd() != null) {
114:                    setDD(earInfo.getDd());
115:                }
116:
117:                // dest file
118:                setDestFile(earInfo.getDest());
119:
120:                // fileset
121:                for (FileSet fileSet : earInfo.getFileSetList()) {
122:                    addFileset(fileSet);
123:                }
124:
125:                // Create directory if it is not existing
126:                File earFileParentDirectory = earInfo.getDest().getParentFile();
127:                if (!earFileParentDirectory.exists()) {
128:                    log("Creating directory '" + earFileParentDirectory + "'",
129:                            Project.MSG_INFO);
130:                    earFileParentDirectory.mkdirs();
131:                }
132:
133:                super .execute();
134:
135:                // Clean all temporary files
136:                for (AbsArchive archive : archives) {
137:                    File tmpFile = archive.getDest();
138:                    if (tmpFile.exists()) {
139:                        tmpFile.delete();
140:                    }
141:                }
142:
143:            }
144:
145:            /**
146:             * Update settings of the given archive.
147:             * @param archive the archive to update.
148:             */
149:            void updateArchive(final AbsArchive archive) {
150:                // change exploded mode to false if ear level is false
151:                if (archive.isExploded() && !earInfo.isExploded()) {
152:                    log(
153:                            "Changing exploded mode to false as the EAR is not in exploded mode.",
154:                            Project.MSG_INFO);
155:                    archive.setExploded(false);
156:                }
157:
158:                // name is defined ? if not set it to the last name of the dest
159:                if (archive.getName() == null) {
160:                    archive.setName(archive.getDest().getName());
161:                }
162:
163:                try {
164:                    archive.setDest(File
165:                            .createTempFile("easybeans-ant", ".tmp"));
166:                } catch (IOException e) {
167:                    throw new BuildException("Cannot create a temp file", e);
168:                }
169:                // Delete the temporary file, it should be created by the archive
170:                // packaging
171:                archive.getDest().delete();
172:            }
173:
174:            /**
175:             * Add the given DD file into the archive.
176:             * @param dd the path to the DDesc file.
177:             */
178:            public void setDD(final File dd) {
179:                ZipFileSet zipFileSet = new ZipFileSet();
180:                zipFileSet.setFile(dd);
181:                zipFileSet.setFullpath(DEPLOYMENT_DESCRIPTOR);
182:                addFileset(zipFileSet);
183:            }
184:
185:            /**
186:             * Add the given archive in a fileset.
187:             * @param archive the path to the file to include.
188:             */
189:            public void addArchiveInFileSet(final AbsArchive archive) {
190:                ZipFileSet zipFileSet = new ZipFileSet();
191:                zipFileSet.setFile(archive.getDest());
192:                zipFileSet.setFullpath(archive.getName());
193:                addFileset(zipFileSet);
194:            }
195:
196:            /**
197:             * Sets the information about an archive.
198:             * @param archiveInfo the object that holds data information.
199:             */
200:            public void setArchiveInfo(final ArchiveInfo archiveInfo) {
201:                // nothing
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.