当前位置: 首页 > news >正文

b站破解2023免费版下载/seo挖关键词

b站破解2023免费版下载,seo挖关键词,广州设计网站建设,肥料网站建设 中企动力2019独角兽企业重金招聘Python工程师标准>>> Spring利用代理,完成RMI服务端和客户端的开发,可以使任意POJO的方法进行暴露 服务接口: package ch16.SimpleRMI; public interface HelloWorld { public String getMessage(); } 服…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Spring利用代理,完成RMI服务端和客户端的开发,可以使任意POJO的方法进行暴露

服务接口:

package ch16.SimpleRMI;

public interface HelloWorld {
   public String getMessage();
}

服务实现:

package ch16.SimpleRMI;

public class HelloWorldImpl implements HelloWorld {

    public String getMessage() {
        
        return "hello world";
    }

}

服务端配置文件:applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="helloWorldService" class="org.springframework.remoting.rmi.RmiServiceExporter">
  <property name="serviceName">
    <value>HelloWorld</value>
  </property>
  <property name="service">
    <bean class="ch16.SimpleRMI.HelloWorldImpl"/>
  </property>
  <property name="serviceInterface">
    <value>ch16.SimpleRMI.HelloWorld</value>
  </property>
  <property name="registryPort">
    <value>9000</value>
  </property>
  <property name="servicePort">
    <value>9001</value>
  </property>
  
</bean>
</beans>

客户端配置文件:applicationContext-client.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="helloworldService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
 <property name="serviceUrl">
   <value>rmi://localhost:9000/HelloWorld</value>
 </property>
 <property name="serviceInterface">
    <bean class="ch16.SimpleRMI.HelloWorld"></bean>
  </property>
</bean>

<bean id="helloworldClient" class="ch16.SimpleRMI.HelloWorldClient">
  <property name="helloworldService">
    <ref local="helloworldService"/>
  </property>
</bean>
</beans>


 

服务端测试代码:

运行后并没有立即退出,因为远程服务是运行在后台的,一直等待客户端的链接

package ch16.SimpleRMI;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("ch16/SimpleRMI/applicationContext.xml");
        System.out.println("host stated...");
    }

}

客户端:

package ch16.SimpleRMI;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloWorldClient {

    private HelloWorld helloworldService;
    public HelloWorld getHelloworldService() {
        return helloworldService;
    }
    public void setHelloworldService(HelloWorld helloworldService) {
        this.helloworldService = helloworldService;
    }
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("ch6/SimpleRMI/applicationContext-client.xml");
        HelloWorldClient helloWorldClient=(HelloWorldClient)context.getBean("helloworldClient");
        helloWorldClient.run();
    }
    public void run(){
        System.out.println(helloworldService.getMessage());
    }

}

运行后,可以看到后台打印出了,服务端输出的Hello World

 

---------------------------------------下面注释为qlp3643_1加-----------------------------------------------------

 

其中需要特别注别的是:

<property name="registryPort">
    <value>9000</value>
  </property>
  <property name="servicePort">
    <value>9001</value>
  </property>
注册端口:registryPort   注册端口是RMI注册远程服务的端口。

服务端口:servicePort    RMI的通讯需要的传送数据的端口。如果没有设置servicePort,则使用随机端口。

转载于:https://my.oschina.net/chendongj/blog/1547527

http://www.lbrq.cn/news/1255249.html

相关文章:

  • 重庆市建设厅官方网站/快手seo关键词优化
  • wordpress仿站主题/sem什么意思
  • 龙华三网合一网站建设/搜索引擎营销怎么做
  • 引流平台有哪些/优化营商环境发言稿
  • 青岛公司网站建设/石家庄网站建设方案优化
  • 室内设计网站免费素材/seo公司推广
  • 做期货苯乙烯的网站/网络营销推广的方法
  • dede网站备份/专业北京seo公司
  • 企业网站开源/黑帽seo工具
  • 上海市住宅建设发展中心网站/网站开发技术有哪些
  • 五g网络是哪个公司/seo门户网价格是多少钱
  • 影楼网站制作/南宁seo专员
  • 天津网站制作/西安百度爱采购推广
  • 江苏企业建站/郑州网站优化推广
  • 桐乡城市建设局网站/b站视频推广的方法有哪些
  • 烟台网站公众号制作/百度信息流优化
  • 个人网站在那建设/世界杯球队最新排名
  • 柳州城乡建设管理局网站/google play官网
  • 网站建设常用代码/网上国网app
  • 免费网站服务商/百度高级搜索
  • 贵阳网站建设设计/搜索引擎优化的报告
  • 花都网站建设公司怎么样/关键词挖掘
  • 网站地图灰色效果的怎么做的/营销网络怎么写
  • 廊坊头条新闻最新消息新闻/重庆seo网络推广平台
  • 酒店设计的网站建设/网站定制
  • 做代购的购物网站/bt兔子磁力天堂
  • 桂林新站优化/色盲怎么治疗
  • 生态环境工程公司网站建设/外贸网站谷歌seo
  • 个人网站怎样申请/seo全网营销公司
  • 小企业一键做网站/百度新闻发布
  • 字符串匹配--KMP算法
  • NLP——BERT模型全面解析:从基础架构到优化演进
  • kafka与其他消息队列(如 RabbitMQ, ActiveMQ)相比,有什么优缺点?
  • Nvidia Orin DK 刷机CUDA TensorRT+硬盘扩容+ROS+Realsense+OpenCV+Ollama+Yolo11 一站式解决方案
  • 高效离线转换方案:支持多任务并行处理
  • sc-atac的基础知识(0)