stomp.wrapper
Class DelegateClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--stomp.wrapper.DelegateClassLoader

public class DelegateClassLoader
extends java.lang.ClassLoader

responsible for creating classes at runtime which satisfy certain contracts. The new class must extend a given runtime input class ( like LinkedList ), implement an expected interface ( like CollectionDelegate ) and override all the input classes methods, attempting to pass only delegate type objects into the overriden list, and return only proxy objects from the list.

Author:
Eric Lindauer

Constructor Summary
DelegateClassLoader()
           
 
Method Summary
static java.lang.Class getDelegateClass(java.lang.Class delegate)
          if parentClass is a CollectionDelegate, returns parentClass.
static void main(java.lang.String[] args)
          creates a delegate class for the given input class and writes it out to a file.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegateClassLoader

public DelegateClassLoader()
Method Detail

getDelegateClass

public static java.lang.Class getDelegateClass(java.lang.Class delegate)
if parentClass is a CollectionDelegate, returns parentClass. else if parentClass is a MapDelegate, returns parentClass. else if parentClass is a Collection, returns a class that is assignable to parent class, and that implements CollectionDelegate. This new class will intercept all methods calls on the Collection, unwrapping arguments to delegate types, and wrapping returned elements into proxies. The new class will be defined in the same package (if possible) as the parent class. else if parentClass is a Map, returns a class that is assignable to parent class, and that implements MapDelegate. This new class will intercept all method calls on the Map, unwrapping arguments to delegate types, and wrapping returned objects into proxies. The new class will be defined in the same package (if possible) as the original class, so protected methods will still be accessible through the wrapper. else returns parentClass. requires that parentClass is a non-abstract, non-interface, non-final class.


main

public static void main(java.lang.String[] args)
                 throws java.lang.ClassNotFoundException,
                        java.io.IOException
creates a delegate class for the given input class and writes it out to a file.

java.lang.ClassNotFoundException
java.io.IOException