jodd.petite
Class PetiteContainer

java.lang.Object
  extended by jodd.petite.PetiteBeans
      extended by jodd.petite.PetiteRegistry
          extended by jodd.petite.PetiteContainer
Direct Known Subclasses:
ProxettaAwarePetiteContainer

public class PetiteContainer
extends PetiteRegistry

Petite IOC container. Consist of following layers:

  • PetiteContainer - top layer that provides business usage
  • PetiteRegistry
  • PetiteBeans


    Field Summary
    static java.lang.String PETITE_CONTAINER_REF_NAME
               
     
    Fields inherited from class jodd.petite.PetiteBeans
    beanCollections, beans, injectionPointFactory, petiteConfig, petiteResolvers, scopes
     
    Constructor Summary
    PetiteContainer()
               
    PetiteContainer(PetiteConfig config)
               
     
    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 configure(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[] names, java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
              Returns Petite bean instance named as one of the provided names.
    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.PetiteRegistry
    defineBean, defineBean, defineBean, defineBean, defineBean, defineBean, defineParameters, defineParameters, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerCtorInjectionPoint, registerCtorInjectionPoint, registerCtorInjectionPoint, registerCtorInjectionPoint, registerInitMethods, registerInitMethods, registerMethodInjectionPoint, registerMethodInjectionPoint, registerMethodInjectionPoint, registerMethodInjectionPoint, registerPropertyInjectionPoint, registerPropertyInjectionPoint, registerSetInjectionPoint, removeBean, removeBean
     
    Methods inherited from class jodd.petite.PetiteBeans
    beansIterator, defineParameter, definePetiteBean, getConfig, getParameter, getResolvers, getTotalBeans, getTotalScopes, isBeanNameRegistered, lookupBeanDefinition, lookupExistingBeanDefinition, registerPetiteBean, registerPetiteCtorInjectionPoint, registerPetiteInitMethods, registerPetiteMethodInjectionPoint, registerPetitePropertyInjectionPoint, registerPetiteSetInjectionPoint, registerScope, removeBeanDefinition, resolveBeanName, resolveBeanNamesForType, resolveBeanParams, resolveCollectionInjectionPoint, resolveCtorInjectionPoint, resolveDefaultCtorInjectionPoint, resolveInitMethods, resolveMethodInjectionPoint, resolvePropertyInjectionPoint, resolveScope
     
    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(PetiteConfig config)
    Method Detail

    configure

    public void configure(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[] names,
                                       java.util.Map<java.lang.String,java.lang.Object> acquiredBeans)
    Returns Petite bean instance named as one of the provided names.


    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-2011 Jodd Team