Spring 发布 RMI (客户端)

上一篇 / 下一篇  2008-04-28 22:45:55 / 个人分类:spring

客户端:

 

packageremote.rmi.client;

 

importremote.rmi.AccountService;

 

publicclassSimpleObject {

   privateAccountServiceaccountService;

 

   publicAccountService getAccountService() {

      returnaccountService;

   }

 

   publicvoidsetAccountService(AccountService accountService) {

      this.accountService= accountService;

   }

   

   

 

}

 

 

XML

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEbeansPUBLIC"-//SPRING//DTD BEAN 2.0//EN""http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

   <beanid="object"class="remote.rmi.client.SimpleObject">

      <propertyname="accountService">

          <reflocal="accountService"/>

      </property>

   </bean>

   

   <beanid="accountService"class="org.springframework.remoting.rmi.RmiProxyFactoryBean">

      <propertyname="serviceUrl"value="rmi://localhost:8080/AccountService"></property>

      <propertyname="serviceInterface"value="remote.rmi.AccountService"></property>

   </bean>

</beans>

 

 

packageremote.rmi.client;

 

importjava.rmi.RemoteException;

importorg.springframework.core.type.filter.TypeFilter;

 

importorg.springframework.context.ApplicationContext;

importorg.springframework.context.support.ClassPathXmlApplicationContext;

 

publicclassClient {

 

   /**

    *@paramargs

    */

   publicstaticvoidmain(String[] args) {

      //TODOAuto-generated method stub

      ApplicationContext context =newClassPathXmlApplicationContext(

             "/remote/rmi/client/client.xml");

 

      SimpleObject bject=(SimpleObject) context.getBean("object");

      try{

          object.getAccountService().getAccount("zhanghaijie");

      }catch(RemoteException e) {

          //TODOAuto-generated catch block

          e.printStackTrace();

      }

   }

 

}

 

 

启动客户端的Client

 


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-07-20  
  12345
6789101112
13141516171819
20212223242526
2728293031  

数据统计

  • 访问量: 206
  • 日志数: 11
  • 建立时间: 2007-12-21
  • 更新时间: 2008-05-17

RSS订阅

Open Toolbar