Search in sources :

Example 1 with SessionProvider

use of org.nutz.mvc.SessionProvider in project nutz by nutzam.

the class NutLoading method depose.

public void depose(NutConfig config) {
    if (log.isInfoEnabled())
        log.infof("Nutz.Mvc[%s] is deposing ...", config.getAppName());
    Stopwatch sw = Stopwatch.begin();
    // Firstly, upload the user customized desctroy
    try {
        Setup setup = config.getAttributeAs(Setup.class, Setup.class.getName());
        if (null != setup)
            setup.destroy(config);
    } catch (Exception e) {
        throw new LoadingException(e);
    } finally {
        SessionProvider sp = config.getSessionProvider();
        if (sp != null)
            sp.notifyStop();
        // If the application has Ioc, depose it
        Ioc ioc = config.getIoc();
        if (null != ioc)
            ioc.depose();
    }
    // Done, print info
    sw.stop();
    if (log.isInfoEnabled())
        log.infof("Nutz.Mvc[%s] is down in %sms", config.getAppName(), sw.getDuration());
}
Also used : Stopwatch(org.nutz.lang.Stopwatch) LoadingException(org.nutz.mvc.LoadingException) Setup(org.nutz.mvc.Setup) Ioc(org.nutz.ioc.Ioc) LoadingException(org.nutz.mvc.LoadingException) SessionProvider(org.nutz.mvc.SessionProvider)

Example 2 with SessionProvider

use of org.nutz.mvc.SessionProvider in project nutz by nutzam.

the class NutLoading method createSessionProvider.

@SuppressWarnings({ "all" })
protected void createSessionProvider(NutConfig config, Class<?> mainModule) throws Exception {
    SessionBy sb = mainModule.getAnnotation(SessionBy.class);
    if (sb != null) {
        SessionProvider sp = null;
        if (sb.args() != null && sb.args().length == 1 && sb.args()[0].startsWith("ioc:"))
            sp = config.getIoc().get(sb.value(), sb.args()[0].substring(4));
        else
            sp = Mirror.me(sb.value()).born((Object[]) sb.args());
        if (log.isInfoEnabled())
            log.info("SessionBy --> " + sp);
        config.setSessionProvider(sp);
    }
}
Also used : SessionBy(org.nutz.mvc.annotation.SessionBy) SessionProvider(org.nutz.mvc.SessionProvider)

Aggregations

SessionProvider (org.nutz.mvc.SessionProvider)2 Ioc (org.nutz.ioc.Ioc)1 Stopwatch (org.nutz.lang.Stopwatch)1 LoadingException (org.nutz.mvc.LoadingException)1 Setup (org.nutz.mvc.Setup)1 SessionBy (org.nutz.mvc.annotation.SessionBy)1