org.apache.tapestry5.internal.services
Class ComponentInstantiatorSourceImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.event.InvalidationEventHubImpl
      extended by org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl
All Implemented Interfaces:
javassist.Translator, ComponentInstantiatorSource, InvalidationEventHub, UpdateListener

public final class ComponentInstantiatorSourceImpl
extends InvalidationEventHubImpl
implements javassist.Translator, ComponentInstantiatorSource, UpdateListener

A wrapper around a Javassist class loader that allows certain classes to be modified as they are loaded.


Constructor Summary
ComponentInstantiatorSourceImpl(org.slf4j.Logger logger, ClassLoader parent, ComponentClassTransformer transformer, InternalRequestGlobals internalRequestGlobals, ClasspathURLConverter classpathURLConverter)
           
 
Method Summary
 void addPackage(String packageName)
          Adds a controlled package.
 void checkForUpdates()
          Invoked to force the receiver to check for updates to whatever underlying resources it makes use of.
 boolean exists(String className)
          Checks to see if a fully qualfied class name exists.
 ClassFactory getClassFactory()
          Returns a class factory that can be used to generate additional classes around enhanced classes, or create subclasses of enhanced classes.
 CtClassSource getClassSource()
          Returns a class source used when creating new classes dynamically.
 Instantiator getInstantiator(String className)
          Given the name of a component class, provides an instantiator for that component.
 InvalidationEventHub getInvalidationEventHub()
          Invalidation event hub used to notify listeners that component classes have changed.
 void onLoad(javassist.ClassPool pool, String classname)
           
 void start(javassist.ClassPool pool)
          Does nothing.
 
Methods inherited from class org.apache.tapestry5.internal.event.InvalidationEventHubImpl
addInvalidationListener, fireInvalidationEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentInstantiatorSourceImpl

public ComponentInstantiatorSourceImpl(org.slf4j.Logger logger,
                                       ClassLoader parent,
                                       ComponentClassTransformer transformer,
                                       InternalRequestGlobals internalRequestGlobals,
                                       ClasspathURLConverter classpathURLConverter)
Method Detail

checkForUpdates

public void checkForUpdates()
Description copied from interface: UpdateListener
Invoked to force the receiver to check for updates to whatever underlying resources it makes use of.

Specified by:
checkForUpdates in interface UpdateListener

onLoad

public void onLoad(javassist.ClassPool pool,
                   String classname)
            throws javassist.NotFoundException,
                   javassist.CannotCompileException
Specified by:
onLoad in interface javassist.Translator
Throws:
javassist.NotFoundException
javassist.CannotCompileException

start

public void start(javassist.ClassPool pool)
           throws javassist.NotFoundException,
                  javassist.CannotCompileException
Does nothing.

Specified by:
start in interface javassist.Translator
Throws:
javassist.NotFoundException
javassist.CannotCompileException

getInstantiator

public Instantiator getInstantiator(String className)
Description copied from interface: ComponentInstantiatorSource
Given the name of a component class, provides an instantiator for that component. Instantiators are cached, so repeated calls to this method with the same class name will return the same instance; however, callers should also be aware that the instantiators may lose validity after an invalidation (caused by changes to external Java class files).

Specified by:
getInstantiator in interface ComponentInstantiatorSource
Parameters:
className - FQCN to find (and perhaps transform and load)
Returns:
an object which can instantiate an instance of the component

addPackage

public void addPackage(String packageName)
Description copied from interface: ComponentInstantiatorSource
Adds a controlled package. Only classes within controlled packages are subject to transformation.

Specified by:
addPackage in interface ComponentInstantiatorSource
Parameters:
packageName - the package name to add (must not be blank)

exists

public boolean exists(String className)
Description copied from interface: ComponentInstantiatorSource
Checks to see if a fully qualfied class name exists. This method appears to exist only for testing.

Specified by:
exists in interface ComponentInstantiatorSource
Parameters:
className - name of class to check
Returns:
true if the class exists (there's a ".class" file), false otherwise

getClassFactory

public ClassFactory getClassFactory()
Description copied from interface: ComponentInstantiatorSource
Returns a class factory that can be used to generate additional classes around enhanced classes, or create subclasses of enhanced classes.

Specified by:
getClassFactory in interface ComponentInstantiatorSource

getClassSource

public CtClassSource getClassSource()
Description copied from interface: ComponentInstantiatorSource
Returns a class source used when creating new classes dynamically.

Specified by:
getClassSource in interface ComponentInstantiatorSource

getInvalidationEventHub

public InvalidationEventHub getInvalidationEventHub()
Description copied from interface: ComponentInstantiatorSource
Invalidation event hub used to notify listeners that component classes have changed.

Specified by:
getInvalidationEventHub in interface ComponentInstantiatorSource
See Also:
ComponentClasses


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.