01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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(
47: m_classToBeLoaded, getClass());
48: if (log.isDebugEnabled())
49: log.debug("Class[" + m_classToBeLoaded + "] FOUND");
50: } catch (ClassNotFoundException cnfe) {
51: if (log.isWarnEnabled())
52: log.warn("Class[" + m_classToBeLoaded
53: + "] NOT FOUND");
54: }
55:
56: }
57: invokeBody(output);
58: }
59:
60: /**
61: * A Test Variable(Used for testing the TagLibraryClassloader)
62: */
63: public void setLoadClass(String extraClass) {
64: m_classToBeLoaded = extraClass;
65: }
66:
67: }
|