KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > flowcontrol > call > TargetCaller


1 /**
2  * $Id: TargetCaller.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.flowcontrol.call;
30
31 import java.util.Map JavaDoc;
32
33 import org.apache.tools.ant.BuildException;
34 import org.apache.tools.ant.taskdefs.Ant;
35 import org.apache.tools.ant.taskdefs.Property;
36 import org.apache.tools.ant.types.PropertySet;
37
38 /**
39  * Helper that calls a another target whether that target is inlined or top-level.
40  *
41  * @since JWare/AntX 0.1
42  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
43  * @version 0.5
44  * @.safety n/a
45  * @.group impl,infra
46  * @see OverlayParametersHelper
47  **/

48
49 public interface TargetCaller
50 {
51     /**
52      * Returns this caller's target's name.
53      **/

54     String JavaDoc getTargetName();
55
56
57     /**
58      * Returns the step on whose behave this caller exists.
59      **/

60     String JavaDoc getStepName();
61
62
63     /**
64      * Create a new property to passthru to called target.
65      **/

66     Property createProperty();
67
68
69     /**
70      * Create a new propertyset to passthru to called target.
71      * @since JWare/AntX 0.4
72      **/

73     PropertySet createPropertySet();
74
75
76     /**
77      * Create a new reference to passthru to called target.
78      * @since JWare/AntX 0.3
79      **/

80     Ant.Reference createReference();
81
82
83     /**
84      * Executes the target this caller references.
85      * @throws BuildException if target does.
86      **/

87     void run() throws BuildException;
88
89
90     /**
91      * Convenient {@linkplain #run() run} alternative that auto-installs
92      * a required property into the to-be-called target's runtime
93      * environment before it's executed. Useful for looping constructs
94      * that call targets as part of their execution w/ a changing
95      * cursor property.
96      * @param property property name (non-null)
97      * @param value property value-- used as-is no additional
98      * replacements are done (non-null)
99      * @throws BuildException if target does.
100      **/

101     void run(String JavaDoc property, String JavaDoc value)
102         throws BuildException;
103
104
105     /**
106      * Convenient {@linkplain #run() run} alternative that auto-installs
107      * contents of properties map into the to-be-called target's runtime
108      * environment before it's executed.
109      * @param properties properties to be installed (non-null)
110      * @throws BuildException if target does.
111      * @since JWare/AntX 0.4
112      **/

113     void run(Map JavaDoc properties)
114         throws BuildException;
115
116
117     /**
118      * Convenient {@linkplain #run() run} alternative that auto-installs
119      * arbitrary numbers of fixture data into the to-be-called target's
120      * runtime environment before it's executed.
121      * @param prep client preparation snippet (non-null)
122      * @throws BuildException if target does.
123      **/

124     void run(TargetCaller.Prep prep)
125         throws BuildException;
126
127
128
129     /**
130      * Helper that lets caller task select which TargetCaller run method to use.
131      * @since JWare/AntX 0.1
132      * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
133      * @version 0.5
134      * @.pattern GoF.Strategy
135      **/

136     interface RunSelector {
137         /**
138          * Run the caller using the appropriate run-method variant.
139          * @param caller the caller to be run (non-null)
140          * @throws BuildException if target does.
141          **/

142         void run(TargetCaller caller) throws BuildException;
143     }
144
145
146
147     /**
148      * Helper that lets caller task prepare a custom runtime environment for
149      * a to-be-called target.
150      * @since JWare/AntX 0.1
151      * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
152      * @version 0.5
153      * @.pattern GoF.Strategy
154      **/

155     interface Prep {
156         /**
157          * Called to prepare the passthru environment appropriately before
158          * the to-be-executed target.
159          * @param caller the caller that will run the target (non-null)
160          * @throws BuildException if unable to prepare target.
161          **/

162         void prepare(TargetCaller caller) throws BuildException;
163     }
164 }
165
166 /* end-of-TargetCaller.java */
167
168
Popular Tags