<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-109  評論-187  文章-25  trackbacks-0

    1

    Package

    net.loocky.rmi.spring

    |-------BusinessService.java

    |-------Service.java

    |-------ServiceClient.java

    |-------ServiceImpl.java

    |-------ServiceServer.java

    |-------rmi-config.xml

    ?

    (1)??? Service.java? is interface

    package net.loocky.rmi.spring;

    ?

    import java.rmi.Remote;

    import java.rmi.RemoteException;

    ?

    ?

    public interface Service? extends Remote{

    ?

    ?????? public String getName()throws RemoteException ;

    ?

    ?????? public void setName(String name)throws RemoteException ;

    ?

    }

    (2)??? BusinessService.java is business interface too ,not extends remote

    package net.loocky.rmi.spring;

    public interface BusinessService {

    ?????? public String getName() ;

    ?

    ?????? public void setName(String name);

    }

    (3)??? ServiceImpl

    package net.loocky.rmi.spring;

    ?

    public class ServiceImpl implements Service, BusinessService {

    ?????? private String name = "111";

    ?

    ?????? public String getName() {

    ????????????? System.out.println(name);

    ????????????? return name;

    ?????? }

    ?

    ?????? public void setName(String name) {

    ????????????? this.name = name;

    ?

    ?????? }

    ?

    }

    (4)??? ServiceServer

    package net.loocky.rmi.spring;

    ?

    import org.springframework.context.ApplicationContext;

    import org.springframework.context.support.ClassPathXmlApplicationContext;

    ?

    public class ServiceServer {

    ?????? public static void main(String[] args) throws Exception {

    ????????????? //load the config file ,and spring will deploy the service automatically

    ????????????? ApplicationContext ctx = new ClassPathXmlApplicationContext(

    ??????????????????????????? "rmi-config.xml");

    ?????? }

    }

    (5)??? ServiceClient

    package net.loocky.rmi.spring;

    ?

    import org.springframework.context.ApplicationContext;

    import org.springframework.context.support.ClassPathXmlApplicationContext;

    ?

    public class ServiceClient {

    ?????? public static void main(String[] args) throws Exception {

    ????????????? // HessianProxyFactory proxyFactory = new HessianProxyFactory();

    ????????????? ApplicationContext ctx = new ClassPathXmlApplicationContext(

    ??????????????????????????? "rmi-config.xml");

    ????????????? BusinessService service = (BusinessService) ctx

    ??????????????????????????? .getBean("myServiceClient");

    ?????? // 下面的方式是不可行的,因為 SPRING 的, CGLIB enhance 了對象

    // BusinessService service =

    ????????????? // (BusinessService)Naming.lookup("rmi://localhost:1099/aaaa");

    ????????????? // service.setName("sssssssssssssss");

    ????????????? System.out.println(service.getName());

    ?????? }

    ?

    }

    (6)??? rmi-config.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 = "myService" class = "net.loocky.rmi.spring.ServiceImpl" />

    ??? < bean id = "serviceExporter" class = "org.springframework.remoting.rmi.RmiServiceExporter" >

    ??????? < property name = "serviceName" >

    ??????????? < value > aaaa </ value >

    ??????? </ property >

    ??????? < property name = "service" >

    ??????? ???? < ref bean = "myService" />

    ??????? </ property >

    ??????? < property name = "serviceInterface" >

    ??????????? < value > net.loocky.rmi.spring.BusinessService </ value >

    ??????? </ property >

    ??????? < property name = "registryPort" >

    ??????????? < value > 1099 </ value >

    ??????? </ property >

    ??? </ bean >

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

    ?????? < property name = "serviceUrl" >

    ?????????? < value > rmi://127.0.0.1:1099/aaaa </ value >

    ?????? </ property >

    ?????? < property name = "serviceInterface" >

    ?????????? < value > net.loocky.rmi.spring.BusinessService </ value >

    ?????? </ property >

    ?

    ??? </ bean >

    </ beans >

    ?

    ?

    posted on 2006-05-29 14:45 小小程序程序員混口飯吃 閱讀(692) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 亚洲国产精品日韩av不卡在线| 国产亚洲人成网站观看| 亚洲综合色区中文字幕| 四虎影视成人永久免费观看视频| 国产亚洲色视频在线| 久久国产乱子伦精品免费午夜| 亚洲精品国产高清嫩草影院| 青娱乐在线免费观看视频| 亚洲国产成人精品女人久久久| 西西人体大胆免费视频| 亚洲AV日韩精品一区二区三区| 免费无码午夜福利片| 自拍偷自拍亚洲精品情侣| baoyu122.永久免费视频| 亚洲国产综合专区电影在线| 91久久青青草原线免费| 亚洲国产综合在线| 午夜神器成在线人成在线人免费| 亚洲国产精品99久久久久久| 亚洲成人影院在线观看| 91国内免费在线视频| 亚洲毛片免费观看| 四虎成人精品一区二区免费网站 | a级毛片毛片免费观看久潮喷| 国产V亚洲V天堂A无码| 曰批全过程免费视频网址| 亚洲综合色婷婷在线观看| 免费看一级做a爰片久久| 中国一级全黄的免费观看| 亚洲无砖砖区免费| 免费一级特黄特色大片在线观看 | 麻豆安全免费网址入口| 亚洲愉拍99热成人精品热久久 | 亚洲人成片在线观看| 国产一级理论免费版| 美女在线视频观看影院免费天天看 | 国产乱弄免费视频| 国产精品网站在线观看免费传媒| 亚洲噜噜噜噜噜影院在线播放 | 久久精品国产亚洲7777| 亚洲视频免费播放|