Top Description Inners Constructors Methods
com.thoughtworks.xstream.core.util

public Class DependencyInjectionFactory

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .InvocationTargetException, java.util.ArrayList, .Arrays, .BitSet, .Comparator, .List, com.thoughtworks.xstream.converters.reflection.ObjectAccessException

A dependency injection factory.
Author
Jörg Schaible
Since
1.2.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Object

Returns:

the instantiated object
newInstance
(final Class<T>
the type to create an instance of
type
,
final Object[]
the possible dependencies
dependencies
)

Create an instance with dependency injection.

public static Object

Returns:

the instantiated object
newInstance
(final Class<T>
the type to create an instance of
type
,
final Object[]
the possible dependencies
dependencies
,
final BitSet
bit mask set by the method for all used dependencies (may be null)
usedDependencies
)

Create an instance with dependency injection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DependencyInjectionFactoryback to summary
public DependencyInjectionFactory()

Method Detail

newInstanceback to summary
public static Object newInstance(final Class<T> type, final 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 a TypedNull instance to inject null as parameter.

Parameters
type:Class<T>

the type to create an instance of

dependencies:Object[]

the possible dependencies

Returns:Object

the instantiated object

Exceptions
ObjectAccessException:
if no instance can be generated
IllegalArgumentException:
if more than 63 dependencies have been provided
Since
1.2.2
newInstanceback to summary
public static Object newInstance(final Class<T> type, final Object[] dependencies, final 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 a TypedNull instance to inject null as parameter.

Parameters
type:Class<T>

the type to create an instance of

dependencies:Object[]

the possible dependencies

usedDependencies:BitSet

bit mask set by the method for all used dependencies (may be null)

Returns:Object

the instantiated object

Exceptions
ObjectAccessException:
if no instance can be generated
IllegalArgumentException:
if more than 63 dependencies have been provided
Since
1.4
com.thoughtworks.xstream.core.util back to summary

private Class DependencyInjectionFactory.TypedValue

extends Object
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.core.util.DependencyInjectionFactory.TypedValue

Field Summary

Modifier and TypeField and Description
pack-priv final Class<T>
pack-priv final Object

Constructor Summary

AccessConstructor and Description
public
TypedValue(final Class<T> type, final Object value)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

typeback to summary
pack-priv final Class<T> type
valueback to summary
pack-priv final Object value

Constructor Detail

TypedValueback to summary
public TypedValue(final Class<T> type, final Object value)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.