Example usage for javax.servlet ServletContext getAttribute

List of usage examples for javax.servlet ServletContext getAttribute

Introduction

In this page you can find the example usage for javax.servlet ServletContext getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the servlet container attribute with the given name, or null if there is no attribute by that name.

Usage

From source file:org.apache.synapse.core.axis2.SynapseStartUpServlet.java

public void init() throws ServletException {
    ServletConfig servletConfig = getServletConfig();
    ServletContext servletContext = servletConfig.getServletContext();
    if (Boolean.TRUE.equals(servletContext.getAttribute(ALREADY_INITED))) {
        return;/*from  w  w  w.j av a 2s .  co  m*/
    }
    ServerManager serverManager = new ServerManager();
    ServerConfigurationInformation information = ServerConfigurationInformationFactory
            .createServerConfigurationInformation(servletConfig);
    serverManager.init(information, null);
    serverManager.start();
    servletContext.setAttribute(ALREADY_INITED, Boolean.TRUE);

    servletContext.setAttribute(SYNAPSE_SERVER_MANAGER, serverManager);
}

From source file:com.github.glue.mvc.guice.GuiceConfigListener.java

@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
    ServletContext servletContext = servletContextEvent.getServletContext();
    GuiceContainer guiceContainer = (GuiceContainer) servletContext.getAttribute(IOCCONTAINER);
    servletContext.removeAttribute(IOCCONTAINER);

    super.contextDestroyed(servletContextEvent);
}

From source file:org.apache.myfaces.webapp.MyFacesServlet.java

public void init(ServletConfig servletConfig) throws ServletException {
    //Check, if ServletContextListener already called
    ServletContext servletContext = servletConfig.getServletContext();
    Boolean b = (Boolean) servletContext
            .getAttribute(org.apache.myfaces.webapp.StartupServletContextListener.FACES_INIT_DONE);
    if (b == null || b.booleanValue() == false) {
        log.warn("ServletContextListener not yet called");
        org.apache.myfaces.webapp.StartupServletContextListener.initFaces(servletConfig.getServletContext());
    }/*from  ww w . j  a  va  2  s. c o m*/
    delegate.init(servletConfig);
    log.info("MyFacesServlet for context '" + servletConfig.getServletContext().getRealPath("/")
            + "' initialized.");
}

From source file:org.intermine.web.logic.session.SessionMethods.java

/**
 * Get the SearchRepository for global (public) objects.
 *
 * @param context the servlet context/*from   w  w  w  .j av a2 s .  c o m*/
 * @return the singleton SearchRepository object
 */
public static SearchRepository getGlobalSearchRepository(ServletContext context) {
    return (SearchRepository) context.getAttribute(Constants.GLOBAL_SEARCH_REPOSITORY);
}

From source file:org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportImpl.java

private void checkPermission(File baseStorage, ServletContext servletContext) {
    BundleContext bundleContext = (BundleContext) servletContext.getAttribute("osgi-bundlecontext"); //$NON-NLS-1$
    Bundle bundle = bundleContext.getBundle();
    AccessControlContext accessControlContext = bundle.adapt(AccessControlContext.class);
    if (accessControlContext == null)
        return;/*from  www  . j a  v a  2s .c  o m*/
    accessControlContext.checkPermission(new FilePermission(baseStorage.getAbsolutePath(), "read,write")); //$NON-NLS-1$
}

From source file:org.intermine.web.logic.session.SessionMethods.java

/**
 * Returns the web properties.//from  w w  w. j av  a 2 s.  c o m
 *
 * @param servletContext a ServletContext object
 * @return a Properties object
 */
public static Properties getWebProperties(ServletContext servletContext) {
    return (Properties) servletContext.getAttribute(Constants.WEB_PROPERTIES);
}

From source file:org.intermine.web.logic.session.SessionMethods.java

/**
 * Gets the aspect categories from the servlet context.
 *
 * @param servletContext the ServletContext
 * @return a Set of aspect names/*from w w  w  . j a  v  a 2  s .  c om*/
 */
public static Set<String> getCategories(ServletContext servletContext) {
    return (Set<String>) servletContext.getAttribute(Constants.CATEGORIES);
}

From source file:org.intermine.web.logic.session.SessionMethods.java

/**
 * Get the InterMineAPI which provides access to core features of an InterMine application.
 * @param servletContext the webapp servletContext
 * @return the InterMine core object//w  w  w  .j ava 2 s . c o  m
 */
public static InterMineAPI getInterMineAPI(ServletContext servletContext) {
    return (InterMineAPI) servletContext.getAttribute(Constants.INTERMINE_API);
}

From source file:org.intermine.web.logic.session.SessionMethods.java

/**
 * Get the AutoCompleter stored on the ServletContext.
 *
 * @param servletContext a ServletContext object
 * @return the AutoCompleter//from www .ja  va  2s. co m
 */
public static AutoCompleter getAutoCompleter(ServletContext servletContext) {
    return (AutoCompleter) servletContext.getAttribute(Constants.AUTO_COMPLETER);
}

From source file:com.wooki.services.security.spring.TapestryResourceVoter.java

/**
 * Initialize tapestry context for spring security.
 * /*w  w w  .jav  a  2 s .c  om*/
 * @param ctx
 */
private void initTapestry(ServletContext ctx) {
    this.tapestryRegistry = (Registry) ctx.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);
    this.encoder = this.tapestryRegistry.getService(ComponentEventLinkEncoder.class);
    this.spoa = this.tapestryRegistry.getService(SessionPersistedObjectAnalyzer.class);
    this.applicationCharset = this.tapestryRegistry.getService(SymbolSource.class)
            .valueForSymbol(SymbolConstants.CHARSET);
    this.globals = this.tapestryRegistry.getService(RequestGlobals.class);
}