org.apache.tapestry5.ioc.internal.services
Class ClassFactoryImpl

java.lang.Object
  extended by org.apache.tapestry5.ioc.internal.services.ClassFactoryImpl
All Implemented Interfaces:
ClassFactory

public class ClassFactoryImpl
extends Object
implements ClassFactory

Implementation of ClassFactory.


Constructor Summary
ClassFactoryImpl()
           
ClassFactoryImpl(ClassLoader classLoader)
           
ClassFactoryImpl(ClassLoader classLoader, ClassFactoryClassPool pool, CtClassSource classSource, org.slf4j.Logger logger)
           
ClassFactoryImpl(ClassLoader classLoader, ClassFactoryClassPool pool, org.slf4j.Logger logger)
          Special constructor used when the class pool is provided externally.
ClassFactoryImpl(ClassLoader classLoader, org.slf4j.Logger log)
          Main constructor where a specific class loader and log is provided.
 
Method Summary
<T> T
createProxy(Class<T> proxyInterface, Class<? extends T> delegateClass, ObjectCreator delegateCreator, String description)
          Creates a proxy for an interface.
<T> T
createProxy(Class<T> proxyInterface, ObjectCreator delegateCreator, String description)
          Creates a proxy for an interface.
 ClassLoader getClassLoader()
          Returns the class loader used when creating new classes; this is generally the same as the current thread's context class loader (except perhaps during testing).
 Location getConstructorLocation(Constructor constructor)
          Return a string representation for the constructor (including class and parameters) and (if available) file name and line number.
 int getCreatedClassCount()
          Returns the number of classes (and interfaces) actually created.
 Location getMethodLocation(Method method)
          Converts a method to a Location, which includes information about the source file name and line number.
 Class importClass(Class clazz)
          Imports the class to make it referenceable within the factory.
 ClassFab newClass(Class serviceInterface)
          Simplified version of ClassFactory.newClass(String, Class) that generates a name based on the service interface name, extends from java.lang.Object, and automatically adds the serviceInterface to the returned ClassFab.
 ClassFab newClass(String name, Class superClass)
          Creates a ClassFab object for the given name; the new class is a subclass of the indicated class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFactoryImpl

public ClassFactoryImpl(ClassLoader classLoader)

ClassFactoryImpl

public ClassFactoryImpl()

ClassFactoryImpl

public ClassFactoryImpl(ClassLoader classLoader,
                        org.slf4j.Logger log)
Main constructor where a specific class loader and log is provided.


ClassFactoryImpl

public ClassFactoryImpl(ClassLoader classLoader,
                        ClassFactoryClassPool pool,
                        org.slf4j.Logger logger)
Special constructor used when the class pool is provided externally.


ClassFactoryImpl

public ClassFactoryImpl(ClassLoader classLoader,
                        ClassFactoryClassPool pool,
                        CtClassSource classSource,
                        org.slf4j.Logger logger)
Method Detail

newClass

public ClassFab newClass(Class serviceInterface)
Description copied from interface: ClassFactory
Simplified version of ClassFactory.newClass(String, Class) that generates a name based on the service interface name, extends from java.lang.Object, and automatically adds the serviceInterface to the returned ClassFab. This is the most common use when creating the kinds of proxies used throughout Tapestry IoC.

Specified by:
newClass in interface ClassFactory

newClass

public ClassFab newClass(String name,
                         Class superClass)
Description copied from interface: ClassFactory
Creates a ClassFab object for the given name; the new class is a subclass of the indicated class. The new class is always public and concrete.

Specified by:
newClass in interface ClassFactory
Parameters:
name - the full qualified name of the class to create (note that it is common to place created classes in the default package)
superClass - the parent class, which is often java.lang.Object

importClass

public Class importClass(Class clazz)
Description copied from interface: ClassFactory
Imports the class to make it referenceable within the factory. The class loader for the class is added to the class path. The class itself is returned, if its bytecode is available. If not, a search up the inhertance occurs until a proper class (that can be referenced in generated bytecode) is found. This is necessary to handle cases where a class is generated at runtime, outside of the class factory, and bytecode is not available for it.

Specified by:
importClass in interface ClassFactory
Returns:
a referenceable super-class

getCreatedClassCount

public int getCreatedClassCount()
Description copied from interface: ClassFactory
Returns the number of classes (and interfaces) actually created.

Specified by:
getCreatedClassCount in interface ClassFactory

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: ClassFactory
Returns the class loader used when creating new classes; this is generally the same as the current thread's context class loader (except perhaps during testing).

Specified by:
getClassLoader in interface ClassFactory

getMethodLocation

public Location getMethodLocation(Method method)
Description copied from interface: ClassFactory
Converts a method to a Location, which includes information about the source file name and line number.

Specified by:
getMethodLocation in interface ClassFactory
Parameters:
method - to look up
Returns:
the location, or null if the necessary information is not available

getConstructorLocation

public Location getConstructorLocation(Constructor constructor)
Description copied from interface: ClassFactory
Return a string representation for the constructor (including class and parameters) and (if available) file name and line number.

Specified by:
getConstructorLocation in interface ClassFactory

createProxy

public <T> T createProxy(Class<T> proxyInterface,
                         ObjectCreator delegateCreator,
                         String description)
Description copied from interface: ClassFactory
Creates a proxy for an interface. All methods of the interface are delegated through the object returned from the ObjectCreator (which is accessed on each method invocation, so it is responsible for caching of the true delegate). The description will be used for the toString() method (unless toString() is part of the proxy interface).

Specified by:
createProxy in interface ClassFactory
Type Parameters:
T - type of proxy
Parameters:
proxyInterface - proxy interface class
delegateCreator - creates the delegate
description - used for the toString() method

createProxy

public <T> T createProxy(Class<T> proxyInterface,
                         Class<? extends T> delegateClass,
                         ObjectCreator delegateCreator,
                         String description)
Description copied from interface: ClassFactory
Creates a proxy for an interface. All methods of the interface are delegated through the object returned from the ObjectCreator (which is accessed on each method invocation, so it is responsible for caching of the true delegate). The description will be used for the toString() method (unless toString() is part of the proxy interface).

Specified by:
createProxy in interface ClassFactory
Type Parameters:
T - type of proxy
Parameters:
proxyInterface - proxy interface class
delegateClass - delegate class
delegateCreator - creates the delegate
description - used for the toString() method


Copyright © 2003-2012 The Apache Software Foundation.