BAEL-639 - moving from test to main source tree
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package org.baeldung.guava;
|
||||
|
||||
public class CustomEvent {
|
||||
private String action;
|
||||
|
||||
public CustomEvent(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.baeldung.guava;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
class EventBusWrapper {
|
||||
|
||||
private static EventBus eventBus = new EventBus();
|
||||
|
||||
static void register(Object object) {
|
||||
eventBus.register(object);
|
||||
}
|
||||
|
||||
static void unregister(Object object) {
|
||||
eventBus.unregister(object);
|
||||
}
|
||||
|
||||
static void post(Object object) {
|
||||
eventBus.post(object);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.baeldung.guava;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class EventListener {
|
||||
|
||||
private static int eventsHandled;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(EventListener.class);
|
||||
|
||||
@Subscribe
|
||||
public void stringEvent(String event) {
|
||||
LOG.info("do event [" + event + "]");
|
||||
eventsHandled++;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void someCustomEvent(CustomEvent customEvent) {
|
||||
LOG.info("do event [" + customEvent.getAction() + "]");
|
||||
eventsHandled++;
|
||||
}
|
||||
|
||||
public int getEventsHandled() {
|
||||
return eventsHandled;
|
||||
}
|
||||
|
||||
public void resetEventsHandled() {
|
||||
eventsHandled = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user