Search in sources :

Example 1 with EzyPluginContext

use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server-example by tvd12.

the class PluginEntry method setupBeanContext.

@Override
protected void setupBeanContext(EzyPluginContext context, EzyBeanContextBuilder builder) {
    EzyPluginSetting setting = context.getPlugin().getSetting();
    String pluginConfigFile = getConfigFile(setting);
    PluginConfig pluginConfig = readPluginConfig(pluginConfigFile);
    logger.info("simple-chat plugin config: {}", pluginConfig);
}
Also used : PluginConfig(com.example.simple_chat.plugin.config.PluginConfig) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Example 2 with EzyPluginContext

use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.

the class EzyPluginResponseImplTest method test.

@Test
public void test() {
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyZone zone = mock(EzyZone.class);
    when(zoneContext.getZone()).thenReturn(zone);
    EzyZoneUserManager userManager = EzyZoneUserManagerImpl.builder().build();
    when(zone.getUserManager()).thenReturn(userManager);
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    EzyPluginResponse cmd = (EzyPluginResponse) new EzyPluginResponseImpl(pluginContext).command("test").params(EzyEntityFactory.newArrayBuilder());
    cmd.execute();
}
Also used : EzyZone(com.tvd12.ezyfoxserver.EzyZone) EzyPluginResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzyPluginResponseImpl) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyPluginResponse(com.tvd12.ezyfoxserver.command.EzyPluginResponse) EzyZoneUserManager(com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 3 with EzyPluginContext

use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.

the class EzyPluginSendResponseImplTest method test.

@Test
public void test() {
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
    pluginSetting.setName("test");
    when(plugin.getSetting()).thenReturn(pluginSetting);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    when(zoneContext.getParent()).thenReturn(serverContext);
    EzyPluginSendResponseImpl cmd = new EzyPluginSendResponseImpl(pluginContext);
    EzyObject data = EzyEntityFactory.newObjectBuilder().build();
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    cmd.execute(data, session, false);
    cmd.execute(data, Lists.newArrayList(session), false);
}
Also used : EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginSendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzyPluginSendResponseImpl) EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyObject(com.tvd12.ezyfox.entity.EzyObject) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 4 with EzyPluginContext

use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.

the class EzyPluginInfoController method handle.

@Override
public void handle(EzyServerContext ctx, EzyPluginInfoRequest request) {
    EzyUser user = request.getUser();
    EzySession session = request.getSession();
    EzyPluginInfoParams params = request.getParams();
    EzyZoneContext zoneCtx = ctx.getZoneContext(user.getZoneId());
    EzyPluginContext pluginCtx = zoneCtx.getPluginContext(params.getPluginName());
    if (pluginCtx != null) {
        EzyPluginSetting setting = pluginCtx.getPlugin().getSetting();
        EzyResponse response = newPluginInfoResponse(setting);
        ctx.send(response, session, false);
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginInfoParams(com.tvd12.ezyfoxserver.request.EzyPluginInfoParams) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Example 5 with EzyPluginContext

use of com.tvd12.ezyfoxserver.context.EzyPluginContext in project ezyfox-server by youngmonkeys.

the class EzyBroadcastPluginsEventImpl method getPluginContextMaps.

private EzyMapSet<EzyConstant, EzyPluginContext> getPluginContextMaps() {
    Collection<EzyPluginContext> pluginContexts = context.getPluginContexts();
    EzyMapSet<EzyConstant, EzyPluginContext> pluginContextMaps = new EzyHashMapSet<>();
    for (EzyPluginContext pluginContext : pluginContexts) {
        EzyPluginSetting pluginSetting = pluginContext.getPlugin().getSetting();
        Set<EzyConstant> listenEvents = pluginSetting.getListenEvents().getEvents();
        for (EzyConstant listenEvent : listenEvents) {
            pluginContextMaps.addItem(listenEvent, pluginContext);
        }
    }
    return pluginContextMaps;
}
Also used : EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzyHashMapSet(com.tvd12.ezyfox.util.EzyHashMapSet) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Aggregations

EzyPluginContext (com.tvd12.ezyfoxserver.context.EzyPluginContext)16 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)13 Test (org.testng.annotations.Test)11 EzyPluginSetting (com.tvd12.ezyfoxserver.setting.EzyPluginSetting)8 BaseTest (com.tvd12.test.base.BaseTest)8 EzyPlugin (com.tvd12.ezyfoxserver.EzyPlugin)7 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)7 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)6 EzyPluginRequestController (com.tvd12.ezyfoxserver.plugin.EzyPluginRequestController)6 EzyArray (com.tvd12.ezyfox.entity.EzyArray)5 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)5 EzySimplePlugin (com.tvd12.ezyfoxserver.EzySimplePlugin)4 EzyZone (com.tvd12.ezyfoxserver.EzyZone)4 EzyPluginSetup (com.tvd12.ezyfoxserver.command.EzyPluginSetup)4 EzyUserRequestPluginEvent (com.tvd12.ezyfoxserver.event.EzyUserRequestPluginEvent)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 EzyServerReadyEvent (com.tvd12.ezyfoxserver.event.EzyServerReadyEvent)3 EzySimpleServerReadyEvent (com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent)3 EzySimpleUserRequestPluginEvent (com.tvd12.ezyfoxserver.event.EzySimpleUserRequestPluginEvent)3 EzySimplePluginSetting (com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting)3