事件驱动设计可以有效降低模块间耦合度。
添加Rribbit依赖
<dependency> <groupId>org.rribbit</groupId> <artifactId>rribbit</artifactId> <version>2.7.0</version> <type>jar</type> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.0.5.RELEASE</version> </dependency>
配置Spring
<context:component-scan base-package="com.sipsd" /> <bean id="creator" class="org.rribbit.creation.SpringBeanClassBasedListenerObjectCreator"> <property name="packageNames"> <list> <value>com.sipsd</value> </list> </property> <property name="scanSubpackages" value="true" /> </bean> <bean id="rrb" class="org.rribbit.util.RRiBbitUtil" factory-method="createRequestResponseBusForLocalUse"> <constructor-arg ref="creator" /> <constructor-arg value="true" /> </bean>
Payment java to:
public class Payment implements Serializable { private static final long serialVersionUID = 7460614839664772877L; private String paymentId; private double amount; private String orderId; /** * @return the orderId */ public String getOrderId() { return orderId; } /** * @param orderId * the orderId to set */ public void setOrderId(String orderId) { this.orderId = orderId; } /** * @return the paymentId */ public String getPaymentId() { return paymentId; } /** * @param paymentId * the paymentId to set */ public void setPaymentId(String paymentId) { this.paymentId = paymentId; } /** * @return the amount */ public double getAmount() { return amount; } /** * @param amount * the amount to set */ public void setAmount(double amount) { this.amount = amount; } }
Payment Service Interface:
public interface PaymentService { @Listener(hint = "createPayment") public Payment createPayment(Payment p); }
Payment Service Implementation:
@Service("paymentService") public class PaymentServiceImpl implements PaymentService { @Override public Payment createPayment(Payment p) { System.out.println("create payment"); p.setAmount(90000); return p; } }
测试:
public class TestRbit { private RequestResponseBus rrb; @Autowired PaymentServiceImpl ps; public static void main(String[] args) { new TestRbit().testRribbit(); } private void testRribbit(){ ApplicationContext context = new ClassPathXmlApplicationContext( "rribbit-appContext.xml"); rrb = (RequestResponseBus) context.getBean("rrb"); Payment p = rrb.send("createPayment", new Payment()); System.out.println(p.getAmount()); } }
相关推荐
过驱动保护工具(过游戏驱动保护工具)过驱动保护工具(过游戏驱动保护工具)过驱动保护工具(过游戏驱动保护工具)过驱动保护工具(过游戏驱动保护工具)过驱动保护工具(过游戏驱动保护工具)过驱动保护工具(过...
MCGS脚本驱动开发工具,可以学习开发基于MCGS嵌入式组态软件相关的仪表驱动,可直接用MCGS触摸屏和仪表进行通讯交互。 脚本驱动是一种使用MCGS增强语言编写的设备驱动程序。 目的,是给用户提供一种与传统MCGS...
MCGS脚本驱动开发工具 使用教程 以及软件 中级使用教程 初级使用教程 脚本驱动开发软件等等
联想工程师专用小工具 网卡驱动降级工具V3.30.1联想工程师专用小工具 网卡驱动降级工具V3.30.1联想工程师专用小工具 网卡驱动降级工具V3.30.1联想工程师专用小工具 网卡驱动降级工具V3.30.1联想工程师专用小工具 ...
昆仑通态脚本驱动开发工具使用指导手册对工程技术人员很有用
Java 开发中事件驱动模型的实例详解,属于转的
sys驱动签名工具.zipsys驱动签名工具.zipsys驱动签名工具.zipsys驱动签名工具.zipsys驱动签名工具.zip
通过事件驱动的事件驱动微服务,使用kafka开发Spring boot微服务服务器.zip
事件驱动模型实例详解(Java篇)
以前有个离线注入工具,比较简单,但是需要PE环境,今天为大家提供一个更加简单的工具,直接在Windows下更新AHCI驱动,重启后在BIOS开启AHCI磁盘模式就搞定了! 软件名: SkyIAR 软件功能: AHCI驱动安装工具SkyIARv...
Windwos驱动加载工具DriverMonitor,非常的好用。DriverStudio下的DriverMonitor.exe驱动加载调试工具。密码123
打印机驱动管理(完全卸载工具).exe
联想工程师专用小工具 强制要求驱动签名修复工具V2.42.1联想工程师专用小工具 强制要求驱动签名修复工具V2.42.1联想工程师专用小工具 强制要求驱动签名修复工具V2.42.1联想工程师专用小工具 强制要求驱动签名修复...
联想工程师专用小工具 联想驱动管理V2.23.1联想工程师专用小工具 联想驱动管理V2.23.1联想工程师专用小工具 联想驱动管理V2.23.1联想工程师专用小工具 联想驱动管理V2.23.1联想工程师专用小工具 联想驱动管理V2.23.1...
振中TP900s驱动及工具,可以烧录程序及USB驱动
是一款很好用的打印机驱动卸载利器,现在有了这工具,工作将会变得相当简单。
C语言实现,用于嵌入式尤其单片机系统,小巧简单易用的事件驱动型按键驱动模块,可无限量扩展按键,按键事件的回调异步处理方式可以简化你的程序结构,按键业务逻辑更清晰。c语言源代码;修订了原版的bug,更易用。...
Windows桌面平台下的驱动加载工具,能够快速加载写好的驱动文件 方便调试