use of com.google.common.eventbus.EventBus in project MinecraftForge by MinecraftForge.
the class LoadController method disableMod.
void disableMod(ModContainer mod) {
HashMap<String, EventBus> temporary = Maps.newHashMap(eventChannels);
String modId = mod.getModId();
EventBus bus = temporary.remove(modId);
bus.post(new FMLModDisabledEvent());
if (errors.get(modId).isEmpty()) {
eventChannels = ImmutableMap.copyOf(temporary);
modStates.put(modId, ModState.DISABLED);
modObjectList.remove(mod);
activeModList.remove(mod);
}
}
use of com.google.common.eventbus.EventBus in project MinecraftForge by MinecraftForge.
the class LoadController method buildModList.
@Subscribe
public void buildModList(FMLLoadEvent event) {
Builder<String, EventBus> eventBus = ImmutableMap.builder();
for (final ModContainer mod : loader.getModList()) {
//Create mod logger, and make the EventBus logger a child of it.
EventBus bus = new EventBus(new SubscriberExceptionHandler() {
@Override
public void handleException(final Throwable exception, final SubscriberExceptionContext context) {
LoadController.this.errorOccurred(mod, exception);
}
});
boolean isActive = mod.registerBus(bus, this);
if (isActive) {
activeModList.add(mod);
modStates.put(mod.getModId(), ModState.UNLOADED);
eventBus.put(mod.getModId(), bus);
FMLCommonHandler.instance().addModToResourcePack(mod);
} else {
FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId());
modStates.put(mod.getModId(), ModState.UNLOADED);
modStates.put(mod.getModId(), ModState.DISABLED);
}
modNames.put(mod.getModId(), mod.getName());
}
eventChannels = eventBus.build();
}
use of com.google.common.eventbus.EventBus in project graylog2-server by Graylog2.
the class StaticFieldFilterTest method testFilter.
@Test
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void testFilter() throws Exception {
Message msg = new Message("hello", "junit", Tools.nowUTC());
msg.setSourceInputId("someid");
when(input.getId()).thenReturn("someid");
when(inputService.all()).thenReturn(Collections.singletonList(input));
when(inputService.find(eq("someid"))).thenReturn(input);
when(inputService.getStaticFields(eq(input))).thenReturn(Collections.singletonList(Maps.immutableEntry("foo", "bar")));
final StaticFieldFilter filter = new StaticFieldFilter(inputService, new EventBus(), Executors.newSingleThreadScheduledExecutor());
filter.filter(msg);
assertEquals("hello", msg.getMessage());
assertEquals("junit", msg.getSource());
assertEquals("bar", msg.getField("foo"));
}
use of com.google.common.eventbus.EventBus in project graylog2-server by Graylog2.
the class GrokPatternRegistryTest method setUp.
@Before
public void setUp() {
eventBus = new EventBus("Test");
executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("updater-%d").build());
when(grokPatternService.loadAll()).thenReturn(GROK_PATTERNS);
grokPatternRegistry = new GrokPatternRegistry(eventBus, grokPatternService, executor);
}
use of com.google.common.eventbus.EventBus in project graylog2-server by Graylog2.
the class IOStateTest method testNotEqualIfDifferentInput.
@Test
public void testNotEqualIfDifferentInput() throws Exception {
EventBus eventBus = mock(EventBus.class);
MessageInput messageInput1 = mock(MessageInput.class);
MessageInput messageInput2 = mock(MessageInput.class);
IOState<MessageInput> inputState1 = new IOState<>(eventBus, messageInput1);
IOState<MessageInput> inputState2 = new IOState<>(eventBus, messageInput2);
assertFalse(inputState1.equals(inputState2));
assertFalse(inputState2.equals(inputState1));
}
Aggregations