Alibaba HSF service – spring factory bean and proxy

HSF is the java RPC framework used in Alibaba, taobao/tmall. It has following bean definition and usage pattern.

spring xml bean definition file:

<bean id=”itemService” class=”com.taobao.hsf.app.spring.util.HSFSpringConsumerBean” init-method=”init”>
<property name=”interfaceName”  value=”com.alibaba.itemService” />
<property name=”version” value=”1.0.0.daily” /> <!– 日常1.0.0.daily,预发线上1.0.0 –>
</bean>

maven dependency:

<dependency>
<groupId>com.taobao.wireless</groupId>
<artifactId>wppjar</artifactId>
<version>1.3.2-SNAPSHOT</version>
</dependency>

Usage pattern:

import com.taobao.wireless.wpp.LbsPushService;

@autowired

ItemService service;

Item item = service.doService(xxx);

The basic idea is as follows:

  1. ItemService is the Interface for the RPC call
  2. com.taobao.hsf.app.spring.util.HSFSpringConsumerBean is the spring factory bean.
  3. When “service” instance is created by the factory bean, a “service” proxy bean is returned, i.e., the service instance is actually a proxy bean of ItemService interface.
  4. When service.doService(xxx) is called, the proxy bean will perform the real action of RPC, i.t., connection management, data serialization, etc.

 

 

 

Advertisements
Alibaba HSF service – spring factory bean and proxy

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s