1 17 18 19 package org.apache.catalina.startup; 20 21 22 import java.lang.reflect.Method ; 23 import java.util.ArrayList ; 24 25 import org.apache.catalina.Context; 26 import org.apache.catalina.Wrapper; 27 import org.apache.catalina.deploy.SecurityConstraint; 28 import org.apache.tomcat.util.IntrospectionUtils; 29 import org.apache.tomcat.util.digester.CallMethodRule; 30 import org.apache.tomcat.util.digester.CallParamRule; 31 import org.apache.tomcat.util.digester.Digester; 32 import org.apache.tomcat.util.digester.Rule; 33 import org.apache.tomcat.util.digester.RuleSetBase; 34 import org.xml.sax.Attributes ; 35 36 37 44 45 public class WebRuleSet extends RuleSetBase { 46 47 48 50 51 54 protected String prefix = null; 55 56 57 60 protected SetSessionConfig sessionConfig; 61 62 63 66 protected SetLoginConfig loginConfig; 67 68 69 72 protected SetJspConfig jspConfig; 73 74 75 77 78 82 public WebRuleSet() { 83 84 this(""); 85 86 } 87 88 89 96 public WebRuleSet(String prefix) { 97 98 super(); 99 this.namespaceURI = null; 100 this.prefix = prefix; 101 102 } 103 104 105 107 108 117 public void addRuleInstances(Digester digester) { 118 sessionConfig = new SetSessionConfig(); 119 jspConfig = new SetJspConfig(); 120 loginConfig = new SetLoginConfig(); 121 122 digester.addRule(prefix + "web-app", 123 new SetPublicIdRule("setPublicId")); 124 digester.addRule(prefix + "web-app", 125 new IgnoreAnnotationsRule()); 126 127 digester.addCallMethod(prefix + "web-app/context-param", 128 "addParameter", 2); 129 digester.addCallParam(prefix + "web-app/context-param/param-name", 0); 130 digester.addCallParam(prefix + "web-app/context-param/param-value", 1); 131 132 digester.addCallMethod(prefix + "web-app/display-name", 133 "setDisplayName", 0); 134 135 digester.addRule(prefix + "web-app/distributable", 136 new SetDistributableRule()); 137 138 digester.addObjectCreate(prefix + "web-app/ejb-local-ref", 139 "org.apache.catalina.deploy.ContextLocalEjb"); 140 digester.addRule(prefix + "web-app/ejb-local-ref", 141 new SetNextNamingRule("addLocalEjb", 142 "org.apache.catalina.deploy.ContextLocalEjb")); 143 144 digester.addCallMethod(prefix + "web-app/ejb-local-ref/description", 145 "setDescription", 0); 146 digester.addCallMethod(prefix + "web-app/ejb-local-ref/ejb-link", 147 "setLink", 0); 148 digester.addCallMethod(prefix + "web-app/ejb-local-ref/ejb-ref-name", 149 "setName", 0); 150 digester.addCallMethod(prefix + "web-app/ejb-local-ref/ejb-ref-type", 151 "setType", 0); 152 digester.addCallMethod(prefix + "web-app/ejb-local-ref/local", 153 "setLocal", 0); 154 digester.addCallMethod(prefix + "web-app/ejb-local-ref/local-home", 155 "setHome", 0); 156 157 digester.addObjectCreate(prefix + "web-app/ejb-ref", 158 "org.apache.catalina.deploy.ContextEjb"); 159 digester.addRule(prefix + "web-app/ejb-ref", 160 new SetNextNamingRule("addEjb", 161 "org.apache.catalina.deploy.ContextEjb")); 162 163 digester.addCallMethod(prefix + "web-app/ejb-ref/description", 164 "setDescription", 0); 165 digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-link", 166 "setLink", 0); 167 digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-ref-name", 168 "setName", 0); 169 digester.addCallMethod(prefix + "web-app/ejb-ref/ejb-ref-type", 170 "setType", 0); 171 digester.addCallMethod(prefix + "web-app/ejb-ref/home", 172 "setHome", 0); 173 digester.addCallMethod(prefix + "web-app/ejb-ref/remote", 174 "setRemote", 0); 175 176 digester.addObjectCreate(prefix + "web-app/env-entry", 177 "org.apache.catalina.deploy.ContextEnvironment"); 178 digester.addRule(prefix + "web-app/env-entry", 179 new SetNextNamingRule("addEnvironment", 180 "org.apache.catalina.deploy.ContextEnvironment")); 181 182 digester.addCallMethod(prefix + "web-app/env-entry/description", 183 "setDescription", 0); 184 digester.addCallMethod(prefix + "web-app/env-entry/env-entry-name", 185 "setName", 0); 186 digester.addCallMethod(prefix + "web-app/env-entry/env-entry-type", 187 "setType", 0); 188 digester.addCallMethod(prefix + "web-app/env-entry/env-entry-value", 189 "setValue", 0); 190 191 digester.addObjectCreate(prefix + "web-app/error-page", 192 "org.apache.catalina.deploy.ErrorPage"); 193 digester.addSetNext(prefix + "web-app/error-page", 194 "addErrorPage", 195 "org.apache.catalina.deploy.ErrorPage"); 196 197 digester.addCallMethod(prefix + "web-app/error-page/error-code", 198 "setErrorCode", 0); 199 digester.addCallMethod(prefix + "web-app/error-page/exception-type", 200 "setExceptionType", 0); 201 digester.addCallMethod(prefix + "web-app/error-page/location", 202 "setLocation", 0); 203 204 digester.addObjectCreate(prefix + "web-app/filter", 205 "org.apache.catalina.deploy.FilterDef"); 206 digester.addSetNext(prefix + "web-app/filter", 207 "addFilterDef", 208 "org.apache.catalina.deploy.FilterDef"); 209 210 digester.addCallMethod(prefix + "web-app/filter/description", 211 "setDescription", 0); 212 digester.addCallMethod(prefix + "web-app/filter/display-name", 213 "setDisplayName", 0); 214 digester.addCallMethod(prefix + "web-app/filter/filter-class", 215 "setFilterClass", 0); 216 digester.addCallMethod(prefix + "web-app/filter/filter-name", 217 "setFilterName", 0); 218 digester.addCallMethod(prefix + "web-app/filter/large-icon", 219 "setLargeIcon", 0); 220 digester.addCallMethod(prefix + "web-app/filter/small-icon", 221 "setSmallIcon", 0); 222 223 digester.addCallMethod(prefix + "web-app/filter/init-param", 224 "addInitParameter", 2); 225 digester.addCallParam(prefix + "web-app/filter/init-param/param-name", 226 0); 227 digester.addCallParam(prefix + "web-app/filter/init-param/param-value", 228 1); 229 230 digester.addObjectCreate(prefix + "web-app/filter-mapping", 231 "org.apache.catalina.deploy.FilterMap"); 232 digester.addSetNext(prefix + "web-app/filter-mapping", 233 "addFilterMap", 234 "org.apache.catalina.deploy.FilterMap"); 235 236 digester.addCallMethod(prefix + "web-app/filter-mapping/filter-name", 237 "setFilterName", 0); 238 digester.addCallMethod(prefix + "web-app/filter-mapping/servlet-name", 239 "addServletName", 0); 240 digester.addCallMethod(prefix + "web-app/filter-mapping/url-pattern", 241 "addURLPattern", 0); 242 243 digester.addCallMethod(prefix + "web-app/filter-mapping/dispatcher", 244 "setDispatcher", 0); 245 246 digester.addCallMethod(prefix + "web-app/listener/listener-class", 247 "addApplicationListener", 0); 248 249 digester.addRule(prefix + "web-app/jsp-config", 250 jspConfig); 251 252 digester.addCallMethod(prefix + "web-app/jsp-config/jsp-property-group/url-pattern", 253 "addJspMapping", 0); 254 255 digester.addCallMethod(prefix + "web-app/listener/listener-class", 256 "addApplicationListener", 0); 257 258 digester.addRule(prefix + "web-app/login-config", 259 loginConfig); 260 261 digester.addObjectCreate(prefix + "web-app/login-config", 262 "org.apache.catalina.deploy.LoginConfig"); 263 digester.addSetNext(prefix + "web-app/login-config", 264 "setLoginConfig", 265 "org.apache.catalina.deploy.LoginConfig"); 266 267 digester.addCallMethod(prefix + "web-app/login-config/auth-method", 268 "setAuthMethod", 0); 269 digester.addCallMethod(prefix + "web-app/login-config/realm-name", 270 "setRealmName", 0); 271 digester.addCallMethod(prefix + "web-app/login-config/form-login-config/form-error-page", 272 "setErrorPage", 0); 273 digester.addCallMethod(prefix + "web-app/login-config/form-login-config/form-login-page", 274 "setLoginPage", 0); 275 276 digester.addCallMethod(prefix + "web-app/mime-mapping", 277 "addMimeMapping", 2); 278 digester.addCallParam(prefix + "web-app/mime-mapping/extension", 0); 279 digester.addCallParam(prefix + "web-app/mime-mapping/mime-type", 1); 280 281 digester.addObjectCreate(prefix + "web-app/resource-env-ref", 282 "org.apache.catalina.deploy.ContextResourceEnvRef"); 283 digester.addRule(prefix + "web-app/resource-env-ref", 284 new SetNextNamingRule("addResourceEnvRef", 285 "org.apache.catalina.deploy.ContextResourceEnvRef")); 286 287 digester.addCallMethod(prefix + "web-app/resource-env-ref/resource-env-ref-name", 288 "setName", 0); 289 digester.addCallMethod(prefix + "web-app/resource-env-ref/resource-env-ref-type", 290 "setType", 0); 291 292 digester.addObjectCreate(prefix + "web-app/message-destination", 293 "org.apache.catalina.deploy.MessageDestination"); 294 digester.addSetNext(prefix + "web-app/message-destination", 295 "addMessageDestination", 296 "org.apache.catalina.deploy.MessageDestination"); 297 298 digester.addCallMethod(prefix + "web-app/message-destination/description", 299 "setDescription", 0); 300 digester.addCallMethod(prefix + "web-app/message-destination/display-name", 301 "setDisplayName", 0); 302 digester.addCallMethod(prefix + "web-app/message-destination/icon/large-icon", 303 "setLargeIcon", 0); 304 digester.addCallMethod(prefix + "web-app/message-destination/icon/small-icon", 305 "setSmallIcon", 0); 306 digester.addCallMethod(prefix + "web-app/message-destination/message-destination-name", 307 "setName", 0); 308 309 digester.addObjectCreate(prefix + "web-app/message-destination-ref", 310 "org.apache.catalina.deploy.MessageDestinationRef"); 311 digester.addSetNext(prefix + "web-app/message-destination-ref", 312 "addMessageDestinationRef", 313 "org.apache.catalina.deploy.MessageDestinationRef"); 314 315 digester.addCallMethod(prefix + "web-app/message-destination-ref/description", 316 "setDescription", 0); 317 digester.addCallMethod(prefix + "web-app/message-destination-ref/message-destination-link", 318 "setLink", 0); 319 digester.addCallMethod(prefix + "web-app/message-destination-ref/message-destination-ref-name", 320 "setName", 0); 321 digester.addCallMethod(prefix + "web-app/message-destination-ref/message-destination-type", 322 "setType", 0); 323 digester.addCallMethod(prefix + "web-app/message-destination-ref/message-destination-usage", 324 "setUsage", 0); 325 326 digester.addObjectCreate(prefix + "web-app/resource-ref", 327 "org.apache.catalina.deploy.ContextResource"); 328 digester.addRule(prefix + "web-app/resource-ref", 329 new SetNextNamingRule("addResource", 330 "org.apache.catalina.deploy.ContextResource")); 331 332 digester.addCallMethod(prefix + "web-app/resource-ref/description", 333 "setDescription", 0); 334 digester.addCallMethod(prefix + "web-app/resource-ref/res-auth", 335 "setAuth", 0); 336 digester.addCallMethod(prefix + "web-app/resource-ref/res-ref-name", 337 "setName", 0); 338 digester.addCallMethod(prefix + "web-app/resource-ref/res-sharing-scope", 339 "setScope", 0); 340 digester.addCallMethod(prefix + "web-app/resource-ref/res-type", 341 "setType", 0); 342 343 digester.addObjectCreate(prefix + "web-app/security-constraint", 344 "org.apache.catalina.deploy.SecurityConstraint"); 345 digester.addSetNext(prefix + "web-app/security-constraint", 346 "addConstraint", 347 "org.apache.catalina.deploy.SecurityConstraint"); 348 349 digester.addRule(prefix + "web-app/security-constraint/auth-constraint", 350 new SetAuthConstraintRule()); 351 digester.addCallMethod(prefix + "web-app/security-constraint/auth-constraint/role-name", 352 "addAuthRole", 0); 353 digester.addCallMethod(prefix + "web-app/security-constraint/display-name", 354 "setDisplayName", 0); 355 digester.addCallMethod(prefix + "web-app/security-constraint/user-data-constraint/transport-guarantee", 356 "setUserConstraint", 0); 357 358 digester.addObjectCreate(prefix + "web-app/security-constraint/web-resource-collection", 359 "org.apache.catalina.deploy.SecurityCollection"); 360 digester.addSetNext(prefix + "web-app/security-constraint/web-resource-collection", 361 "addCollection", 362 "org.apache.catalina.deploy.SecurityCollection"); 363 digester.addCallMethod(prefix + "web-app/security-constraint/web-resource-collection/http-method", 364 "addMethod", 0); 365 digester.addCallMethod(prefix + "web-app/security-constraint/web-resource-collection/url-pattern", 366 "addPattern", 0); 367 digester.addCallMethod(prefix + "web-app/security-constraint/web-resource-collection/web-resource-name", 368 "setName", 0); 369 370 digester.addCallMethod(prefix + "web-app/security-role/role-name", 371 "addSecurityRole", 0); 372 373 digester.addObjectCreate(prefix + "web-app/service-ref", 374 "org.apache.catalina.deploy.ContextService"); 375 digester.addRule(prefix + "web-app/service-ref", 376 new SetNextNamingRule("addService", 377 "org.apache.catalina.deploy.ContextService")); 378 379 digester.addCallMethod(prefix + "web-app/service-ref/description", 380 "setDescription", 0); 381 digester.addCallMethod(prefix + "web-app/service-ref/display-name", 382 "setDisplayname", 0); 383 digester.addCallMethod(prefix + "web-app/service-ref/icon", 384 "setIcon", 0); 385 digester.addCallMethod(prefix + "web-app/service-ref/service-ref-name", 386 "setName", 0); 387 digester.addCallMethod(prefix + "web-app/service-ref/service-interface", 388 "setServiceinterface", 0); 389 digester.addCallMethod(prefix + "web-app/service-ref/wsdl-file", 390 "setWsdlfile", 0); 391 digester.addCallMethod(prefix + "web-app/service-ref/jaxrpc-mapping-file", 392 "setJaxrpcmappingfile", 0); 393 digester.addCallMethod(prefix + "web-app/service-ref/service-qname/namespaceURI", 394 "setNamespaceURI", 0); 395 digester.addCallMethod(prefix + "web-app/service-ref/service-qname/localpart", 396 "setLocalpart", 0); 397 digester.addCallMethod(prefix + 398 "web-app/service-ref/port-component/service-endpoint-interface", 399 "setServiceendpoint", 0); 400 digester.addCallMethod(prefix + "web-app/service-ref/port-component/port-component-link", 401 "setPortlink", 0); 402 digester.addCallMethod(prefix + "web-app/service-ref/handler", 403 "setHandler", 0); 404 digester.addCallMethod(prefix + "web-app/service-ref/service-ref-type", 405 "setType", 0); 406 407 digester.addRule(prefix + "web-app/servlet", 408 new WrapperCreateRule()); 409 digester.addSetNext(prefix + "web-app/servlet", 410 "addChild", 411 "org.apache.catalina.Container"); 412 413 digester.addCallMethod(prefix + "web-app/servlet/init-param", 414 "addInitParameter", 2); 415 digester.addCallParam(prefix + "web-app/servlet/init-param/param-name", 416 0); 417 digester.addCallParam(prefix + "web-app/servlet/init-param/param-value", 418 1); 419 420 digester.addCallMethod(prefix + "web-app/servlet/jsp-file", 421 "setJspFile", 0); 422 digester.addCallMethod(prefix + "web-app/servlet/load-on-startup", 423 "setLoadOnStartupString", 0); 424 digester.addCallMethod(prefix + "web-app/servlet/run-as/role-name", 425 "setRunAs", 0); 426 427 digester.addCallMethod(prefix + "web-app/servlet/security-role-ref", 428 "addSecurityReference", 2); 429 digester.addCallParam(prefix + "web-app/servlet/security-role-ref/role-link", 1); 430 digester.addCallParam(prefix + "web-app/servlet/security-role-ref/role-name", 0); 431 432 digester.addCallMethod(prefix + "web-app/servlet/servlet-class", 433 "setServletClass", 0); 434 digester.addCallMethod(prefix + "web-app/servlet/servlet-name", 435 "setName", 0); 436 437 digester.addRule(prefix + "web-app/servlet-mapping", 438 new CallMethodMultiRule("addServletMapping", 2, 0)); 439 digester.addCallParam(prefix + "web-app/servlet-mapping/servlet-name", 1); 440 digester.addRule(prefix + "web-app/servlet-mapping/url-pattern", new CallParamMultiRule(0)); 441 442 digester.addRule(prefix + "web-app/session-config", 443 sessionConfig); 444 445 digester.addCallMethod(prefix + "web-app/session-config/session-timeout", 446 "setSessionTimeout", 1, 447 new Class [] { Integer.TYPE }); 448 digester.addCallParam(prefix + "web-app/session-config/session-timeout", 0); 449 450 digester.addCallMethod(prefix + "web-app/taglib", 451 "addTaglib", 2); 452 digester.addCallParam(prefix + "web-app/taglib/taglib-location", 1); 453 digester.addCallParam(prefix + "web-app/taglib/taglib-uri", 0); 454 455 digester.addCallMethod(prefix + "web-app/welcome-file-list/welcome-file", 456 "addWelcomeFile", 0); 457 458 digester.addCallMethod(prefix + "web-app/locale-encoding-mapping-list/locale-encoding-mapping", 459 "addLocaleEncodingMappingParameter", 2); 460 digester.addCallParam(prefix + "web-app/locale-encoding-mapping-list/locale-encoding-mapping/locale", 0); 461 digester.addCallParam(prefix + "web-app/locale-encoding-mapping-list/locale-encoding-mapping/encoding", 1); 462 463 } 464 465 468 public void recycle(){ 469 jspConfig.isJspConfigSet = false; 470 sessionConfig.isSessionConfigSet = false; 471 loginConfig.isLoginConfigSet = false; 472 } 473 } 474 475 476 478 479 483 final class SetLoginConfig extends Rule { 484 protected boolean isLoginConfigSet = false; 485 public SetLoginConfig() { 486 } 487 488 public void begin(String namespace, String name, Attributes attributes) 489 throws Exception { 490 if (isLoginConfigSet){ 491 throw new IllegalArgumentException ( 492 "<login-config> element is limited to 1 occurance"); 493 } 494 isLoginConfigSet = true; 495 } 496 497 } 498 499 500 504 final class SetJspConfig extends Rule { 505 protected boolean isJspConfigSet = false; 506 public SetJspConfig() { 507 } 508 509 public void begin(String namespace, String name, Attributes attributes) 510 throws Exception { 511 if (isJspConfigSet){ 512 throw new IllegalArgumentException ( 513 "<jsp-config> element is limited to 1 occurance"); 514 } 515 isJspConfigSet = true; 516 } 517 518 } 519 520 521 525 final class SetSessionConfig extends Rule { 526 protected boolean isSessionConfigSet = false; 527 public SetSessionConfig() { 528 } 529 530 public void begin(String namespace, String name, Attributes attributes) 531 throws Exception { 532 if (isSessionConfigSet){ 533 throw new IllegalArgumentException ( 534 "<session-config> element is limited to 1 occurance"); 535 } 536 isSessionConfigSet = true; 537 } 538 539 } 540 541 546 547 final class SetAuthConstraintRule extends Rule { 548 549 public SetAuthConstraintRule() { 550 } 551 552 public void begin(String namespace, String name, Attributes attributes) 553 throws Exception { 554 SecurityConstraint securityConstraint = 555 (SecurityConstraint) digester.peek(); 556 securityConstraint.setAuthConstraint(true); 557 if (digester.getLogger().isDebugEnabled()) { 558 digester.getLogger() 559 .debug("Calling SecurityConstraint.setAuthConstraint(true)"); 560 } 561 } 562 563 } 564 565 566 570 571 final class SetDistributableRule extends Rule { 572 573 public SetDistributableRule() { 574 } 575 576 public void begin(String namespace, String name, Attributes attributes) 577 throws Exception { 578 Context context = (Context) digester.peek(); 579 context.setDistributable(true); 580 if (digester.getLogger().isDebugEnabled()) { 581 digester.getLogger().debug 582 (context.getClass().getName() + ".setDistributable( true)"); 583 } 584 } 585 586 } 587 588 589 593 594 final class SetPublicIdRule extends Rule { 595 596 public SetPublicIdRule(String method) { 597 this.method = method; 598 } 599 600 private String method = null; 601 602 public void begin(String namespace, String name, Attributes attributes) 603 throws Exception { 604 605 Context context = (Context) digester.peek(digester.getCount() - 1); 606 Object top = digester.peek(); 607 Class paramClasses[] = new Class [1]; 608 paramClasses[0] = "String".getClass(); 609 String paramValues[] = new String [1]; 610 paramValues[0] = digester.getPublicId(); 611 612 Method m = null; 613 try { 614 m = top.getClass().getMethod(method, paramClasses); 615 } catch (NoSuchMethodException e) { 616 digester.getLogger().error("Can't find method " + method + " in " 617 + top + " CLASS " + top.getClass()); 618 return; 619 } 620 621 m.invoke(top, (Object [])paramValues); 622 if (digester.getLogger().isDebugEnabled()) 623 digester.getLogger().debug("" + top.getClass().getName() + "." 624 + method + "(" + paramValues[0] + ")"); 625 626 } 627 628 } 629 630 631 635 636 final class WrapperCreateRule extends Rule { 637 638 public WrapperCreateRule() { 639 } 640 641 public void begin(String namespace, String name, Attributes attributes) 642 throws Exception { 643 Context context = 644 (Context) digester.peek(digester.getCount() - 1); 645 Wrapper wrapper = context.createWrapper(); 646 digester.push(wrapper); 647 if (digester.getLogger().isDebugEnabled()) 648 digester.getLogger().debug("new " + wrapper.getClass().getName()); 649 } 650 651 public void end(String namespace, String name) 652 throws Exception { 653 Wrapper wrapper = (Wrapper) digester.pop(); 654 if (digester.getLogger().isDebugEnabled()) 655 digester.getLogger().debug("pop " + wrapper.getClass().getName()); 656 } 657 658 } 659 660 661 665 final class CallParamMultiRule extends CallParamRule { 666 667 public CallParamMultiRule(int paramIndex) { 668 super(paramIndex); 669 } 670 671 public void end(String namespace, String name) { 672 if (bodyTextStack != null && !bodyTextStack.empty()) { 673 Object parameters[] = (Object []) digester.peekParams(); 675 ArrayList params = (ArrayList ) parameters[paramIndex]; 676 if (params == null) { 677 params = new ArrayList (); 678 parameters[paramIndex] = params; 679 } 680 params.add(bodyTextStack.pop()); 681 } 682 } 683 684 } 685 686 687 691 final class CallMethodMultiRule extends CallMethodRule { 692 693 protected int multiParamIndex = 0; 694 695 public CallMethodMultiRule(String methodName, int paramCount, int multiParamIndex) { 696 super(methodName, paramCount); 697 this.multiParamIndex = multiParamIndex; 698 } 699 700 public void end() throws Exception { 701 702 Object parameters[] = null; 704 if (paramCount > 0) { 705 parameters = (Object []) digester.popParams(); 706 } else { 707 super.end(); 708 } 709 710 ArrayList multiParams = (ArrayList ) parameters[multiParamIndex]; 711 712 Object paramValues[] = new Object [paramTypes.length]; 716 for (int i = 0; i < paramTypes.length; i++) { 717 if (i != multiParamIndex) { 718 if(parameters[i] == null || (parameters[i] instanceof String 721 && !String .class.isAssignableFrom(paramTypes[i]))) { 722 paramValues[i] = 723 IntrospectionUtils.convert((String ) parameters[i], paramTypes[i]); 724 } else { 725 paramValues[i] = parameters[i]; 726 } 727 } 728 } 729 730 Object target; 732 if (targetOffset >= 0) { 733 target = digester.peek(targetOffset); 734 } else { 735 target = digester.peek(digester.getCount() + targetOffset); 736 } 737 738 if (target == null) { 739 StringBuffer sb = new StringBuffer (); 740 sb.append("[CallMethodRule]{"); 741 sb.append(""); 742 sb.append("} Call target is null ("); 743 sb.append("targetOffset="); 744 sb.append(targetOffset); 745 sb.append(",stackdepth="); 746 sb.append(digester.getCount()); 747 sb.append(")"); 748 throw new org.xml.sax.SAXException (sb.toString()); 749 } 750 751 for (int j = 0; j < multiParams.size(); j++) { 752 Object param = multiParams.get(j); 753 if(param == null || (param instanceof String 754 && !String .class.isAssignableFrom(paramTypes[multiParamIndex]))) { 755 paramValues[multiParamIndex] = 756 IntrospectionUtils.convert((String ) param, paramTypes[multiParamIndex]); 757 } else { 758 paramValues[multiParamIndex] = param; 759 } 760 Object result = IntrospectionUtils.callMethodN(target, methodName, 761 paramValues, paramTypes); 762 } 763 764 } 765 766 } 767 768 769 770 774 775 final class IgnoreAnnotationsRule extends Rule { 776 777 public IgnoreAnnotationsRule() { 778 } 779 780 public void begin(String namespace, String name, Attributes attributes) 781 throws Exception { 782 Context context = (Context) digester.peek(digester.getCount() - 1); 783 String value = attributes.getValue("metadata-complete"); 784 if ("true".equals(value)) { 785 context.setIgnoreAnnotations(true); 786 } 787 if (digester.getLogger().isDebugEnabled()) { 788 digester.getLogger().debug 789 (context.getClass().getName() + ".setIgnoreAnnotations( " + 790 context.getIgnoreAnnotations() + ")"); 791 } 792 } 793 794 } 795 | Popular Tags |