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:com.concursive.connect.web.controller.servlets.URLControllerServlet.java
protected static Connection getConnection(ServletContext context) throws SQLException { ConnectionElement ce = getConnectionElement(context); ConnectionPool sqlDriver = (ConnectionPool) context.getAttribute("ConnectionPool"); return sqlDriver.getConnection(ce, false); }
From source file:edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionRegistry.java
/** * Create the registry and store it in the context. *//*from w ww . j a v a 2 s .c om*/ public static void createRegistry(ServletContext ctx, Collection<? extends Permission> permissions) { if (ctx == null) { throw new NullPointerException("ctx may not be null."); } if (permissions == null) { throw new NullPointerException("permissions may not be null."); } if (ctx.getAttribute(ATTRIBUTE_NAME) != null) { throw new IllegalStateException("PermissionRegistry has already been set."); } PermissionRegistry registry = new PermissionRegistry(); registry.addPermissions(permissions); ctx.setAttribute(ATTRIBUTE_NAME, registry); }
From source file:org.apache.hadoop.fs.webdav.WebdavServlet.java
private static Configuration getConf(ServletContext application) { Configuration conf = (Configuration) application.getAttribute("dfs.servlet.conf.key"); if (conf == null) { conf = hadoopConfig;// w w w.ja v a 2s. c o m Enumeration e = application.getInitParameterNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); conf.set(name, application.getInitParameter(name)); } application.setAttribute("dfs.servlet.conf.key", conf); } if (currentUserName != null) { WebAppContext webapp = (WebAppContext) application.getAttribute(WebdavServer.WEB_APP_CONTEXT); WebdavHashUserRealm userRealm = (WebdavHashUserRealm) webapp.getSecurityHandler().getUserRealm(); List<String> userRoles = userRealm.getUserRoles(currentUserName); currentUserRoles = userRoles; UnixUserGroupInformation ugi = new UnixUserGroupInformation(currentUserName, userRoles.toArray(new String[0])); UnixUserGroupInformation.saveToConf(conf, UnixUserGroupInformation.UGI_PROPERTY_NAME, ugi); } return conf; }
From source file:edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder.java
public static IndexBuilder getBuilder(ServletContext ctx) { Object o = ctx.getAttribute(IndexBuilder.class.getName()); if (o instanceof IndexBuilder) { return (IndexBuilder) o; } else {// w ww . j a v a 2 s. com log.error("IndexBuilder has not been initialized."); return null; } }
From source file:org.apache.tapestry.asset.AssetExternalizer.java
/** * Gets the externalizer singleton for the application. If it does not already * exist, it is created and stored into the {@link ServletContext}. * * <p>Each Tapestry application within a single {@link ServletContext} * will have its own externalizer; they are differentiated by the * application name.//from ww w .j ava 2s . c o m * * @see org.apache.tapestry.spec.ApplicationSpecification#getName() * **/ public static AssetExternalizer get(IRequestCycle cycle) { HttpServlet servlet = cycle.getRequestContext().getServlet(); ServletContext context = servlet.getServletContext(); String servletName = servlet.getServletName(); String attributeName = "org.apache.tapestry.AssetExternalizer:" + servletName; AssetExternalizer result = (AssetExternalizer) context.getAttribute(attributeName); if (result == null) { result = new AssetExternalizer(cycle); context.setAttribute(attributeName, result); } return result; }
From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache.java
/** * Use getVClassGroupCache(ServletContext) to get a VClassGroupCache. *///from www.j av a 2 s . c om public static VClassGroupCache getVClassGroupCache(ServletContext sc) { return (VClassGroupCache) sc.getAttribute(ATTRIBUTE_NAME); }
From source file:org.apache.nutch.searcher.NutchBean.java
/** * Returns the cached instance in the servlet context. * /*from ww w . ja va 2s . co m*/ * @see NutchBeanConstructor */ public static NutchBean get(ServletContext app, Configuration conf) throws IOException { final NutchBean bean = (NutchBean) app.getAttribute(KEY); return bean; }
From source file:com.concursive.connect.web.rss.servlets.FeedServlet.java
protected static Connection getConnection(ServletContext context) throws SQLException { ConnectionElement ce = getConnectionElement(context); ConnectionPool sqlDriver = (ConnectionPool) context.getAttribute("ConnectionPoolRSS"); return sqlDriver.getConnection(ce, false); }
From source file:com.takin.mvc.mvc.server.CommonsMultipartResolver.java
/** * Return the temporary directory for the current web application, * as provided by the servlet container.//from w ww . jav a 2 s . c o m * @param servletContext the servlet context of the web application * @return the File representing the temporary directory */ private static File getTempDir(ServletContext servletContext) { Assert.notNull(servletContext, "ServletContext must not be null"); return (File) servletContext.getAttribute(TEMP_DIR_CONTEXT_ATTRIBUTE); }
From source file:org.apache.ofbiz.widget.WidgetWorker.java
public static String determineAutoLinkType(String linkType, String target, String targetType, HttpServletRequest request) {//from w ww. ja v a2 s.co m if ("auto".equals(linkType)) { if ("intra-app".equals(targetType)) { String requestUri = (target.indexOf('?') > -1) ? target.substring(0, target.indexOf('?')) : target; ServletContext servletContext = request.getSession().getServletContext(); RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); ConfigXMLReader.RequestMap requestMap = null; try { requestMap = rh.getControllerConfig().getRequestMapMap().get(requestUri); } catch (WebAppConfigurationException e) { Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); } if (requestMap != null && requestMap.event != null) { return "hidden-form"; } else { return "anchor"; } } else { return "anchor"; } } else { return linkType; } }