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);
}
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());
}
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);
}
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();
}
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);
}
Aggregations