public class InstantiateFactory<T> extends java.lang.Object implements Factory<T>, java.io.Serializable
WARNING: This class will throw an
UnsupportedOperationException
when trying to serialize or
de-serialize an instance to prevent potential remote code execution exploits.
In order to re-enable serialization support for InstantiateTransformer
the following system property can be used (via -Dproperty=true):
org.apache.commons.collections.enableUnsafeSerialization
Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
iArgs
The constructor arguments
|
private java.lang.Class<T> |
iClassToInstantiate
The class to create
|
private java.lang.reflect.Constructor<T> |
iConstructor
The constructor
|
private java.lang.Class<?>[] |
iParamTypes
The constructor parameter types
|
private static long |
serialVersionUID
The serial version
|
Constructor and Description |
---|
InstantiateFactory(java.lang.Class<T> classToInstantiate)
Constructor that performs no validation.
|
InstantiateFactory(java.lang.Class<T> classToInstantiate,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] args)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
T |
create()
Creates an object using the stored constructor.
|
private void |
findConstructor()
Find the Constructor for the class specified.
|
static <T> Factory<T> |
instantiateFactory(java.lang.Class<T> classToInstantiate,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] args)
Factory method that performs validation.
|
private void |
readObject(java.io.ObjectInputStream is)
Overrides the default readObject implementation to prevent
de-serialization (see COLLECTIONS-580).
|
private void |
writeObject(java.io.ObjectOutputStream os)
Overrides the default writeObject implementation to prevent
serialization (see COLLECTIONS-580).
|
private static final long serialVersionUID
private final java.lang.Class<T> iClassToInstantiate
private final java.lang.Class<?>[] iParamTypes
private final java.lang.Object[] iArgs
private transient java.lang.reflect.Constructor<T> iConstructor
public InstantiateFactory(java.lang.Class<T> classToInstantiate)
instantiateFactory
if you want that.classToInstantiate
- the class to instantiatepublic InstantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
instantiateFactory
if you want that.classToInstantiate
- the class to instantiateparamTypes
- the constructor parameter types, clonedargs
- the constructor arguments, clonedpublic static <T> Factory<T> instantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
T
- the type the factory createsclassToInstantiate
- the class to instantiate, not nullparamTypes
- the constructor parameter types, clonedargs
- the constructor arguments, clonedprivate void findConstructor()
public T create()
private void writeObject(java.io.ObjectOutputStream os) throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream is) throws java.lang.ClassNotFoundException, java.io.IOException
java.lang.ClassNotFoundException
java.io.IOException