Source Code Cross Referenced for ModifierFactory.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_lib » genclientstub » modifier » 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 » JOnAS 4.8.6 » org.objectweb.jonas_lib.genclientstub.modifier 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2003-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.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: ModifierFactory.java 5590 2004-10-11 13:16:15Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_lib.genclientstub.modifier;
025:
026:        import java.io.File;
027:        import java.io.IOException;
028:        import java.util.jar.JarFile;
029:
030:        import org.objectweb.jonas_lib.I18n;
031:        import org.objectweb.jonas_lib.genbase.GenBaseException;
032:        import org.objectweb.jonas_lib.genbase.archive.Application;
033:        import org.objectweb.jonas_lib.genbase.archive.Archive;
034:        import org.objectweb.jonas_lib.genbase.archive.Client;
035:        import org.objectweb.jonas_lib.genbase.archive.EjbJar;
036:        import org.objectweb.jonas_lib.genbase.archive.FileArchive;
037:        import org.objectweb.jonas_lib.genbase.archive.J2EEArchive;
038:        import org.objectweb.jonas_lib.genbase.archive.JarArchive;
039:        import org.objectweb.jonas_lib.genbase.archive.WebApp;
040:        import org.objectweb.jonas_lib.genbase.modifier.AbsModifierFactory;
041:        import org.objectweb.jonas_lib.genbase.modifier.ArchiveModifier;
042:        import org.objectweb.jonas_lib.genclientstub.ClientStubGenException;
043:
044:        /**
045:         * Used to create the right ArchiveModifier from a given filename (ear, jar,
046:         * war, ...)
047:         *
048:         * @author Guillaume Sauthier
049:         */
050:        public class ModifierFactory extends AbsModifierFactory {
051:
052:            /** i18n */
053:            private static I18n i18n = I18n.getInstance(ModifierFactory.class);
054:
055:            /**
056:             * Empty Constructor for utility class
057:             */
058:            private ModifierFactory() {
059:                super ();
060:            }
061:
062:            /**
063:             * Returns an <code>ArchiveModifier</code> according to archive type
064:             * (application, ejbjar, webapp or client).
065:             *
066:             * @param filename input filename.
067:             *
068:             * @return an <code>ArchiveModifier</code>.
069:             *
070:             * @exception GenBaseException when archive creation fails.
071:             */
072:            public static ArchiveModifier getModifier(String filename)
073:                    throws GenBaseException {
074:                Archive archive = null;
075:                J2EEArchive j2eeArchive = null;
076:                ArchiveModifier modifier = null;
077:                int mode;
078:
079:                File file = new File(filename);
080:
081:                if (file.exists()) {
082:                    if (file.isFile()) {
083:                        // should be a jar file
084:                        // test jar file
085:                        JarFile jarfile;
086:
087:                        try {
088:                            jarfile = new JarFile(file);
089:                        } catch (IOException ioe) {
090:                            // not a jar file
091:                            String err = i18n.getMessage(
092:                                    "ModifierFactory.getModifier.notjar",
093:                                    filename);
094:                            throw new ClientStubGenException(err);
095:                        }
096:
097:                        // Create the inner Archive
098:                        archive = new JarArchive(file);
099:
100:                        // now we are sure that filename is a correct jar
101:                        if (isApplication(jarfile)) {
102:                            // Application J2EE Archive
103:                            j2eeArchive = new Application(archive);
104:                            mode = APPLICATION;
105:
106:                        } else if (isEjbJar(jarfile)) {
107:                            // EjbJar J2EE Archive
108:                            j2eeArchive = new EjbJar(archive);
109:                            mode = EJBJAR;
110:
111:                        } else if (isWebApp(jarfile)) {
112:                            // WebApp J2EE Archive
113:                            j2eeArchive = new WebApp(archive);
114:                            mode = WEBAPP;
115:
116:                        } else if (isClient(jarfile)) {
117:                            // Client J2EE Archive
118:                            j2eeArchive = new Client(archive);
119:                            mode = CLIENT;
120:
121:                        } else {
122:                            // unsupported archive type
123:                            String err = i18n.getMessage(
124:                                    "ModifierFactory.getModifier.unsupported",
125:                                    filename);
126:                            throw new ClientStubGenException(err);
127:                        }
128:                    } else {
129:                        // directory unpacked
130:                        // Create the inner Archive
131:                        archive = new FileArchive(file);
132:
133:                        // now we are sure that filename is a correct jar
134:                        if (isApplication(file)) {
135:                            // Application J2EE Archive
136:                            j2eeArchive = new Application(archive);
137:                            mode = APPLICATION;
138:
139:                        } else if (isEjbJar(file)) {
140:                            // EjbJar J2EE Archive
141:                            j2eeArchive = new EjbJar(archive);
142:                            mode = EJBJAR;
143:
144:                        } else if (isWebApp(file)) {
145:                            // WebApp J2EE Archive
146:                            j2eeArchive = new WebApp(archive);
147:                            mode = WEBAPP;
148:
149:                        } else if (isClient(file)) {
150:                            // Client J2EE Archive
151:                            j2eeArchive = new Client(archive);
152:                            mode = CLIENT;
153:
154:                        } else {
155:                            // unsupported archive type
156:                            String err = i18n.getMessage(
157:                                    "ModifierFactory.getModifier.unsupported",
158:                                    filename);
159:                            throw new ClientStubGenException(err);
160:                        }
161:                    }
162:                } else {
163:                    String err = i18n.getMessage(
164:                            "ModifierFactory.getModifier.notfound", filename);
165:                    throw new ClientStubGenException(err);
166:                }
167:
168:                // init the archive
169:                j2eeArchive.initialize();
170:
171:                //create the modifier
172:                switch (mode) {
173:                case APPLICATION:
174:                    modifier = new ApplicationModifier(
175:                            (Application) j2eeArchive);
176:
177:                    break;
178:
179:                case EJBJAR:
180:                    modifier = new EjbJarModifier((EjbJar) j2eeArchive);
181:
182:                    break;
183:
184:                case WEBAPP:
185:                    modifier = new WebAppModifier((WebApp) j2eeArchive);
186:
187:                    break;
188:
189:                case CLIENT:
190:                    modifier = new ClientModifier((Client) j2eeArchive);
191:
192:                    break;
193:
194:                default:
195:                    // cannot happen
196:                }
197:
198:                return modifier;
199:
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.