jodd.petite
Class PetiteBeans

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

public abstract class PetiteBeans
extends java.lang.Object

Base layer of Petite Container. Holds beans and scopes definitions.


Field Summary
protected  java.util.Map<java.lang.Class,java.lang.String[]> beanCollections
          Map of all bean collections.
protected  java.util.Map<java.lang.String,BeanDefinition> beans
          Map of all beans definitions.
protected  InjectionPointFactory injectionPointFactory
          Injection point factory.
protected  PetiteConfig petiteConfig
          Petite configuration.
protected  PetiteResolvers petiteResolvers
          Petite resolvers.
protected  java.util.Map<java.lang.Class<? extends Scope>,Scope> scopes
          Map of all bean scopes.
 
Constructor Summary
protected PetiteBeans(PetiteConfig petiteConfig)
           
 
Method Summary
 java.util.Iterator<BeanDefinition> beansIterator()
          Returns iterator over all registered beans.
 void defineParameter(java.lang.String name, java.lang.Object value)
          Defines new parameter.
protected  void definePetiteBean(java.lang.String name, java.lang.Class type, java.lang.Class<? extends Scope> scopeType, WiringMode wiringMode)
          Single point of bean definition.
 PetiteConfig getConfig()
          Returns Petite configuration.
 java.lang.Object getParameter(java.lang.String name)
          Returns defined parameter.
 PetiteResolvers getResolvers()
          Returns Petite resolvers.
 int getTotalBeans()
          Returns total number of registered beans.
 int getTotalScopes()
          Returns total number of used scopes.
 boolean isBeanNameRegistered(java.lang.String name)
          Returns true if bean name is registered.
protected  BeanDefinition lookupBeanDefinition(java.lang.String name)
          Lookups for bean definition.
protected  BeanDefinition lookupExistingBeanDefinition(java.lang.String name)
          Lookups for existing bean.
protected  BeanDefinition registerPetiteBean(java.lang.String name, java.lang.Class type, java.lang.Class<? extends Scope> scopeType, WiringMode wiringMode)
          Single point of bean registration.
protected  void registerPetiteCtorInjectionPoint(java.lang.String beanName, java.lang.Class[] paramTypes, java.lang.String[] references)
          Single point of constructor injection point registration.
protected  void registerPetiteInitMethods(java.lang.String beanName, java.lang.String[] beforeMethodNames, java.lang.String[] afterMethodNames)
          Single point of init method registration.
protected  void registerPetiteMethodInjectionPoint(java.lang.String beanName, java.lang.String methodName, java.lang.Class[] arguments, java.lang.String[] references)
          Single point of method injection point registration.
protected  void registerPetitePropertyInjectionPoint(java.lang.String beanName, java.lang.String property, java.lang.String reference)
          Single point of property injection point registration.
protected  void registerPetiteSetInjectionPoint(java.lang.String beanName, java.lang.String property)
          Single point of property injection point registration.
 void registerScope(java.lang.Class<? extends Scope> scopeType, Scope scope)
          Registers new scope.
protected  BeanDefinition removeBeanDefinition(java.lang.String name)
          Removes bean and returns definition of removed bean.
 java.lang.String resolveBeanName(java.lang.Class type)
          Resolves bean's name from bean annotation or type name.
protected  java.lang.String[] resolveBeanNamesForType(java.lang.Class type)
          Resolve bean names for give type.
protected  java.lang.String[] resolveBeanParams(java.lang.String name, boolean resolveReferenceParams)
          Prepares list of all bean parameters and optionally resolves inner references.
protected  SetInjectionPoint[] resolveCollectionInjectionPoint(java.lang.Class type, boolean autowire)
           
protected  CtorInjectionPoint resolveCtorInjectionPoint(java.lang.Class type)
           
protected  CtorInjectionPoint resolveDefaultCtorInjectionPoint(java.lang.Class type)
           
protected  InitMethodPoint[] resolveInitMethods(java.lang.Object bean)
           
protected  MethodInjectionPoint[] resolveMethodInjectionPoint(java.lang.Class type)
           
protected  PropertyInjectionPoint[] resolvePropertyInjectionPoint(java.lang.Class type, boolean autowire)
           
protected  Scope resolveScope(java.lang.Class<? extends Scope> scopeType)
          Resolves scope from scope type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beans

protected final java.util.Map<java.lang.String,BeanDefinition> beans
Map of all beans definitions.


scopes

protected final java.util.Map<java.lang.Class<? extends Scope>,Scope> scopes
Map of all bean scopes.


beanCollections

protected final java.util.Map<java.lang.Class,java.lang.String[]> beanCollections
Map of all bean collections.


petiteConfig

protected final PetiteConfig petiteConfig
Petite configuration.


injectionPointFactory

protected final InjectionPointFactory injectionPointFactory
Injection point factory.


petiteResolvers

protected final PetiteResolvers petiteResolvers
Petite resolvers.

Constructor Detail

PetiteBeans

protected PetiteBeans(PetiteConfig petiteConfig)
Method Detail

getResolvers

public PetiteResolvers getResolvers()
Returns Petite resolvers.


getConfig

public PetiteConfig getConfig()
Returns Petite configuration. All changes on config should be applied before beans registration process starts.


resolveScope

protected Scope resolveScope(java.lang.Class<? extends Scope> scopeType)
Resolves scope from scope type.


registerScope

public void registerScope(java.lang.Class<? extends Scope> scopeType,
                          Scope scope)
Registers new scope. It is not necessary to manually register scopes, since they become registered on first scope resolving. However, it is possible to pre-register some scopes, or to replace one scope type with another. This may be important for testing purposes when using container-depended scopes.


lookupBeanDefinition

protected BeanDefinition lookupBeanDefinition(java.lang.String name)
Lookups for bean definition. Returns null if bean name doesn't exist.


lookupExistingBeanDefinition

protected BeanDefinition lookupExistingBeanDefinition(java.lang.String name)
Lookups for existing bean. Throws exception if bean is not found.


isBeanNameRegistered

public boolean isBeanNameRegistered(java.lang.String name)
Returns true if bean name is registered.


resolveBeanName

public java.lang.String resolveBeanName(java.lang.Class type)
Resolves bean's name from bean annotation or type name. May be used for resolving bean name of base type during registration of bean subclass.


registerPetiteBean

protected BeanDefinition registerPetiteBean(java.lang.String name,
                                            java.lang.Class type,
                                            java.lang.Class<? extends Scope> scopeType,
                                            WiringMode wiringMode)
Single point of bean registration. The following rules are applied:
  • if name is missing, it will be resolved from the class (name or annotation)
  • if wiring mode is missing, it will be resolved from the class (annotation or default one)
  • if scope type is missing, it will be resolved from the class (annotation or default one)


  • definePetiteBean

    protected void definePetiteBean(java.lang.String name,
                                    java.lang.Class type,
                                    java.lang.Class<? extends Scope> scopeType,
                                    WiringMode wiringMode)
    Single point of bean definition.


    removeBeanDefinition

    protected BeanDefinition removeBeanDefinition(java.lang.String name)
    Removes bean and returns definition of removed bean. All resolvers references are deleted, too. Returns bean definition of removed bean or null.


    resolveBeanNamesForType

    protected java.lang.String[] resolveBeanNamesForType(java.lang.Class type)
    Resolve bean names for give type.


    registerPetiteCtorInjectionPoint

    protected void registerPetiteCtorInjectionPoint(java.lang.String beanName,
                                                    java.lang.Class[] paramTypes,
                                                    java.lang.String[] references)
    Single point of constructor injection point registration.


    registerPetitePropertyInjectionPoint

    protected void registerPetitePropertyInjectionPoint(java.lang.String beanName,
                                                        java.lang.String property,
                                                        java.lang.String reference)
    Single point of property injection point registration.


    registerPetiteSetInjectionPoint

    protected void registerPetiteSetInjectionPoint(java.lang.String beanName,
                                                   java.lang.String property)
    Single point of property injection point registration.


    registerPetiteMethodInjectionPoint

    protected void registerPetiteMethodInjectionPoint(java.lang.String beanName,
                                                      java.lang.String methodName,
                                                      java.lang.Class[] arguments,
                                                      java.lang.String[] references)
    Single point of method injection point registration.


    registerPetiteInitMethods

    protected void registerPetiteInitMethods(java.lang.String beanName,
                                             java.lang.String[] beforeMethodNames,
                                             java.lang.String[] afterMethodNames)
    Single point of init method registration.


    getTotalBeans

    public int getTotalBeans()
    Returns total number of registered beans.


    getTotalScopes

    public int getTotalScopes()
    Returns total number of used scopes.


    beansIterator

    public java.util.Iterator<BeanDefinition> beansIterator()
    Returns iterator over all registered beans.


    resolveCtorInjectionPoint

    protected CtorInjectionPoint resolveCtorInjectionPoint(java.lang.Class type)

    resolveDefaultCtorInjectionPoint

    protected CtorInjectionPoint resolveDefaultCtorInjectionPoint(java.lang.Class type)

    resolvePropertyInjectionPoint

    protected PropertyInjectionPoint[] resolvePropertyInjectionPoint(java.lang.Class type,
                                                                     boolean autowire)

    resolveCollectionInjectionPoint

    protected SetInjectionPoint[] resolveCollectionInjectionPoint(java.lang.Class type,
                                                                  boolean autowire)

    resolveMethodInjectionPoint

    protected MethodInjectionPoint[] resolveMethodInjectionPoint(java.lang.Class type)

    resolveInitMethods

    protected InitMethodPoint[] resolveInitMethods(java.lang.Object bean)

    defineParameter

    public void defineParameter(java.lang.String name,
                                java.lang.Object value)
    Defines new parameter. Parameters with same name will be replaced.


    getParameter

    public java.lang.Object getParameter(java.lang.String name)
    Returns defined parameter.


    resolveBeanParams

    protected java.lang.String[] resolveBeanParams(java.lang.String name,
                                                   boolean resolveReferenceParams)
    Prepares list of all bean parameters and optionally resolves inner references.



    Copyright © 2003-2011 Jodd Team