    1   /*
    2    * Copyright 2002,2004 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  package org.apache.commons.jelly.test.impl;
    17
    18  import org.apache.commons.jelly.JellyTagException;
    19  import org.apache.commons.jelly.TagSupport;
    20  import org.apache.commons.jelly.XMLOutput;
    21  import org.apache.commons.jelly.util.ClassLoaderUtils;
    22  import org.apache.commons.logging.Log;
    23  import org.apache.commons.logging.LogFactory;
    24
    25  /***
    26   * Simple Test Tag
    27   *
    28   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
    29   */
    30  public class DummyTag extends TagSupport {
    31      /*** The Log to which logging calls will be made. */
    32      private static final Log log = LogFactory.getLog(DummyTag.class);
    33      /*** A test class to be loaded by the Tag*/
    34      private String m_classToBeLoaded = null;
    35
    36      /***
    37       *
    38       * @see org.apache.commons.jelly.Tag#doTag(XMLOutput)
    39       * @see org.apache.commons.jelly.tags.core.JellyTag
    40       */
    41      public void doTag(XMLOutput output) throws JellyTagException {
    42          if (log.isDebugEnabled())
    43              log.debug("********Executing DummyTag Body*********");
    44          if (m_classToBeLoaded != null) {
    45              try {
    46                  Class clazz = ClassLoaderUtils.loadClass(m_classToBeLoaded, getClass());
    47                  if (log.isDebugEnabled())
    48                      log.debug("Class[" + m_classToBeLoaded + "] FOUND");
    49              }
    50              catch (ClassNotFoundException cnfe) {
    51                  if (log.isWarnEnabled())
    52                      log.warn("Class[" + m_classToBeLoaded + "] NOT FOUND");
    53              }
    54
    55          }
    56          invokeBody(output);
    57      }
    58
    59      /***
    60       * A Test Variable(Used for testing the TagLibraryClassloader)
    61       */
    62      public void setLoadClass(String extraClass) {
    63          m_classToBeLoaded = extraClass;
    64      }
    65
    66  }