List of usage examples for javax.servlet ServletContext setAttribute
public void setAttribute(String name, Object object);
From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale.java
/** * Store a list of selectable Locales in the servlet context, so we can * easily build the selection panel in the GUI. Clears any forced locale. *//*from ww w .j ava 2 s . co m*/ public static void setSelectableLocales(ServletContext ctx, List<Locale> selectableLocales) { log.debug("Setting selectable locales: " + selectableLocales); ctx.setAttribute(ATTRIBUTE_NAME, new ContextSelectedLocale(selectableLocales)); }
From source file:org.codehaus.groovy.grails.web.context.GrailsConfigUtils.java
public static void configureServletContextAttributes(ServletContext servletContext, GrailsApplication application, GrailsPluginManager pluginManager, WebApplicationContext webContext) { servletContext.setAttribute(ApplicationAttributes.PLUGIN_MANAGER, pluginManager); // use config file locations if available servletContext.setAttribute(ApplicationAttributes.PARENT_APPLICATION_CONTEXT, webContext.getParent()); servletContext.setAttribute(GrailsApplication.APPLICATION_ID, application); servletContext.setAttribute(ApplicationAttributes.APPLICATION_CONTEXT, webContext); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); }
From source file:org.openmrs.contrib.metadatarepository.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the data layer. * * @param context The servlet context//from ww w. jav a 2 s. co m */ public static void setupContext(ServletContext context) { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); log.debug("Drop-down initialization complete [OK]"); CompassGps compassGps = ctx.getBean(CompassGps.class); compassGps.index(); }
From source file:edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList.java
/** * Get the current PolicyList from the context, or create one if there is * none. This method may return an empty list, but it never returns null. *//* w w w . java 2 s . co m*/ private static PolicyList getPolicyList(ServletContext ctx) { if (ctx == null) { throw new NullPointerException("ctx may not be null."); } Object obj = ctx.getAttribute(ATTRIBUTE_POLICY_LIST); if (obj == null) { obj = new PolicyList(); ctx.setAttribute(ATTRIBUTE_POLICY_LIST, obj); } if (!(obj instanceof PolicyList)) { throw new IllegalStateException("Expected to find an instance of " + PolicyList.class.getName() + " in the context, but found an instance of " + obj.getClass().getName() + " instead."); } return (PolicyList) obj; }
From source file:com.gisgraphy.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the * data layer./*w w w . j a va2 s .c om*/ * * @param context * The servlet context */ public static void setupContext(ServletContext context) { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); log.debug("Drop-down initialization complete [OK]"); }
From source file:ejportal.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the * data layer.//from w w w.j a v a 2 s.c o m * * @param context * The servlet context */ public static void setupContext(final ServletContext context) { final ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); final LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); StartupListener.log.debug("Drop-down initialization complete [OK]"); }
From source file:com.facetime.communication.activemq.AmqConsumer.java
public static void initContext(ServletContext context) { initConnectionFactory(context);//from w w w .ja va2 s . com context.setAttribute("webClients", new HashMap<String, AmqConsumer>()); if (selectorName == null) { selectorName = context.getInitParameter(SELECTOR_NAME); } if (selectorName == null) { selectorName = "selector"; } }
From source file:org.musicrecital.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the data layer. * * @param context The servlet context/* w ww .j a v a 2 s .co m*/ */ public static void setupContext(ServletContext context) { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); log.debug("Drop-down initialization complete [OK]"); // Any manager extending GenericManager will do: GenericManager manager = (GenericManager) ctx.getBean("userManager"); doReindexing(manager); log.debug("Full text search reindexing complete [OK]"); }
From source file:alpha.portal.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the * data layer.// w w w . j ava 2 s. c o m * * @param context * The servlet context */ public static void setupContext(final ServletContext context) { final ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); final LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); StartupListener.log.debug("Drop-down initialization complete [OK]"); final CompassGps compassGps = ctx.getBean(CompassGps.class); compassGps.index(); }
From source file:edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties.java
/** * Protected access, so the Stub class can call it for unit tests. * Otherwise, this should only be called by ConfigurationPropertiesSetup. *//* w w w . ja v a2 s .c om*/ protected static void setBean(ServletContext context, ConfigurationProperties bean) { if (context == null) { throw new NullPointerException("context may not be null."); } if (bean == null) { throw new NullPointerException("bean may not be null."); } context.setAttribute(ATTRIBUTE_NAME, bean); log.info(bean); }