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

瓜果蔬菜做的好的电商网站如何建立优秀企业网站

瓜果蔬菜做的好的电商网站,如何建立优秀企业网站,现在还有人做网站吗,游戏网站设计模板spring rmi1.引言 本文介绍了如何使用Spring Integration RMI通道适配器通过RMI发送和接收消息。 它由以下部分组成#xff1a; 实施服务#xff1a;第一部分着重于创建和公开服务。 实现客户端#xff1a;显示如何使用MessagingTemplate类调用服务。 抽象SI逻辑#xf… spring rmi 1.引言 本文介绍了如何使用Spring Integration RMI通道适配器通过RMI发送和接收消息。 它由以下部分组成 实施服务第一部分着重于创建和公开服务。 实现客户端显示如何使用MessagingTemplate类调用服务。 抽象SI逻辑最后我添加了另一部分解释了如何实现抽象所有Spring Integration代码的相同客户端而使客户端专注于其业务逻辑。 您可以在github上获取源代码。 2.实施服务 第一部分非常简单。 该服务是通过注释定义的因此它将通过组件扫描自动检测。 它注入了一个存储库该存储库从嵌入式数据库获取数据这将在同一部分中显示 Service(defaultEmployeeService) public class EmployeeServiceImpl implements EmployeeService {Autowiredprivate EmployeeRepository employeeRepository;Overridepublic Employee retrieveEmployee(int id) {return employeeRepository.getEmployee(id);} } 存储库如下 Repository public class EmployeeRepositoryImpl implements EmployeeRepository {private JdbcTemplate template;private RowMapperEmployee rowMapper new EmployeeRowMapper();private static final String SEARCH select * from employees where id ?;private static final String COLUMN_ID id;private static final String COLUMN_NAME name;Autowiredpublic EmployeeRepositoryImpl(DataSource dataSource) {this.template new JdbcTemplate(dataSource);}public Employee getEmployee(int id) {return template.queryForObject(SEARCH, rowMapper, id);}private class EmployeeRowMapper implements RowMapperEmployee {public Employee mapRow(ResultSet rs, int i) throws SQLException {Employee employee new Employee();employee.setId(rs.getInt(COLUMN_ID));employee.setName(rs.getString(COLUMN_NAME));return employee;}} } 以下配置通过RMI公开服务 服务器配置文件 context:component-scan base-packagexpadro.spring.integration/int-rmi:inbound-gateway request-channelrequestEmployee/int:channel idrequestEmployee/int:service-activator methodretrieveEmployee input-channelrequestEmployee refdefaultEmployeeService/bean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource / /bean!-- in-memory database -- jdbc:embedded-database iddataSourcejdbc:script locationclasspath:db/schemas/schema.sql /jdbc:script locationclasspath:db/schemas/data.sql / /jdbc:embedded-database 让我们关注带有int名称空间的行 网关的功能是将消息传递系统的管道与应用程序的其余部分分开。 这样它就被业务逻辑隐藏了。 网关是双向的因此您具有 入站网关将消息带入应用程序并等待响应。 出站网关调用外部系统并将响应发送回应用程序。 在此示例中我们使用RMI入站网关。 它将通过RMI接收一条消息并将其发送到requestEmployee通道该通道也在此处定义。 最后 服务激活器允许您将spring bean连接到消息通道。 在这里它连接到requestEmployee通道。 消息将到达通道服务激活器将调用retrieveEmployee方法。 考虑到如果bean只有一个公共方法或带有ServiceActivator注释的方法则不需要method属性。 然后响应将发送到回复通道。 由于我们没有定义此通道因此它将创建一个临时回复通道。 3实施客户 我们将要实现的客户端将调用服务以检索员工。 为此它将使用MessagingTemplate类 RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration(locations{classpath:xpadro/spring/integration/test/config/client-config.xml}) public class TestRmiClient {AutowiredMessageChannel localChannel;AutowiredMessagingTemplate template;Testpublic void retrieveExistingEmployee() {Employee employee (Employee) template.convertSendAndReceive(localChannel, 2);Assert.assertNotNull(employee);Assert.assertEquals(2, employee.getId());Assert.assertEquals(Bruce Springsteen, employee.getName());} } 客户端使用messagingTemplate将Integer对象转换为Message并将其发送到本地通道。 如下所示有一个出站网关连接到本地通道。 该出站网关将通过RMI发送请求消息。 int-rmi:outbound-gateway request-channellocalChannel remote-channelrequestEmployee hostlocalhost/int:channel idlocalChannel/bean classorg.springframework.integration.core.MessagingTemplate /4抽象SI逻辑 在上一节中您可能已经注意到访问服务的客户端类具有特定于Spring Integration的逻辑及其业务代码 它使用MessagingTemplate它是一个SI类。 它了解本地通道该本地通道特定于消息传递系统 在本节中我将实现与抽象消息传递逻辑相同的示例因此客户端将只关心其业务逻辑。 首先让我们看一下新客户端 RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration(locations{classpath:xpadro/spring/integration/test/config/client-gateway-config.xml}) public class TestRmiGatewayClient {Autowiredprivate EmployeeService service;Testpublic void retrieveExistingEmployee() {Employee employee service.retrieveEmployee(2);Assert.assertNotNull(employee);Assert.assertEquals(2, employee.getId());Assert.assertEquals(Bruce Springsteen, employee.getName());} } 现在我们可以看到客户端仅实现其业务逻辑而不使用消息通道或消息传递模板。 它将仅调用服务接口。 所有消息传递定义都在配置文件中。 int-rmi:outbound-gateway request-channellocalChannel remote-channelrequestEmployee hostlocalhost/int:channel idlocalChannel/int:gateway default-request-channellocalChannel service-interfacexpadro.spring.integration.service.EmployeeService/ 客户端网关配置文件 我们在这里所做的是添加一个网关该网关将拦截对服务接口EmployeeService的调用。 Spring Integration将使用GatewayProxyFactoryBean类在服务接口周围创建代理。 该代理将使用消息传递模板将调用发送到请求通道并等待响应。 5结论 我们已经看到了如何使用Spring Integration通过RMI访问服务。 我们还看到我们不仅可以使用MessagingTemplate显式发送消息还可以使用GatewayProxyFactoryBean透明地发送消息。 参考 Spring Integration –使用 XavierPadró博客博客中的JCG合作伙伴 Xavier Padro 使用RMI通道适配器 。 翻译自: https://www.javacodegeeks.com/2014/02/spring-integration-using-rmi-channel-adapters.htmlspring rmi
http://www.pierceye.com/news/199057/

相关文章:

  • 网站项目建设主要内容网站导航优化的描述
  • 网站后台修改图片网站制作多少钱公司
  • 做网站后台需要写代码吗益阳seo网站建设
  • 小程序网站做多大尺寸辽阳住房和城乡建设网站
  • 昆山app网站制作网站的管理权限有什么用
  • 购物网站建设开题报告企业宣传方案模板
  • cdr做好排班怎么做网站我的免费网是个什么网站
  • 如何做别人网站镜像地区性中介类网站建设
  • 做的网站怎么查看点击率安装wordpress主题失败
  • 网站历史权重查询免费的黄冈网站有哪些下载软件
  • 宝安三网合一网站建设河北智能网站建设平台
  • 在百度上做网站有用吗wordpress环境虚拟机安装
  • 怎么做网站图片链接中元建设网站
  • 邢台做网站优化价格网站基本维护
  • 网站集群建设价格wordpress 加文章列表
  • 官方网站案例用ps做网站主页
  • 做名片的网站推广型网站建设销售
  • 河南省建设执业资格注册中心网站网站推广公司 sit
  • 来年做那个网站致富网站工作室 需要什么手续
  • 宜兴网站建设哪家好网站建设设计公司排名
  • 婚庆公司网站怎么做wordpress 首页置顶
  • 电商网站开发人员结构江苏住房和城乡建设厅网站首页
  • 快速建站的模板陕西省建设网三类人员继续教育
  • 谷歌浏览器对做网站有什么好处广州最好网站策划
  • 西安北郊做网站重庆手机软件开发
  • 怀化刚刚发生的大事台州seo服务
  • 织梦做的网站打开空白巴中网站制作公司
  • 如何使用jq做弹幕网站设计漂亮的网站
  • 电商网站是获取流量广西南宁网站排名优化
  • 网站板块设计有哪些开发网站监控推荐