Search in sources :

Example 6 with EzyFeatureCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntry method createBeanContext.

private EzyBeanContext createBeanContext(EzyPluginContext context) {
    EzyBindingContext bindingContext = createBindingContext();
    EzyMarshaller marshaller = bindingContext.newMarshaller();
    EzyUnmarshaller unmarshaller = bindingContext.newUnmarshaller();
    EzyResponseFactory pluginResponseFactory = createPluginResponseFactory(context, marshaller);
    ScheduledExecutorService executorService = context.get(ScheduledExecutorService.class);
    EzyPluginSetting pluginSetting = context.getPlugin().getSetting();
    EzyBeanContextBuilder beanContextBuilder = EzyBeanContext.builder().addSingleton("pluginContext", context).addSingleton("marshaller", marshaller).addSingleton("unmarshaller", unmarshaller).addSingleton("executorService", executorService).addSingleton("zoneContext", context.getParent()).addSingleton("serverContext", context.getParent().getParent()).addSingleton("pluginResponseFactory", pluginResponseFactory).addSingleton("featureCommandManager", new EzyFeatureCommandManager()).addSingleton("requestCommandManager", new EzyRequestCommandManager()).activeProfiles(pluginSetting.getActiveProfiles());
    Class[] singletonClasses = getSingletonClasses();
    beanContextBuilder.addSingletonClasses(singletonClasses);
    Class[] prototypeClasses = getPrototypeClasses();
    beanContextBuilder.addPrototypeClasses(prototypeClasses);
    Set<String> scanablePackages = internalGetScanableBeanPackages();
    if (pluginSetting.getPackageName() != null) {
        scanablePackages.add(pluginSetting.getPackageName());
    }
    EzyReflection reflection = new EzyReflectionProxy(scanablePackages);
    beanContextBuilder.addSingletonClasses((Set) reflection.getAnnotatedExtendsClasses(EzyEventHandler.class, EzyPluginEventController.class));
    beanContextBuilder.addSingletonClasses((Set) reflection.getAnnotatedClasses(EzyRequestController.class));
    beanContextBuilder.addSingletonClasses((Set) reflection.getAnnotatedClasses(EzyExceptionHandler.class));
    beanContextBuilder.addSingletonClasses((Set) reflection.getAnnotatedClasses(EzyRequestInterceptor.class));
    beanContextBuilder.scan(scanablePackages);
    setupBeanContext(context, beanContextBuilder);
    return beanContextBuilder.build();
}
Also used : EzyResponseFactory(com.tvd12.ezyfoxserver.support.factory.EzyResponseFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyBindingContext(com.tvd12.ezyfox.binding.EzyBindingContext) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) EzyUnmarshaller(com.tvd12.ezyfox.binding.EzyUnmarshaller) EzyMarshaller(com.tvd12.ezyfox.binding.EzyMarshaller) EzyBeanContextBuilder(com.tvd12.ezyfox.bean.EzyBeanContextBuilder) EzyReflectionProxy(com.tvd12.ezyfox.reflect.EzyReflectionProxy) EzyReflection(com.tvd12.ezyfox.reflect.EzyReflection)

Example 7 with EzyFeatureCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager in project ezyfox-server by youngmonkeys.

the class EzyUserRequestAppSingletonControllerTest method test.

@Test
public void test() throws Exception {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyExceptionHandlerImplementer.setDebug(true);
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
    EzySimpleZone zone = new EzySimpleZone();
    zone.setSetting(zoneSetting);
    EzySimpleZoneContext zoneContext = new EzySimpleZoneContext();
    zoneContext.setZone(zone);
    zoneContext.init();
    zoneContext.setParent(serverContext);
    EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
    appSetting.setName("test");
    EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
    EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
    EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
    EzySimpleApplication application = new EzySimpleApplication();
    application.setSetting(appSetting);
    application.setUserManager(appUserManager);
    application.setEventControllers(eventControllers);
    ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
    EzySimpleAppContext appContext = new EzySimpleAppContext();
    appContext.setApp(application);
    appContext.setParent(zoneContext);
    appContext.setExecutorService(appScheduledExecutorService);
    appContext.init();
    EzySimpleAppEntry entry = new EzyAppEntryEx();
    entry.config(appContext);
    entry.start();
    handleClientRequest(appContext);
    EzyBeanContext beanContext = appContext.get(EzyBeanContext.class);
    EzyRequestCommandManager requestCommandManager = beanContext.getSingleton(EzyRequestCommandManager.class);
    EzyFeatureCommandManager featureCommandManager = beanContext.getSingleton(EzyFeatureCommandManager.class);
    Asserts.assertTrue(requestCommandManager.containsCommand("v1.2.2/hello"));
    Asserts.assertTrue(requestCommandManager.containsCommand("v122/listener/hello"));
    Asserts.assertTrue(requestCommandManager.isManagementCommand("v1.2.2/hello"));
    Asserts.assertTrue(requestCommandManager.isPaymentCommand("v1.2.2/hello"));
    Asserts.assertEquals(featureCommandManager.getFeatureByCommand("v1.2.2/hello"), "hello.world");
    entry.destroy();
}
Also used : EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyEventControllers(com.tvd12.ezyfoxserver.wrapper.EzyEventControllers) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySimpleAppContext(com.tvd12.ezyfoxserver.context.EzySimpleAppContext) EzySimpleAppEntry(com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 8 with EzyFeatureCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager in project ezyfox-server by youngmonkeys.

the class EzyRequestHandlersImplementerTest method testImplementDuplicateCommandButAllowOverride.

@Test
public void testImplementDuplicateCommandButAllowOverride() {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
    EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
    EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
    implementer.setFeatureCommandManager(featureCommandManager);
    implementer.setRequestCommandManager(requestCommandManager);
    implementer.setAllowOverrideCommand(true);
    implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
Also used : HelloController(com.tvd12.ezyfoxserver.support.test.controller.HelloController) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzyRequestHandlersImplementer(com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer) Test(org.testng.annotations.Test)

Example 9 with EzyFeatureCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager in project ezyfox-server by youngmonkeys.

the class EzyRequestHandlersImplementerTest method testImplementFailedCase3.

@Test(expectedExceptions = EzyDuplicateRequestHandlerException.class)
public void testImplementFailedCase3() {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
    EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
    EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
    implementer.setFeatureCommandManager(featureCommandManager);
    implementer.setRequestCommandManager(requestCommandManager);
    implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
Also used : HelloController(com.tvd12.ezyfoxserver.support.test.controller.HelloController) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzyRequestHandlersImplementer(com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer) Test(org.testng.annotations.Test)

Aggregations

EzyFeatureCommandManager (com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager)9 EzyRequestCommandManager (com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager)8 Test (org.testng.annotations.Test)7 EzyRequestHandlersImplementer (com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 EzyResponseFactory (com.tvd12.ezyfoxserver.support.factory.EzyResponseFactory)3 HelloController (com.tvd12.ezyfoxserver.support.test.controller.HelloController)3 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)2 EzyBeanContextBuilder (com.tvd12.ezyfox.bean.EzyBeanContextBuilder)2 EzyBindingContext (com.tvd12.ezyfox.binding.EzyBindingContext)2 EzyMarshaller (com.tvd12.ezyfox.binding.EzyMarshaller)2 EzyUnmarshaller (com.tvd12.ezyfox.binding.EzyUnmarshaller)2 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)2 EzyReflection (com.tvd12.ezyfox.reflect.EzyReflection)2 EzyReflectionProxy (com.tvd12.ezyfox.reflect.EzyReflectionProxy)2 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)2 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)2 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)2 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)2 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)2