use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.
the class EzyPluginsStarter method startPlugin.
protected void startPlugin(String pluginName) {
try {
logger.debug("plugin: {} loading...", pluginName);
EzyPluginContext context = zoneContext.getPluginContext(pluginName);
EzyPlugin plugin = context.getPlugin();
EzyPluginEntry entry = startPlugin(pluginName, newPluginEntryLoader(pluginName));
((EzyEntryAware) plugin).setEntry(entry);
logger.debug("plugin: {} loaded", pluginName);
} catch (Exception e) {
logger.error("can not start plugin: {}", pluginName, e);
}
}
use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntry method config.
@Override
public void config(EzyPluginContext context) {
preConfig(context);
EzyBeanContext beanContext = createBeanContext(context);
context.setProperty(EzyBeanContext.class, beanContext);
addEventControllers(context, beanContext);
setPluginRequestController(context, beanContext);
postConfig(context);
postConfig(context, beanContext);
}
use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntry method addEventControllers.
private void addEventControllers(EzyPluginContext context, EzyBeanContext beanContext) {
EzySetup setup = context.get(EzySetup.class);
List<Object> eventControllers = beanContext.getSingletons(EzyEventHandler.class);
sortEventHandlersByPriority(eventControllers);
for (Object controller : eventControllers) {
Class<?> handlerType = controller.getClass();
EzyEventHandler annotation = handlerType.getAnnotation(EzyEventHandler.class);
String eventName = EzyEventHandlerAnnotations.getEvent(annotation);
setup.addEventController(EzyEventType.valueOf(eventName), (EzyEventController) controller);
logger.info("add event {} controller {}", eventName, controller);
}
}
use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.
the class EzySimplePluginEntry method createPluginResponseFactory.
private EzyResponseFactory createPluginResponseFactory(EzyPluginContext pluginContext, EzyMarshaller marshaller) {
EzyPluginResponseFactory factory = new EzyPluginResponseFactory();
factory.setPluginContext(pluginContext);
factory.setMarshaller(marshaller);
return factory;
}
use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImplTest method firePluginEventExceptionCase.
@Test
public void firePluginEventExceptionCase() {
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
EzyZone zone = mock(EzyZone.class);
when(zoneContext.getZone()).thenReturn(zone);
EzySimpleZoneSetting setting = new EzySimpleZoneSetting();
setting.setName("test");
when(zone.getSetting()).thenReturn(setting);
EzyPluginContext pluginContext = mock(EzyPluginContext.class);
EzyPlugin plugin = mock(EzyPlugin.class);
when(pluginContext.getPlugin()).thenReturn(plugin);
EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
when(plugin.getSetting()).thenReturn(pluginSetting);
EzySimpleListenEvents listenEvents = pluginSetting.getListenEvents();
listenEvents.setEvent("SERVER_READY");
doThrow(new IllegalStateException("server maintain")).when(pluginContext).handleEvent(any(), any());
when(zoneContext.getPluginContexts()).thenReturn(Lists.newArrayList(pluginContext));
EzyBroadcastPluginsEventImpl cmd = new EzyBroadcastPluginsEventImpl(zoneContext);
EzyServerReadyEvent event = new EzySimpleServerReadyEvent();
cmd.fire(EzyEventType.SERVER_READY, event, true);
}
Aggregations