Source Code Cross Referenced for WebRuleSet.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) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:
0018:        package org.apache.catalina.startup;
0019:
0020:        import java.lang.reflect.Method;
0021:        import java.util.ArrayList;
0022:
0023:        import org.apache.catalina.Context;
0024:        import org.apache.catalina.Wrapper;
0025:        import org.apache.catalina.deploy.ContextHandler;
0026:        import org.apache.catalina.deploy.ContextService;
0027:        import org.apache.catalina.deploy.SecurityConstraint;
0028:        import org.apache.catalina.deploy.SecurityRoleRef;
0029:        import org.apache.tomcat.util.IntrospectionUtils;
0030:        import org.apache.tomcat.util.digester.CallMethodRule;
0031:        import org.apache.tomcat.util.digester.CallParamRule;
0032:        import org.apache.tomcat.util.digester.Digester;
0033:        import org.apache.tomcat.util.digester.Rule;
0034:        import org.apache.tomcat.util.digester.RuleSetBase;
0035:        import org.apache.tomcat.util.digester.SetNextRule;
0036:        import org.xml.sax.Attributes;
0037:
0038:        /**
0039:         * <p><strong>RuleSet</strong> for processing the contents of a web application
0040:         * deployment descriptor (<code>/WEB-INF/web.xml</code>) resource.</p>
0041:         *
0042:         * @author Craig R. McClanahan
0043:         * @version $Revision: 550263 $ $Date: 2007-06-24 19:28:45 +0200 (dim., 24 juin 2007) $
0044:         */
0045:
0046:        public class WebRuleSet extends RuleSetBase {
0047:
0048:            // ----------------------------------------------------- Instance Variables
0049:
0050:            /**
0051:             * The matching pattern prefix to use for recognizing our elements.
0052:             */
0053:            protected String prefix = null;
0054:
0055:            /**
0056:             * The <code>SetSessionConfig</code> rule used to parse the web.xml
0057:             */
0058:            protected SetSessionConfig sessionConfig;
0059:
0060:            /**
0061:             * The <code>SetLoginConfig</code> rule used to parse the web.xml
0062:             */
0063:            protected SetLoginConfig loginConfig;
0064:
0065:            /**
0066:             * The <code>SetJspConfig</code> rule used to parse the web.xml
0067:             */
0068:            protected SetJspConfig jspConfig;
0069:
0070:            // ------------------------------------------------------------ Constructor
0071:
0072:            /**
0073:             * Construct an instance of this <code>RuleSet</code> with the default
0074:             * matching pattern prefix.
0075:             */
0076:            public WebRuleSet() {
0077:
0078:                this ("");
0079:
0080:            }
0081:
0082:            /**
0083:             * Construct an instance of this <code>RuleSet</code> with the specified
0084:             * matching pattern prefix.
0085:             *
0086:             * @param prefix Prefix for matching pattern rules (including the
0087:             *  trailing slash character)
0088:             */
0089:            public WebRuleSet(String prefix) {
0090:
0091:                super ();
0092:                this .namespaceURI = null;
0093:                this .prefix = prefix;
0094:
0095:            }
0096:
0097:            // --------------------------------------------------------- Public Methods
0098:
0099:            /**
0100:             * <p>Add the set of Rule instances defined in this RuleSet to the
0101:             * specified <code>Digester</code> instance, associating them with
0102:             * our namespace URI (if any).  This method should only be called
0103:             * by a Digester instance.</p>
0104:             *
0105:             * @param digester Digester instance to which the new Rule instances
0106:             *  should be added.
0107:             */
0108:            public void addRuleInstances(Digester digester) {
0109:                sessionConfig = new SetSessionConfig();
0110:                jspConfig = new SetJspConfig();
0111:                loginConfig = new SetLoginConfig();
0112:
0113:                digester.addRule(prefix + "web-app", new SetPublicIdRule(
0114:                        "setPublicId"));
0115:                digester.addRule(prefix + "web-app",
0116:                        new IgnoreAnnotationsRule());
0117:
0118:                digester.addCallMethod(prefix + "web-app/context-param",
0119:                        "addParameter", 2);
0120:                digester.addCallParam(prefix
0121:                        + "web-app/context-param/param-name", 0);
0122:                digester.addCallParam(prefix
0123:                        + "web-app/context-param/param-value", 1);
0124:
0125:                digester.addCallMethod(prefix + "web-app/display-name",
0126:                        "setDisplayName", 0);
0127:
0128:                digester.addRule(prefix + "web-app/distributable",
0129:                        new SetDistributableRule());
0130:
0131:                digester.addObjectCreate(prefix + "web-app/ejb-local-ref",
0132:                        "org.apache.catalina.deploy.ContextLocalEjb");
0133:                digester.addRule(prefix + "web-app/ejb-local-ref",
0134:                        new SetNextNamingRule("addLocalEjb",
0135:                                "org.apache.catalina.deploy.ContextLocalEjb"));
0136:
0137:                digester.addCallMethod(prefix
0138:                        + "web-app/ejb-local-ref/description",
0139:                        "setDescription", 0);
0140:                digester.addCallMethod(prefix
0141:                        + "web-app/ejb-local-ref/ejb-link", "setLink", 0);
0142:                digester.addCallMethod(prefix
0143:                        + "web-app/ejb-local-ref/ejb-ref-name", "setName", 0);
0144:                digester.addCallMethod(prefix
0145:                        + "web-app/ejb-local-ref/ejb-ref-type", "setType", 0);
0146:                digester.addCallMethod(prefix + "web-app/ejb-local-ref/local",
0147:                        "setLocal", 0);
0148:                digester.addCallMethod(prefix
0149:                        + "web-app/ejb-local-ref/local-home", "setHome", 0);
0150:
0151:                digester.addObjectCreate(prefix + "web-app/ejb-ref",
0152:                        "org.apache.catalina.deploy.ContextEjb");
0153:                digester.addRule(prefix + "web-app/ejb-ref",
0154:                        new SetNextNamingRule("addEjb",
0155:                                "org.apache.catalina.deploy.ContextEjb"));
0156:
0157:                digester.addCallMethod(prefix + "web-app/ejb-ref/description",
0158:                        "setDescription", 0);
0159:                digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-link",
0160:                        "setLink", 0);
0161:                digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-ref-name",
0162:                        "setName", 0);
0163:                digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-ref-type",
0164:                        "setType", 0);
0165:                digester.addCallMethod(prefix + "web-app/ejb-ref/home",
0166:                        "setHome", 0);
0167:                digester.addCallMethod(prefix + "web-app/ejb-ref/remote",
0168:                        "setRemote", 0);
0169:
0170:                digester.addObjectCreate(prefix + "web-app/env-entry",
0171:                        "org.apache.catalina.deploy.ContextEnvironment");
0172:                digester
0173:                        .addRule(
0174:                                prefix + "web-app/env-entry",
0175:                                new SetNextNamingRule("addEnvironment",
0176:                                        "org.apache.catalina.deploy.ContextEnvironment"));
0177:
0178:                digester.addCallMethod(
0179:                        prefix + "web-app/env-entry/description",
0180:                        "setDescription", 0);
0181:                digester.addCallMethod(prefix
0182:                        + "web-app/env-entry/env-entry-name", "setName", 0);
0183:                digester.addCallMethod(prefix
0184:                        + "web-app/env-entry/env-entry-type", "setType", 0);
0185:                digester.addCallMethod(prefix
0186:                        + "web-app/env-entry/env-entry-value", "setValue", 0);
0187:
0188:                digester.addObjectCreate(prefix + "web-app/error-page",
0189:                        "org.apache.catalina.deploy.ErrorPage");
0190:                digester.addSetNext(prefix + "web-app/error-page",
0191:                        "addErrorPage", "org.apache.catalina.deploy.ErrorPage");
0192:
0193:                digester.addCallMethod(
0194:                        prefix + "web-app/error-page/error-code",
0195:                        "setErrorCode", 0);
0196:                digester.addCallMethod(prefix
0197:                        + "web-app/error-page/exception-type",
0198:                        "setExceptionType", 0);
0199:                digester.addCallMethod(prefix + "web-app/error-page/location",
0200:                        "setLocation", 0);
0201:
0202:                digester.addObjectCreate(prefix + "web-app/filter",
0203:                        "org.apache.catalina.deploy.FilterDef");
0204:                digester.addSetNext(prefix + "web-app/filter", "addFilterDef",
0205:                        "org.apache.catalina.deploy.FilterDef");
0206:
0207:                digester.addCallMethod(prefix + "web-app/filter/description",
0208:                        "setDescription", 0);
0209:                digester.addCallMethod(prefix + "web-app/filter/display-name",
0210:                        "setDisplayName", 0);
0211:                digester.addCallMethod(prefix + "web-app/filter/filter-class",
0212:                        "setFilterClass", 0);
0213:                digester.addCallMethod(prefix + "web-app/filter/filter-name",
0214:                        "setFilterName", 0);
0215:                digester.addCallMethod(prefix + "web-app/filter/large-icon",
0216:                        "setLargeIcon", 0);
0217:                digester.addCallMethod(prefix + "web-app/filter/small-icon",
0218:                        "setSmallIcon", 0);
0219:
0220:                digester.addCallMethod(prefix + "web-app/filter/init-param",
0221:                        "addInitParameter", 2);
0222:                digester.addCallParam(prefix
0223:                        + "web-app/filter/init-param/param-name", 0);
0224:                digester.addCallParam(prefix
0225:                        + "web-app/filter/init-param/param-value", 1);
0226:
0227:                digester.addObjectCreate(prefix + "web-app/filter-mapping",
0228:                        "org.apache.catalina.deploy.FilterMap");
0229:                digester.addSetNext(prefix + "web-app/filter-mapping",
0230:                        "addFilterMap", "org.apache.catalina.deploy.FilterMap");
0231:
0232:                digester.addCallMethod(prefix
0233:                        + "web-app/filter-mapping/filter-name",
0234:                        "setFilterName", 0);
0235:                digester.addCallMethod(prefix
0236:                        + "web-app/filter-mapping/servlet-name",
0237:                        "addServletName", 0);
0238:                digester.addCallMethod(prefix
0239:                        + "web-app/filter-mapping/url-pattern",
0240:                        "addURLPattern", 0);
0241:
0242:                digester.addCallMethod(prefix
0243:                        + "web-app/filter-mapping/dispatcher", "setDispatcher",
0244:                        0);
0245:
0246:                digester.addCallMethod(prefix
0247:                        + "web-app/listener/listener-class",
0248:                        "addApplicationListener", 0);
0249:
0250:                digester.addRule(prefix + "web-app/jsp-config", jspConfig);
0251:
0252:                digester.addCallMethod(prefix
0253:                        + "web-app/jsp-config/jsp-property-group/url-pattern",
0254:                        "addJspMapping", 0);
0255:
0256:                digester.addCallMethod(prefix
0257:                        + "web-app/listener/listener-class",
0258:                        "addApplicationListener", 0);
0259:
0260:                digester.addRule(prefix + "web-app/login-config", loginConfig);
0261:
0262:                digester.addObjectCreate(prefix + "web-app/login-config",
0263:                        "org.apache.catalina.deploy.LoginConfig");
0264:                digester.addSetNext(prefix + "web-app/login-config",
0265:                        "setLoginConfig",
0266:                        "org.apache.catalina.deploy.LoginConfig");
0267:
0268:                digester.addCallMethod(prefix
0269:                        + "web-app/login-config/auth-method", "setAuthMethod",
0270:                        0);
0271:                digester.addCallMethod(prefix
0272:                        + "web-app/login-config/realm-name", "setRealmName", 0);
0273:                digester
0274:                        .addCallMethod(
0275:                                prefix
0276:                                        + "web-app/login-config/form-login-config/form-error-page",
0277:                                "setErrorPage", 0);
0278:                digester
0279:                        .addCallMethod(
0280:                                prefix
0281:                                        + "web-app/login-config/form-login-config/form-login-page",
0282:                                "setLoginPage", 0);
0283:
0284:                digester.addCallMethod(prefix + "web-app/mime-mapping",
0285:                        "addMimeMapping", 2);
0286:                digester.addCallParam(
0287:                        prefix + "web-app/mime-mapping/extension", 0);
0288:                digester.addCallParam(
0289:                        prefix + "web-app/mime-mapping/mime-type", 1);
0290:
0291:                digester.addObjectCreate(prefix + "web-app/resource-env-ref",
0292:                        "org.apache.catalina.deploy.ContextResourceEnvRef");
0293:                digester
0294:                        .addRule(
0295:                                prefix + "web-app/resource-env-ref",
0296:                                new SetNextNamingRule("addResourceEnvRef",
0297:                                        "org.apache.catalina.deploy.ContextResourceEnvRef"));
0298:
0299:                digester.addCallMethod(prefix
0300:                        + "web-app/resource-env-ref/resource-env-ref-name",
0301:                        "setName", 0);
0302:                digester.addCallMethod(prefix
0303:                        + "web-app/resource-env-ref/resource-env-ref-type",
0304:                        "setType", 0);
0305:
0306:                digester.addObjectCreate(
0307:                        prefix + "web-app/message-destination",
0308:                        "org.apache.catalina.deploy.MessageDestination");
0309:                digester.addSetNext(prefix + "web-app/message-destination",
0310:                        "addMessageDestination",
0311:                        "org.apache.catalina.deploy.MessageDestination");
0312:
0313:                digester.addCallMethod(prefix
0314:                        + "web-app/message-destination/description",
0315:                        "setDescription", 0);
0316:                digester.addCallMethod(prefix
0317:                        + "web-app/message-destination/display-name",
0318:                        "setDisplayName", 0);
0319:                digester.addCallMethod(prefix
0320:                        + "web-app/message-destination/icon/large-icon",
0321:                        "setLargeIcon", 0);
0322:                digester.addCallMethod(prefix
0323:                        + "web-app/message-destination/icon/small-icon",
0324:                        "setSmallIcon", 0);
0325:                digester
0326:                        .addCallMethod(
0327:                                prefix
0328:                                        + "web-app/message-destination/message-destination-name",
0329:                                "setName", 0);
0330:
0331:                digester.addObjectCreate(prefix
0332:                        + "web-app/message-destination-ref",
0333:                        "org.apache.catalina.deploy.MessageDestinationRef");
0334:                digester.addSetNext(prefix + "web-app/message-destination-ref",
0335:                        "addMessageDestinationRef",
0336:                        "org.apache.catalina.deploy.MessageDestinationRef");
0337:
0338:                digester.addCallMethod(prefix
0339:                        + "web-app/message-destination-ref/description",
0340:                        "setDescription", 0);
0341:                digester
0342:                        .addCallMethod(
0343:                                prefix
0344:                                        + "web-app/message-destination-ref/message-destination-link",
0345:                                "setLink", 0);
0346:                digester
0347:                        .addCallMethod(
0348:                                prefix
0349:                                        + "web-app/message-destination-ref/message-destination-ref-name",
0350:                                "setName", 0);
0351:                digester
0352:                        .addCallMethod(
0353:                                prefix
0354:                                        + "web-app/message-destination-ref/message-destination-type",
0355:                                "setType", 0);
0356:                digester
0357:                        .addCallMethod(
0358:                                prefix
0359:                                        + "web-app/message-destination-ref/message-destination-usage",
0360:                                "setUsage", 0);
0361:
0362:                digester.addObjectCreate(prefix + "web-app/resource-ref",
0363:                        "org.apache.catalina.deploy.ContextResource");
0364:                digester.addRule(prefix + "web-app/resource-ref",
0365:                        new SetNextNamingRule("addResource",
0366:                                "org.apache.catalina.deploy.ContextResource"));
0367:
0368:                digester.addCallMethod(prefix
0369:                        + "web-app/resource-ref/description", "setDescription",
0370:                        0);
0371:                digester.addCallMethod(
0372:                        prefix + "web-app/resource-ref/res-auth", "setAuth", 0);
0373:                digester.addCallMethod(prefix
0374:                        + "web-app/resource-ref/res-ref-name", "setName", 0);
0375:                digester.addCallMethod(prefix
0376:                        + "web-app/resource-ref/res-sharing-scope", "setScope",
0377:                        0);
0378:                digester.addCallMethod(
0379:                        prefix + "web-app/resource-ref/res-type", "setType", 0);
0380:
0381:                digester.addObjectCreate(
0382:                        prefix + "web-app/security-constraint",
0383:                        "org.apache.catalina.deploy.SecurityConstraint");
0384:                digester.addSetNext(prefix + "web-app/security-constraint",
0385:                        "addConstraint",
0386:                        "org.apache.catalina.deploy.SecurityConstraint");
0387:
0388:                digester.addRule(prefix
0389:                        + "web-app/security-constraint/auth-constraint",
0390:                        new SetAuthConstraintRule());
0391:                digester
0392:                        .addCallMethod(
0393:                                prefix
0394:                                        + "web-app/security-constraint/auth-constraint/role-name",
0395:                                "addAuthRole", 0);
0396:                digester.addCallMethod(prefix
0397:                        + "web-app/security-constraint/display-name",
0398:                        "setDisplayName", 0);
0399:                digester
0400:                        .addCallMethod(
0401:                                prefix
0402:                                        + "web-app/security-constraint/user-data-constraint/transport-guarantee",
0403:                                "setUserConstraint", 0);
0404:
0405:                digester
0406:                        .addObjectCreate(
0407:                                prefix
0408:                                        + "web-app/security-constraint/web-resource-collection",
0409:                                "org.apache.catalina.deploy.SecurityCollection");
0410:                digester
0411:                        .addSetNext(
0412:                                prefix
0413:                                        + "web-app/security-constraint/web-resource-collection",
0414:                                "addCollection",
0415:                                "org.apache.catalina.deploy.SecurityCollection");
0416:                digester
0417:                        .addCallMethod(
0418:                                prefix
0419:                                        + "web-app/security-constraint/web-resource-collection/http-method",
0420:                                "addMethod", 0);
0421:                digester
0422:                        .addCallMethod(
0423:                                prefix
0424:                                        + "web-app/security-constraint/web-resource-collection/url-pattern",
0425:                                "addPattern", 0);
0426:                digester
0427:                        .addCallMethod(
0428:                                prefix
0429:                                        + "web-app/security-constraint/web-resource-collection/web-resource-name",
0430:                                "setName", 0);
0431:
0432:                digester.addCallMethod(prefix
0433:                        + "web-app/security-role/role-name", "addSecurityRole",
0434:                        0);
0435:
0436:                digester.addObjectCreate(prefix + "web-app/service-ref",
0437:                        "org.apache.catalina.deploy.ContextService");
0438:                digester.addRule(prefix + "web-app/service-ref",
0439:                        new SetNextNamingRule("addService",
0440:                                "org.apache.catalina.deploy.ContextService"));
0441:
0442:                digester.addCallMethod(prefix
0443:                        + "web-app/service-ref/description", "setDescription",
0444:                        0);
0445:                digester.addCallMethod(prefix
0446:                        + "web-app/service-ref/display-name", "setDisplayname",
0447:                        0);
0448:                digester.addCallMethod(prefix + "web-app/service-ref/icon",
0449:                        "setIcon", 0);
0450:                digester.addCallMethod(prefix
0451:                        + "web-app/service-ref/service-ref-name", "setName", 0);
0452:                digester
0453:                        .addCallMethod(prefix
0454:                                + "web-app/service-ref/service-interface",
0455:                                "setType", 0);
0456:                digester.addCallMethod(
0457:                        prefix + "web-app/service-ref/wsdl-file",
0458:                        "setWsdlfile", 0);
0459:                digester.addCallMethod(prefix
0460:                        + "web-app/service-ref/jaxrpc-mapping-file",
0461:                        "setJaxrpcmappingfile", 0);
0462:                digester.addRule(prefix + "web-app/service-ref/service-qname",
0463:                        new ServiceQnameRule());
0464:
0465:                digester.addRule(prefix
0466:                        + "web-app/service-ref/port-component-ref",
0467:                        new CallMethodMultiRule("addPortcomponent", 2, 1));
0468:                digester
0469:                        .addCallParam(
0470:                                prefix
0471:                                        + "web-app/service-ref/port-component-ref/service-endpoint-interface",
0472:                                0);
0473:                digester
0474:                        .addRule(
0475:                                prefix
0476:                                        + "web-app/service-ref/port-component-ref/port-component-link",
0477:                                new CallParamMultiRule(1));
0478:
0479:                digester.addObjectCreate(
0480:                        prefix + "web-app/service-ref/handler",
0481:                        "org.apache.catalina.deploy.ContextHandler");
0482:                digester.addRule(prefix + "web-app/service-ref/handler",
0483:                        new SetNextRule("addHandler",
0484:                                "org.apache.catalina.deploy.ContextHandler"));
0485:
0486:                digester.addCallMethod(prefix
0487:                        + "web-app/service-ref/handler/handler-name",
0488:                        "setName", 0);
0489:                digester.addCallMethod(prefix
0490:                        + "web-app/service-ref/handler/handler-class",
0491:                        "setHandlerclass", 0);
0492:
0493:                digester.addCallMethod(prefix
0494:                        + "web-app/service-ref/handler/init-param",
0495:                        "setProperty", 2);
0496:                digester.addCallParam(prefix
0497:                        + "web-app/service-ref/handler/init-param/param-name",
0498:                        0);
0499:                digester.addCallParam(prefix
0500:                        + "web-app/service-ref/handler/init-param/param-value",
0501:                        1);
0502:
0503:                digester.addRule(prefix
0504:                        + "web-app/service-ref/handler/soap-header",
0505:                        new SoapHeaderRule());
0506:
0507:                digester.addCallMethod(prefix
0508:                        + "web-app/service-ref/handler/soap-role",
0509:                        "addSoapRole", 0);
0510:                digester.addCallMethod(prefix
0511:                        + "web-app/service-ref/handler/port-name",
0512:                        "addPortName", 0);
0513:
0514:                digester.addRule(prefix + "web-app/servlet",
0515:                        new WrapperCreateRule());
0516:                digester.addSetNext(prefix + "web-app/servlet", "addChild",
0517:                        "org.apache.catalina.Container");
0518:
0519:                digester.addCallMethod(prefix + "web-app/servlet/init-param",
0520:                        "addInitParameter", 2);
0521:                digester.addCallParam(prefix
0522:                        + "web-app/servlet/init-param/param-name", 0);
0523:                digester.addCallParam(prefix
0524:                        + "web-app/servlet/init-param/param-value", 1);
0525:
0526:                digester.addCallMethod(prefix + "web-app/servlet/jsp-file",
0527:                        "setJspFile", 0);
0528:                digester.addCallMethod(prefix
0529:                        + "web-app/servlet/load-on-startup",
0530:                        "setLoadOnStartupString", 0);
0531:                digester.addCallMethod(prefix
0532:                        + "web-app/servlet/run-as/role-name", "setRunAs", 0);
0533:
0534:                digester.addRule(prefix + "web-app/servlet/security-role-ref",
0535:                        new SecurityRoleRefCreateRule());
0536:                digester.addCallMethod(prefix
0537:                        + "web-app/servlet/security-role-ref/role-link",
0538:                        "setLink", 0);
0539:                digester.addCallMethod(prefix
0540:                        + "web-app/servlet/security-role-ref/role-name",
0541:                        "setName", 0);
0542:
0543:                digester.addCallMethod(
0544:                        prefix + "web-app/servlet/servlet-class",
0545:                        "setServletClass", 0);
0546:                digester.addCallMethod(prefix + "web-app/servlet/servlet-name",
0547:                        "setName", 0);
0548:
0549:                digester.addRule(prefix + "web-app/servlet-mapping",
0550:                        new CallMethodMultiRule("addServletMapping", 2, 0));
0551:                digester.addCallParam(prefix
0552:                        + "web-app/servlet-mapping/servlet-name", 1);
0553:                digester.addRule(
0554:                        prefix + "web-app/servlet-mapping/url-pattern",
0555:                        new CallParamMultiRule(0));
0556:
0557:                digester.addRule(prefix + "web-app/session-config",
0558:                        sessionConfig);
0559:
0560:                digester.addCallMethod(prefix
0561:                        + "web-app/session-config/session-timeout",
0562:                        "setSessionTimeout", 1, new Class[] { Integer.TYPE });
0563:                digester.addCallParam(prefix
0564:                        + "web-app/session-config/session-timeout", 0);
0565:
0566:                digester.addCallMethod(prefix + "web-app/taglib", "addTaglib",
0567:                        2);
0568:                digester.addCallParam(
0569:                        prefix + "web-app/taglib/taglib-location", 1);
0570:                digester.addCallParam(prefix + "web-app/taglib/taglib-uri", 0);
0571:
0572:                digester.addCallMethod(prefix
0573:                        + "web-app/welcome-file-list/welcome-file",
0574:                        "addWelcomeFile", 0);
0575:
0576:                digester
0577:                        .addCallMethod(
0578:                                prefix
0579:                                        + "web-app/locale-encoding-mapping-list/locale-encoding-mapping",
0580:                                "addLocaleEncodingMappingParameter", 2);
0581:                digester
0582:                        .addCallParam(
0583:                                prefix
0584:                                        + "web-app/locale-encoding-mapping-list/locale-encoding-mapping/locale",
0585:                                0);
0586:                digester
0587:                        .addCallParam(
0588:                                prefix
0589:                                        + "web-app/locale-encoding-mapping-list/locale-encoding-mapping/encoding",
0590:                                1);
0591:
0592:            }
0593:
0594:            /**
0595:             * Reset counter used for validating the web.xml file.
0596:             */
0597:            public void recycle() {
0598:                jspConfig.isJspConfigSet = false;
0599:                sessionConfig.isSessionConfigSet = false;
0600:                loginConfig.isLoginConfigSet = false;
0601:            }
0602:        }
0603:
0604:        // ----------------------------------------------------------- Private Classes
0605:
0606:        /**
0607:         * Rule to check that the <code>login-config</code> is occuring 
0608:         * only 1 time within the web.xml
0609:         */
0610:        final class SetLoginConfig extends Rule {
0611:            protected boolean isLoginConfigSet = false;
0612:
0613:            public SetLoginConfig() {
0614:            }
0615:
0616:            public void begin(String namespace, String name,
0617:                    Attributes attributes) throws Exception {
0618:                if (isLoginConfigSet) {
0619:                    throw new IllegalArgumentException(
0620:                            "<login-config> element is limited to 1 occurance");
0621:                }
0622:                isLoginConfigSet = true;
0623:            }
0624:
0625:        }
0626:
0627:        /**
0628:         * Rule to check that the <code>jsp-config</code> is occuring 
0629:         * only 1 time within the web.xml
0630:         */
0631:        final class SetJspConfig extends Rule {
0632:            protected boolean isJspConfigSet = false;
0633:
0634:            public SetJspConfig() {
0635:            }
0636:
0637:            public void begin(String namespace, String name,
0638:                    Attributes attributes) throws Exception {
0639:                if (isJspConfigSet) {
0640:                    throw new IllegalArgumentException(
0641:                            "<jsp-config> element is limited to 1 occurance");
0642:                }
0643:                isJspConfigSet = true;
0644:            }
0645:
0646:        }
0647:
0648:        /**
0649:         * Rule to check that the <code>session-config</code> is occuring 
0650:         * only 1 time within the web.xml
0651:         */
0652:        final class SetSessionConfig extends Rule {
0653:            protected boolean isSessionConfigSet = false;
0654:
0655:            public SetSessionConfig() {
0656:            }
0657:
0658:            public void begin(String namespace, String name,
0659:                    Attributes attributes) throws Exception {
0660:                if (isSessionConfigSet) {
0661:                    throw new IllegalArgumentException(
0662:                            "<session-config> element is limited to 1 occurance");
0663:                }
0664:                isSessionConfigSet = true;
0665:            }
0666:
0667:        }
0668:
0669:        /**
0670:         * A Rule that calls the <code>setAuthConstraint(true)</code> method of
0671:         * the top item on the stack, which must be of type
0672:         * <code>org.apache.catalina.deploy.SecurityConstraint</code>.
0673:         */
0674:
0675:        final class SetAuthConstraintRule extends Rule {
0676:
0677:            public SetAuthConstraintRule() {
0678:            }
0679:
0680:            public void begin(String namespace, String name,
0681:                    Attributes attributes) throws Exception {
0682:                SecurityConstraint securityConstraint = (SecurityConstraint) digester
0683:                        .peek();
0684:                securityConstraint.setAuthConstraint(true);
0685:                if (digester.getLogger().isDebugEnabled()) {
0686:                    digester
0687:                            .getLogger()
0688:                            .debug(
0689:                                    "Calling SecurityConstraint.setAuthConstraint(true)");
0690:                }
0691:            }
0692:
0693:        }
0694:
0695:        /**
0696:         * Class that calls <code>setDistributable(true)</code> for the top object
0697:         * on the stack, which must be a <code>org.apache.catalina.Context</code>.
0698:         */
0699:
0700:        final class SetDistributableRule extends Rule {
0701:
0702:            public SetDistributableRule() {
0703:            }
0704:
0705:            public void begin(String namespace, String name,
0706:                    Attributes attributes) throws Exception {
0707:                Context context = (Context) digester.peek();
0708:                context.setDistributable(true);
0709:                if (digester.getLogger().isDebugEnabled()) {
0710:                    digester.getLogger().debug(
0711:                            context.getClass().getName()
0712:                                    + ".setDistributable( true)");
0713:                }
0714:            }
0715:
0716:        }
0717:
0718:        /**
0719:         * Class that calls a property setter for the top object on the stack,
0720:         * passing the public ID of the entity we are currently processing.
0721:         */
0722:
0723:        final class SetPublicIdRule extends Rule {
0724:
0725:            public SetPublicIdRule(String method) {
0726:                this .method = method;
0727:            }
0728:
0729:            private String method = null;
0730:
0731:            public void begin(String namespace, String name,
0732:                    Attributes attributes) throws Exception {
0733:
0734:                Object top = digester.peek();
0735:                Class paramClasses[] = new Class[1];
0736:                paramClasses[0] = "String".getClass();
0737:                String paramValues[] = new String[1];
0738:                paramValues[0] = digester.getPublicId();
0739:
0740:                Method m = null;
0741:                try {
0742:                    m = top.getClass().getMethod(method, paramClasses);
0743:                } catch (NoSuchMethodException e) {
0744:                    digester.getLogger().error(
0745:                            "Can't find method " + method + " in " + top
0746:                                    + " CLASS " + top.getClass());
0747:                    return;
0748:                }
0749:
0750:                m.invoke(top, (Object[]) paramValues);
0751:                if (digester.getLogger().isDebugEnabled())
0752:                    digester.getLogger().debug(
0753:                            "" + top.getClass().getName() + "." + method + "("
0754:                                    + paramValues[0] + ")");
0755:
0756:            }
0757:
0758:        }
0759:
0760:        /**
0761:         * A Rule that calls the factory method on the specified Context to
0762:         * create the object that is to be added to the stack.
0763:         */
0764:
0765:        final class WrapperCreateRule extends Rule {
0766:
0767:            public WrapperCreateRule() {
0768:            }
0769:
0770:            public void begin(String namespace, String name,
0771:                    Attributes attributes) throws Exception {
0772:                Context context = (Context) digester
0773:                        .peek(digester.getCount() - 1);
0774:                Wrapper wrapper = context.createWrapper();
0775:                digester.push(wrapper);
0776:                if (digester.getLogger().isDebugEnabled())
0777:                    digester.getLogger().debug(
0778:                            "new " + wrapper.getClass().getName());
0779:            }
0780:
0781:            public void end(String namespace, String name) throws Exception {
0782:                Wrapper wrapper = (Wrapper) digester.pop();
0783:                if (digester.getLogger().isDebugEnabled())
0784:                    digester.getLogger().debug(
0785:                            "pop " + wrapper.getClass().getName());
0786:            }
0787:
0788:        }
0789:
0790:        /**
0791:         * A Rule that can be used to call multiple times a method as many times as needed
0792:         * (used for addServletMapping).
0793:         */
0794:        final class CallParamMultiRule extends CallParamRule {
0795:
0796:            public CallParamMultiRule(int paramIndex) {
0797:                super (paramIndex);
0798:            }
0799:
0800:            public void end(String namespace, String name) {
0801:                if (bodyTextStack != null && !bodyTextStack.empty()) {
0802:                    // what we do now is push one parameter onto the top set of parameters
0803:                    Object parameters[] = (Object[]) digester.peekParams();
0804:                    ArrayList params = (ArrayList) parameters[paramIndex];
0805:                    if (params == null) {
0806:                        params = new ArrayList();
0807:                        parameters[paramIndex] = params;
0808:                    }
0809:                    params.add(bodyTextStack.pop());
0810:                }
0811:            }
0812:
0813:        }
0814:
0815:        /**
0816:         * A Rule that can be used to call multiple times a method as many times as needed
0817:         * (used for addServletMapping).
0818:         */
0819:        final class CallMethodMultiRule extends CallMethodRule {
0820:
0821:            protected int multiParamIndex = 0;
0822:
0823:            public CallMethodMultiRule(String methodName, int paramCount,
0824:                    int multiParamIndex) {
0825:                super (methodName, paramCount);
0826:                this .multiParamIndex = multiParamIndex;
0827:            }
0828:
0829:            public void end() throws Exception {
0830:
0831:                // Retrieve or construct the parameter values array
0832:                Object parameters[] = null;
0833:                if (paramCount > 0) {
0834:                    parameters = (Object[]) digester.popParams();
0835:                } else {
0836:                    super .end();
0837:                }
0838:
0839:                ArrayList multiParams = (ArrayList) parameters[multiParamIndex];
0840:
0841:                // Construct the parameter values array we will need
0842:                // We only do the conversion if the param value is a String and
0843:                // the specified paramType is not String. 
0844:                Object paramValues[] = new Object[paramTypes.length];
0845:                for (int i = 0; i < paramTypes.length; i++) {
0846:                    if (i != multiParamIndex) {
0847:                        // convert nulls and convert stringy parameters 
0848:                        // for non-stringy param types
0849:                        if (parameters[i] == null
0850:                                || (parameters[i] instanceof  String && !String.class
0851:                                        .isAssignableFrom(paramTypes[i]))) {
0852:                            paramValues[i] = IntrospectionUtils.convert(
0853:                                    (String) parameters[i], paramTypes[i]);
0854:                        } else {
0855:                            paramValues[i] = parameters[i];
0856:                        }
0857:                    }
0858:                }
0859:
0860:                // Determine the target object for the method call
0861:                Object target;
0862:                if (targetOffset >= 0) {
0863:                    target = digester.peek(targetOffset);
0864:                } else {
0865:                    target = digester.peek(digester.getCount() + targetOffset);
0866:                }
0867:
0868:                if (target == null) {
0869:                    StringBuffer sb = new StringBuffer();
0870:                    sb.append("[CallMethodRule]{");
0871:                    sb.append("");
0872:                    sb.append("} Call target is null (");
0873:                    sb.append("targetOffset=");
0874:                    sb.append(targetOffset);
0875:                    sb.append(",stackdepth=");
0876:                    sb.append(digester.getCount());
0877:                    sb.append(")");
0878:                    throw new org.xml.sax.SAXException(sb.toString());
0879:                }
0880:
0881:                if (multiParams == null) {
0882:                    paramValues[multiParamIndex] = null;
0883:                    Object result = IntrospectionUtils.callMethodN(target,
0884:                            methodName, paramValues, paramTypes);
0885:                    return;
0886:                }
0887:
0888:                for (int j = 0; j < multiParams.size(); j++) {
0889:                    Object param = multiParams.get(j);
0890:                    if (param == null
0891:                            || (param instanceof  String && !String.class
0892:                                    .isAssignableFrom(paramTypes[multiParamIndex]))) {
0893:                        paramValues[multiParamIndex] = IntrospectionUtils
0894:                                .convert((String) param,
0895:                                        paramTypes[multiParamIndex]);
0896:                    } else {
0897:                        paramValues[multiParamIndex] = param;
0898:                    }
0899:                    Object result = IntrospectionUtils.callMethodN(target,
0900:                            methodName, paramValues, paramTypes);
0901:                }
0902:
0903:            }
0904:
0905:        }
0906:
0907:        /**
0908:         * A Rule that check if the annotations have to be loaded.
0909:         * 
0910:         */
0911:
0912:        final class IgnoreAnnotationsRule extends Rule {
0913:
0914:            public IgnoreAnnotationsRule() {
0915:            }
0916:
0917:            public void begin(String namespace, String name,
0918:                    Attributes attributes) throws Exception {
0919:                Context context = (Context) digester
0920:                        .peek(digester.getCount() - 1);
0921:                String value = attributes.getValue("metadata-complete");
0922:                if ("true".equals(value)) {
0923:                    context.setIgnoreAnnotations(true);
0924:                }
0925:                if (digester.getLogger().isDebugEnabled()) {
0926:                    digester.getLogger().debug(
0927:                            context.getClass().getName()
0928:                                    + ".setIgnoreAnnotations( "
0929:                                    + context.getIgnoreAnnotations() + ")");
0930:                }
0931:            }
0932:
0933:        }
0934:
0935:        /**
0936:         * A Rule that sets soap headers on the ContextHandler.
0937:         * 
0938:         */
0939:        final class SoapHeaderRule extends Rule {
0940:
0941:            public SoapHeaderRule() {
0942:            }
0943:
0944:            public void body(String text) throws Exception {
0945:                String namespaceuri = null;
0946:                String localpart = text;
0947:                int colon = text.indexOf(':');
0948:                if (colon >= 0) {
0949:                    String prefix = text.substring(0, colon);
0950:                    namespaceuri = digester.findNamespaceURI(prefix);
0951:                    localpart = text.substring(colon + 1);
0952:                }
0953:                ContextHandler contextHandler = (ContextHandler) digester
0954:                        .peek();
0955:                contextHandler.addSoapHeaders(localpart, namespaceuri);
0956:            }
0957:        }
0958:
0959:        /**
0960:         * A Rule that sets service qname on the ContextService.
0961:         * 
0962:         */
0963:        final class ServiceQnameRule extends Rule {
0964:
0965:            public ServiceQnameRule() {
0966:            }
0967:
0968:            public void body(String text) throws Exception {
0969:                String namespaceuri = null;
0970:                String localpart = text;
0971:                int colon = text.indexOf(':');
0972:                if (colon >= 0) {
0973:                    String prefix = text.substring(0, colon);
0974:                    namespaceuri = digester.findNamespaceURI(prefix);
0975:                    localpart = text.substring(colon + 1);
0976:                }
0977:                ContextService contextService = (ContextService) digester
0978:                        .peek();
0979:                contextService.setServiceqnameLocalpart(localpart);
0980:                contextService.setServiceqnameNamespaceURI(namespaceuri);
0981:            }
0982:        }
0983:
0984:        /**
0985:         * A Rule that adds a security-role-ref to a servlet, allowing for the fact that
0986:         * role-link is an optional element.
0987:         */
0988:        final class SecurityRoleRefCreateRule extends Rule {
0989:
0990:            public SecurityRoleRefCreateRule() {
0991:            }
0992:
0993:            public void begin(String namespace, String name,
0994:                    Attributes attributes) throws Exception {
0995:                SecurityRoleRef securityRoleRef = new SecurityRoleRef();
0996:                digester.push(securityRoleRef);
0997:                if (digester.getLogger().isDebugEnabled())
0998:                    digester.getLogger().debug("new SecurityRoleRef");
0999:            }
1000:
1001:            public void end(String namespace, String name) throws Exception {
1002:                SecurityRoleRef securityRoleRef = (SecurityRoleRef) digester
1003:                        .pop();
1004:                Wrapper wrapper = (Wrapper) digester.peek();
1005:
1006:                wrapper.addSecurityReference(securityRoleRef.getName(),
1007:                        securityRoleRef.getLink());
1008:
1009:                if (digester.getLogger().isDebugEnabled())
1010:                    digester.getLogger().debug("pop SecurityRoleRef");
1011:            }
1012:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.