Spring&Hession 整合

Spring 是常见的Java bean 容器
Hession 是一个RPC通信框架,效率虽然不如thrift和Google Protocol Buffer,但是比较容易上手
配置情况如下(基于tomcat容器)
Server:
tomcat-web.xml
<servlet>
          <servlet-name>userStarReadServiceExporter</servlet-name>
          <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
</servlet>
<context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>
          classpath:conf/applicationContext*.xml
     </param-value>
</context-param>

<listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

applicationcontext.xml  
<bean id="userStarReadService" class="com.******.impl.StarReadServiceImpl">
     <property name="manager" ref="userStarManager" />
</bean>
 
<!-- hessain service api exporter -->
<bean name="userStarReadServiceExporter" class="org.springframework.remoting.caucho.HessianServiceExporter">
     <property name="service" ref="userStarReadService"/>
     <property name="serviceInterface" value="com.******.IStarReadService"/>
</bean>


client:
userService = (IUserService) new ZhishiHessianProxyFactory(timeoutInMillis, timeoutInMillis).create(IUserService.class, url);





你可能感兴趣的:(java,spring,tomcat,hession)