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


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 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:
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.common;
027:
028:        import java.io.File;
029:        import java.io.FileInputStream;
030:        import java.util.ArrayList;
031:        import java.util.Collections;
032:        import java.util.Properties;
033:
034:        /**
035:         * This class implements utility methods for the manipulation of application modules
036:         * @author Adriana Danes
037:         */
038:        public class JModule {
039:            /**
040:             * file extension containing the different module types
041:             */
042:            public static final String EJBJAR_EXTENSION = "jar";
043:            public static final String RAR_EXTENSION = "rar";
044:            public static final String WAR_EXTENSION = "war";
045:            public static final String EAR_EXTENSION = "ear";
046:
047:            /**
048:             * Child directory of a expanded container
049:             */
050:            public static final String EJBJAR_CHILD_DIR = "META-INF";
051:            public static final String RAR_CHILD_DIR = "META-INF";
052:            public static final String WAR_CHILD_DIR = "WEB-INF";
053:            public static final String EAR_CHILD_DIR = "META-INF";
054:
055:            /**
056:             * xml file in a child directory of a expanded container
057:             */
058:            public static final String EJBJAR_CONFIRM_FILE = "ejb-jar.xml";
059:            public static final String RAR_CONFIRM_FILE = "ra.xml";
060:            public static final String WAR_CONFIRM_FILE = "web.xml";
061:            public static final String EAR_CONFIRM_FILE = "application.xml";
062:
063:            /**
064:             * properties file extension
065:             */
066:            public static final String PROPS_EXTENSION = "properties";
067:
068:            /**
069:             * name of the directory containig configuration
070:             */
071:            public static final String CONF_DIR = "conf";
072:
073:            public static ArrayList getFilesInDir(String dirName,
074:                    String extension) throws Exception {
075:                ArrayList al = new ArrayList();
076:                File file = new File(dirName);
077:                String[] files = file.list();
078:                int pos;
079:                String fileName;
080:                if (files != null) {
081:                    for (int i = 0; i < files.length; i++) {
082:                        file = new File(dirName, files[i]);
083:                        if (file.isFile() == true) {
084:                            fileName = file.getName().toLowerCase();
085:                            pos = fileName.lastIndexOf(extension);
086:                            if (pos > -1) {
087:                                if (pos == (fileName.length() - extension
088:                                        .length())) {
089:                                    al.add(file.getName());
090:                                }
091:                            }
092:                        }
093:                    }
094:                }
095:                Collections.sort(al);
096:                return al;
097:            }
098:
099:            public static ArrayList getDatasourcePropsInDir() throws Exception {
100:                // Get all files include in configuration directory
101:                ArrayList al = getFilesInDir(JProp.getJonasBase()
102:                        + File.separator + CONF_DIR, PROPS_EXTENSION);
103:                // Keep all datasources properties
104:                String sPath;
105:                Properties oProps = new Properties();
106:                boolean bDelete;
107:                int i = 0;
108:                while (i < al.size()) {
109:                    sPath = JProp.getJonasBase() + File.separator + CONF_DIR
110:                            + File.separator + al.get(i).toString();
111:                    bDelete = true;
112:                    try {
113:                        oProps.clear();
114:                        oProps.load(new FileInputStream(sPath));
115:                        // Detect datasource property
116:                        if (oProps.getProperty("datasource.name") != null) {
117:                            // Remove Extension
118:                            int iPos = al.get(i).toString().toLowerCase()
119:                                    .lastIndexOf(".properties");
120:                            al.set(i, al.get(i).toString().substring(0, iPos));
121:                            // Next
122:                            i++;
123:                            bDelete = false;
124:                        }
125:                    } catch (Exception e) {
126:                        // none
127:                    } finally {
128:                        // Remove no-datasource
129:                        if (bDelete == true) {
130:                            al.remove(i);
131:                        }
132:                    }
133:                }
134:                return al;
135:            }
136:
137:            public static ArrayList getMailFactoryPropsInDir(String type)
138:                    throws Exception {
139:                // Get all files include in configuration directory
140:                ArrayList al = getFilesInDir(JProp.getJonasBase()
141:                        + File.separator + CONF_DIR, PROPS_EXTENSION);
142:                // Keep all datasources properties
143:                String sPath;
144:                Properties oProps = new Properties();
145:                boolean bDelete;
146:                int i = 0;
147:                while (i < al.size()) {
148:                    sPath = JProp.getJonasBase() + File.separator + CONF_DIR
149:                            + File.separator + al.get(i).toString();
150:                    bDelete = true;
151:                    try {
152:                        oProps.clear();
153:                        oProps.load(new FileInputStream(sPath));
154:                        // Detect mail factory property
155:                        if (oProps.getProperty("mail.factory.name") != null) {
156:                            boolean bToReturn;
157:                            if (type == null) {
158:                                // any type OK
159:                                bToReturn = true;
160:                            } else {
161:                                // Check type 
162:                                if (oProps.getProperty("mail.factory.type")
163:                                        .equals(type) == true) {
164:                                    bToReturn = true;
165:                                } else {
166:                                    bToReturn = false;
167:                                }
168:                            }
169:                            if (bToReturn == true) {
170:                                // Remove Extension
171:                                int iPos = al.get(i).toString().toLowerCase()
172:                                        .lastIndexOf(".properties");
173:                                al.set(i, al.get(i).toString().substring(0,
174:                                        iPos));
175:                                // Next
176:                                i++;
177:                                bDelete = false;
178:                            }
179:                        }
180:                    } catch (Exception e) {
181:                        // none
182:                    } finally {
183:                        // Remove no-mail factory
184:                        if (bDelete == true) {
185:                            al.remove(i);
186:                        }
187:                    }
188:                }
189:                return al;
190:            }
191:
192:            public static ArrayList getMailFactoryPropsInDir() throws Exception {
193:                return getMailFactoryPropsInDir(null);
194:            }
195:
196:            public static void prefixAutoload(String autoloaddir,
197:                    ArrayList p_List) {
198:                String sDir = autoloaddir + File.separator;// "autoloaddir/"
199:                for (int i = 0; i < p_List.size(); i++) {
200:                    p_List.set(i, sDir + p_List.get(i));
201:                }
202:            }
203:
204:            /**
205:             * Return the list of all installed containers in a directory.
206:             * The container may be : <br>
207:             * - a archive file container with a known extension : jar, war, ear, rar<br>
208:             * - a directory where the container is expanded<br>
209:             * To control if a directory contains a expanded container, it's necessary
210:             * to provide the child directory and the xml file that confirm the expanded container.<br>
211:             * Parameter example to retrieve :<br>
212:             * - web application : war, WEB-INF, web.xml
213:             * - application : ear, META-INF, application.xml
214:             * - ejb container : jar, META-INF, ejb-jar.xml
215:             * - resource : rar, META-INF, ra.xml
216:             *
217:             * @param p_DirName The name of the directory to find
218:             * @param p_Extension The extension of container (jar, war, ear, rar)
219:             * @param p_DirChildConfirm The child directory that confirm the container
220:             * @param p_FileConfirm The xml file inside the child directory that confirm the container
221:             * @return A list of absolute path container
222:             * @throws Exception
223:             */
224:            public static ArrayList getInstalledContainersInDir(
225:                    String p_DirName, String p_Extension,
226:                    String p_DirChildConfirm, String p_FileConfirm)
227:                    throws Exception {
228:
229:                // Return variable
230:                ArrayList al = new ArrayList();
231:                // Variables used in loop
232:                int iPos;
233:                String sFilename;
234:                File oDirChild;
235:                File oFileConfirm;
236:                // Search all files in directory
237:                File oFile = new File(p_DirName);
238:                String[] asFiles = oFile.list();
239:
240:                if (asFiles != null) {
241:                    // Loop for each found file
242:                    for (int i = 0; i < asFiles.length; i++) {
243:                        oFile = new File(p_DirName, asFiles[i]);
244:                        // Detect file with extension
245:                        if (oFile.isFile() == true) {
246:                            sFilename = oFile.getName().toLowerCase();
247:                            iPos = sFilename.lastIndexOf(p_Extension);
248:                            if (iPos > -1) {
249:                                if (iPos == (sFilename.length() - p_Extension
250:                                        .length())) {
251:                                    al.add(oFile.getCanonicalFile().toURL()
252:                                            .getPath());
253:                                }
254:                            }
255:                        }
256:                        // Detect directory of expanded container
257:                        else if (oFile.isDirectory() == true) {
258:                            oDirChild = new File(oFile, p_DirChildConfirm);
259:                            if ((oDirChild.exists() == true)
260:                                    && (oDirChild.isDirectory() == true)) {
261:                                oFileConfirm = new File(oDirChild,
262:                                        p_FileConfirm);
263:                                if (oFileConfirm.exists() == true) {
264:                                    al.add(oFile.getCanonicalFile().toURL()
265:                                            .getPath());
266:                                }
267:                            }
268:                        }
269:                    }
270:                }
271:                return al;
272:            }
273:
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.