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


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2006 Bull S.A.S.
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: ClusterDaemonConfigurationManager.java 8443 2006-06-09 10:01:52Z pelletib $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_clusterd.lib;
025:
026:        import java.io.File;
027:        import java.io.FileInputStream;
028:        import java.io.IOException;
029:        import java.io.InputStream;
030:        import java.io.InputStreamReader;
031:        import java.io.Reader;
032:
033:        import org.objectweb.jonas_clusterd.api.ClusterDaemonConfiguration;
034:        import org.objectweb.jonas_clusterd.api.ClusterDaemonConfigurationException;
035:        import org.objectweb.jonas_clusterd.api.ClusterDaemonSchemas;
036:        import org.objectweb.jonas_clusterd.rules.ClusterDaemonRuleSet;
037:        import org.objectweb.jonas_clusterd.xml.ClusterDaemon;
038:
039:        import org.objectweb.jonas.common.Log;
040:        import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
041:        import org.objectweb.jonas_lib.deployment.digester.JDigester;
042:        import org.objectweb.jonas_lib.deployment.lib.AbsDeploymentDescManager;
043:        import org.objectweb.util.monolog.api.BasicLevel;
044:        import org.objectweb.util.monolog.api.Logger;
045:
046:        /**
047:         * Description of the cluster daemon configuration
048:         * @author Benoit Pelletier
049:         */
050:        public class ClusterDaemonConfigurationManager extends
051:                AbsDeploymentDescManager {
052:
053:            /**
054:             * Path of the clusterd.xml configuration file
055:             */
056:            public static final String CLUSTERD_FILE_NAME = "clusterd.xml";
057:
058:            /**
059:             * Digester used to parse clusterd.xml
060:             */
061:            private static JDigester clusterDaemonDigester = null;
062:
063:            /**
064:             * Rules to parse the application.xml
065:             */
066:            private static ClusterDaemonRuleSet clusterDaemonRuleSet = new ClusterDaemonRuleSet();
067:
068:            /**
069:             * logger
070:             */
071:            private static Logger logger = Log
072:                    .getLogger(Log.JONAS_CLUSTER_DAEMON);
073:
074:            /**
075:             * Flag for parser validation
076:             */
077:            private static boolean parsingWithValidation = true;
078:
079:            /**
080:             * Private Empty constructor for utility class
081:             */
082:            private ClusterDaemonConfigurationManager() {
083:            }
084:
085:            /**
086:             * Get an instance of a ClusterDaemonConfiguration by parsing the clusterd.xml configuration file.
087:             * @param clusterDaemonFileName used when specific cluster daemon configuration file name has to be used
088:             * @param classLoaderForCls the classloader for the classes.
089:             * @return a ClusterDaemonConfiguration instance by parsing the clusterd.xml file
090:             * @throws ClusterDaemonConfigurationException if the clusterd.xml file is corrupted.
091:             */
092:            public static ClusterDaemonConfiguration getClusterDaemonConfiguration(
093:                    String clusterDaemonFileName, ClassLoader classLoaderForCls)
094:                    throws ClusterDaemonConfigurationException {
095:
096:                //Input Stream
097:                InputStream is = null;
098:                String fileName = null;
099:                if (clusterDaemonFileName == null) {
100:                    // clusterd.xml in JONAS_BASE/conf
101:                    fileName = System.getProperty("jonas.base")
102:                            + File.separator + "conf" + File.separator
103:                            + CLUSTERD_FILE_NAME;
104:                } else {
105:                    fileName = clusterDaemonFileName;
106:                }
107:                // load clusterd.xml
108:                File clusterDaemonFile = new File(fileName);
109:                if (!clusterDaemonFile.exists()) {
110:                    is = classLoaderForCls
111:                            .getResourceAsStream(CLUSTERD_FILE_NAME);
112:                    if (is == null) {
113:                        throw new ClusterDaemonConfigurationException(
114:                                "Cannot read the " + fileName + " and "
115:                                        + CLUSTERD_FILE_NAME
116:                                        + " is not accessible in the classpath");
117:                    }
118:                } else {
119:                    try {
120:                        is = new FileInputStream(clusterDaemonFile);
121:                    } catch (Exception e) {
122:                        throw new ClusterDaemonConfigurationException(
123:                                "Cannot read the " + CLUSTERD_FILE_NAME, e);
124:                    }
125:                }
126:                ClusterDaemon clusterDaemon = loadClusterDaemon(
127:                        new InputStreamReader(is), CLUSTERD_FILE_NAME);
128:                try {
129:                    is.close();
130:                } catch (IOException e) {
131:                    // Can't close the file
132:                    logger.log(BasicLevel.WARN, "Cannot close InputStream for "
133:                            + CLUSTERD_FILE_NAME);
134:                }
135:
136:                // instantiate the domain map
137:                ClusterDaemonConfiguration clusterDaemonConfiguration = new ClusterDaemonConfiguration(
138:                        clusterDaemon);
139:                return clusterDaemonConfiguration;
140:            }
141:
142:            /**
143:             * Load the clusterd.xml file.
144:             * @param reader the Reader of the XML file.
145:             * @param fileName the name of the file (clusterd.xml).
146:             * @throws ClusterDaemonConfigurationException if the file is corrupted.
147:             * @return a ClusterDaemon object.
148:             */
149:            public static ClusterDaemon loadClusterDaemon(Reader reader,
150:                    String fileName) throws ClusterDaemonConfigurationException {
151:
152:                ClusterDaemon clusterDaemon = new ClusterDaemon();
153:                // Create if domainDigester is null
154:                if (clusterDaemonDigester == null) {
155:                    try {
156:                        // Create and initialize the digester
157:
158:                        clusterDaemonDigester = new JDigester(
159:                                clusterDaemonRuleSet,
160:                                getParsingWithValidation(), true, null,
161:                                new ClusterDaemonSchemas());
162:                    } catch (DeploymentDescException e) {
163:                        throw new ClusterDaemonConfigurationException(e);
164:                    }
165:                }
166:
167:                try {
168:                    clusterDaemonDigester
169:                            .parse(reader, fileName, clusterDaemon);
170:                } catch (DeploymentDescException e) {
171:                    throw new ClusterDaemonConfigurationException(e);
172:                } finally {
173:                    clusterDaemonDigester.push(null);
174:                }
175:
176:                return clusterDaemon;
177:            }
178:
179:            /**
180:             * Controls whether the parser is reporting all validity errors.
181:             * @return if true, all external entities will be read.
182:             */
183:            public static boolean getParsingWithValidation() {
184:                return parsingWithValidation;
185:            }
186:
187:            /**
188:             * Controls whether the parser is reporting all validity errors.
189:             * @param validation if true, all external entities will be read.
190:             */
191:            public static void setParsingWithValidation(boolean validation) {
192:                ClusterDaemonConfigurationManager.parsingWithValidation = validation;
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.