Spring讓Hessian變得不但強大
這個例子很簡單
整合以上篇Hello Hessian為基礎
一
jdk
順便說下
二
hessian
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
<bean id=
<bean name=
<property name=
<property name=
</bean>
</beans>
<?xml version=
<web
xmlns:xsi=
xsi:schemaLocation=
version=
<context
<param
<param
/WEB
</param
</context
<servlet>
<servlet
<servlet
<load
</servlet>
<servlet
<servlet
<url
</servlet
</web
陷阱
a)hessian
b)hessian
三
因為涉及到類加載順序問題
部署後
三
這次測試
package lavasoft
import com
import lavasoft
import
/**
* 客戶端調用(會依賴服務接口)
*
* @author leizhimin
*/
public class Client {
public static void main(String[] args) throws MalformedURLException {
String url = //localhost:
HessianProxyFactory factory = new HessianProxyFactory();
Hello hello = (Hello) factory
System
}
}
運行結果
Hello Hessian!
Process finished with exit code
還有一種測試方法
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
<property name=
<property name=
</bean>
</beans>
然後寫個測試類
package lavasoft
import lavasoft
import orgntext
import orgntext
/**
* Spring整合Hessian
*
* @author leizhimin
*/
public class TestClient {
public static void main(String[] args) {
try {
ApplicationContext context = new ClassPathXmlApplicationContext(
Hello hello = (Hello) context
System
}
catch (Exception e) {
e
}
}
}
運行結果
Hello Spring Hession!
Process finished with exit code
陷阱
整個工程所以依賴的包
log
spring
spring
spring
spring
spring
spring
spring
spring
spring
spring
spring
spring
spring
spring
hessian
aopalliance
commons
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28360.html