Source Code Cross Referenced for ClusterRuleSetFactory.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » catalina » startup » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.catalina.startup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.catalina.startup;
019:
020:        import org.apache.tomcat.util.digester.Digester;
021:        import org.apache.tomcat.util.digester.RuleSetBase;
022:        import java.lang.reflect.Constructor;
023:
024:        import org.apache.juli.logging.Log;
025:        import org.apache.juli.logging.LogFactory;
026:
027:        import java.lang.reflect.InvocationTargetException;
028:
029:        public class ClusterRuleSetFactory {
030:
031:            public static Log log = LogFactory
032:                    .getLog(ClusterRuleSetFactory.class);
033:
034:            public static RuleSetBase getClusterRuleSet(String prefix) {
035:
036:                //OLD CLUSTER 1
037:                //first try the same classloader as this class server/lib
038:                try {
039:                    return loadRuleSet(prefix,
040:                            "org.apache.catalina.cluster.ClusterRuleSet",
041:                            ClusterRuleSetFactory.class.getClassLoader());
042:                } catch (Exception x) {
043:                    //display warning
044:                    if (log.isDebugEnabled())
045:                        log
046:                                .debug("Unable to load ClusterRuleSet (org.apache.catalina.cluster.ClusterRuleSet), falling back on context classloader");
047:                }
048:                //try to load it from the context class loader
049:                try {
050:                    return loadRuleSet(prefix,
051:                            "org.apache.catalina.cluster.ClusterRuleSet",
052:                            Thread.currentThread().getContextClassLoader());
053:                } catch (Exception x) {
054:                    //display warning
055:                    if (log.isDebugEnabled())
056:                        log
057:                                .debug("Unable to load ClusterRuleSet (org.apache.catalina.cluster.ClusterRuleSet), will try to load the HA cluster");
058:                }
059:
060:                //NEW CLUSTER 2
061:                //first try the same classloader as this class server/lib
062:                try {
063:                    return loadRuleSet(prefix,
064:                            "org.apache.catalina.ha.ClusterRuleSet",
065:                            ClusterRuleSetFactory.class.getClassLoader());
066:                } catch (Exception x) {
067:                    //display warning
068:                    if (log.isDebugEnabled())
069:                        log
070:                                .debug("Unable to load HA ClusterRuleSet (org.apache.catalina.ha.ClusterRuleSet), falling back on context classloader");
071:                }
072:                //try to load it from the context class loader
073:                try {
074:                    return loadRuleSet(prefix,
075:                            "org.apache.catalina.ha.ClusterRuleSet", Thread
076:                                    .currentThread().getContextClassLoader());
077:                } catch (Exception x) {
078:                    //display warning
079:                    if (log.isDebugEnabled())
080:                        log
081:                                .debug("Unable to load HA ClusterRuleSet (org.apache.catalina.ha.ClusterRuleSet), falling back on DefaultClusterRuleSet");
082:                }
083:
084:                log
085:                        .info("Unable to find a cluster rule set in the classpath. Will load the default rule set.");
086:                return new DefaultClusterRuleSet(prefix);
087:            }
088:
089:            protected static RuleSetBase loadRuleSet(String prefix,
090:                    String className, ClassLoader cl)
091:                    throws ClassNotFoundException, InstantiationException,
092:                    NoSuchMethodException, IllegalAccessException,
093:                    InvocationTargetException {
094:                Class clazz = Class.forName(className, true, cl);
095:                Constructor cons = clazz
096:                        .getConstructor(new Class[] { String.class });
097:                return (RuleSetBase) cons.newInstance(prefix);
098:            }
099:
100:            /**
101:             * <p><strong>RuleSet</strong> for processing the contents of a
102:             * Cluster definition element.  </p>
103:             *
104:             * @author Filip Hanik
105:             * @author Peter Rossbach
106:             * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
107:             */
108:
109:            public static class DefaultClusterRuleSet extends RuleSetBase {
110:
111:                // ----------------------------------------------------- Instance Variables
112:
113:                /**
114:                 * The matching pattern prefix to use for recognizing our elements.
115:                 */
116:                protected String prefix = null;
117:
118:                // ------------------------------------------------------------ Constructor
119:
120:                /**
121:                 * Construct an instance of this <code>RuleSet</code> with the default
122:                 * matching pattern prefix.
123:                 */
124:                public DefaultClusterRuleSet() {
125:
126:                    this ("");
127:
128:                }
129:
130:                /**
131:                 * Construct an instance of this <code>RuleSet</code> with the specified
132:                 * matching pattern prefix.
133:                 *
134:                 * @param prefix Prefix for matching pattern rules (including the
135:                 *  trailing slash character)
136:                 */
137:                public DefaultClusterRuleSet(String prefix) {
138:                    super ();
139:                    this .namespaceURI = null;
140:                    this .prefix = prefix;
141:                }
142:
143:                // --------------------------------------------------------- Public Methods
144:
145:                /**
146:                 * <p>Add the set of Rule instances defined in this RuleSet to the
147:                 * specified <code>Digester</code> instance, associating them with
148:                 * our namespace URI (if any).  This method should only be called
149:                 * by a Digester instance.</p>
150:                 *
151:                 * @param digester Digester instance to which the new Rule instances
152:                 *  should be added.
153:                 */
154:                public void addRuleInstances(Digester digester) {
155:                    //Cluster configuration start
156:                    digester.addObjectCreate(prefix + "Membership", null, // MUST be specified in the element
157:                            "className");
158:                    digester.addSetProperties(prefix + "Membership");
159:                    digester.addSetNext(prefix + "Membership",
160:                            "setMembershipService",
161:                            "org.apache.catalina.cluster.MembershipService");
162:
163:                    digester.addObjectCreate(prefix + "Sender", null, // MUST be specified in the element
164:                            "className");
165:                    digester.addSetProperties(prefix + "Sender");
166:                    digester.addSetNext(prefix + "Sender", "setClusterSender",
167:                            "org.apache.catalina.cluster.ClusterSender");
168:
169:                    digester.addObjectCreate(prefix + "Receiver", null, // MUST be specified in the element
170:                            "className");
171:                    digester.addSetProperties(prefix + "Receiver");
172:                    digester.addSetNext(prefix + "Receiver",
173:                            "setClusterReceiver",
174:                            "org.apache.catalina.cluster.ClusterReceiver");
175:
176:                    digester.addObjectCreate(prefix + "Valve", null, // MUST be specified in the element
177:                            "className");
178:                    digester.addSetProperties(prefix + "Valve");
179:                    digester.addSetNext(prefix + "Valve", "addValve",
180:                            "org.apache.catalina.Valve");
181:
182:                    digester.addObjectCreate(prefix + "Deployer", null, // MUST be specified in the element
183:                            "className");
184:                    digester.addSetProperties(prefix + "Deployer");
185:                    digester.addSetNext(prefix + "Deployer",
186:                            "setClusterDeployer",
187:                            "org.apache.catalina.cluster.ClusterDeployer");
188:
189:                    digester.addObjectCreate(prefix + "Listener", null, // MUST be specified in the element
190:                            "className");
191:                    digester.addSetProperties(prefix + "Listener");
192:                    digester.addSetNext(prefix + "Listener",
193:                            "addLifecycleListener",
194:                            "org.apache.catalina.LifecycleListener");
195:
196:                    digester.addObjectCreate(prefix + "ClusterListener", null, // MUST be specified in the element
197:                            "className");
198:                    digester.addSetProperties(prefix + "ClusterListener");
199:                    digester.addSetNext(prefix + "ClusterListener",
200:                            "addClusterListener",
201:                            "org.apache.catalina.cluster.MessageListener");
202:                    //Cluster configuration end
203:                }
204:
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.