info.magnolia.module.groovy.support.classes
Class GroovyClassFactory

java.lang.Object
  extended by info.magnolia.module.groovy.support.classes.GroovyClassFactory
All Implemented Interfaces:
info.magnolia.objectfactory.ClassFactory

public class GroovyClassFactory
extends Object
implements info.magnolia.objectfactory.ClassFactory

A ClassFactory which attempts to load classes using a GroovyClassLoader if they were not found using a delegate (which is a DefaultClassFactory by default). A little bit of background: When loading classes via the GroovyClassLoader, we loose control on where classes are loaded from. The GroovyClassLoader will always first attempt to load any given class via its parent*. This is actually the expected behaviour from regular ClassLoader implementations. As long as we first try loading our classes via the DefaultClassFactory, we're fine, we keep control of the order in which ClassLoaders are poked for classes. By default, the GroovyClassLoader uses the current thread's ContextClassLoader, while we first use the caller's ClassLoader, *then* the thread's. Any class/script loaded via the GroovyClassLoader and using classes that haven't been loaded yet will thus see those classes loaded via the current thread's ContextClassLoader. If this were to become an issue, we'd probably need to create something along the lines of a ClassFactoryAwareClassLoader, and give that as a parent to the GroovyClassLoader.

Version:
$Revision: $ ($Author: $)
Author:
gjoseph

Constructor Summary
GroovyClassFactory()
           
GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate, HierarchyManagerProvider hmp)
           
 
Method Summary
<C> Class<C>
forName(String className)
           
<T> T
newInstance(Class<T> c, Class<?>[] argTypes, Object... params)
           
<T> T
newInstance(Class<T> c, Object... objects)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyClassFactory

public GroovyClassFactory()

GroovyClassFactory

public GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate,
                          HierarchyManagerProvider hmp)
Method Detail

forName

public <C> Class<C> forName(String className)
                 throws ClassNotFoundException
Specified by:
forName in interface info.magnolia.objectfactory.ClassFactory
Throws:
ClassNotFoundException

newInstance

public <T> T newInstance(Class<T> c,
                         Object... objects)
Specified by:
newInstance in interface info.magnolia.objectfactory.ClassFactory

newInstance

public <T> T newInstance(Class<T> c,
                         Class<?>[] argTypes,
                         Object... params)
Specified by:
newInstance in interface info.magnolia.objectfactory.ClassFactory


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.