Class DependencyInjectionFactory
- java.lang.Object
-
- com.thoughtworks.xstream.core.util.DependencyInjectionFactory
-
public class DependencyInjectionFactory extends java.lang.Object
A dependency injection factory.- Since:
- 1.2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DependencyInjectionFactory.TypedValue
-
Constructor Summary
Constructors Constructor Description DependencyInjectionFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
newInstance(java.lang.Class type, java.lang.Object[] dependencies)
Create an instance with dependency injection.static java.lang.Object
newInstance(java.lang.Class type, java.lang.Object[] dependencies, java.util.BitSet usedDependencies)
Create an instance with dependency injection.
-
-
-
Method Detail
-
newInstance
public static java.lang.Object newInstance(java.lang.Class type, java.lang.Object[] dependencies)
Create an instance with dependency injection. The given dependencies are used to match the parameters of the constructors of the type. Constructors with most parameters are examined first. A parameter type sequence matching the sequence of the dependencies' types match first. Otherwise all the types of the dependencies must match one of the the parameters although no dependency is used twice. Use aTypedNull
instance to injectnull
as parameter.- Parameters:
type
- the type to create an instance ofdependencies
- the possible dependencies- Returns:
- the instantiated object
- Throws:
ObjectAccessException
- if no instance can be generatedjava.lang.IllegalArgumentException
- if more than 63 dependencies have been provided- Since:
- 1.2.2
-
newInstance
public static java.lang.Object newInstance(java.lang.Class type, java.lang.Object[] dependencies, java.util.BitSet usedDependencies)
Create an instance with dependency injection. The given dependencies are used to match the parameters of the constructors of the type. Constructors with most parameters are examined first. A parameter type sequence matching the sequence of the dependencies' types match first. Otherwise all the types of the dependencies must match one of the the parameters although no dependency is used twice. Use aTypedNull
instance to injectnull
as parameter.- Parameters:
type
- the type to create an instance ofdependencies
- the possible dependenciesusedDependencies
- bit mask set by the method for all used dependencies (may benull
)- Returns:
- the instantiated object
- Throws:
ObjectAccessException
- if no instance can be generatedjava.lang.IllegalArgumentException
- if more than 63 dependencies have been provided- Since:
- 1.4
-
-