01: /* QuiltRegistry.java */
02: package org.quilt.reg;
03:
04: import org.quilt.cl.*;
05:
06: /**
07: * A registry for use by Quilt class loaders. Adds transformers to the
08: * class loader prior to use. Stores information collected while loading
09: * classes under a String array key. Dumps that information on request.
10: *
11: * @author <a href="jddixon@users.sourceforge.net">Jim Dixon</a>
12: */
13: public abstract class QuiltRegistry extends Registry {
14:
15: /** List of class transformers associated with this registry. */
16: protected ClassXformer cxf[];
17:
18: /** List of method transformers associated with this registry. */
19: protected MethodXformer mxf[];
20:
21: /** List of graph transformers associated with this registry. */
22: protected GraphXformer gxf[];
23:
24: /** The Quilt class loader using this registry. */
25: protected QuiltClassLoader qcl_;
26:
27: public QuiltRegistry(QuiltClassLoader qcl) {
28: super ();
29: if (qcl == null) {
30: throw new IllegalArgumentException("null QuiltClassLoader");
31: }
32: qcl_ = qcl;
33: }
34:
35: /**
36: * Attaches transformers to the class loader; classes extending
37: * this class should call in the constructor after setting up the
38: * lists.
39: */
40: public final void setTransformers() {
41: if (cxf != null) {
42: for (int i = 0; i < cxf.length; i++) {
43: qcl_.addClassXformer(cxf[i]);
44: }
45: }
46: if (mxf != null) {
47: for (int i = 0; i < mxf.length; i++) {
48: qcl_.addMethodXformer(mxf[i]);
49: }
50: }
51: if (gxf != null) {
52: for (int i = 0; i < gxf.length; i++) {
53: qcl_.addGraphXformer(gxf[i]);
54: }
55: }
56: }
57:
58: /** Resets items in the registry in an application-specific manner. */
59: abstract public void reset();
60:
61: /** Dumps the registry in a form appropriate to the application. */
62: abstract public String getReport();
63:
64: }
|