public class LoadBalanceProxyFactoryBean extends ServiceMultiInterfaceAccessor implements org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware
<bean id="lbRmiService" class="com.baidu.jprotobuf.pbrpc.client.ha.lb.LoadBalanceProxyFactoryBean">
<property name="serviceInterface" value="com.baidu.rigel.system.subsystem.submodule.service.TestService"></property>
<property name="extraInterfaces">
<list>
<value>com.baidu.rigel.service.remote.support.transaction.TransactionManager</value>
</list>
</property>
<property name="targetBeans">
<map key-type="java.lang.String">
<entry key="helloService1" value-ref="helloServiceClient" />
<entry key="helloService2" value-ref="helloServiceClient2" />
</map>
</property>
<property name="loadBalanceStrategy">
<bean class="com.baidu.jprotobuf.pbrpc.client.ha.lb.strategy.RoundRobinLoadBalanceStrategy">
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Integer">
<entry key="helloService1" value="1" />
<entry key="helloService2" value="1" />
</map>
</constructor-arg>
</bean>
</property>
<property name="failOverInterceptor">
<bean class="com.baidu.jprotobuf.pbrpc.client.ha.lb.failover.rmi.RmiFailOverInterceptor">
<property name="recoverServiceUrls">
<map key-type="java.lang.String">
<entry key="helloService1" value="rmi://localhost:1199/Service" />
<entry key="helloService2" value="rmi://localhost:1198/Service" />
</map>
</property>
</bean>
</property>
<property name="recoverInterval" value="1000"></property>
</bean>
| 限定符和类型 | 类和说明 |
|---|---|
static class |
LoadBalanceProxyFactoryBean.FactoryBeanInvokeInfo
The Class FactoryBeanInvokeInfo.
|
| 构造器和说明 |
|---|
LoadBalanceProxyFactoryBean() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addTargetBean(String key,
Object targetBean)
add target bean.
|
void |
afterPropertiesSet() |
void |
cleanResource(boolean needFreeThreadPool) |
void |
destroy() |
protected ClassLoader |
getBeanClassLoader()
Gets the bean class loader.
|
Map<String,LoadBalanceProxyFactoryBean.FactoryBeanInvokeInfo> |
getFailedFactoryBeans()
Gets the failed factory beans.
|
FailOverInterceptor |
getFailOverInterceptor()
Gets the fail over interceptor.
|
Object |
getObject() |
Class |
getObjectType() |
long |
getRecoverInterval()
Gets the recover interval.
|
boolean |
hasFactoryBeanFailed()
Checks for factory bean failed.
|
Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation) |
Object |
invokeWithMaxTry(org.aopalliance.intercept.MethodInvocation invocation,
int maxTry)
Invoke with max try.
|
boolean |
isFailOver()
Checks if is fail over.
|
protected boolean |
isHeartBeat()
Checks if is heart beat.
|
boolean |
isSingleton() |
void |
recoverFactoryBean(String key)
Recover factory bean.
|
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanName(String beanName) |
void |
setFailOverEvent(FailOverEvent failOverEvent)
Sets the fail over event.
|
void |
setFailOverInterceptor(FailOverInterceptor failOverInterceptor)
Sets the fail over interceptor.
|
void |
setHeartBeat(boolean heartBeat)
Sets the heart beat.
|
void |
setLoadBalanceStrategy(LoadBalanceStrategy loadBalanceStrategy)
Sets the load balance strategy.
|
void |
setRecoverInterval(long recoverInterval)
Sets the recover interval.
|
void |
setStrategyInterceptor(StrategyInterceptor strategyInterceptor)
Sets the strategy interceptor.
|
void |
setTargetBeans(Map<String,Object> targetFactoryBeans)
Sets the target beans.
|
getExtraInterfaces, getExtraServiceInterfaces, setExtraInterfacesgetServiceInterface, setServiceInterfacepublic void setFailOverEvent(FailOverEvent failOverEvent)
failOverEvent - the new fail over eventpublic void setTargetBeans(Map<String,Object> targetFactoryBeans)
targetFactoryBeans - the target factory beanspublic void addTargetBean(String key, Object targetBean)
key - the keytargetBean - the target beanpublic void setLoadBalanceStrategy(LoadBalanceStrategy loadBalanceStrategy)
loadBalanceStrategy - the new load balance strategypublic FailOverInterceptor getFailOverInterceptor()
public void setFailOverInterceptor(FailOverInterceptor failOverInterceptor)
failOverInterceptor - the new fail over interceptorpublic boolean isFailOver()
public void afterPropertiesSet()
throws Exception
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanExceptionpublic Object getObject()
getObject 在接口中 org.springframework.beans.factory.FactoryBeanpublic Class getObjectType()
getObjectType 在接口中 org.springframework.beans.factory.FactoryBeanpublic boolean isSingleton()
isSingleton 在接口中 org.springframework.beans.factory.FactoryBeanpublic void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader 在接口中 org.springframework.beans.factory.BeanClassLoaderAwareprotected ClassLoader getBeanClassLoader()
public Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
invoke 在接口中 org.aopalliance.intercept.MethodInterceptorThrowablepublic Object invokeWithMaxTry(org.aopalliance.intercept.MethodInvocation invocation, int maxTry) throws Throwable
invocation - the invocationmaxTry - the max tryThrowable - the throwablepublic Map<String,LoadBalanceProxyFactoryBean.FactoryBeanInvokeInfo> getFailedFactoryBeans()
public void recoverFactoryBean(String key)
key - the keypublic boolean hasFactoryBeanFailed()
public void destroy()
throws Exception
destroy 在接口中 org.springframework.beans.factory.DisposableBeanExceptionpublic void cleanResource(boolean needFreeThreadPool)
public void setStrategyInterceptor(StrategyInterceptor strategyInterceptor)
strategyInterceptor - the new strategy interceptorpublic void setRecoverInterval(long recoverInterval)
recoverInterval - the new recover intervalpublic long getRecoverInterval()
protected boolean isHeartBeat()
public void setHeartBeat(boolean heartBeat)
heartBeat - the new heart beatpublic void setBeanName(String beanName)
setBeanName 在接口中 org.springframework.beans.factory.BeanNameAwareCopyright © 2022 Baidu, Inc.. All rights reserved.