List of usage examples for javax.servlet ServletContext getAttribute
public Object getAttribute(String name);
null
if there is no attribute by that name. From source file:org.intermine.bio.webservice.GFFQueryService.java
/** * Read the SO term name to class name mapping file and return it as a Map from class name to * SO term name. The Map is cached as the SO_CLASS_NAMES attribute in the servlet context. * * @throws ServletException if the SO class names properties file cannot be found * @param servletContext the ServletContext * @return a map/* w w w . ja v a 2 s . co m*/ */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static Map<String, String> getSoClassNames(ServletContext servletContext) throws ServletException { final String soClassNames = "SO_CLASS_NAMES"; Properties soNameProperties; if (servletContext.getAttribute(soClassNames) == null) { soNameProperties = new Properties(); try { InputStream is = servletContext.getResourceAsStream("/WEB-INF/soClassName.properties"); soNameProperties.load(is); } catch (Exception e) { throw new ServletException("Error loading so class name mapping file", e); } servletContext.setAttribute(soClassNames, soNameProperties); } else { soNameProperties = (Properties) servletContext.getAttribute(soClassNames); } return new HashMap<String, String>((Map) soNameProperties); }
From source file:edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper.java
public static PropertyRestrictionPolicyHelper getBean(ServletContext ctx) { Object attribute = ctx.getAttribute(ATTRIBUTE_NAME); if (!(attribute instanceof PropertyRestrictionPolicyHelper)) { throw new IllegalStateException("PropertyRestrictionPolicyHelper has not been initialized."); }//from ww w. j a v a 2s. c om return (PropertyRestrictionPolicyHelper) attribute; }
From source file:edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.java
public static ModelAccess on(ServletContext ctx) { Object o = ctx.getAttribute(ATTRIBUTE_NAME); if (o instanceof ModelAccess) { return (ModelAccess) o; } else {/*from www .j a va 2 s .co m*/ ModelAccess ma = new ModelAccess(Scope.CONTEXT, null); ctx.setAttribute(ATTRIBUTE_NAME, ma); return ma; } }
From source file:edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.DataGetterUtils.java
public static Map<String, PageDataGetter> getPageDataGetterMap(ServletContext sc) { setupDataGetters(sc);//from w ww . j ava 2s .c om return (Map<String, PageDataGetter>) sc.getAttribute(DATA_GETTER_MAP); }
From source file:org.artifactory.webapp.servlet.RequestUtils.java
/** * @param servletContext The servlet context * @return The artifactory spring context *//* w w w . jav a 2 s . co m*/ public static ArtifactoryContext getArtifactoryContext(ServletContext servletContext) { return (ArtifactoryContext) servletContext.getAttribute(ArtifactoryContext.APPLICATION_CONTEXT_KEY); }
From source file:be.fedict.eid.idp.protocol.saml2.AbstractSAML2ProtocolService.java
public static IdentityProviderConfiguration getIdPConfiguration(ServletContext servletContext) { return (IdentityProviderConfiguration) servletContext.getAttribute(IDP_CONFIG_CONTEXT_ATTRIBUTE); }
From source file:com.kurento.kmf.spring.KurentoApplicationContextUtils.java
public static void registerKurentoServletContextListener(ServletContext ctx) { // Add listener for closing Kurento ApplicationContexts on container // shutdown//from w w w .ja v a 2s. co m if (ctx.getAttribute(KURENTO_SERVLET_CONTEXT_LISTENER_ATTRIBUTE_NAME) != null) { log.info("Kurento ServletContextListener already registered, we don't register it again ..."); return; } log.info("Registering Kurento ServletContextListener ..."); ctx.setAttribute(KURENTO_SERVLET_CONTEXT_LISTENER_ATTRIBUTE_NAME, "initialized"); ctx.addListener(KurentoServletContextListener.class); }
From source file:edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean.java
public static RevisionInfoBean getBean(ServletContext context) { if (context == null) { log.warn("Tried to get revision info bean from a null context"); return DUMMY_BEAN; }/* www .j a v a 2 s .c o m*/ Object o = context.getAttribute(ATTRIBUTE_NAME); if (o == null) { log.warn("Tried to get revision info bean, but didn't find any."); return DUMMY_BEAN; } if (!(o instanceof RevisionInfoBean)) { log.error("Tried to get revision info bean, but found an instance of " + o.getClass().getName() + ": " + o); return DUMMY_BEAN; } return (RevisionInfoBean) o; }
From source file:com.apdplat.platform.spring.APDPlatContextLoaderListener.java
/** * Find all ServletContext attributes which implement {@link DisposableBean} * and destroy them, removing all affected ServletContext attributes eventually. * @param sc the ServletContext to check */// w w w.j av a2 s .c om static void cleanupAttributes(ServletContext sc) { Enumeration attrNames = sc.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); if (attrName.startsWith("org.springframework.")) { Object attrValue = sc.getAttribute(attrName); if (attrValue instanceof DisposableBean) { try { ((DisposableBean) attrValue).destroy(); } catch (Throwable ex) { logger.error("Couldn't invoke destroy method of attribute with name '" + attrName + "'", ex); } } } } }
From source file:com.concursive.connect.web.controller.servlets.URLControllerServlet.java
protected static ConnectionElement getConnectionElement(ServletContext context) { ApplicationPrefs prefs = (ApplicationPrefs) context.getAttribute("applicationPrefs"); ConnectionElement ce = new ConnectionElement(); ce.setDriver(prefs.get("SITE.DRIVER")); ce.setUrl(prefs.get("SITE.URL")); ce.setUsername(prefs.get("SITE.USER")); ce.setPassword(prefs.get("SITE.PASSWORD")); return ce;//from www .j a v a2 s. c om }