简体   繁体   中英

How can I share an EventBus for a Java and a GWT project at the same time?

I have a java project which uses the Guava EventBus . Now I want to use the code from this project to work with GWT without rewriting it. I know that GWT has its own EventBus but I cannot change the import in my Java project because this would break the Java project.

In my GWT project I included the guava and gwt-guava jars. I also included:

<inherits name="com.google.common.collect.Collect"/>

in my gwt.xml file. Guava worked at least for other classes (eg, Strings) in GWT project.

I want to use Guava's EventBus instead of the one provided by GWT. I need this because my Java project will not work with that GWT EventBus. The problem is that the GWT project uses the GWT EventBus and the Java Project uses the Guava EventBus. How do I get these things together? It would b great if I could replace the Guava EventBus from the Java project in my GWT project somehow.

How can How can I use Guava EventBus with GWT? Is there a way to use it without changing the dependencies in the other Java project?

Guava's EventBus isn't available in GWT client code. (You can tell because it doesn't have the @GwtCompatible annotation .)

Sometimes a class that's not available under GWT can be made available. EventBus , though, uses Java reflection, which is mostly unavailable under GWT, so it can't be made available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM