public class InnerRsfApiBinder extends Object implements RsfApiBinder
RsfPublisher.ConfigurationBuilder<T>, RsfPublisher.FilterBindBuilder<T>, RsfPublisher.LinkedBuilder<T>, RsfPublisher.RegisterBuilder<T>
ApiBinder.InjectConstructorBindingBuilder<T>, ApiBinder.InjectPropertyBindingBuilder<T>, ApiBinder.LifeBindingBuilder<T>, ApiBinder.LinkedBindingBuilder<T>, ApiBinder.MetaDataBindingBuilder<T>, ApiBinder.NamedBindingBuilder<T>, ApiBinder.OptionPropertyBindingBuilder<T>, ApiBinder.ScopedBindingBuilder<T>, ApiBinder.TypeSupplierBindingBuilder<T>
Modifier | Constructor and Description |
---|---|
protected |
InnerRsfApiBinder(ApiBinder apiBinder,
RsfEnvironment rsfEnvironment) |
Modifier and Type | Method and Description |
---|---|
protected <T> RsfBindInfo<T> |
addService(net.hasor.rsf.container.ServiceDefine<T> serviceDefine) |
protected void |
addShareFilter(net.hasor.rsf.container.FilterDefine filterDefine) |
RsfPublisher |
bindFilter(String filterID,
BindInfo<RsfFilter> filterBindInfo)
添加全局的RsfFilter。
|
RsfPublisher |
bindFilter(String filterID,
Class<? extends RsfFilter> rsfFilterType)
添加全局的RsfFilter。
|
RsfPublisher |
bindFilter(String filterID,
RsfFilter instance)
添加全局的RsfFilter。
|
RsfPublisher |
bindFilter(String filterID,
Supplier<? extends RsfFilter> provider)
添加全局的RsfFilter。
|
void |
bindInterceptor(Predicate<Class<?>> matcherClass,
Predicate<Method> matcherMethod,
MethodInterceptor interceptor)
使用匹配器配置Aop。
|
void |
bindInterceptor(String matcherExpression,
MethodInterceptor interceptor)
使用表达式配置Aop。
|
<T extends Scope> |
bindScope(String scopeName,
Supplier<T> scopeSupplier)
注册作用域。
|
<T extends EventListener> |
bindSpiJudge(Class<T> spiType,
Supplier<SpiJudge> spiJudgeSupplier)
设置一个 SPI 仲裁,一个SPI只能注册一个仲裁
|
<T extends EventListener> |
bindSpiListener(Class<T> spiType,
Supplier<T> listener)
添加SPI监听器
|
<T> ApiBinder.NamedBindingBuilder<T> |
bindType(Class<T> type)
bind type to context , 通过返回的 Builder 可以对绑定进行后续更加细粒度的配置。
|
ApiBinder.LinkedBindingBuilder<PropertyDelegate> |
dynamicProperty(Predicate<Class<?>> matcherClass,
String propertyName,
Class<?> propertyType)
匹配类,将符合条件的 Bean 新增一个属性,该方法会生成属性对应的 get/set 方法。
|
ApiBinder.LinkedBindingBuilder<PropertyDelegate> |
dynamicReadOnlyProperty(Predicate<Class<?>> matcherClass,
String propertyName,
Class<?> propertyType)
匹配类,将符合条件的 Bean 新增一个只读属性,该方法会生成属性对应的 get 方法。
|
<T> List<BindInfo<T>> |
findBindingRegister(Class<T> bindType)
通过一个类型获取所有绑定该类型下的绑定信息。
|
<T> BindInfo<T> |
findBindingRegister(String withName,
Class<T> bindType)
通过一个类型获取所有绑定该类型下的绑定信息。
|
Set<Class<?>> |
findClass(Class<?> featureType)
在框架扫描包的范围内查找具有特征类集合(特征可以是继承的类、标记的注解)。
-- 该方法会放弃在匹配的过程中如果类无法被ClassLoader所加载的类。 |
Set<Class<?>> |
findClass(Class<?> featureType,
String... scanPackages)
在框架扫描包的范围内查找具有特征类集合(特征可以是继承的类、标记的注解)。
-- 该方法会放弃在匹配的过程中如果类无法被ClassLoader所加载的类。 |
Supplier<Scope> |
findScope(String scopeName)
根据名字查找作用域
|
<T> BindInfo<T> |
getBindInfo(Class<T> bindType)
根据ID获取
BindInfo |
<T> BindInfo<T> |
getBindInfo(String bindID)
根据ID获取
BindInfo |
RsfEnvironment |
getEnvironment()
|
ApiBinder |
installModule(Module... module)
安装其它插件。
|
boolean |
isSingleton(BindInfo<?> bindInfo)
是否为单例
|
boolean |
isSingleton(Class<?> targetType)
是否为单例
|
ApiBinder |
loadModule(Class<?> moduleType,
TypeSupplier typeSupplier)
加载带有 @DimModule 注解的类。
|
<T> RsfPublisher.ConfigurationBuilder<T> |
rsfService(BindInfo<T> bindInfo)
绑定一个类型到RSF环境。
|
<T> RsfPublisher.LinkedBuilder<T> |
rsfService(Class<T> type)
绑定一个类型到RSF环境。
|
<T> RsfPublisher.ConfigurationBuilder<T> |
rsfService(Class<T> type,
BindInfo<T> bindInfo)
绑定一个类型并且为这个类型指定一个实现类。开发者可以通过返回的 Builder 可以对绑定进行后续更加细粒度的绑定。
|
<T> RsfPublisher.ConfigurationBuilder<T> |
rsfService(Class<T> type,
Class<? extends T> implementation)
绑定一个类型并且为这个类型指定一个实现类。开发者可以通过返回的 Builder 可以对绑定进行后续更加细粒度的绑定。
|
<T> RsfPublisher.ConfigurationBuilder<T> |
rsfService(Class<T> type,
Supplier<T> provider)
绑定一个类型并且为这个类型指定一个Provider。开发者可以通过返回的 Builder 可以对绑定进行后续更加细粒度的绑定。
|
<T> RsfPublisher.ConfigurationBuilder<T> |
rsfService(Class<T> type,
T instance)
绑定一个类型并且为这个类型指定一个实例。开发者可以通过返回的 Builder 可以对绑定进行后续更加细粒度的绑定。
|
protected <T> Supplier<? extends T> |
toProvider(BindInfo<T> bindInfo) |
protected <T> Supplier<? extends T> |
toProvider(Class<T> bindInfo) |
<T extends ApiBinder> |
tryCast(Class<T> castApiBinder)
尝试把 ApiBinder 转换为另一个 ApiBinder(如果它支持)
tips: 如果不支持转换则返回空。 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bindFilter, bindFilter, bindFilter, bindFilter, rsfService, rsfService, rsfService, rsfService, rsfService
bindScope, bindScope, bindSpiJudge, bindSpiListener, bindType, bindType, bindType, bindType, bindType, bindType, bindType, findScope, getProvider, getProvider, lazyLoad, loadModule, loadModule, loadModule, loadSpiListener, loadSpiListener, loadSpiListener, loadSpiListener, onShutdown, onShutdown
protected InnerRsfApiBinder(ApiBinder apiBinder, RsfEnvironment rsfEnvironment)
protected <T> RsfBindInfo<T> addService(net.hasor.rsf.container.ServiceDefine<T> serviceDefine)
protected void addShareFilter(net.hasor.rsf.container.FilterDefine filterDefine)
public RsfEnvironment getEnvironment()
RsfApiBinder
getEnvironment
in interface ApiBinder
getEnvironment
in interface RsfApiBinder
getEnvironment
in interface RsfPublisher
RsfEnvironment
public <T> RsfPublisher.ConfigurationBuilder<T> rsfService(BindInfo<T> bindInfo)
RsfApiBinder
rsfService
in interface RsfApiBinder
bindInfo
- 服务类型public Set<Class<?>> findClass(Class<?> featureType)
ApiBinder
public Set<Class<?>> findClass(Class<?> featureType, String... scanPackages)
ApiBinder
public <T extends ApiBinder> T tryCast(Class<T> castApiBinder)
ApiBinder
public ApiBinder installModule(Module... module) throws Throwable
ApiBinder
installModule
in interface ApiBinder
module
- 新安装的插件Throwable
- 在执行loadModule方法期间发生异常的。Module.loadModule(ApiBinder)
public boolean isSingleton(BindInfo<?> bindInfo)
ApiBinder
isSingleton
in interface ApiBinder
public boolean isSingleton(Class<?> targetType)
ApiBinder
isSingleton
in interface ApiBinder
public ApiBinder loadModule(Class<?> moduleType, TypeSupplier typeSupplier)
ApiBinder
loadModule
in interface ApiBinder
public void bindInterceptor(String matcherExpression, MethodInterceptor interceptor)
ApiBinder
例:
格式:<返回值> <类名>.<方法名>(<参数签名列表>) * *.*() 匹配:任意无参方法 * *.*(*) 匹配:任意方法 * *.add*(*) 匹配:任意add开头的方法 * *.add*(*,*) 匹配:任意add开头并且具有两个参数的方法。 * net.test.hasor.*(*) 匹配:包“net.test.hasor”下的任意类,任意方法。 * net.test.hasor.add*(*) 匹配:包“net.test.hasor”下的任意类,任意add开头的方法。 java.lang.String *.*(*) 匹配:任意返回值为String类型的方法。
bindInterceptor
in interface ApiBinder
matcherExpression
- 格式为“<返回值> <类名>.<方法名>(<参数签名列表>)
”interceptor
- 拦截器对象public void bindInterceptor(Predicate<Class<?>> matcherClass, Predicate<Method> matcherMethod, MethodInterceptor interceptor)
ApiBinder
bindInterceptor
in interface ApiBinder
matcherClass
- 类型匹配器matcherMethod
- 方法匹配器interceptor
- 拦截器对象public ApiBinder.LinkedBindingBuilder<PropertyDelegate> dynamicProperty(Predicate<Class<?>> matcherClass, String propertyName, Class<?> propertyType)
ApiBinder
dynamicProperty
in interface ApiBinder
matcherClass
- 属性名propertyName
- 属性名propertyType
- 属性类型ApiBinder.LinkedBindingBuilder
。public ApiBinder.LinkedBindingBuilder<PropertyDelegate> dynamicReadOnlyProperty(Predicate<Class<?>> matcherClass, String propertyName, Class<?> propertyType)
ApiBinder
dynamicReadOnlyProperty
in interface ApiBinder
matcherClass
- 属性名propertyName
- 属性名propertyType
- 属性类型ApiBinder.LinkedBindingBuilder
。public <T> BindInfo<T> getBindInfo(String bindID)
ApiBinder
BindInfo
getBindInfo
in interface ApiBinder
public <T> BindInfo<T> getBindInfo(Class<T> bindType)
ApiBinder
BindInfo
getBindInfo
in interface ApiBinder
public <T> List<BindInfo<T>> findBindingRegister(Class<T> bindType)
ApiBinder
findBindingRegister
in interface ApiBinder
bindType
- bean typepublic <T> BindInfo<T> findBindingRegister(String withName, Class<T> bindType)
ApiBinder
findBindingRegister
in interface ApiBinder
withName
- 绑定名bindType
- bean typepublic <T> ApiBinder.NamedBindingBuilder<T> bindType(Class<T> type)
ApiBinder
-- ApiBinder.NamedBindingBuilder
类型,为绑定起名字。继承自:ApiBinder.LinkedBindingBuilder
-- ApiBinder.LinkedBindingBuilder
类型,为绑定设置实现方式。继承自:ApiBinder.InjectPropertyBindingBuilder
-- ApiBinder.InjectPropertyBindingBuilder
类型,为绑定设置注入属性。继承自:ApiBinder.LifeBindingBuilder
-- ApiBinder.LifeBindingBuilder
类型,为绑定设置生命周期方法配置。继承自:ApiBinder.ScopedBindingBuilder
-- ApiBinder.ScopedBindingBuilder
类型,为绑定设置作用域。继承自:ApiBinder.OptionPropertyBindingBuilder
-- ApiBinder.OptionPropertyBindingBuilder
类型,为绑定设置作用域。继承自:ApiBinder.MetaDataBindingBuilder
-- ApiBinder.MetaDataBindingBuilder
类型,绑定元信息配置。
bindType
in interface ApiBinder
type
- bean type。ApiBinder.NamedBindingBuilder
。public <T extends EventListener> void bindSpiListener(Class<T> spiType, Supplier<T> listener)
ApiBinder
bindSpiListener
in interface ApiBinder
public <T extends EventListener> void bindSpiJudge(Class<T> spiType, Supplier<SpiJudge> spiJudgeSupplier)
ApiBinder
bindSpiJudge
in interface ApiBinder
public <T extends Scope> Supplier<T> bindScope(String scopeName, Supplier<T> scopeSupplier)
ApiBinder
public Supplier<Scope> findScope(String scopeName)
ApiBinder
public RsfPublisher bindFilter(String filterID, RsfFilter instance)
RsfPublisher
bindFilter
in interface RsfPublisher
filterID
- filter IDinstance
- 过滤器实例public RsfPublisher bindFilter(String filterID, BindInfo<RsfFilter> filterBindInfo)
RsfPublisher
bindFilter
in interface RsfPublisher
filterID
- filter IDfilterBindInfo
- provider for RsfFilterpublic RsfPublisher bindFilter(String filterID, Class<? extends RsfFilter> rsfFilterType)
RsfPublisher
bindFilter
in interface RsfPublisher
filterID
- filter IDrsfFilterType
- type for RsfFilterpublic RsfPublisher bindFilter(String filterID, Supplier<? extends RsfFilter> provider)
RsfPublisher
bindFilter
in interface RsfPublisher
filterID
- filter IDprovider
- provider for RsfFilterpublic <T> RsfPublisher.LinkedBuilder<T> rsfService(Class<T> type)
RsfPublisher
rsfService
in interface RsfPublisher
type
- 服务类型RsfPublisher.LinkedBuilder
public <T> RsfPublisher.ConfigurationBuilder<T> rsfService(Class<T> type, T instance)
RsfPublisher
该方法相当于“rsfBinder.rsfService(type).toInstance(instance);
”
rsfService
in interface RsfPublisher
type
- 服务类型instance
- 为绑定指定的实例对象。RsfPublisher.ConfigurationBuilder
RsfPublisher.rsfService(Class)
public <T> RsfPublisher.ConfigurationBuilder<T> rsfService(Class<T> type, Class<? extends T> implementation)
RsfPublisher
该方法相当于“rsfBinder.rsfService(type).to(implementation);
”
rsfService
in interface RsfPublisher
type
- 服务类型implementation
- 为绑定指定的实现类。RsfPublisher.ConfigurationBuilder
RsfPublisher.rsfService(Class)
public <T> RsfPublisher.ConfigurationBuilder<T> rsfService(Class<T> type, Supplier<T> provider)
RsfPublisher
该方法相当于“rsfBinder.rsfService(type).toProvider(provider);
”
rsfService
in interface RsfPublisher
type
- 服务类型provider
- 为绑定指定的实现类。RsfPublisher.ConfigurationBuilder
RsfPublisher.rsfService(Class)
public <T> RsfPublisher.ConfigurationBuilder<T> rsfService(Class<T> type, BindInfo<T> bindInfo)
RsfPublisher
该方法相当于“rsfBinder.rsfService(type).toInfo(bindInfo);
”
rsfService
in interface RsfPublisher
type
- 服务类型bindInfo
- 为绑定指定的实现类。RsfPublisher.ConfigurationBuilder
RsfPublisher.rsfService(Class)
Copyright © 2020. All rights reserved.