ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Spring 发布 RMI (客户端)

Spring 发布 RMI (客户端)

原创 Linux操作系统 作者:seablue_xj 时间:2008-04-28 22:45:55 0 删除 编辑

客户端:

 

package remote.rmi.client;

 

import remote.rmi.AccountService;

 

public class SimpleObject {

    private AccountService accountService;

 

    public AccountService getAccountService() {

       return accountService;

    }

 

    public void setAccountService(AccountService accountService) {

       this.accountService = accountService;

    }

   

   

 

}

 

 

XML

xml version="1.0" encoding="UTF-8"?>

DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" >

<beans>

    <bean id="object" class="remote.rmi.client.SimpleObject">

       <property name="accountService">

           <ref local="accountService"/>

       property>

    bean>

   

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

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

       <property name="serviceInterface" value="remote.rmi.AccountService">property>

    bean>

beans>

 

 

package remote.rmi.client;

 

import java.rmi.RemoteException;

import org.springframework.core.type.filter.TypeFilter;

 

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

 

public class Client {

 

    /**

     * @param args

     */

    public static void main(String[] args) {

       // TODO Auto-generated method stub

       ApplicationContext context = new ClassPathXmlApplicationContext(

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

 

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

       try {

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

       } catch (RemoteException e) {

           // TODO Auto-generated catch block

           e.printStackTrace();

       }

    }

 

}

 

 

启动客户端的Client

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7528999/viewspace-255449/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: RSA加密
下一篇: spring 2.5 aop 1
请登录后发表评论 登录
全部评论

注册时间:2007-12-21

  • 博文量
    10
  • 访问量
    10912