01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.services;
16:
17: import org.apache.tapestry.internal.event.InvalidationEventHub;
18: import org.apache.tapestry.ioc.services.ClassFactory;
19:
20: /**
21: * Creates {@link org.apache.tapestry.internal.services.Instantiator}s for components, based on
22: * component class name. This will involve transforming the component's class before it is loaded.
23: * <p>
24: * In addition, a source acts as an event hub for
25: * {@link org.apache.tapestry.internal.events.InvalidationListener}s, so that any information derived from
26: * loaded classes can be discarded and rebuilt when classes change.
27: * <p>
28: * The strategy used is that when <em>any</em> class (in a controlled package) changes, the entire
29: * class loader is discarded, along with any instances derived from those classes. A new class
30: * loader is created, and then invalidation events are fired to listeners.
31: */
32: public interface ComponentInstantiatorSource extends
33: InvalidationEventHub {
34:
35: /**
36: * Given the name of a component class, provides an instantiator for that component.
37: * Instantiators are cached, so repeated calls to this method with the same class name will
38: * return the same instance; however, callers should also be aware that the instantiators may
39: * lose validity after an invalidation (caused by changes to external Java class files).
40: *
41: * @param classname
42: * FQCN to find (and perhaps transform and load)
43: * @return an object which can instantiate an instance of the component
44: */
45: Instantiator findInstantiator(String classname);
46:
47: /**
48: * Adds a controlled package. Only classes within controlled packages are subject to
49: * transformation.
50: *
51: * @param packageName
52: * the package name to add (must not be blank)
53: */
54: void addPackage(String packageName);
55:
56: /**
57: * Checks to see if a fully qualfied class name exists.
58: *
59: * @param className
60: * name of class to check
61: * @return true if the class exists (there's a ".class" file), false otherwise
62: */
63: boolean exists(String className);
64:
65: /**
66: * Returns a class factory that can be used to generate additional classes around enhanced
67: * classes, or create subclasses of enhanced classes.
68: */
69: ClassFactory getClassFactory();
70:
71: }
|