Example usage for javax.servlet.jsp PageContext APPLICATION_SCOPE

List of usage examples for javax.servlet.jsp PageContext APPLICATION_SCOPE

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext APPLICATION_SCOPE.

Prototype

int APPLICATION_SCOPE

To view the source code for javax.servlet.jsp PageContext APPLICATION_SCOPE.

Click Source Link

Document

Application scope: named reference remains available in the ServletContext until it is reclaimed.

Usage

From source file:net.ontopia.topicmaps.db2tm.Utils.java

/**
 * INTERNAL: Helper method for maintaining a relation mapping
 * instance throughout a page context./*from  w  w  w. j  av  a  2s.  co m*/
 */
public static RelationMapping getRelationMapping(PageContext ctxt) {
    RelationMapping db = (RelationMapping) ctxt.getAttribute("RelationMapping", PageContext.APPLICATION_SCOPE);
    if (db == null) {
        db = new RelationMapping();
        ctxt.setAttribute("RelationMapping", db, PageContext.APPLICATION_SCOPE);
    }
    return db;
}

From source file:org.shredzone.commons.taglib.proxy.AbstractTagProxy.java

/**
 * Gets the {@link BeanFactory} from the given {@link JspContext}. The default
 * implementation automagically finds a {@link BeanFactory} that was previously set by
 * a {@link FrameworkServlet}. The result is cached.
 *
 * @param jspContext/*w  w  w .  j  av a 2  s  .  c o m*/
 *            {@link JspContext} to be used
 * @return {@link BeanFactory} found
 */
@SuppressWarnings("unchecked")
protected BeanFactory getBeanFactory(JspContext jspContext) {
    Object bfCache = jspContext.getAttribute(TAGPROXY_BEANFACTORY_CACHE, PageContext.APPLICATION_SCOPE);
    if (bfCache != null && bfCache instanceof BeanFactory) {
        return (BeanFactory) bfCache;
    }

    Enumeration<String> en = jspContext.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
    while (en.hasMoreElements()) {
        String attribute = en.nextElement();
        if (attribute.startsWith(FrameworkServlet.SERVLET_CONTEXT_PREFIX)) {
            Object bf = jspContext.getAttribute(attribute, PageContext.APPLICATION_SCOPE);
            if (bf != null && bf instanceof BeanFactory) {
                BeanFactory bfBean = (BeanFactory) bf;
                jspContext.setAttribute(TAGPROXY_BEANFACTORY_CACHE, bfBean, PageContext.APPLICATION_SCOPE);
                return bfBean;
            }
        }
    }

    throw new IllegalStateException(
            "Could not find a BeanFactory. Use a FrameworkServlet or @BeanFactoryReference.");
}

From source file:info.magnolia.cms.taglibs.Out.java

/**
 * Setter for <code>scope</code>.
 * @param scope The scope to set.// w w w  .ja v a 2s.co m
 */
public void setScope(String scope) {
    if ("request".equalsIgnoreCase(scope)) { //$NON-NLS-1$
        this.scope = PageContext.REQUEST_SCOPE;
    } else if ("session".equalsIgnoreCase(scope)) { //$NON-NLS-1$
        this.scope = PageContext.SESSION_SCOPE;
    } else if ("application".equalsIgnoreCase(scope)) { //$NON-NLS-1$
        this.scope = PageContext.APPLICATION_SCOPE;
    } else {
        // default
        this.scope = PageContext.PAGE_SCOPE;
    }
}

From source file:net.mlw.vlh.web.tag.ValueListSpaceTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
 *//*from  w w w  .ja  v a 2s.  co  m*/
public int doStartTag() throws JspException {

    parentRootTag = (ValueListSpaceTag) findAncestorWithClass(this, ValueListSpaceTag.class);

    Object bean;

    if ("session".equals(valueListScope)) {
        bean = pageContext.getAttribute(valueListName, PageContext.SESSION_SCOPE);
    } else if ("application".equals(valueListScope)) {
        bean = pageContext.getAttribute(valueListName, PageContext.APPLICATION_SCOPE);
    } else {
        bean = pageContext.getAttribute(valueListName, PageContext.REQUEST_SCOPE);
    }

    if (bean != null) {
        if (bean instanceof ValueList) {
            setValueList((ValueList) bean);
        } else if (bean instanceof List) {
            setValueList(new DefaultListBackedValueList((List) bean));
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("List '" + valueListName + "' was wrapped with DefaultListBackedValueList.");
            }
        } else {
            String msg = "ValueList '" + valueListName + "' of of unknown type " + bean.getClass().getName()
                    + "!";
            LOGGER.warn(msg);
        }
    } else {
        LOGGER.error("ValueList '" + valueListName + "'  was not found in the scope '"
                + (valueListScope == null ? "request" : valueListScope) + "'!");
    }

    if (bean != null) {
        pageContext.setAttribute(valueListName, bean);
    }

    tableInfo.setName(valueListName);
    tableInfo.setConfig(getConfig());
    tableInfo.setPageContext(pageContext);
    // TODO Do not swallow this!!!!!
    pageContext.setAttribute(ImagesHomeDisplayHelper.IMAGES_HOME_ATTRIBUTE_KEY,
            ((HtmlDisplayProvider) tableInfo.getConfig().getDisplayProvider("html"))
                    .getImageHome((HttpServletRequest) pageContext.getRequest()));
    /**
     * @author Luciano Cunha
     */
    excludeParameters();

    return super.doStartTag();
}

From source file:com.googlecode.jtiger.modules.ecside.util.ExtremeUtils.java

/**
 * Get the bean out of the proper scope.
 *//*from w  w  w . ja v a 2s. c o  m*/
public static Object retrieveFromScope(PageContext pageContext, String name, String scope) {
    if (StringUtils.isBlank(scope)) {
        return pageContext.findAttribute(name);
    }

    int scopeType = PageContext.REQUEST_SCOPE;

    if (scope.equalsIgnoreCase("page")) {
        scopeType = PageContext.PAGE_SCOPE;
    } else if (scope.equalsIgnoreCase("application")) {
        scopeType = PageContext.APPLICATION_SCOPE;
    } else if (scope.equalsIgnoreCase("session")) {
        scopeType = PageContext.SESSION_SCOPE;
    }

    return pageContext.getAttribute(name, scopeType);
}

From source file:gov.nih.nci.cabig.caaers.web.tags.csm.CSMAccessControlTag.java

/**
 * Populates the variable in the specified scope. 
 * @param varValue// ww w.  jav a 2  s .c om
 */
private void setVariable(boolean varValue) {

    if (var == null)
        return;

    int intScope = StringUtils.equals(scope, "request") ? PageContext.REQUEST_SCOPE
            : StringUtils.equals(scope, "session") ? PageContext.SESSION_SCOPE
                    : StringUtils.equals(scope, "application") ? PageContext.APPLICATION_SCOPE
                            : PageContext.PAGE_SCOPE;

    pageContext.setAttribute(getVar(), varValue, intScope);
}

From source file:de.micromata.genome.gwiki.page.gspt.ServletStandalonePageContext.java

@Override
public Object getAttribute(String key, int scope) {
    switch (scope) {
    case PageContext.REQUEST_SCOPE:
        return request.getAttribute(key);
    case PageContext.APPLICATION_SCOPE:
        return servletCtx.getAttribute(key);
    case PageContext.SESSION_SCOPE:
        if (session != null) {
            return session.getAttribute(key);
        }/*from w w  w.j a  v  a  2  s.  c o m*/
        return null;
    default:
        return pageAttributes.get(key);
    }
}

From source file:ar.com.zauber.commons.web.uri.assets.AbstractSpringTag.java

/** @return {@link UriFactory} to use */
protected final UriFactory getUriFactory() {
    return resolve(UriFactory.class, SpringBeans.ASSET_URIFACTORY_KEY, REQUEST_URIFACTORY,
            REQUEST_URIFACTORY_WARNING, URIFACTORY_FACTORY, PageContext.APPLICATION_SCOPE);
}

From source file:de.micromata.genome.gwiki.page.gspt.StandAlonePageContext.java

private static void assertValidScope(int scope, boolean allowSession, boolean allowApplication) {
    if ((scope < PageContext.PAGE_SCOPE) || (scope > PageContext.APPLICATION_SCOPE)) {
        throw new IllegalArgumentException("scope " + scope + " not supported");
    }/*from ww  w  .j  a v  a  2 s  .  c  o  m*/
    if ((allowSession == false) && (scope == PageContext.SESSION_SCOPE)) {
        throw new IllegalArgumentException("session scope not supported");
    }
}

From source file:de.micromata.genome.gwiki.page.gspt.ServletStandalonePageContext.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//from w w  w  .j  a v a  2 s . c  om
public Enumeration getAttributeNamesInScope(int scope) {
    switch (scope) {
    case PageContext.REQUEST_SCOPE:
        return request.getAttributeNames();
    case PageContext.SESSION_SCOPE:
        if (session != null) {
            return session.getAttributeNames();
        }
        return IteratorUtils.asEnumeration(IteratorUtils.EMPTY_ITERATOR);
    case PageContext.APPLICATION_SCOPE:
        return servletCtx.getAttributeNames();
    default:
        return IteratorUtils.asEnumeration(pageAttributes.keySet().iterator());
    }

}