Search in sources :

Example 1 with EzyAppSetting

use of com.tvd12.ezyfoxserver.setting.EzyAppSetting in project ezyfox-server by youngmonkeys.

the class EzyAppSendResponseImpl method newResponse.

protected EzyResponse newResponse(EzyData data) {
    EzyAppSetting setting = context.getApp().getSetting();
    EzyRequestAppResponseParams params = new EzyRequestAppResponseParams();
    params.setAppId(setting.getId());
    params.setData(data);
    return new EzyRequestAppResponse(params);
}
Also used : EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyRequestAppResponse(com.tvd12.ezyfoxserver.response.EzyRequestAppResponse) EzyRequestAppResponseParams(com.tvd12.ezyfoxserver.response.EzyRequestAppResponseParams)

Example 2 with EzyAppSetting

use of com.tvd12.ezyfoxserver.setting.EzyAppSetting in project ezyfox-server by youngmonkeys.

the class EzyAppsStarter method newAppEntryLoader.

protected EzyAppEntryLoader newAppEntryLoader(String appName) throws Exception {
    Class<EzyAppEntryLoader> entryLoaderClass = getAppEntryLoaderClass(appName);
    EzyAppSetting appSetting = getAppByName(appName);
    if (appSetting.getEntryLoaderArgs() == null) {
        return entryLoaderClass.newInstance();
    }
    return (EzyAppEntryLoader) entryLoaderClass.getConstructors()[0].newInstance(appSetting.getEntryLoaderArgs());
}
Also used : EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyAppEntryLoader(com.tvd12.ezyfoxserver.ext.EzyAppEntryLoader)

Example 3 with EzyAppSetting

use of com.tvd12.ezyfoxserver.setting.EzyAppSetting in project ezyfox-server by youngmonkeys.

the class EzySimpleAppEntryTest method scanPackages.

@Test
public void scanPackages() {
    // given
    EzyAppContext appContext = mock(EzyAppContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyApplication application = mock(EzyApplication.class);
    EzyAppUserManager appUserManager = mock(EzyAppUserManager.class);
    EzyAppSetup appSetup = mock(EzyAppSetup.class);
    EzyAppSetting appSetting = mock(EzyAppSetting.class);
    when(application.getSetting()).thenReturn(appSetting);
    InternalAppEntry sut = new InternalAppEntry();
    // when
    when(appContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(appContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(appContext.getApp()).thenReturn(application);
    when(application.getUserManager()).thenReturn(appUserManager);
    when(appContext.get(EzyAppSetup.class)).thenReturn(appSetup);
    sut.config(appContext);
    // then
    EzyBeanContext beanContext = sut.beanContext;
    MongoConfig mongoConfig = (MongoConfig) beanContext.getBean(MongoConfig.class);
    Set<String> expectedPackages = Sets.newHashSet(EzySupportConstants.DEFAULT_PACKAGE_TO_SCAN, "com.tvd12.ezyfoxserver.support.v120.test.entry");
    Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan);
    Singleton singleton = (Singleton) beanContext.getBean(Singleton.class);
    Asserts.assertNotNull(singleton);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyAppSetup(com.tvd12.ezyfoxserver.command.EzyAppSetup) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySingleton(com.tvd12.ezyfox.bean.annotation.EzySingleton) Test(org.testng.annotations.Test)

Example 4 with EzyAppSetting

use of com.tvd12.ezyfoxserver.setting.EzyAppSetting in project ezyfox-server by youngmonkeys.

the class EzySimpleAppEntry method createBeanContext.

protected EzyBeanContext createBeanContext(EzyAppContext context) {
    EzyBindingContext bindingContext = createBindingContext();
    EzyMarshaller marshaller = bindingContext.newMarshaller();
    EzyUnmarshaller unmarshaller = bindingContext.newUnmarshaller();
    EzyResponseFactory appResponseFactory = createAppResponseFactory(context, marshaller);
    ScheduledExecutorService executorService = context.get(ScheduledExecutorService.class);
    EzyAppSetting appSetting = context.getApp().getSetting();
    EzyBeanContextBuilder beanContextBuilder = EzyBeanContext.builder().addSingleton("appContext", context).addSingleton("marshaller", marshaller).addSingleton("unmarshaller", unmarshaller).addSingleton("executorService", executorService).addSingleton("zoneContext", context.getParent()).addSingleton("serverContext", context.getParent().getParent()).addSingleton("userManager", context.getApp().getUserManager()).addSingleton("appResponseFactory", appResponseFactory).addSingleton("featureCommandManager", new EzyFeatureCommandManager()).addSingleton("requestCommandManager", new EzyRequestCommandManager()).activeProfiles(appSetting.getActiveProfiles());
    Class[] singletonClasses = getSingletonClasses();
    beanContextBuilder.addSingletonClasses(singletonClasses);
    Class[] prototypeClasses = getPrototypeClasses();
    beanContextBuilder.addPrototypeClasses(prototypeClasses);
    Set<String> scanablePackages = internalGetScanableBeanPackages();
    if (appSetting.getPackageName() != null) {
        scanablePackages.add(appSetting.getPackageName());
    }
    EzyReflection reflection = new EzyReflectionProxy(scanablePackages);
    beanContextBuilder.addSingletonClasses((Set) reflection.getAnnotatedExtendsClasses(EzyEventHandler.class, EzyAppEventController.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) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) 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 5 with EzyAppSetting

use of com.tvd12.ezyfoxserver.setting.EzyAppSetting in project ezyfox-server-example by tvd12.

the class AppEntry method setupBeanContext.

@Override
protected void setupBeanContext(EzyAppContext context, EzyBeanContextBuilder builder) {
    EzyAppSetting setting = context.getApp().getSetting();
    String appConfigFile = getConfigFile(setting);
    builder.addProperties(appConfigFile);
    logger.info("hello-word app config file: {}", appConfigFile);
}
Also used : EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting)

Aggregations

EzyAppSetting (com.tvd12.ezyfoxserver.setting.EzyAppSetting)8 EzyAppUserManager (com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)2 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)2 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)2 AppConfig (com.example.simple_chat.config.AppConfig)1 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)1 EzyBeanContextBuilder (com.tvd12.ezyfox.bean.EzyBeanContextBuilder)1 EzySingleton (com.tvd12.ezyfox.bean.annotation.EzySingleton)1 EzyBindingContext (com.tvd12.ezyfox.binding.EzyBindingContext)1 EzyMarshaller (com.tvd12.ezyfox.binding.EzyMarshaller)1 EzyUnmarshaller (com.tvd12.ezyfox.binding.EzyUnmarshaller)1 EzyArray (com.tvd12.ezyfox.entity.EzyArray)1 EzyReflection (com.tvd12.ezyfox.reflect.EzyReflection)1 EzyReflectionProxy (com.tvd12.ezyfox.reflect.EzyReflectionProxy)1 EzyAppSetup (com.tvd12.ezyfoxserver.command.EzyAppSetup)1 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)1 EzySimpleAppUserDelegate (com.tvd12.ezyfoxserver.delegate.EzySimpleAppUserDelegate)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1