类 ReferenceBean<T>
- java.lang.Object
-
- org.apache.dubbo.config.spring.ReferenceBean<T>
-
- 所有已实现的接口:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware
public class ReferenceBean<T> extends Object implements org.springframework.beans.factory.FactoryBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Spring FactoryBean for
Step 1: Register ReferenceBean in Java-config class:ReferenceConfig.@Configuration public class ReferenceConfiguration { @Bean @DubboReference(group = "demo") public ReferenceBean<HelloService> helloService() { return new ReferenceBean(); } // As GenericService @Bean @DubboReference(group = "demo", interfaceClass = HelloService.class) public ReferenceBean<GenericService> genericHelloService() { return new ReferenceBean(); } }Or register ReferenceBean in xml:<dubbo:reference id="helloService" interface="org.apache.dubbo.config.spring.api.HelloService"/> <!-- As GenericService --> <dubbo:reference id="genericHelloService" interface="org.apache.dubbo.config.spring.api.HelloService" generic="true"/>
Step 2: Inject ReferenceBean by @Autowiredpublic class FooController { @Autowired private HelloService helloService; @Autowired private GenericService genericHelloService; }
-
-
构造器概要
构造器 构造器 说明 ReferenceBean()ReferenceBean(Map<String,Object> referenceProps)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()voiddestroy()ClassgetActualInterface()StringgetGroup()StringgetId()Class<?>getInterfaceClass()StringgetKey()ObjectgetObject()Create bean instance.Class<?>getObjectType()org.springframework.beans.MutablePropertyValuesgetPropertyValues()ReferenceConfiggetReferenceConfig()Map<String,Object>getReferenceProps()StringgetVersion()booleanisSingleton()voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetBeanClassLoader(ClassLoader classLoader)voidsetBeanName(String name)voidsetId(String id)voidsetKeyAndReferenceConfig(String key, ReferenceConfig referenceConfig)
-
-
-
方法详细资料
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- 指定者:
setApplicationContext在接口中org.springframework.context.ApplicationContextAware
-
setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)
- 指定者:
setBeanClassLoader在接口中org.springframework.beans.factory.BeanClassLoaderAware
-
setBeanName
public void setBeanName(String name)
- 指定者:
setBeanName在接口中org.springframework.beans.factory.BeanNameAware
-
getObject
public Object getObject()
Create bean instance. When Spring searches beans by type, if Spring cannot determine the type of a factory bean, it may try to initialize it. The ReferenceBean is also a FactoryBean. In addition, if some ReferenceBeans are dependent on beans that are initialized very early, and dubbo config beans are not ready yet, there will be many unexpected problems if initializing the dubbo reference immediately. When it is initialized, only a lazy proxy object will be created, and dubbo reference-related resources will not be initialized.
In this way, the influence of Spring is eliminated, and the dubbo configuration initialization is controllable. Dubbo config beans are initialized in DubboConfigInitializationPostProcessor.
The actual references will be processing in DubboBootstrap.referServices().- 指定者:
getObject在接口中org.springframework.beans.factory.FactoryBean<T>- 另请参阅:
DubboConfigInitializationPostProcessor,DubboBootstrap
-
getObjectType
public Class<?> getObjectType()
- 指定者:
getObjectType在接口中org.springframework.beans.factory.FactoryBean<T>
-
isSingleton
@Parameter(excluded=true) public boolean isSingleton()
- 指定者:
isSingleton在接口中org.springframework.beans.factory.FactoryBean<T>
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- 指定者:
afterPropertiesSet在接口中org.springframework.beans.factory.InitializingBean- 抛出:
Exception
-
destroy
public void destroy()
- 指定者:
destroy在接口中org.springframework.beans.factory.DisposableBean
-
getId
public String getId()
-
setId
public void setId(String id)
-
getInterfaceClass
public Class<?> getInterfaceClass()
-
getActualInterface
public Class getActualInterface()
-
getGroup
public String getGroup()
-
getVersion
public String getVersion()
-
getKey
public String getKey()
-
getPropertyValues
public org.springframework.beans.MutablePropertyValues getPropertyValues()
-
getReferenceConfig
public ReferenceConfig getReferenceConfig()
-
setKeyAndReferenceConfig
public void setKeyAndReferenceConfig(String key, ReferenceConfig referenceConfig)
-
-