1. /* $Id: LoaderSetProperties.java,v 1.5 2004/05/10 06:34:01 skitching Exp $
  2. *
  3. * Copyright 2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.commons.digester.plugins.strategies;
  18. import org.apache.commons.digester.Digester;
  19. import org.apache.commons.logging.Log;
  20. import org.apache.commons.digester.plugins.RuleLoader;
  21. import org.apache.commons.digester.plugins.PluginException;
  22. /**
  23. * A RuleLoader which creates a single SetPropertiesRule and adds it to the
  24. * digester when its addRules() method is invoked.
  25. * <p>
  26. * This loader ensures that any xml attributes on the plugin tag get
  27. * mapped to equivalent properties on a javabean. This allows JavaBean
  28. * classes to be used as plugins without any requirement to create custom
  29. * plugin rules.
  30. *
  31. * @since 1.6
  32. */
  33. public class LoaderSetProperties extends RuleLoader {
  34. /**
  35. * Just add a SetPropertiesRule at the specified path.
  36. */
  37. public void addRules(Digester digester, String path) {
  38. Log log = digester.getLogger();
  39. boolean debug = log.isDebugEnabled();
  40. if (debug) {
  41. log.debug(
  42. "LoaderSetProperties loading rules for plugin at path ["
  43. + path + "]");
  44. }
  45. digester.addSetProperties(path);
  46. }
  47. }