KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > Iteration


1 /**
2  * $Id: Iteration.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2004-2005 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;
30
31 import java.lang.reflect.Field JavaDoc;
32 import java.util.Map JavaDoc;
33
34 import org.apache.tools.ant.BuildException;
35 import org.apache.tools.ant.Project;
36
37 import com.idaremedia.apis.UIStringManager;
38
39 import com.idaremedia.antx.apis.ProblemHandler;
40 import com.idaremedia.antx.apis.Requester;
41 import com.idaremedia.antx.helpers.InstanceFactory;
42 import com.idaremedia.antx.helpers.SIDs;
43 import com.idaremedia.antx.helpers.Tk;
44
45 /**
46  * Embodies the configured fixture of an execution iteration. In other words, a
47  * glorified "holder of stuff".
48  * <p/>
49  * It is important that an Iteration be "self-creating" so we can function in
50  * environments where AntX is not part of a single controlling application or tool or
51  * when AntX is not started explicitly by some initialization task. To support this
52  * automagical creation for Iteration subclasses, we rely on the standard Java service
53  * lookup pattern: we first look for a class name stored under the system property
54  * <span class="src">com.idaremedia.antx.Iteration</span>. If no such property exists,
55  * we look for a class definition in a file resource stored at
56  * <span class="src">META-INF/services/com.idaremedia.antx.Iteration</span>.
57  * <p/>
58  * If used from an always-on or iteration assembly line service (like an Ant console
59  * or remote Ant server), it is that launcher's responsibility to synchronize the
60  * re-creation of the active AntX iteration instance. The idea is that calls to the
61  * mutative admin interface (<span class="src">{@linkplain #set set}</span> and
62  * <span class="src">{@linkplain #reset}</span>) will be restricted (and synchronized)
63  * by the launch mechanism. Typically the "new iteration" sequence would first reset
64  * the existing global fixture components using <span class="src">AntXFixture.reset</span>
65  * and then reset the Iteration using <span class="src">Iteration.reset</span>.
66  * <p/>
67  * AntX-based tools can extend the standard Iteration to both add new fixture elements
68  * and replace the default standard ones. For instance, a tool could make the default
69  * {@linkplain Stringifier} something a client could specify instead of the default
70  * instance defined by AntX.
71  *
72  * @since JWare/AntX 0.5
73  * @author ssmc, &copy;2004-2005 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
74  * @version 0.5
75  * @.safety guarded
76  * @.group api,infra
77  * @see com.idaremedia.antx.starters.IterationConfigurator IterationConfigurator
78  **/

79
80 public class Iteration
81 {
82 // ---------------------------------------------------------------------------------------
83
// Administation API for AntX-based tool or application
84
// ---------------------------------------------------------------------------------------
85

86     private static final Map JavaDoc IDs = AntXFixture.newMap();//*all* IDs ever used
87

88
89     /**
90      * Factory method for creating a new Iteration instance. We try to use
91      * a service-provider-isque way of looking for an application specific
92      * Iteration class. AntX-based applications can create a
93      * <span class="src">META-INF/services/com.idaremedia.antx.Iteration</span>
94      * entry in their distribution jars. Script writers can define a system
95      * property "<span class="src">com.idaremedia.antx.Iteration</span>" to
96      * locally override whatever's in their classpaths.
97      * @return a new iteration instance (never <i>null</i>)
98      * @throws BuildException if a custom class was specified but it could
99      * not be loaded as an Iteration.
100      **/

101     private static Iteration newi()
102     {
103         String JavaDoc classname = Tk.loadSpiImpl(Iteration.class,Requester.ANONYMOUS);
104         if (classname!=null) {
105             try {
106                 Class JavaDoc c = Class.forName(classname);
107                 return (Iteration)c.newInstance();
108             } catch(Exception JavaDoc anyX) {
109                 String JavaDoc error = AntX.uistrs().get("task.bad.custimpl.class1",
110                     classname, Iteration.class.getName());
111                 Requester.ANONYMOUS.log(error, Project.MSG_ERR);
112                 throw new BuildException(error,anyX);
113             }
114         }
115         return new Iteration();
116     }
117
118
119
120     /**
121      * Global Iteration instance (only one active at a time).
122      * <b>!!! Location of this static variable is important !!!</b>
123      */

124     private static Iteration INSTANCE = newi();//NB:be valid always!
125

126
127
128     /**
129      * Returns the current iteration object. Never returns <i>null</i>.
130      **/

131     public static final Iteration get()
132     {
133         return INSTANCE;
134     }
135
136
137
138     /**
139      * Initializes the (next) iteration to a specific subclass instance.
140      * This method should be used by harnesses and "always-on" tools to
141      * create a fresh (custom) iteration. <em>Information from the current
142      * iteration is discarded.</em>
143      * @param iteration the next iteration (non-null)
144      * @throws IllegalArgumentException if iteration is <i>null</i>
145      */

146     public static final void set(Iteration iteration)
147     {
148         if (iteration==null) {
149             throw new IllegalArgumentException JavaDoc("iteration reference");
150         }
151         INSTANCE = iteration;
152     }
153
154
155
156     /**
157      * Initializes the (next) iteration to a new standard iteration
158      * instance. This method should be used by harnesses and "always-on"
159      * tools to create a fresh iteration. <em>Information from the current
160      * iteration is discarded.</em>
161      */

162     public static final void reset()
163     {
164         INSTANCE = newi();
165     }
166
167 // ---------------------------------------------------------------------------------------
168
// Diagnostics API for Iterations (see valueURIs and Conditions)
169
// ---------------------------------------------------------------------------------------
170

171     /**
172      * Returns a diagnostic string that represents the information
173      * indicated by incoming URI. Will return <i>null</i> if unable
174      * to understand incoming URI. Currently understands: "id",
175      * "classname", "valueuri?<i>scheme-name</i>", and
176      * "property?<i>property-name</i>".
177      * @param uri information to be described (non-null)
178      * @return description or <i>null</i> if URI not understood.
179      * @throws IllegalArgumentException if URI is <i>null</i>.
180      * @since JWare/AntX 0.5
181      * @.impl Helps debug Iteration-related issues from scripts.
182      **/

183     public String JavaDoc toString(String JavaDoc uri)
184     {
185         if (uri==null) {
186             throw new IllegalArgumentException JavaDoc();
187         }
188         if ("classname".equals(uri)) {
189             return getClass().getName();
190         }
191         if ("id".equals(uri)) {
192            return getITID();
193         }
194         if (uri.startsWith("property?")) {
195             String JavaDoc property = uri.substring(9/*"property?".length*/);
196             return FixtureExaminer.getIterationProperty(property,null);
197         }
198         if (uri.startsWith("valueuri?")) {
199             String JavaDoc urischeme = uri.substring(9/*"valueuri?".length*/);
200             if (FixtureExaminer.isBuiltinValueURIScheme(urischeme)) {
201                 return "builtin";
202             }
203             Class JavaDoc c = valueURIHandler(urischeme).getClass();
204             return (c==ValueURIHandler.None.class ? "none" : c.getName());
205         }
206         return null;
207     }
208
209
210 // ---------------------------------------------------------------------------------------
211
// "Subclassable" instance API and matching singleton API
212
// ---------------------------------------------------------------------------------------
213

214     /**
215      * Initialize a new Iteration instance. Default implementation
216      * has few member fields (relies mostly on existing, common
217      * utilities and/or singletons).
218      **/

219     protected Iteration()
220     {
221         String JavaDoc sId = null;
222         synchronized(IDs) {
223             sId = SIDs.next(new SIDs.Finder() {
224                 public boolean exists(String JavaDoc id) {
225                     if (!IDs.containsKey(id)) {
226                         IDs.put(id,Boolean.TRUE);
227                         return false;
228                     }
229                     return true;
230                 }
231             });
232         }
233         m_itid = "Iteration"+sId;
234         m_refTable.put("Iteration.ITID",m_itid);
235         m_valueUriFactory.put("null",ValueURIHandler.None.class);
236         m_testField=sId; // @.impl Used for testing injection(do not remove)
237
}
238
239
240
241     /**
242      * Returns this iteration's unique identifier. This id is generated
243      * when each iteration is created and it immutable thereafter. Each
244      * id is unique to a particular VM instance.
245      * @since JWare/AntX 0.5
246      **/

247     public final String JavaDoc getITID()
248     {
249         return m_itid;
250     }
251
252
253
254     /**
255      * Returns this iteration's configuration lock. Must never
256      * return <i>null</i> although can return different locks for
257      * different configuration aspects.
258      * @param aspect [optional] purpose of lock
259      * @return lock (non-null)
260      **/

261     public Object JavaDoc getConfigLock(String JavaDoc aspect)
262     {
263         return m_configLock;
264     }
265
266
267
268     /**
269      * Returns the <em>current</em> iteration's configuration lock. Use
270      * this lock to coordinate iteration configuraton via reflection.
271      * @param aspect [optional] purpose of lock
272      * @return lock (non-null)
273      **/

274     public static final Object JavaDoc lock(String JavaDoc aspect)
275     {
276         return Iteration.get().getConfigLock(aspect);
277     }
278
279
280
281     /**
282      * Returns this iteration's application's builtin strings.
283      * Never returns <i>null</i>; returns {@linkplain AntX#uistrs}
284      * by default.
285      **/

286     protected UIStringManager getUIStrs()
287     {
288         return AntX.uistrs();
289     }
290
291
292
293     /**
294      * Returns the <em>current</em> iteration's builtin strings.
295      * Never returns <i>null</i>.
296      * @see AntX#uistrs
297      **/

298     public static final UIStringManager uistrs()
299     {
300         return Iteration.get().getUIStrs();
301     }
302
303
304
305     /**
306      * Returns this iteration's application's configuration
307      * properties prefix. Never returns <i>null</i>; returns
308      * {@linkplain AntX#ANTX_CONFIG_ID} by default.
309      **/

310     protected String JavaDoc getConfigId()
311     {
312         return AntX.ANTX_CONFIG_ID;
313     }
314
315
316
317     /**
318      * Returns the current application's configuration
319      * properties prefix. Never returns <i>null</i>.
320      **/

321     public static final String JavaDoc configId()
322     {
323         return Iteration.get().getConfigId();
324     }
325
326
327
328     /**
329      * Returns this iteration's property value defaults. Never
330      * returns <i>null</i>.
331      **/

332     protected Defaults getDefaults()
333     {
334         return m_defaultsINSTANCE;
335     }
336
337
338
339     /**
340      * Returns the current iteration's property value defaults.
341      * Never returns <i>null</i>.
342      **/

343     public static final Defaults defaultdefaults()
344     {
345         return Iteration.get().getDefaults();
346     }
347
348
349
350     /**
351      * Returns this iteration's default set of fixture exclusions.
352      * Never returns <i>null</i>.
353      **/

354     protected ExcludedFixture getFixtureExcludes()
355     {
356         return m_xcludedFixtureINSTANCE;
357     }
358
359
360
361     /**
362      * Returns the current iteration's default fixture exclusions.
363      * Never returns <i>null</i>.
364      **/

365     public static final ExcludedFixture defaultFixtureExcludes()
366     {
367         return Iteration.get().getFixtureExcludes();
368     }
369
370
371
372     /**
373      * Returns the lenient Stringifier for this iteration. Never
374      * returns <i>null</i>.
375      **/

376     protected Stringifier getLenientStringifier()
377     {
378         return m_stringifierINSTANCE;
379     }
380
381
382
383     /**
384      * Returns the lenient Stringifier for the <em>current</em>
385      * iteration. Never returns <i>null</i>.
386      **/

387     public static final Stringifier lenientStringifer()
388     {
389         return Iteration.get().getLenientStringifier();
390     }
391
392
393
394     /**
395      * Returns the strict Stringifier for this iteration. Never
396      * returns <i>null</i>.
397      **/

398     protected Stringifier getStrictStringifier()
399     {
400         return m_strictStringifierINSTANCE;
401     }
402
403
404
405     /**
406      * Returns the strict Stringifier for the <em>current</em>
407      * iteration. Never returns <i>null</i>.
408      **/

409     public static final Stringifier strictStringifier()
410     {
411         return Iteration.get().getStrictStringifier();
412     }
413
414
415
416     /**
417      * Returns the collection of exportable, modifiable properties
418      * for this iteration. Never returns <i>null</i>.
419      **/

420     protected ExportedProperties getExportableProperties()
421     {
422         return m_exportedPropertiesINSTANCE;
423     }
424
425
426
427     /**
428      * Returns the collection of exportable, modifiable properties
429      * for the <em>current</em> iteration. Never returns <i>null</i>.
430      **/

431     public static final ExportedProperties exportableProperties()
432     {
433         return Iteration.get().getExportableProperties();
434     }
435
436
437
438     /**
439      * Returns the collection of <em>all</em> fixture overlays
440      * linked to the curent iteration. The returned value contains
441      * all thread-local overlay stacks.
442      * @.impl Used by the FixtureOverlays helper only. We should
443      * use that class's APIs in our own getters.
444      **/

445     static FixtureOverlays.Handle fixtureOverlays()
446     {
447         return Iteration.get().m_fixtureOverlays;
448     }
449
450
451
452     /**
453      * Returns the last installed overlay in this iteration
454      * for the named category. Will return <i>null</i> if no such
455      * item exists.
456      * @param FXID the fixture category identifier (non-null)
457      * @return last installed overlay or <i>null</i> if none
458      **/

459     protected Object JavaDoc getNearestOverlayFor(String JavaDoc FXID)
460     {
461         return FixtureOverlays.getContextInstance().nearest(FXID);
462     }
463
464
465
466     /**
467      * Returns the last installed overlay in the <em>current</em>
468      * iteration for the named category. Will return <i>null</i> if
469      * no such component exists.
470      * @param FXID the fixture category identifier (non-null)
471      * @return last installed overlay or <i>null</i> if none
472      **/

473     public static final Object JavaDoc nearestOverlayFor(String JavaDoc FXID)
474     {
475         return Iteration.get().getNearestOverlayFor(FXID);
476     }
477
478
479
480     /**
481      * Returns the string manager most recently installed as the
482      * default for the iteration. Will return the default string
483      * manager only if no other string manager is installed. Never
484      * returns <i>null</i>.
485      **/

486     protected UIStringManager getStringManager()
487     {
488         return UISMContext.getStringManagerNoNull();
489     }
490
491
492
493     /**
494      * Returns the <em>current</em> iteration's nearest string
495      * manager. Never returns <i>null</i>.
496      **/

497     public static final UIStringManager stringManager()
498     {
499         return Iteration.get().getStringManager();
500     }
501
502
503
504     /**
505      * Returns the current default problem handler in this thread.
506      * Never returns <i>null</i>.
507      **/

508     protected ProblemHandler getProblemsHandler()
509     {
510         return Problems.getDefaultHandlerNoNull();
511     }
512
513
514
515     /**
516      * Returns the <em>current</em> iteration's default problem
517      * handler. Never returns <i>null</i>.
518      **/

519     public static final ProblemHandler problemsHandler()
520     {
521         return Iteration.get().getProblemsHandler();
522     }
523
524 // ---------------------------------------------------------------------------------------
525
// Value URI Management:
526
// ---------------------------------------------------------------------------------------
527

528     /**
529      * Returns a value URI handler for given prefix. Never returns
530      * <i>null</i> but can return a no-op proxy handler. Note that the
531      * incoming prefix name should <em>not</em> include the leading '$'
532      * or the trailing ':'.
533      * @param prefix value uri's marker prefix (like "alias" or "baseurl");
534      * @return a handler (never <i>null</i>)
535      * @throws IllegalArgumentException if parameter is null.
536      **/

537     public static ValueURIHandler valueURIHandler(String JavaDoc prefix)
538     {
539         if (prefix==null) {
540             throw new IllegalArgumentException JavaDoc();
541         }
542         return (ValueURIHandler)
543             Iteration.get().m_valueUriFactory.newInstance(prefix);
544     }
545
546
547
548     /**
549      * Installs a new value URI handler into the current iteration iff
550      * there isn't a handler already installed. Note that the incoming prefix
551      * name should <em>not</em> include the leading '$' or the trailing ':'.
552      * @param prefix value uri's marker prefix (like "alias" or "baseurl");
553      * @param handlerClass the handler's class (non-null)
554      * @throws IllegalArgumentException if either parameter is null.
555      * @return <i>true</i> if installation went ok.
556      **/

557     public static boolean initValueURIHandler(String JavaDoc prefix, Class JavaDoc handlerClass)
558     {
559         if (prefix==null || handlerClass==null) {
560             throw new IllegalArgumentException JavaDoc();
561         }
562         InstanceFactory factory = Iteration.get().m_valueUriFactory;
563         synchronized(factory) {
564             if (!factory.containsKey(prefix)) {
565                 factory.put(prefix,handlerClass);
566                 return true;
567             }
568         }
569         return false;
570     }
571
572
573
574     /**
575      * Installs a value URI handler into the current iteration replacing
576      * any existing handler unconditionally. Note that the incoming prefix
577      * name should <em>not</em> include the leading '$' or the trailing ':'.
578      * @param prefix value uri's marker prefix (like "alias" or "baseurl");
579      * @param handlerClass the handler's class (non-null)
580      * @throws IllegalArgumentException if either parameter is null.
581      * @return the previous handler (useful for temporary replacement)
582      **/

583     public static Class JavaDoc replaceValueURIHandler(String JavaDoc prefix, Class JavaDoc handlerClass)
584     {
585         if (prefix==null || handlerClass==null) {
586             throw new IllegalArgumentException JavaDoc();
587         }
588         InstanceFactory factory = Iteration.get().m_valueUriFactory;
589         return (Class JavaDoc)factory.put(prefix,handlerClass);
590     }
591
592
593
594     /**
595      * Uninstalls a temporarily assigned AntX value URI handler
596      * for the current iteration. Note that the incoming prefix
597      * name should <em>not</em> include the leading '$' or the trailing ':'.
598      * @param prefix the marker uri prefix (like "alias" or "artifact");
599      * @throws IllegalArgumentException if parameter is null.
600      **/

601     public static void removeValueURIHandler(String JavaDoc prefix)
602     {
603         if (prefix==null) {
604             throw new IllegalArgumentException JavaDoc();
605         }
606         InstanceFactory factory = Iteration.get().m_valueUriFactory;
607         factory.put(prefix,null);
608     }
609
610 // ---------------------------------------------------------------------------------------
611
// Generic Reference/Property Management:
612
// ---------------------------------------------------------------------------------------
613

614     private static final String JavaDoc PROPERTYARG= "property name";
615     private static final String JavaDoc CATEGORYARG= "category";
616
617     /**
618      * Returns the named iteration property or <i>null</i> if no
619      * match found.
620      * @param name property's name (non-null)
621      * @throws IllegalArgumentException if name is <i>null</i>.
622      **/

623     public static Object JavaDoc getProperty(String JavaDoc name)
624     {
625         if (name==null) {
626             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
627         }
628         return Iteration.get().m_refTable.get(name);
629     }
630
631
632
633     /**
634      * Returns the named iteration category property or <i>null</i>
635      * if no match found.
636      * @param category the iteration category (non-null)
637      * @param name property's name (non-null)
638      * @throws IllegalArgumentException if name or category is <i>null</i>.
639      **/

640     public static Object JavaDoc getProperty(String JavaDoc category, String JavaDoc name)
641     {
642         if (category==null) {
643             throw new IllegalArgumentException JavaDoc(CATEGORYARG);
644         }
645         if (name==null) {
646             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
647         }
648         Object JavaDoc item = Iteration.get().m_refTable.get(category);
649         if (item instanceof Map JavaDoc) {
650             return ((Map JavaDoc)item).get(name);
651         }
652         return null;
653     }
654
655
656
657     /**
658      * Updates an iteration property's value.
659      * @param name property's name (non-null)
660      * @param value the property's value
661      * @throws IllegalArgumentException if name is <i>null</i>.
662      * @return the previously installed value (can be <i>null</i>)
663      **/

664     public static Object JavaDoc setProperty(String JavaDoc name, Object JavaDoc value)
665     {
666         if (name==null) {
667             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
668         }
669         return Iteration.get().m_refTable.put(name,value);
670     }
671
672
673
674     /**
675      * Updates a named iteration category property. If the category's map
676      * does not exist, a thread-safe map in created and inserted automatically.
677      * @param category the iteration category (non-null)
678      * @param name property's name (non-null)
679      * @param value the property's value
680      * @throws IllegalArgumentException if name or category is <i>null</i>.
681      * @return the previously installed value (can be <i>null</i>)
682      **/

683     public static Object JavaDoc setProperty(String JavaDoc category, String JavaDoc name, Object JavaDoc value)
684     {
685         if (category==null) {
686             throw new IllegalArgumentException JavaDoc(CATEGORYARG);
687         }
688         if (name==null) {
689             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
690         }
691         Map JavaDoc reftable = Iteration.get().m_refTable;
692         Object JavaDoc prev = null;
693         synchronized(reftable) {
694             Object JavaDoc item = reftable.get(category);
695             if (item==null) {
696                 item = AntXFixture.newSynchronizedMap();
697                 reftable.put(category,item);
698                 prev = ((Map JavaDoc)item).put(name,value);
699             } else if (item instanceof Map JavaDoc) {
700                 prev = ((Map JavaDoc)item).put(name,value);
701             }
702         }
703         return prev;
704     }
705
706
707
708     /**
709      * Removes an existing iteration property and any associated values.
710      * @param name property's name (non-null)
711      * @throws IllegalArgumentException if name is <i>null</i>.
712      * @return the previously installed value (can be <i>null</i>)
713      **/

714     public static Object JavaDoc removeProperty(String JavaDoc name)
715     {
716         if (name==null) {
717             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
718         }
719         return Iteration.get().m_refTable.remove(name);
720     }
721
722
723
724     /**
725      * Removes an existing iteration category property. Does not remove the
726      * category's map if this is the last property; caller must do that explicitly
727      * with a call to {@linkplain #removeProperty(String) removeProperty(category)}.
728      * @param category the iteration category (non-null)
729      * @param name property's name (non-null)
730      * @throws IllegalArgumentException if name or category is <i>null</i>.
731      * @return the previously installed value (can be <i>null</i>)
732      **/

733     public static Object JavaDoc removeProperty(String JavaDoc category, String JavaDoc name)
734     {
735         if (category==null) {
736             throw new IllegalArgumentException JavaDoc(CATEGORYARG);
737         }
738         if (name==null) {
739             throw new IllegalArgumentException JavaDoc(PROPERTYARG);
740         }
741         Object JavaDoc item = Iteration.get().m_refTable.get(category);
742         if (item instanceof Map JavaDoc) {
743             return ((Map JavaDoc)item).remove(name);
744         }
745         return null;
746     }
747
748
749
750 // ---------------------------------------------------------------------------------------
751
// Sub-class visible member fields:
752
// ---------------------------------------------------------------------------------------
753

754     /**
755      * This iteration's default property values manager. Initialized
756      * to a standard AntX {@linkplain Defaults defaults} object.
757      * @since JWare/AntX 0.5
758      */

759     protected Defaults m_defaultsINSTANCE= new Defaults();
760
761
762     /**
763      * This iteration's default set of fixture exclusion (for isolates and
764      * other configuration tasks). Initialized to a standard AntX
765      * {@linkplain ExcludedFixture excluded fixture} object.
766      * @since JWare/AntX 0.5
767      */

768     protected ExcludedFixture m_xcludedFixtureINSTANCE= new ExcludedFixture();
769     
770
771     /**
772      * This iteration's lenient stringifier. Initialized to a standard
773      * {@linkplain Stringifier}.
774      */

775     protected Stringifier m_stringifierINSTANCE= new Stringifier(true);
776
777
778     /**
779      * This iteration's strict stringifier. Initialized to a standard
780      * {@linkplain Stringifier}.
781      */

782     protected Stringifier m_strictStringifierINSTANCE= new Stringifier(false);
783
784
785     /**
786      * This iteration's manager for variable properties. Initialized to
787      * a standard {@linkplain ExportedProperties}.
788      */

789     protected ExportedProperties m_exportedPropertiesINSTANCE= new ExportedProperties();
790
791
792     /**
793      * This iteration's value URI handler factory. Will produce
794      * no-op proxy handlers for any prefix. Subclasses can change this
795      * item's contents and configuration; they cannot remove or
796      * delete this object.
797      * @since JWare/AntX 0.5
798      */

799     protected final InstanceFactory m_valueUriFactory =
800         new InstanceFactory(ValueURIHandler.None.class);
801
802
803
804     /**
805      * Returns the current value of an iteration member field. Will
806      * also return <i>null</i> if no such field exists within this
807      * iteration.
808      * @param fieldname field's name (non-null)
809      * @return field value (can be <i>null</i>)
810      * @throws NoSuchFieldException if unable to find field in iteration.
811      * @throws IllegalAccessException if unable to retrieve field value.
812      * @since JWare/AntX 0.5
813      **/

814     protected final Object JavaDoc getFieldValue(String JavaDoc fieldname)
815         throws NoSuchFieldException JavaDoc, IllegalAccessException JavaDoc
816     {
817         if (fieldname==null) {
818             throw new IllegalArgumentException JavaDoc();
819         }
820         Field JavaDoc f = Tk.findField(getClass(),fieldname);
821         boolean was = f.isAccessible();
822         if (!was) {
823             f.setAccessible(true);
824         }
825         try {
826             return f.get(this);
827         } finally {
828             if (!was) {
829                 f.setAccessible(false);
830             }
831         }
832     }
833
834
835
836     private Object JavaDoc m_configLock = new int[0];
837     private final String JavaDoc m_itid;
838     private Map JavaDoc m_refTable = AntXFixture.newSynchronizedMap();
839
840     // @.impl
841
// This is a VM-shared <em>class</em> variable. OK slowly... with overlays classes
842
// are the expected clients. Each client class uses the same overlay handle
843
// singleton, but each class scopes its iteration variables based on class-specific
844
// categories. Of course, the whole mess is scoped per thread so one threads overlay
845
// changes do not impact anothers.
846
private final FixtureOverlays.Handle m_fixtureOverlays
847         = new FixtureOverlays.Handle();
848     
849     // @.impl Used for testing injection-- do not remove or alter!
850
String JavaDoc m_testField;
851 }
852
853
854 /* end-of-Iteration.java */
Popular Tags