IWebApplication.java :  » MVC » simpleframework » net » simpleframework » web » Java Open Source

Java Open Source » MVC » simpleframework 
simpleframework » net » simpleframework » web » IWebApplication.java
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);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.