package net.simpleframework.web;
import javax.servlet.ServletContext;
import net.simpleframework.core.IApplication;
import net.simpleframework.util.LocaleI18n;
/**
* LGPLv3
*
* @author (cknet@126.com, 13910090885)
* http://code.google.com/p/simpleframework/
* http://www.simpleframework.net
*/
public interface IWebApplication extends IApplication {
ServletContext getServletContext();
@Override
WebApplicationConfig getApplicationConfig();
public static class Instance {
static final String WEB_APPLICATION_INSTANCE = "__web_application";
static ServletContext servletContext;
public static IWebApplication getApplication() {
return servletContext != null ? (IWebApplication) servletContext
.getAttribute(WEB_APPLICATION_INSTANCE) : null;
}
public static void doInit(final ServletContext servletContext,
final IWebApplication application) {
LocaleI18n.addBasename(IWebApplication.class);
Instance.servletContext = servletContext;
servletContext.setAttribute(WEB_APPLICATION_INSTANCE, application);
}
}
}
|