发表于: 2018-09-10 23:22:14

1 425


今天完成的事情:

task7代码整理,提交任务,SpringRMI学习

明天计划的事情:

结合demo的代码对SpringRMI学习

遇到的问题: 


收获:

1、task7代码中存在的问题

(1)restful风格接口
Integer type:约定1、2。。。
(2)code、message,Spring   统一管理
(3)绑定、修改手机号、邮箱之前要验证登录状态;
(4)使用较多的参数,设一个形参
代码重构
做任务过程中,从简单的demo到完成任务,代码在不断变得修改;应该先设计,在敲代码;但学习的过程中做不到;要完善的话,需要重构代码;
DB设计:手机验证码、邮箱验证码
对登录、注册、绑定进行封装,restful风格接口,根据不同的传参选择不同的方法;

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找相应的实现;

一个大致流程上的认识,结合代码再进行学习;



返回列表 返回列表
评论

    分享到