spring整合RMIscriptfunction StorePage(){ddocumenttd.selection?(d.selection.type!None?d.sele
spring整合RMI
<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
}
public void doOtherService(int other) {
// bla.. bla
}
}
接下来在伺服端,您只要在Bean定义档中定义,让Spring管理、生成Bean,即可注册、启动RMI服务,例如:?
rmi-server.xml <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="someService"
encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="someServiceProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> <property name="serviceUrl"> <value>rmi://localhost/SomeService</value> </property> <property name="serviceInterface"> <value>onlyfun.caterpillar.ISomeService</value> </property> </bean></beans>
?
以下是个简单的客户端呼叫远程服务的例子:
?
....
ApplicationContext context =
new FileSystemXmlApplicationContext("rmi-client.xml");
ISomeService service = (ISomeService) context.getBean("someServiceProxy");
String result = service.doSomeService("Some request");
System.out.println(result);
....
?
?