com.thoughtworks.xstream.core.util
Class DependencyInjectionFactory

java.lang.Object
  extended by com.thoughtworks.xstream.core.util.DependencyInjectionFactory

public class DependencyInjectionFactory
extends Object

A dependency injection factory.

Since:
1.2.2
Author:
Jörg Schaible

Constructor Summary
DependencyInjectionFactory()
           
 
Method Summary
static Object newInstance(Class type, Object[] dependencies)
          Create an instance with dependency injection.
static Object newInstance(Class type, Object[] dependencies, BitSet usedDependencies)
          Create an instance with dependency injection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyInjectionFactory

public DependencyInjectionFactory()
Method Detail

newInstance

public static Object newInstance(Class type,
                                 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 - the type to create an instance of
dependencies - the possible dependencies
Returns:
the instantiated object
Throws:
ObjectAccessException - if no instance can be generated
Since:
1.2.2

newInstance

public static Object newInstance(Class type,
                                 Object[] dependencies,
                                 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 - the type to create an instance of
dependencies - the possible dependencies
usedDependencies - bit mask set by the method for all used dependencies (may be null)
Returns:
the instantiated object
Throws:
ObjectAccessException - if no instance can be generated
Since:
1.4


Copyright © 2012. All Rights Reserved.