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

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

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

    隨筆-109  評(píng)論-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");

    ?????? // 下面的方式是不可行的,因?yàn)?/span> SPRING 的, CGLIB enhance 了對(duì)象

    // 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) 評(píng)論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 久久久久久亚洲AV无码专区| 亚洲视频一区网站| 久久久久免费精品国产| 亚洲精品视频在线播放| 永久黄网站色视频免费| 久久久久久久久久免免费精品| 亚洲嫩草影院久久精品| 好吊妞998视频免费观看在线| 一区二区免费电影| 亚洲日韩在线视频| 亚洲乱码中文字幕手机在线 | 亚洲色欲www综合网| 午夜免费不卡毛片完整版| 久青草视频在线观看免费| 亚洲国产人成在线观看| 亚洲精品无码AV中文字幕电影网站 | 亚洲三级中文字幕| 亚洲中文字幕无码久久精品1| 欧美最猛性xxxxx免费| 久久免费99精品国产自在现线| 亚洲精品123区在线观看| 国产亚洲精AA在线观看SEE| 成年女人毛片免费观看97| 国产一区二区三区免费观在线| 伊人久久五月丁香综合中文亚洲| 亚洲线精品一区二区三区影音先锋| 成人超污免费网站在线看| 暖暖日本免费中文字幕| 免费在线观看亚洲| 亚洲av无码国产综合专区| 国产成人精品日本亚洲网站| 免费国产成人高清视频网站| 在线永久看片免费的视频| 精品无码国产污污污免费| 日本不卡免费新一区二区三区| 风间由美在线亚洲一区| 亚洲伦理一二三四| 亚洲Av无码精品色午夜| 中文字幕亚洲专区| 亚洲A∨精品一区二区三区| 韩国欧洲一级毛片免费|