public class GroovyClassFactory extends Object implements info.magnolia.objectfactory.ReloadableClassFactory
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.
Constructor and Description |
---|
GroovyClassFactory() |
GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate) |
GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate,
info.magnolia.context.Context context)
Deprecated.
since 2.4.4 please use
GroovyClassFactory() instead. |
GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate,
HierarchyManagerProvider hmp)
Deprecated.
since 2.4.3 please use
GroovyClassFactory() instead. |
Modifier and Type | Method and Description |
---|---|
<C> Class<C> |
forName(String className) |
<T> T |
newInstance(Class<T> c,
Class<?>[] argTypes,
Object... params) |
<T> T |
newInstance(Class<T> c,
Object... objects) |
<T> Class<T> |
reload(Class<T> c) |
public GroovyClassFactory()
public GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate)
@Deprecated public GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate, HierarchyManagerProvider hmp)
GroovyClassFactory()
instead.@Deprecated public GroovyClassFactory(info.magnolia.objectfactory.ClassFactory delegate, info.magnolia.context.Context context)
GroovyClassFactory()
instead.public <C> Class<C> forName(String className) throws ClassNotFoundException
forName
in interface info.magnolia.objectfactory.ClassFactory
ClassNotFoundException
public <T> T newInstance(Class<T> c, Object... objects)
newInstance
in interface info.magnolia.objectfactory.ClassFactory
public <T> T newInstance(Class<T> c, Class<?>[] argTypes, Object... params)
newInstance
in interface info.magnolia.objectfactory.ClassFactory
public <T> Class<T> reload(Class<T> c) throws ClassNotFoundException
reload
in interface info.magnolia.objectfactory.ReloadableClassFactory
ClassNotFoundException
Copyright © 2017 Magnolia International Ltd.. All rights reserved.