java - android和javafx轻量级兼容事件框架

标签 java android events event-handling javafx

我的要求是我正在寻找一个在 Android 和 Java Fx(Windows 和 Linux 平台)中兼容的轻量级事件框架,以便它在这两种技术中无缝运行。

我研究了现有的基于事件的框架。
1) Eventing framework mbassador (by bennidi)-> 是否兼容android 4.0 (Ice Cream sandwich) 因为它可以与 javafx 一起正常工作,而且重量轻,性能也不错。
2) Guava EventBus :- 从文档来看,它似乎与 android 兼容,但性能如何,它是否比 mbassador 更好。

最佳答案

事件框架 MBassador 与 Android 4.0 兼容。
Guava Event Bus 是轻量级的,并且与这两种技术兼容。

上述两个框架都是轻量级的,并为订阅/ Release模式提供了强大的机制,根据 MBassador 的描述,它的初始设计灵感来自 Guava Event Bus,但 Strong在某些情况下,对 Guava Event Bus 中使用的监听器的引用是问题。

根据 GitHub MBassador 中描述的学分部分

The initial inspiration for creating this component came from trying out Google Guava's event bus implementation. I liked the simplicity of its design and I do trust the developers at Google a lot, so I was happy to find that they also provided an event bus system. The main reason it proved to be unusable for our scenario was that it uses strong references to the listeners such that every object has to be explicitly deregistered. This was difficult in our Spring managed environment. Finally, I decided to create a custom implementation, which then matured to be stable, extensible and yet very efficient

这两个框架都很健壮、轻量级,具体使用哪一个取决于您的要求。

我在 [Java 事件总线库比较]]( http://codeblock.engio.net/?p=37 ) 上找到了性能比较(我从该站点的谷歌缓存页面获得了结果),其中比较了 Google Guava、SimpleBus、EventBus 和 mbassador 框架,MBassador 是明显的赢家

编辑:我删除了图片快照,只关注最终结果,

The shown performance characteristics of the compared implementations indicate that,
1. Listener subscription is an expensive operation for all implementations but MBassador and Guava
2. Concurrent access does generally slow down the bus performance because of higher contention/synchronization.
3. SimpleBus is by far the slowest implementation.
4. MBassador is by far the fastest implementation in all scenarios. It also offers the best scaling characteristics meaning that higher concurrency rates do not slow down the bus performance as much as the others. This is because MBassador relies on a custom data structure with very fast write operations that do not block readers and at the same time do not copy existing data structures (most other implementations use CopyOnWriteArrayList).

总结 在过去的几个月里,我们一直在使用 MBassador,它符合我们的要求,它在 Android、JavaFX< 中运行良好/strong> 并且在 Linux、Windows、Mac 等操作系统上也适用于 simple java

关于java - android和javafx轻量级兼容事件框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18437990/

相关文章:

java - Junit断言

java - DatePickerDialog 错误地将最小日期强制为 1970 年 1 月 1 日

安卓错误 : Failed to install : timeout

java - 为什么这些值会重复?

java - 如何处理由于分组函数导致的 JDBC 数字类型精度损失

java - PHONE_STATE 接收器无法与基于上下文的接收器一起使用

java - Android sqlite 列未找到错误

actionscript-3 - 在模型 (MVC) AS3 中调用dispatchEvent 时,addEventListener 不起作用

javascript - 如何订阅一个方法来触发 onchange 和自定义事件?

jquery - 如何使用 jquery .mouseleave 事件调用函数