Package jodd.petite
Class PetiteContainer
- java.lang.Object
-
- jodd.petite.PetiteBeans
-
- jodd.petite.PetiteContainer
-
- Direct Known Subclasses:
ProxettaAwarePetiteContainer
public class PetiteContainer extends PetiteBeans
Petite IOC container.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPETITE_CONTAINER_REF_NAMEPetite container reference name.protected ScopedProxyManagerscopedProxyManager-
Fields inherited from class jodd.petite.PetiteBeans
annotationResolver, beanCollections, beans, beansAlt, externalsCache, paramManager, petiteConfig, petiteResolvers, providers, referencesResolver, scopes
-
-
Constructor Summary
Constructors Constructor Description PetiteContainer()Creates new Petite container usingdefault configuration.PetiteContainer(PetiteConfig config)Creates new Petite container usingprovided configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBean(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.voidaddBean(java.lang.String name, java.lang.Object bean, WiringMode wiringMode)Adds object instance to the container as singleton bean.voidaddSelf()Adds self instance to the container so internal beans may fetch container for further usage.voidaddSelf(java.lang.String name)Adds self instance to the container so internal beans may fetch container for further usage.<E> EcreateBean(java.lang.Class<E> type)Creates and wires a bean within the container using default wiring mode and default init methods flag.<E> EcreateBean(java.lang.Class<E> type, WiringMode wiringMode)Creates and wires a bean within the container and optionally invokes init methods.PetiteRegistrycreateContainerRegistry()CreatesPetiteRegistryhelper tool for this container.<T> TgetBean(java.lang.Class<T> type)Returns Petite bean instance.<T> TgetBean(java.lang.String name)Returns Petite bean instance.protected java.lang.ObjectgetBean(BeanReferences beanReferences)Returns Petite bean instance named as one of the provided names.java.lang.ObjectgetBeanProperty(java.lang.String name)Returns petite bean property value.protected voidinitBeanDefinition(BeanDefinition def)Resolves and initializes bean definition.<T> TinvokeMethod(java.lang.Object bean, java.lang.reflect.Method method)Invokes the method of some bean with the container, when its parameters requires to be injected into.protected java.lang.ObjectinvokeProvider(ProviderDefinition provider)Invokes provider to get a bean.protected java.lang.ObjectlookupMixingScopedBean(BeanDefinition def, BeanReferences refNames)protected voidregisterBeanAndWireAndInjectParamsAndInvokeInitMethods(BeanData beanData)Wires bean, injects parameters and invokes init methods.voidsetBeanProperty(java.lang.String name, java.lang.Object value)Sets petite bean property.voidshutdown()Shutdowns container.voidwire(java.lang.Object bean)Wires provided bean with the container using default wiring mode.voidwire(java.lang.Object bean, WiringMode wiringMode)Wires provided bean with the container and optionally invokes init methods.-
Methods inherited from class jodd.petite.PetiteBeans
beanNames, beansCount, config, createBeandDefinitionForExternalBeans, createBeanDefinitionForRegistration, defineParameter, defineParameters, defineParameters, forEachBean, forEachBeanType, getParameter, isBeanNameRegistered, lookupBeanDefinition, lookupBeanDefinitions, lookupExistingBeanDefinition, paramManager, registerBean, registerPetiteBean, registerPetiteBean, registerPetiteBean, registerPetiteCtorInjectionPoint, registerPetiteDestroyMethods, registerPetiteInitMethods, registerPetiteMethodInjectionPoint, registerPetitePropertyInjectionPoint, registerPetiteProvider, registerPetiteProvider, registerPetiteSetInjectionPoint, registerScope, removeBean, removeBean, resolveBeanName, resolveBeanNamesForType, resolveScope, scopesCount, setExternalsCache
-
-
-
-
Field Detail
-
PETITE_CONTAINER_REF_NAME
public static final java.lang.String PETITE_CONTAINER_REF_NAME
Petite container reference name. Used when container itself is added as its bean.- See Also:
addSelf(),addSelf(String), Constant Field Values
-
scopedProxyManager
protected final ScopedProxyManager scopedProxyManager
-
-
Constructor Detail
-
PetiteContainer
public PetiteContainer()
Creates new Petite container usingdefault configuration.
-
PetiteContainer
public PetiteContainer(PetiteConfig config)
Creates new Petite container usingprovided configuration.
-
-
Method Detail
-
lookupMixingScopedBean
protected java.lang.Object lookupMixingScopedBean(BeanDefinition def, BeanReferences refNames)
-
getBean
public <T> T getBean(java.lang.Class<T> type)
Returns Petite bean instance. Bean name will be resolved from provided type.
-
getBean
protected java.lang.Object getBean(BeanReferences beanReferences)
Returns Petite bean instance named as one of the provided names. Returnsnullif bean is not found.
-
getBean
public <T> T 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)
-
initBeanDefinition
protected void initBeanDefinition(BeanDefinition def)
Resolves and initializes bean definition. May be called multiple times.
-
registerBeanAndWireAndInjectParamsAndInvokeInitMethods
protected void registerBeanAndWireAndInjectParamsAndInvokeInitMethods(BeanData beanData)
Wires bean, injects parameters and invokes init methods. Such a loooong name :)
-
wire
public void wire(java.lang.Object bean)
Wires provided bean with the container using default wiring mode. Bean is not registered withing container.
-
wire
public void wire(java.lang.Object bean, WiringMode wiringMode)Wires provided bean with the container and optionally invokes init methods. Bean is not registered withing container.
-
invokeMethod
public <T> T invokeMethod(java.lang.Object bean, java.lang.reflect.Method method)Invokes the method of some bean with the container, when its parameters requires to be injected into. The bean is not registered within container.
-
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)Creates and wires a bean within the container and optionally invokes init methods. However, bean is not registered.
-
invokeProvider
protected java.lang.Object invokeProvider(ProviderDefinition provider)
Invokes provider to get a bean.
-
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.
-
createContainerRegistry
public PetiteRegistry createContainerRegistry()
CreatesPetiteRegistryhelper tool for this container.
-
shutdown
public void shutdown()
Shutdowns container. After container is down, it can't be used anymore.
-
-