jodd.petite
Class PetiteContainer

java.lang.Object
  extended by jodd.petite.PetiteContainerRegistry
      extended by jodd.petite.PetiteContainer

public class PetiteContainer
extends PetiteContainerRegistry

Petite IOC container. Generally, it is composed of two parts: manager and container. Manager deals with binding information regarding registration and configuration. Container itself is used during runtime for acquiring bean instances.


Field Summary
static java.lang.String PETITE_CONTAINER_REF_NAME
           
 
Fields inherited from class jodd.petite.PetiteContainerRegistry
petiteConfig, petiteManager
 
Constructor Summary
PetiteContainer()
           
PetiteContainer(PetiteManager pm, PetiteConfig pcfg)
           
 
Method Summary
 void addBean(java.lang.String name, java.lang.Object bean)
          Adds object instance to the container as singleton bean using default wiring mode and default init method flag.
 void addBean(java.lang.String name, java.lang.Object bean, WiringMode wiringMode)
          Adds object instance to the container as singleton bean.
 void addSelf()
          Adds self instance to the container so internal beans may fetch container for further usage.
 void addSelf(java.lang.String name)
          Adds self instance to the container so internal beans may fetch container for further usage.
 void confgure(PetiteConfigurator... petiteConfigurators)
          Configures this instance of container.
<E> E
createBean(java.lang.Class<E> type)
          Creates and wires a bean within the container using default wiring mode and default init methods flag.
<E> E
createBean(java.lang.Class<E> type, WiringMode wiringMode, boolean init)
          Creates and wires a bean within the container and optionally invokes init methods.
<T> T
getBean(java.lang.Class<T> type)
          Returns Petite bean instance.
 java.lang.Object getBean(java.lang.String name)
          Returns Petite bean instance.
protected  java.lang.Object getBean(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
          Returns petite bean instance.
 java.lang.Object getBeanProperty(java.lang.String name)
          Returns petite bean property value.
protected  void injectParams(java.lang.Object bean, BeanDefinition def)
          Injects all parameters.
protected  void invokeInitMethods(java.lang.Object bean, BeanDefinition def, java.lang.Boolean fireFirstOff)
          Invokes all init methods.
protected  java.lang.Object newBeanInstance(BeanDefinition def, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
          Creates new bean instance and performs constructor injection.
 void setBeanProperty(java.lang.String name, java.lang.Object value)
          Sets petite bean property.
 void wire(java.lang.Object bean)
          Wires provided bean with the container using default wiring mode and default init methods flag.
 void wire(java.lang.Object bean, WiringMode wiringMode, boolean init)
          Wires provided bean with the container and optionally invokes init methods.
protected  void wireBean(java.lang.Object bean, BeanDefinition def, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
          Wires beans.
protected  void wireFields(java.lang.Object bean, BeanDefinition def, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
          Wires fields.
protected  void wireMethods(java.lang.Object bean, BeanDefinition def, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
          Wires methods.
 
Methods inherited from class jodd.petite.PetiteContainerRegistry
beansIterator, defineBean, defineBean, defineBean, defineBean, defineBean, defineBean, defineParameter, defineParameters, definePetiteBean, getConfig, getManager, getTotalBeans, getTotalScopes, isBeanNameRegistered, lookupBeanDefinition, lookupExistingBeanDefinition, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerCtorInjectionPoint, registerCtorInjectionPoint, registerCtorInjectionPoint, registerCtorInjectionPoint, registerInitMethods, registerInitMethods, registerMethodInjectionPoint, registerMethodInjectionPoint, registerMethodInjectionPoint, registerMethodInjectionPoint, registerPetiteBean, registerPetiteCtorInjectionPoint, registerPetiteInitMethods, registerPetiteMethodInjectionPoint, registerPetitePropertyInjectionPoint, registerPropertyInjectionPoint, registerPropertyInjectionPoint, removeBean, removeBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PETITE_CONTAINER_REF_NAME

public static final java.lang.String PETITE_CONTAINER_REF_NAME
See Also:
Constant Field Values
Constructor Detail

PetiteContainer

public PetiteContainer()

PetiteContainer

public PetiteContainer(PetiteManager pm,
                       PetiteConfig pcfg)
Method Detail

confgure

public void confgure(PetiteConfigurator... petiteConfigurators)
Configures this instance of container.


newBeanInstance

protected java.lang.Object newBeanInstance(BeanDefinition def,
                                           java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
Creates new bean instance and performs constructor injection.


wireBean

protected void wireBean(java.lang.Object bean,
                        BeanDefinition def,
                        java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
Wires beans.

Parameters:
bean - target bean
def - bean definition
acquiredBeans - set of acquired beans

wireFields

protected void wireFields(java.lang.Object bean,
                          BeanDefinition def,
                          java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
Wires fields.


wireMethods

protected void wireMethods(java.lang.Object bean,
                           BeanDefinition def,
                           java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
Wires methods.


invokeInitMethods

protected void invokeInitMethods(java.lang.Object bean,
                                 BeanDefinition def,
                                 java.lang.Boolean fireFirstOff)
Invokes all init methods.


injectParams

protected void injectParams(java.lang.Object bean,
                            BeanDefinition def)
Injects all parameters.


getBean

public <T> T getBean(java.lang.Class<T> type)
Returns Petite bean instance. Bean name will be resolved from provided type.


getBean

public java.lang.Object getBean(java.lang.String name)
Returns Petite bean instance. Petite container will find the bean in corresponding scope and all its dependencies, either by constructor or property injection. When using constructor injection, cyclic dependencies can not be prevented, but at least they are detected.

See Also:
createBean(Class)

getBean

protected java.lang.Object getBean(java.lang.String name,
                                   java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
Returns petite bean instance.

See Also:
createBean(Class)

wire

public void wire(java.lang.Object bean)
Wires provided bean with the container using default wiring mode and default init methods flag. Bean is not registered.


wire

public void wire(java.lang.Object bean,
                 WiringMode wiringMode,
                 boolean init)
Wires provided bean with the container and optionally invokes init methods. Bean is not registered.


createBean

public <E> E createBean(java.lang.Class<E> type)
Creates and wires a bean within the container using default wiring mode and default init methods flag. Bean is not registered.


createBean

public <E> E createBean(java.lang.Class<E> type,
                        WiringMode wiringMode,
                        boolean init)
Creates and wires a bean within the container and optionally invokes init methods. However, bean is not registered.


addBean

public void addBean(java.lang.String name,
                    java.lang.Object bean)
Adds object instance to the container as singleton bean using default wiring mode and default init method flag.


addBean

public void addBean(java.lang.String name,
                    java.lang.Object bean,
                    WiringMode wiringMode)
Adds object instance to the container as singleton bean.


addSelf

public void addSelf(java.lang.String name)
Adds self instance to the container so internal beans may fetch container for further usage. No wiring is used and no init methods are invoked.


addSelf

public void addSelf()
Adds self instance to the container so internal beans may fetch container for further usage. No wiring is used and no init methods are invoked.


setBeanProperty

public void setBeanProperty(java.lang.String name,
                            java.lang.Object value)
Sets petite bean property.


getBeanProperty

public java.lang.Object getBeanProperty(java.lang.String name)
Returns petite bean property value.



Copyright © 2003-2010 Jodd Team