使用:
在pom里面引入jsf的jar包。
<
dependency
>
<
groupId
>com.jd</
groupId
>
<
artifactId
>jsf</
artifactId
>
<
version
>最新版本</
version
>
</
dependency
>
|
如果需要发布Webservices,还得在项目中单独引入cxf的jar包。
如果需要发布Rest,还得在项目中单独引入resteasy相关的jar包
1.在服务端写杰夫接口模块和杰夫实现类模块,在服务端杰夫实现类模块配置文件配置好提供者并配置对杰夫接口的maven依赖。服务端接口(不是杰夫接口)所在项目打包后放到私服。(杰夫接口名有人以facade结尾命名)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jsf="http://jsf.jd.com/schema/jsf"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://jsf.jd.com/schema/jsf http://jsf.jd.com/schema/jsf/jsf.xsd" default-autowire="byName">
<!-- 服务端 -->
<jsf:server id="jsf" protocol="jsf"/>
<!-- jsf provider发生异常provider应用无异常信息问题处理-->
<jsf:filter id="logExceptionFilter" class="com.jd.ihhotel.jsf.exception.RpcExceptionFilter"
providers="*"/>(继承的公司的类,可不使用)
<!--JSF provider-->
<jsf:provider id="domesticOrderFacade"
interface="com.jd.ihhotel.jsf.api.service.DomesticOrderFacade"
alias="trip-ihhotel-man-order-test" ref="domesticOrderImpl" server="jsf"/>
<!--实现类-->
<bean id="domesticOrderImpl"
class="com.jd.ihhotel.jsf.service.impl.DomesticOrderImpl"/>
</beans>
2.消费端项目配置好对服务端杰夫接口模块的maven依赖后,在配置文件配置消费者即可,接口名和别名必须和服务端的一致。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jsf="http://jsf.jd.com/schema/jsf"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://jsf.jd.com/schema/jsf http://jsf.jd.com/schema/jsf/jsf.xsd" default-autowire="byName">
<jsf:consumer id="domesticOrderFacade"
interface="com.jd.ihhotel.jsf.api.service.DomesticOrderFacade"
protocol="jsf" alias="trip-ihhotel-man-order-test" timeout="5000"
retries="0">
</jsf:consumer>
</beans>
http://jpcloud.jd.com/pages/viewpage.action?pageId=10671259#JSF
3.引入杰夫配置文件:
<!-- jsf配置文件 --> <import resource="config/spring-jsf-client.xml"/> <import resource="config/spring-jsf-server.xml"/>当然服务端只需配一个,客户端配一个即可。除非即使客户端又是服务端。
请注意:服务匹配是依靠 interface(接口) 以及 alias(别名)两个配置来完成的;
也就是说调用端(Service Consumer)必须与服务端(Service Provider)的interface 与alias 属性配置必须完全一致,否则调用时会收到一个No Provider(没有服务提供者)的错误!
反过来依赖是因为权利问题?(jsf反过来依赖)