info.magnolia.objectfactory
Interface ClassFactory

All Known Implementing Classes:
DefaultClassFactory

public interface ClassFactory

ClassFactory implementations are responsible for locating and instantiating classes. Specific implementations could take care of container-specific hacks, provide support for a scripting language, etc. TODO ? an spi-like layer that would allow to have multiple implementations of this and delegate to the first which "accepts" the given parameters ?

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

Method Summary
<C> java.lang.Class<C>
forName(java.lang.String className)
           
<T> T
newInstance(java.lang.Class<T> c, java.lang.Class<?>[] argTypes, java.lang.Object... params)
          Instantiates the given class with the given parameters, using a constructor that matches the given argTypes exactly.
<T> T
newInstance(java.lang.Class<T> c, java.lang.Object... params)
          Instantiates the given class with the given parameters.
 

Method Detail

forName

<C> java.lang.Class<C> forName(java.lang.String className)
                           throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

newInstance

<T> T newInstance(java.lang.Class<T> c,
                  java.lang.Object... params)
Instantiates the given class with the given parameters. This attempts to find a matching constructor. For the empty constructor, pass no parameters (or an empty array, or null). Null arguments are not supported.

Throws:
MgnlInstantiationException - wrapping possible instantiation exceptions

newInstance

<T> T newInstance(java.lang.Class<T> c,
                  java.lang.Class<?>[] argTypes,
                  java.lang.Object... params)
Instantiates the given class with the given parameters, using a constructor that matches the given argTypes exactly. To pass "null" to a single-arg constructor, use newInstance(c, new Object[]{null}) (otherwise the *array* itself will be considered null)

Throws:
MgnlInstantiationException - wrapping possible instantiation exceptions


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.