Search in sources :

Example 6 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);
    AppConfig appConfig = readAppConfig(appConfigFile);
    logger.info("hello-word app config: {}", appConfig);
}
Also used : EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) AppConfig(com.example.simple_chat.config.AppConfig)

Example 7 with EzyAppSetting

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

the class EzySimpleServerContextBuilder method newAppContext.

protected EzyAppContext newAppContext(EzyZoneContext parent, EzyAppSetting setting) {
    EzySimpleAppUserDelegate userDelegate = new EzySimpleAppUserDelegate();
    EzyAppUserManager appUserManager = newAppUserManager(setting, userDelegate);
    EzyEventControllers eventControllers = newEventControllers();
    EzySimpleApplication app = new EzySimpleApplication();
    app.setSetting(setting);
    app.setUserManager(appUserManager);
    app.setEventControllers(eventControllers);
    ScheduledExecutorService appExecutorService = newAppExecutorService(setting);
    EzySimpleAppContext appContext = new EzySimpleAppContext();
    userDelegate.setAppContext(appContext);
    appContext.setApp(app);
    appContext.setParent(parent);
    appContext.setExecutorService(appExecutorService);
    appContext.init();
    return appContext;
}
Also used : EzyEventControllers(com.tvd12.ezyfoxserver.wrapper.EzyEventControllers) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySimpleAppUserDelegate(com.tvd12.ezyfoxserver.delegate.EzySimpleAppUserDelegate)

Example 8 with EzyAppSetting

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

the class EzyAccessAppController method doHandle.

protected void doHandle(EzyServerContext ctx, EzyAccessAppRequest request) {
    EzyUser user = request.getUser();
    int zoneId = user.getZoneId();
    EzyAccessAppParams params = request.getParams();
    EzyZoneContext zoneContext = ctx.getZoneContext(zoneId);
    EzyAppContext appContext = zoneContext.getAppContext(params.getAppName());
    EzyApplication app = appContext.getApp();
    EzyAppSetting appSetting = app.getSetting();
    EzyAppUserManager appUserManger = app.getUserManager();
    EzySession session = request.getSession();
    String username = user.getName();
    Lock lock = appUserManger.getLock(username);
    lock.lock();
    try {
        boolean hasNotAccessed = !appUserManger.containsUser(user);
        if (hasNotAccessed) {
            checkAppUserMangerAvailable(appUserManger);
        }
        EzyUserAccessAppEvent accessAppEvent = new EzySimpleUserAccessAppEvent(user);
        appContext.handleEvent(EzyEventType.USER_ACCESS_APP, accessAppEvent);
        if (hasNotAccessed) {
            addUser(appUserManger, user, appSetting);
            EzyUserAccessedAppEvent accessedAppEvent = new EzySimpleUserAccessedAppEvent(user);
            appContext.handleEvent(EzyEventType.USER_ACCESSED_APP, accessedAppEvent);
        }
        EzyArray output = accessAppEvent.getOutput();
        EzyResponse accessAppResponse = newAccessAppResponse(appSetting, output);
        ctx.send(accessAppResponse, session, false);
    } finally {
        lock.unlock();
        appUserManger.removeLock(username);
    }
}
Also used : EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyAccessAppParams(com.tvd12.ezyfoxserver.request.EzyAccessAppParams) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzySimpleUserAccessedAppEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserAccessedAppEvent) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Lock(java.util.concurrent.locks.Lock) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzyUserAccessedAppEvent(com.tvd12.ezyfoxserver.event.EzyUserAccessedAppEvent) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyUserAccessAppEvent(com.tvd12.ezyfoxserver.event.EzyUserAccessAppEvent) EzySimpleUserAccessAppEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserAccessAppEvent)

Example 9 with EzyAppSetting

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

the class EzySimpleAppUserDelegate method newExitedAppResponse.

protected EzyResponse newExitedAppResponse(EzyConstant reason) {
    EzyExitedAppParams params = new EzyExitedAppParams();
    EzyAppSetting appSetting = appContext.getApp().getSetting();
    params.setApp(appSetting);
    params.setReason(reason);
    return new EzyExitedAppResponse(params);
}
Also used : EzyExitedAppParams(com.tvd12.ezyfoxserver.response.EzyExitedAppParams) EzyAppSetting(com.tvd12.ezyfoxserver.setting.EzyAppSetting) EzyExitedAppResponse(com.tvd12.ezyfoxserver.response.EzyExitedAppResponse)

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