1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.define;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.MissingAttributeException;
20 import org.apache.commons.jelly.Script;
21 import org.apache.commons.jelly.TagSupport;
22 import org.apache.commons.jelly.XMLOutput;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25
26 /***
27 * The <invoke> tag will invoke a given Script instance.
28 * It can be used with the <script> tag which defines scripts
29 * as variables that can later be invoked by this <invoke> tag.
30 *
31 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
32 * @version $Revision: 155420 $
33 */
34 public class InvokeTag extends TagSupport {
35
36 /*** The Log to which logging calls will be made. */
37 private static final Log log = LogFactory.getLog(InvokeTag.class);
38
39 private Script script;
40
41
42 public InvokeTag() {
43 }
44
45 /***
46 * Sets the Script to be invoked by this tag, which typically has been previously
47 * defined by the use of the <script> tag.
48 */
49 public void setScript(Script script) {
50 this.script = script;
51 }
52
53
54
55 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
56 if ( script == null ) {
57 throw new MissingAttributeException("script");
58 }
59 script.run(context, output);
60 }
61 }