<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 小小程序程序員混口飯吃 閱讀(696) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 97视频免费在线| a毛片基地免费全部视频| 亚洲成色WWW久久网站| 国产精成人品日日拍夜夜免费| 亚洲日韩精品一区二区三区无码| 最近免费中文字幕MV在线视频3| 亚洲国产精品综合久久网各 | 无码人妻丰满熟妇区免费| 亚洲毛片基地4455ww| 久久精品国产亚洲7777| 黄色网址免费大全| 人人爽人人爽人人片av免费| 亚洲美女免费视频| 亚洲色偷拍区另类无码专区| 亚洲一级免费毛片| aa级女人大片喷水视频免费| 亚洲深深色噜噜狠狠网站| 亚洲人成网7777777国产| 女人与禽交视频免费看| 99在线热播精品免费99热| 亚洲中文字幕一区精品自拍| 亚洲国产精华液网站w| 国产又粗又长又硬免费视频| 精品熟女少妇av免费久久| 一级黄色片免费观看| 伊人久久五月丁香综合中文亚洲| 亚洲热线99精品视频| 国产大片免费观看中文字幕| 18禁无遮挡无码国产免费网站| WWW免费视频在线观看播放| 亚洲精品GV天堂无码男同| 在线观看亚洲一区二区| 亚洲日韩小电影在线观看| 日本一区免费电影| 久久久久久久免费视频| 99ee6热久久免费精品6| 91成人免费福利网站在线| 日韩免费高清一级毛片| 亚洲精品无码久久久久APP| 亚洲同性男gay网站在线观看| 久久噜噜噜久久亚洲va久|