public abstract class BeanContainer
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected java.util.Map<java.lang.Class<?>,TypeMap<BeanBuilder<?>>> |
beanBuilders
bean 构建器
|
protected java.util.Map<java.lang.Class<?>,BeanExtractor<?>> |
beanExtractors
bean 提取器
|
protected java.util.Map<java.lang.Class<?>,TypeMap<BeanInjector<?>>> |
beanInjectors
bean 注入器
|
protected java.util.Map<java.lang.Class<?>,InterceptorEntity> |
beanInterceptors
bean 拦截器
|
protected java.util.concurrent.locks.ReentrantLock |
SYNC_LOCK |
构造器和说明 |
---|
BeanContainer(SolonApp app,
java.lang.ClassLoader classLoader,
Props props) |
限定符和类型 | 方法和说明 |
---|---|
AotCollector |
aot() |
SolonApp |
app() |
<T> T |
attachGet(java.lang.Class<T> clz)
附件获取
|
<T> T |
attachOf(java.lang.Class<T> clz,
java.util.function.Supplier<T> supplier)
附件
|
<T> void |
attachSet(java.lang.Class<T> clz,
T val)
附件设置
|
protected void |
beanBasePublish(BeanWrap wrap)
bean base type 发布(通知外部订阅者)
|
protected void |
beanBaseSubscribe(java.util.function.Consumer<BeanWrap> callback,
int index)
bean base type 订阅
|
protected void |
beanBindingSupT(java.lang.Class<?> clz,
BeanWrap bw)
尝试Bean的实现泛型接口类型绑定
|
<T extends java.lang.annotation.Annotation> |
beanBuilderAdd(java.lang.Class<T> annoClz,
BeanBuilder<T> builder)
添加构建处理
|
<T extends java.lang.annotation.Annotation> |
beanBuilderAdd(java.lang.Class<T> annoClz,
java.lang.Class<?> targetClz,
BeanBuilder<T> builder)
添加分类构建处理
|
<T extends java.lang.annotation.Annotation> |
beanExtractorAdd(java.lang.Class<T> annoClz,
BeanExtractor<T> extractor)
添加提取处理
|
boolean |
beanExtractorHas(java.lang.Class<? extends java.lang.annotation.Annotation> annoClz)
是否有提取处理
|
java.util.List<BeanWrap> |
beanFind(java.util.function.BiPredicate<java.lang.String,BeanWrap> condition)
查找bean包装
|
java.util.List<BeanWrap> |
beanFind(java.util.function.Predicate<BeanWrap> condition)
查找bean包装
|
void |
beanForeach(java.util.function.BiConsumer<java.lang.String,BeanWrap> action)
遍历bean库 (拿到的是bean包装)
|
void |
beanForeach(java.util.function.Consumer<BeanWrap> action)
遍历bean包装库
|
protected void |
beanHashPublish(java.lang.Object nameOrType,
BeanWrap wrap)
bean hash 发布(通知外部订阅者)
|
protected void |
beanHashSubscribe(java.lang.Object nameOrType,
java.util.function.Consumer<BeanWrap> callback)
bean hash 订阅
|
void |
beanInject(VarHolder vh,
java.lang.String name)
尝试变量注入 字段或参数
|
protected void |
beanInject(VarHolder vh,
java.lang.String name,
boolean required,
boolean autoRefreshed) |
<T extends java.lang.annotation.Annotation> |
beanInjectorAdd(java.lang.Class<T> annoClz,
BeanInjector<T> injector)
添加注入处理
|
<T extends java.lang.annotation.Annotation> |
beanInjectorAdd(java.lang.Class<T> annoClz,
java.lang.Class<?> targetClz,
BeanInjector<T> injector)
添加分类注入处理
|
protected void |
beanInjectProperties(java.lang.Class<?> clz,
java.lang.Object obj) |
<T extends java.lang.annotation.Annotation> |
beanInterceptorAdd(java.lang.Class<T> annoClz,
Interceptor interceptor)
添加拦截处理
|
<T extends java.lang.annotation.Annotation> |
beanInterceptorAdd(java.lang.Class<T> annoClz,
Interceptor interceptor,
int index)
添加拦截处理
|
<T extends java.lang.annotation.Annotation> |
beanInterceptorGet(java.lang.Class<T> annoClz)
获取拦截处理
|
boolean |
beanInterceptorHas(java.lang.reflect.AnnotatedElement ae)
是否有拦截处理
|
boolean |
beanInterceptorHas(java.lang.annotation.Annotation a)
是否有拦截处理
|
void |
beanRegister(BeanWrap bw,
java.lang.String name,
boolean typed)
尝试BEAN注册(按名字和类型存入容器;并进行类型映射)
|
protected void |
beanRegisterSupI(java.lang.Class<?> clz,
BeanWrap bw)
尝试Bean的实现接口类型注册
|
protected void |
beanStop0()
bean 停止(if Closeable)
|
Props |
cfg()
获取属性(写法上,更接近 Solon.cfg())
|
void |
clear() |
void |
copyTo(BeanContainer container)
容器能力制复到另一个容器
|
protected java.lang.String |
findConfigKey(java.lang.String name)
找到真实的name
|
<T> T |
getBean(java.lang.Class<T> type)
获取 Bean
|
<T> T |
getBean(java.lang.String name)
获取 Bean
|
<T> void |
getBeanAsync(java.lang.Class<T> type,
java.util.function.Consumer<T> callback)
异步获取 Bean
|
<T> void |
getBeanAsync(java.lang.String name,
java.util.function.Consumer<T> callback)
异步获取 Bean
|
<T> T |
getBeanOrNew(java.lang.Class<T> type)
获取 或创建 bean
|
<T> java.util.Map<java.lang.String,T> |
getBeansMapOfType(java.lang.Class<T> baseType)
获取某类型的 bean map
|
<T> java.util.Map<java.lang.String,T> |
getBeansMapOfType(java.lang.Class<T> baseType,
java.lang.String geneticName)
获取某类型的 bean map
|
<T> java.util.List<T> |
getBeansOfType(java.lang.Class<T> baseType)
获取某类型的 bean list
|
<T> java.util.List<T> |
getBeansOfType(java.lang.Class<T> baseType,
java.lang.String geneticName)
获取某类型的 bean list
|
java.lang.ClassLoader |
getClassLoader()
获取类加载器
|
BeanWrap |
getWrap(java.lang.Object nameOrType)
获取一个bean包装
|
void |
getWrapAsync(java.lang.Object nameOrType,
java.util.function.Consumer<BeanWrap> callback)
异步获取一个bean包装
|
java.util.List<BeanWrap> |
getWrapsOfType(java.lang.Class<?> baseType)
获取一个bean包装列表
|
boolean |
hasWrap(java.lang.Object nameOrType) |
abstract void |
lifecycle(int index,
int priority,
Lifecycle lifecycle)
添加生命周期 bean
|
abstract void |
lifecycle(int index,
Lifecycle lifecycle)
添加生命周期 bean
|
abstract void |
lifecycle(Lifecycle lifecycle)
添加生命周期 bean
|
void |
putWrap(java.lang.Class<?> type,
BeanWrap wrap)
存入到bean库(存入成功会进行通知)
|
void |
putWrap(java.lang.String name,
BeanWrap wrap)
存入bean库(存入成功会进行通知)
|
void |
removeWrap(java.lang.Class<?> type)
删除 bean 包装
|
void |
removeWrap(java.lang.String name)
删除 bean 包装
|
<T> void |
subBeansOfType(java.lang.Class<T> baseType,
java.util.function.Consumer<T> callback)
订阅某类型的 Bean
|
void |
subWrapsOfType(java.lang.Class<?> baseType,
java.util.function.Consumer<BeanWrap> callback)
订阅某类型的 bean 包装
|
void |
subWrapsOfType(java.lang.Class<?> baseType,
java.util.function.Consumer<BeanWrap> callback,
int index)
订阅某类型的 bean 包装
|
BeanWrap |
wrap(java.lang.Class<?> type)
包装
|
BeanWrap |
wrap(java.lang.Class<?> type,
java.lang.Object bean)
包装
|
BeanWrap |
wrap(java.lang.Class<?> type,
java.lang.Object bean,
boolean typed)
包装
|
BeanWrap |
wrap(java.lang.String name,
java.lang.Class<?> clz)
包装
|
BeanWrap |
wrap(java.lang.String name,
java.lang.Class<?> clz,
boolean typed)
包装
|
BeanWrap |
wrap(java.lang.String name,
java.lang.Object bean)
包装
|
BeanWrap |
wrap(java.lang.String name,
java.lang.Object bean,
boolean typed)
包装
|
BeanWrap |
wrapAndPut(java.lang.Class<?> type)
包装并推入
|
BeanWrap |
wrapAndPut(java.lang.Class<?> type,
java.lang.Object bean)
包装并推入
|
BeanWrap |
wrapAndPut(java.lang.Class<?> type,
java.lang.Object bean,
boolean typed)
包装并推入
|
BeanWrap |
wrapAndPut(java.lang.String name,
java.lang.Object bean)
包装并推入
|
BeanWrap |
wrapAndPut(java.lang.String name,
java.lang.Object bean,
boolean typed)
包装并推入
|
protected abstract BeanWrap |
wrapCreate(java.lang.Class<?> type,
java.lang.Object bean,
java.lang.String name,
boolean typed) |
void |
wrapPublish(BeanWrap wrap)
wrap 发布,偏向对外 (只支持 @Bean 和 @Component 的 wrap)
|
protected final java.util.concurrent.locks.ReentrantLock SYNC_LOCK
protected final java.util.Map<java.lang.Class<?>,TypeMap<BeanBuilder<?>>> beanBuilders
protected final java.util.Map<java.lang.Class<?>,TypeMap<BeanInjector<?>>> beanInjectors
protected final java.util.Map<java.lang.Class<?>,BeanExtractor<?>> beanExtractors
protected final java.util.Map<java.lang.Class<?>,InterceptorEntity> beanInterceptors
public SolonApp app()
public Props cfg()
public AotCollector aot()
public <T> T attachGet(java.lang.Class<T> clz)
public <T> void attachSet(java.lang.Class<T> clz, T val)
public <T> T attachOf(java.lang.Class<T> clz, java.util.function.Supplier<T> supplier)
public java.lang.ClassLoader getClassLoader()
public void clear()
public void copyTo(BeanContainer container)
public <T extends java.lang.annotation.Annotation> void beanBuilderAdd(java.lang.Class<T> annoClz, BeanBuilder<T> builder)
annoClz
- 注解类型builder
- 构建器public <T extends java.lang.annotation.Annotation> void beanBuilderAdd(java.lang.Class<T> annoClz, java.lang.Class<?> targetClz, BeanBuilder<T> builder)
annoClz
- 注解类型targetClz
- 构建目标类型builder
- 构建器public <T extends java.lang.annotation.Annotation> void beanInjectorAdd(java.lang.Class<T> annoClz, BeanInjector<T> injector)
public <T extends java.lang.annotation.Annotation> void beanInjectorAdd(java.lang.Class<T> annoClz, java.lang.Class<?> targetClz, BeanInjector<T> injector)
annoClz
- 注解类型targetClz
- 注入目标类型injector
- 注入器public <T extends java.lang.annotation.Annotation> void beanExtractorAdd(java.lang.Class<T> annoClz, BeanExtractor<T> extractor)
public boolean beanExtractorHas(java.lang.Class<? extends java.lang.annotation.Annotation> annoClz)
public <T extends java.lang.annotation.Annotation> void beanInterceptorAdd(java.lang.Class<T> annoClz, Interceptor interceptor, int index)
index
- 执行顺序public <T extends java.lang.annotation.Annotation> void beanInterceptorAdd(java.lang.Class<T> annoClz, Interceptor interceptor)
public <T extends java.lang.annotation.Annotation> InterceptorEntity beanInterceptorGet(java.lang.Class<T> annoClz)
public boolean beanInterceptorHas(java.lang.reflect.AnnotatedElement ae)
public boolean beanInterceptorHas(java.lang.annotation.Annotation a)
protected void beanHashSubscribe(java.lang.Object nameOrType, java.util.function.Consumer<BeanWrap> callback)
protected void beanBaseSubscribe(java.util.function.Consumer<BeanWrap> callback, int index)
protected void beanHashPublish(java.lang.Object nameOrType, BeanWrap wrap)
protected void beanBasePublish(BeanWrap wrap)
public void wrapPublish(BeanWrap wrap)
public void removeWrap(java.lang.String name)
public void removeWrap(java.lang.Class<?> type)
public void putWrap(java.lang.String name, BeanWrap wrap)
wrap
- 如果raw为null,拒绝注册public void putWrap(java.lang.Class<?> type, BeanWrap wrap)
wrap
- 如果raw为null,拒绝注册public boolean hasWrap(java.lang.Object nameOrType)
public BeanWrap getWrap(java.lang.Object nameOrType)
nameOrType
- bean name or typepublic java.util.List<BeanWrap> getWrapsOfType(java.lang.Class<?> baseType)
baseType
- 基类public void getWrapAsync(java.lang.Object nameOrType, java.util.function.Consumer<BeanWrap> callback)
nameOrType
- bean name or typepublic void subWrapsOfType(java.lang.Class<?> baseType, java.util.function.Consumer<BeanWrap> callback)
baseType
- 基类public void subWrapsOfType(java.lang.Class<?> baseType, java.util.function.Consumer<BeanWrap> callback, int index)
baseType
- 基类public <T> T getBean(java.lang.String name)
name
- 名字public <T> T getBean(java.lang.Class<T> type)
type
- 类型public <T> java.util.List<T> getBeansOfType(java.lang.Class<T> baseType)
baseType
- 基类public <T> java.util.List<T> getBeansOfType(java.lang.Class<T> baseType, java.lang.String geneticName)
baseType
- 基类geneticName
- 泛型名public <T> java.util.Map<java.lang.String,T> getBeansMapOfType(java.lang.Class<T> baseType)
baseType
- 基类public <T> java.util.Map<java.lang.String,T> getBeansMapOfType(java.lang.Class<T> baseType, java.lang.String geneticName)
baseType
- 基类geneticName
- 泛型名public <T> T getBeanOrNew(java.lang.Class<T> type)
type
- 类型public <T> void getBeanAsync(java.lang.String name, java.util.function.Consumer<T> callback)
name
- 名字public <T> void getBeanAsync(java.lang.Class<T> type, java.util.function.Consumer<T> callback)
type
- 类型public <T> void subBeansOfType(java.lang.Class<T> baseType, java.util.function.Consumer<T> callback)
baseType
- 基类public BeanWrap wrap(java.lang.Class<?> type)
public BeanWrap wrap(java.lang.Class<?> type, java.lang.Object bean)
public BeanWrap wrap(java.lang.Class<?> type, java.lang.Object bean, boolean typed)
public BeanWrap wrap(java.lang.String name, java.lang.Object bean)
public BeanWrap wrap(java.lang.String name, java.lang.Object bean, boolean typed)
public BeanWrap wrap(java.lang.String name, java.lang.Class<?> clz)
public BeanWrap wrap(java.lang.String name, java.lang.Class<?> clz, boolean typed)
public BeanWrap wrapAndPut(java.lang.Class<?> type)
public BeanWrap wrapAndPut(java.lang.Class<?> type, java.lang.Object bean)
public BeanWrap wrapAndPut(java.lang.Class<?> type, java.lang.Object bean, boolean typed)
public BeanWrap wrapAndPut(java.lang.String name, java.lang.Object bean)
public BeanWrap wrapAndPut(java.lang.String name, java.lang.Object bean, boolean typed)
protected abstract BeanWrap wrapCreate(java.lang.Class<?> type, java.lang.Object bean, java.lang.String name, boolean typed)
public void beanRegister(BeanWrap bw, java.lang.String name, boolean typed)
protected void beanRegisterSupI(java.lang.Class<?> clz, BeanWrap bw)
protected void beanBindingSupT(java.lang.Class<?> clz, BeanWrap bw)
public void beanInject(VarHolder vh, java.lang.String name)
vh
- 变量包装器name
- 名字(bean name || config ${name})protected void beanInject(VarHolder vh, java.lang.String name, boolean required, boolean autoRefreshed)
protected void beanInjectProperties(java.lang.Class<?> clz, java.lang.Object obj)
protected java.lang.String findConfigKey(java.lang.String name)
name
- 原始name,${a:${b:3}}public abstract void lifecycle(Lifecycle lifecycle)
public abstract void lifecycle(int index, Lifecycle lifecycle)
index
- 顺序public abstract void lifecycle(int index, int priority, Lifecycle lifecycle)
index
- 顺序priority
- 优先级(此处,相当于二级顺序)public void beanForeach(java.util.function.BiConsumer<java.lang.String,BeanWrap> action)
public void beanForeach(java.util.function.Consumer<BeanWrap> action)
public java.util.List<BeanWrap> beanFind(java.util.function.BiPredicate<java.lang.String,BeanWrap> condition)
public java.util.List<BeanWrap> beanFind(java.util.function.Predicate<BeanWrap> condition)
protected void beanStop0()