KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > solo > AutoRunLibraryTaskSet


1 /**
2  * $Id: AutoRunLibraryTaskSet.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 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 (LGPL) as published
8  * by the Free Software Foundation; either version 2.1 of the License, or (at your option)
9  * any 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 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 GNU 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.solo;
30
31 import org.apache.tools.ant.Task;
32 import org.apache.tools.ant.TaskContainer;
33
34 import com.idaremedia.antx.AntX;
35 import com.idaremedia.antx.AssertableLibDefinition;
36 import com.idaremedia.antx.ownhelpers.TaskExaminer;
37 import com.idaremedia.antx.starters.TaskSet;
38
39 /**
40  * A taskset that is defined as part of a standard Ant library. The taskset's nested
41  * elements are <em>automatically executed</em> when the library is installed which can
42  * be immediate or delayed if the library is installed using the special "antlib:" XML
43  * namespace construct (typical).
44  * <p>
45  * Do not use a autorun taskset to replace the standard
46  * <span class="src">&lt;import&gt;</span> task. Auto run scriptlets are most useful for
47  * adhoc decoration of existing build or test scripts where the tasks run a simple fixture
48  * configuration instructions (particularly if the setup spans projects).
49  * <p>
50  * You should pay careful attention to the tasks you include for autorun. Generally,
51  * data object declarations, iteraton initializers, and other simple configuration tasks
52  * are the best components to include in an antlib (aside from the other Ant definition
53  * tasks like presetdefs and macrodefs).
54  * <p>
55  * Refer to the AntXtras/SAM project for a more elegant solution than autorun;
56  * specifically &lt;run-configuration&gt;.
57  *
58  * @since JWare/AntX 0.5
59  * @author ssmc, &copy;2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
60  * @version 0.5
61  * @.safety single
62  * @.group api,infra
63  * @.pattern GoF.Adapter
64  **/

65
66 public class AutoRunLibraryTaskSet extends AssertableLibDefinition
67     implements TaskContainer
68 {
69     /**
70      * Initializes a new autorun taskset instance.
71      **/

72     public AutoRunLibraryTaskSet()
73     {
74         super(AntX.fixture+"AutoRun:");
75     }
76
77
78
79     /**
80      * Initializes a new autorun taskset instance from subclass.
81      * @param iam CV-label (non-null)
82      **/

83     public AutoRunLibraryTaskSet(String JavaDoc iam)
84     {
85         super(iam);
86     }
87
88
89
90     /**
91      * Initializes this autorun taskset's internal helper. All add
92      * requests are delegated to this helper.
93      */

94     public void init()
95     {
96         super.init();
97         if (m_impl==null) {
98             m_impl = new TaskSet();
99             TaskExaminer.initTaskFrom(m_impl,this);
100          }
101     }
102
103
104
105     /**
106      * Adds a new task to this library task set. The new task is
107      * actually added to the underlying taskset for later execution.
108      */

109     public void addTask(Task task)
110     {
111         m_impl.addTask(task);
112     }
113
114
115
116     /**
117      * Performs all of this task's nested elements.
118      * @throws org.apache.tools.ant.BuildException if any nested task does
119      */

120     public void execute()
121     {
122         verifyCanExecute_("exec");
123         m_impl.perform();
124     }
125
126
127
128     private TaskSet m_impl;
129 }
130
131 /* end-of-AutoRunLibraryTaskSet.java */
Popular Tags