Source Code Cross Referenced for ContextRuleSet.java in  » Web-Server » Rimfaxe-Web-Server » 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 » Web Server » Rimfaxe Web Server » org.apache.catalina.startup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java,v 1.3 2001/11/08 21:03:15 remm Exp $
003:         * $Revision: 1.3 $
004:         * $Date: 2001/11/08 21:03:15 $
005:         *
006:         * ====================================================================
007:         *
008:         * The Apache Software License, Version 1.1
009:         *
010:         * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
011:         * reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions
015:         * are met:
016:         *
017:         * 1. Redistributions of source code must retain the above copyright
018:         *    notice, this list of conditions and the following disclaimer.
019:         *
020:         * 2. Redistributions in binary form must reproduce the above copyright
021:         *    notice, this list of conditions and the following disclaimer in
022:         *    the documentation and/or other materials provided with the
023:         *    distribution.
024:         *
025:         * 3. The end-user documentation included with the redistribution, if
026:         *    any, must include the following acknowlegement:
027:         *       "This product includes software developed by the
028:         *        Apache Software Foundation (http://www.apache.org/)."
029:         *    Alternately, this acknowlegement may appear in the software itself,
030:         *    if and wherever such third-party acknowlegements normally appear.
031:         *
032:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033:         *    Foundation" must not be used to endorse or promote products derived
034:         *    from this software without prior written permission. For written
035:         *    permission, please contact apache@apache.org.
036:         *
037:         * 5. Products derived from this software may not be called "Apache"
038:         *    nor may "Apache" appear in their names without prior written
039:         *    permission of the Apache Group.
040:         *
041:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         *
055:         * This software consists of voluntary contributions made by many
056:         * individuals on behalf of the Apache Software Foundation.  For more
057:         * information on the Apache Software Foundation, please see
058:         * <http://www.apache.org/>.
059:         *
060:         */
061:
062:        package org.apache.catalina.startup;
063:
064:        import java.lang.reflect.Constructor;
065:        import java.lang.reflect.Method;
066:        import org.apache.catalina.Container;
067:        import org.apache.catalina.Context;
068:        import org.apache.catalina.Loader;
069:        import org.apache.catalina.Wrapper;
070:        import org.apache.catalina.deploy.SecurityConstraint;
071:        import org.apache.commons.digester.Digester;
072:        import org.apache.commons.digester.Rule;
073:        import org.apache.commons.digester.RuleSetBase;
074:        import org.xml.sax.Attributes;
075:
076:        /**
077:         * <p><strong>RuleSet</strong> for processing the contents of a
078:         * Context or DefaultContext definition element.  To enable parsing of a
079:         * DefaultContext, be sure to specify a prefix that ends with "/Default".</p>
080:         *
081:         * @author Craig R. McClanahan
082:         * @version $Revision: 1.3 $ $Date: 2001/11/08 21:03:15 $
083:         */
084:
085:        public class ContextRuleSet extends RuleSetBase {
086:
087:            // ----------------------------------------------------- Instance Variables
088:
089:            /**
090:             * The matching pattern prefix to use for recognizing our elements.
091:             */
092:            protected String prefix = null;
093:
094:            // ------------------------------------------------------------ Constructor
095:
096:            /**
097:             * Construct an instance of this <code>RuleSet</code> with the default
098:             * matching pattern prefix.
099:             */
100:            public ContextRuleSet() {
101:
102:                this ("");
103:
104:            }
105:
106:            /**
107:             * Construct an instance of this <code>RuleSet</code> with the specified
108:             * matching pattern prefix.
109:             *
110:             * @param prefix Prefix for matching pattern rules (including the
111:             *  trailing slash character)
112:             */
113:            public ContextRuleSet(String prefix) {
114:
115:                super ();
116:                this .namespaceURI = null;
117:                this .prefix = prefix;
118:
119:            }
120:
121:            // --------------------------------------------------------- Public Methods
122:
123:            /**
124:             * <p>Add the set of Rule instances defined in this RuleSet to the
125:             * specified <code>Digester</code> instance, associating them with
126:             * our namespace URI (if any).  This method should only be called
127:             * by a Digester instance.</p>
128:             *
129:             * @param digester Digester instance to which the new Rule instances
130:             *  should be added.
131:             */
132:            public void addRuleInstances(Digester digester) {
133:
134:                if (!isDefaultContext()) {
135:                    digester.addObjectCreate(prefix + "Context",
136:                            "org.apache.catalina.core.StandardContext",
137:                            "className");
138:                } else {
139:                    digester.addObjectCreate(prefix + "Context",
140:                            "org.apache.catalina.core.StandardDefaultContext",
141:                            "className");
142:                }
143:                digester.addSetProperties(prefix + "Context");
144:                if (!isDefaultContext()) {
145:                    digester.addRule(prefix + "Context",
146:                            new CopyParentClassLoaderRule(digester));
147:                    digester
148:                            .addRule(
149:                                    prefix + "Context",
150:                                    new LifecycleListenerRule(
151:                                            digester,
152:                                            "org.apache.catalina.startup.ContextConfig",
153:                                            "configClass"));
154:                    digester.addSetNext(prefix + "Context", "addChild",
155:                            "org.apache.catalina.Container");
156:                } else {
157:                    digester.addSetNext(prefix + "Context",
158:                            "addDefaultContext",
159:                            "org.apache.catalina.DefaultContext");
160:                }
161:
162:                digester.addCallMethod(prefix + "Context/InstanceListener",
163:                        "addInstanceListener", 0);
164:
165:                digester.addObjectCreate(prefix + "Context/Listener", null, // MUST be specified in the element
166:                        "className");
167:                digester.addSetProperties(prefix + "Context/Listener");
168:                digester.addSetNext(prefix + "Context/Listener",
169:                        "addLifecycleListener",
170:                        "org.apache.catalina.LifecycleListener");
171:
172:                digester.addRule(prefix + "Context/Loader",
173:                        new CreateLoaderRule(digester,
174:                                "org.apache.catalina.loader.WebappLoader",
175:                                "className"));
176:                digester.addSetProperties(prefix + "Context/Loader");
177:                digester.addSetNext(prefix + "Context/Loader", "setLoader",
178:                        "org.apache.catalina.Loader");
179:
180:                digester.addObjectCreate(prefix + "Context/Logger", null, // MUST be specified in the element
181:                        "className");
182:                digester.addSetProperties(prefix + "Context/Logger");
183:                digester.addSetNext(prefix + "Context/Logger", "setLogger",
184:                        "org.apache.catalina.Logger");
185:
186:                digester.addObjectCreate(prefix + "Context/Manager",
187:                        "org.apache.catalina.session.StandardManager",
188:                        "className");
189:                digester.addSetProperties(prefix + "Context/Manager");
190:                digester.addSetNext(prefix + "Context/Manager", "setManager",
191:                        "org.apache.catalina.Manager");
192:
193:                digester.addObjectCreate(prefix + "Context/Manager/Store",
194:                        null, // MUST be specified in the element
195:                        "className");
196:                digester.addSetProperties(prefix + "Context/Manager/Store");
197:                digester.addSetNext(prefix + "Context/Manager/Store",
198:                        "setStore", "org.apache.catalina.Store");
199:
200:                digester.addObjectCreate(prefix + "Context/Parameter",
201:                        "org.apache.catalina.deploy.ApplicationParameter");
202:                digester.addSetProperties(prefix + "Context/Parameter");
203:                digester.addSetNext(prefix + "Context/Parameter",
204:                        "addApplicationParameter",
205:                        "org.apache.catalina.deploy.ApplicationParameter");
206:
207:                digester.addObjectCreate(prefix + "Context/Realm", null, // MUST be specified in the element
208:                        "className");
209:                digester.addSetProperties(prefix + "Context/Realm");
210:                digester.addSetNext(prefix + "Context/Realm", "setRealm",
211:                        "org.apache.catalina.Realm");
212:
213:                digester.addObjectCreate(prefix + "Context/ResourceLink",
214:                        "org.apache.catalina.deploy.ContextResourceLink");
215:                digester.addSetProperties(prefix + "Context/ResourceLink");
216:                digester.addSetNext(prefix + "Context/ResourceLink",
217:                        "addResourceLink",
218:                        "org.apache.catalina.deploy.ContextResourceLink");
219:
220:                digester.addObjectCreate(prefix + "Context/Resources",
221:                        "org.apache.naming.resources.FileDirContext",
222:                        "className");
223:                digester.addSetProperties(prefix + "Context/Resources");
224:                digester.addSetNext(prefix + "Context/Resources",
225:                        "setResources", "javax.naming.directory.DirContext");
226:
227:                digester.addObjectCreate(prefix + "Context/Valve", null, // MUST be specified in the element
228:                        "className");
229:                digester.addSetProperties(prefix + "Context/Valve");
230:                digester.addSetNext(prefix + "Context/Valve", "addValve",
231:                        "org.apache.catalina.Valve");
232:
233:                digester.addCallMethod(prefix + "Context/WrapperLifecycle",
234:                        "addWrapperLifecycle", 0);
235:
236:                digester.addCallMethod(prefix + "Context/WrapperListener",
237:                        "addWrapperListener", 0);
238:
239:            }
240:
241:            // ------------------------------------------------------ Protected Methods
242:
243:            /**
244:             * Are we processing a DefaultContext element?
245:             */
246:            protected boolean isDefaultContext() {
247:
248:                return (prefix.endsWith("/Default"));
249:
250:            }
251:
252:        }
253:
254:        // ----------------------------------------------------------- Private Classes
255:
256:        /**
257:         * Rule that creates a new <code>Loader</code> instance, with the parent
258:         * class loader associated with the top object on the stack (which must be
259:         * a <code>Container</code>), and pushes it on to the stack.
260:         */
261:
262:        final class CreateLoaderRule extends Rule {
263:
264:            public CreateLoaderRule(Digester digester, String loaderClass,
265:                    String attributeName) {
266:
267:                super (digester);
268:                this .loaderClass = loaderClass;
269:                this .attributeName = attributeName;
270:
271:            }
272:
273:            private String attributeName;
274:
275:            private String loaderClass;
276:
277:            public void begin(Attributes attributes) throws Exception {
278:
279:                // Look up the required parent class loader
280:                Container container = (Container) digester.peek();
281:                ClassLoader parentClassLoader = container
282:                        .getParentClassLoader();
283:
284:                // Instantiate a new Loader implementation object
285:                String className = loaderClass;
286:                if (attributeName != null) {
287:                    String value = attributes.getValue(attributeName);
288:                    if (value != null)
289:                        className = value;
290:                }
291:                Class clazz = Class.forName(className);
292:                Class types[] = { ClassLoader.class };
293:                Object args[] = { parentClassLoader };
294:                Constructor constructor = clazz.getDeclaredConstructor(types);
295:                Loader loader = (Loader) constructor.newInstance(args);
296:
297:                // Push the new loader onto the stack
298:                digester.push(loader);
299:                if (digester.getDebug() >= 1)
300:                    digester.log("new " + loader.getClass().getName());
301:
302:            }
303:
304:            public void end() throws Exception {
305:
306:                Loader loader = (Loader) digester.pop();
307:                if (digester.getDebug() >= 1)
308:                    digester.log("pop " + loader.getClass().getName());
309:
310:            }
311:
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.