public abstract class PetiteBeans
extends java.lang.Object
Petite Container
.
Holds beans and scopes definitions.Modifier and Type | Field and Description |
---|---|
protected AnnotationResolver |
annotationResolver |
protected TypeCache<java.lang.String[]> |
beanCollections
Map of all bean collections.
|
protected java.util.Map<java.lang.String,BeanDefinition> |
beans
Map of all beans definitions.
|
protected java.util.Map<java.lang.String,BeanDefinition> |
beansAlt
Map of alternative beans names.
|
protected TypeCache<BeanDefinition> |
externalsCache
Cache used for storing the internals about the external types that are not
registered withing the container.
|
protected ParamManager |
paramManager
|
protected PetiteConfig |
petiteConfig
|
protected PetiteResolvers |
petiteResolvers
|
protected java.util.Map<java.lang.String,ProviderDefinition> |
providers
Map of all providers.
|
protected ReferencesResolver |
referencesResolver
|
protected TypeCache<Scope> |
scopes
Map of all bean scopes.
|
Modifier | Constructor and Description |
---|---|
protected |
PetiteBeans(PetiteConfig petiteConfig) |
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.String> |
beanNames()
Returns set of all bean names.
|
int |
beansCount()
Returns total number of registered beans.
|
PetiteConfig |
config()
Returns
Petite configuration . |
protected <T> BeanDefinition |
createBeandDefinitionForExternalBeans(java.lang.Class<T> type,
WiringMode wiringMode)
Creates
BeanDefinition for all external beans. |
protected <T> BeanDefinition |
createBeanDefinitionForRegistration(java.lang.String name,
java.lang.Class<T> type,
Scope scope,
WiringMode wiringMode,
java.util.function.Consumer<T> consumer)
Creates
BeanDefinition on
bean registration . |
void |
defineParameter(java.lang.String name,
java.lang.Object value)
Defines new parameter.
|
void |
defineParameters(java.util.Map<?,?> properties)
Defines many parameters at once.
|
void |
defineParameters(Props props)
Defines many parameters at once from
Props . |
void |
forEachBean(java.util.function.Consumer<BeanDefinition> beanDefinitionConsumer)
Iterates all beans.
|
void |
forEachBeanType(java.lang.Class type,
java.util.function.Consumer<java.lang.String> beanNameConsumer)
Iterates all beans that are of given type.
|
java.lang.Object |
getParameter(java.lang.String name)
Returns defined parameter.
|
boolean |
isBeanNameRegistered(java.lang.String name)
Returns
true if bean name is registered. |
BeanDefinition |
lookupBeanDefinition(java.lang.String name)
Lookups for
bean definition . |
protected BeanDefinition |
lookupBeanDefinitions(BeanReferences beanReferences)
Lookups for first founded
bean definition . |
protected BeanDefinition |
lookupExistingBeanDefinition(java.lang.String name)
Lookups for existing
bean definition . |
ParamManager |
paramManager()
Returns parameter manager.
|
protected void |
registerBean(java.lang.String name,
BeanDefinition beanDefinition)
Registers bean definition by putting it in the beans map.
|
BeanDefinition |
registerPetiteBean(java.lang.Class type)
Registers a bean using provided class that is annotated.
|
<T> BeanDefinition<T> |
registerPetiteBean(java.lang.Class<T> type,
java.util.function.Consumer<T> consumer)
Registers a bean using provided class that is annotated.
|
<T> BeanDefinition<T> |
registerPetiteBean(java.lang.Class<T> type,
java.lang.String name,
java.lang.Class<? extends Scope> scopeType,
WiringMode wiringMode,
boolean define,
java.util.function.Consumer<T> consumer)
Registers or defines a bean.
|
void |
registerPetiteCtorInjectionPoint(java.lang.String beanName,
java.lang.Class[] paramTypes,
java.lang.String[] references)
Registers constructor injection point.
|
void |
registerPetiteDestroyMethods(java.lang.String beanName,
java.lang.String... destroyMethodNames)
Registers destroy method.
|
void |
registerPetiteInitMethods(java.lang.String beanName,
InitMethodInvocationStrategy invocationStrategy,
java.lang.String... initMethodNames)
Registers init method.
|
void |
registerPetiteMethodInjectionPoint(java.lang.String beanName,
java.lang.String methodName,
java.lang.Class[] arguments,
java.lang.String[] references)
Registers method injection point.
|
void |
registerPetitePropertyInjectionPoint(java.lang.String beanName,
java.lang.String property,
java.lang.String reference)
Registers property injection point.
|
void |
registerPetiteProvider(java.lang.String providerName,
java.lang.Class type,
java.lang.String staticMethodName,
java.lang.Class[] arguments)
Registers static method provider.
|
void |
registerPetiteProvider(java.lang.String providerName,
java.lang.String beanName,
java.lang.String methodName,
java.lang.Class[] arguments)
Registers instance method provider.
|
void |
registerPetiteSetInjectionPoint(java.lang.String beanName,
java.lang.String property)
Registers set injection point.
|
void |
registerScope(java.lang.Class<? extends Scope> scopeType,
Scope scope)
Registers new scope.
|
void |
removeBean(java.lang.Class type)
Removes all petite beans of provided type.
|
BeanDefinition |
removeBean(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)
Resolves bean names for give type.
|
<S extends Scope> |
resolveScope(java.lang.Class<S> scopeType)
Resolves and registers scope from a scope type.
|
int |
scopesCount()
Returns total number of used scopes.
|
void |
setExternalsCache(TypeCache<BeanDefinition> typeCacheImplementation)
Sets the type of cache used for storing the configurations for external types that
are not part of the container.
|
protected final java.util.Map<java.lang.String,BeanDefinition> beans
protected final java.util.Map<java.lang.String,BeanDefinition> beansAlt
protected final java.util.Map<java.lang.String,ProviderDefinition> providers
protected final TypeCache<java.lang.String[]> beanCollections
protected TypeCache<BeanDefinition> externalsCache
protected final PetiteConfig petiteConfig
protected final ReferencesResolver referencesResolver
protected final PetiteResolvers petiteResolvers
protected final ParamManager paramManager
protected final AnnotationResolver annotationResolver
protected PetiteBeans(PetiteConfig petiteConfig)
public void setExternalsCache(TypeCache<BeanDefinition> typeCacheImplementation)
PetiteContainer.wire(Object)
and PetiteContainer.invokeMethod(Object, Method)
.public ParamManager paramManager()
public PetiteConfig config()
Petite configuration
.
All changes on config should be done before
beans registration process starts.public <S extends Scope> S resolveScope(java.lang.Class<S> scopeType)
public void registerScope(java.lang.Class<? extends Scope> scopeType, Scope scope)
public BeanDefinition lookupBeanDefinition(java.lang.String name)
bean definition
.
Returns null
if bean name doesn't exist.protected BeanDefinition lookupBeanDefinitions(BeanReferences beanReferences)
bean definition
.
Returns null
if none of the beans is found.protected BeanDefinition lookupExistingBeanDefinition(java.lang.String name)
bean definition
.
Throws exception if bean is not found.public boolean isBeanNameRegistered(java.lang.String name)
true
if bean name is registered.public java.lang.String resolveBeanName(java.lang.Class type)
protected <T> BeanDefinition createBeanDefinitionForRegistration(java.lang.String name, java.lang.Class<T> type, Scope scope, WiringMode wiringMode, java.util.function.Consumer<T> consumer)
BeanDefinition
on
bean registration
.
This is a hook for modifying the bean data, like passing proxifed class etc.
By default returns new instance of BeanDefinition
.protected <T> BeanDefinition createBeandDefinitionForExternalBeans(java.lang.Class<T> type, WiringMode wiringMode)
BeanDefinition
for all external beans.public BeanDefinition registerPetiteBean(java.lang.Class type)
public <T> BeanDefinition<T> registerPetiteBean(java.lang.Class<T> type, java.util.function.Consumer<T> consumer)
public <T> BeanDefinition<T> registerPetiteBean(java.lang.Class<T> type, java.lang.String name, java.lang.Class<? extends Scope> scopeType, WiringMode wiringMode, boolean define, java.util.function.Consumer<T> consumer)
type
- bean type, must be specifiedname
- bean name, if null
it will be resolved from the class (name or annotation)scopeType
- bean scope, if null
it will be resolved from the class (annotation or default one)wiringMode
- wiring mode, if null
it will be resolved from the class (annotation or default one)define
- when set to true
bean will be defined - all injection points will be set to noneprotected void registerBean(java.lang.String name, BeanDefinition beanDefinition)
public void removeBean(java.lang.Class type)
removeBean(String)
public BeanDefinition removeBean(java.lang.String name)
null
.protected java.lang.String[] resolveBeanNamesForType(java.lang.Class type)
public void registerPetiteCtorInjectionPoint(java.lang.String beanName, java.lang.Class[] paramTypes, java.lang.String[] references)
beanName
- bean nameparamTypes
- constructor parameter types, may be null
references
- references for argumentspublic void registerPetitePropertyInjectionPoint(java.lang.String beanName, java.lang.String property, java.lang.String reference)
beanName
- bean nameproperty
- property namereference
- explicit injection reference, may be null
public void registerPetiteSetInjectionPoint(java.lang.String beanName, java.lang.String property)
beanName
- bean nameproperty
- set property namepublic void registerPetiteMethodInjectionPoint(java.lang.String beanName, java.lang.String methodName, java.lang.Class[] arguments, java.lang.String[] references)
beanName
- bean namemethodName
- method namearguments
- method arguments, may be null
references
- injection referencespublic void registerPetiteInitMethods(java.lang.String beanName, InitMethodInvocationStrategy invocationStrategy, java.lang.String... initMethodNames)
beanName
- bean nameinvocationStrategy
- moment of invocationinitMethodNames
- init method namespublic void registerPetiteDestroyMethods(java.lang.String beanName, java.lang.String... destroyMethodNames)
beanName
- bean namedestroyMethodNames
- destroy method namespublic void registerPetiteProvider(java.lang.String providerName, java.lang.String beanName, java.lang.String methodName, java.lang.Class[] arguments)
providerName
- provider namebeanName
- bean namemethodName
- instance method namearguments
- method argument typespublic void registerPetiteProvider(java.lang.String providerName, java.lang.Class type, java.lang.String staticMethodName, java.lang.Class[] arguments)
providerName
- provider nametype
- class typestaticMethodName
- static method namearguments
- method argument typespublic int beansCount()
public int scopesCount()
public java.util.Set<java.lang.String> beanNames()
public void forEachBean(java.util.function.Consumer<BeanDefinition> beanDefinitionConsumer)
snapshot of bean names
.public void forEachBeanType(java.lang.Class type, java.util.function.Consumer<java.lang.String> beanNameConsumer)
public void defineParameter(java.lang.String name, java.lang.Object value)
public java.lang.Object getParameter(java.lang.String name)
public void defineParameters(java.util.Map<?,?> properties)
Copyright © 2003-present Jodd Team