发表于: 2018-09-10 23:22:14
1 424
今天完成的事情:
task7代码整理,提交任务,SpringRMI学习
明天计划的事情:
结合demo的代码对SpringRMI学习
遇到的问题:
收获:
1、task7代码中存在的问题
2、结合之前的简单demo,先拆分了任务二中代码中的Service,demo跑通,需要在进行学习;
整体结构
client:
server:
(1)将Service层以下的代码作为Server,通过xml文件将Service注册为可远程调用的服务;
applicationContext-bean.xml
<bean name="userServiceImpl" class="com.service.UserServiceImpl"/>
<bean name="userService" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service" ref="userServiceImpl"/>
<property name="serviceName" value="userService"/>
<property name="serviceInterface" value="com.service.UserService"/>
<property name="registryPort" value="1021"/>
</bean>
(2)Controller层和View层作为Client;其中的service层只提供接口,而具体的实现由上面正常启动的Server提供;applicationContext-rmi-client.xml-------相当于为Controller提供实现类的bean文件;
<bean name="userService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://127.0.0.1:1021/userService"/>
<property name="serviceInterface" value="com.service.UserService"/>
</bean>
原来web.xml中加载spring的上下文,替换为这个xml文件;
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-rmi-client.xml</param-value>
</context-param>
总体上对原来的代码改动不大;主要是上面两个xml文件的对应关系,来实现Client只需要写接口;从Server找相应的实现;
一个大致流程上的认识,结合代码再进行学习;
评论