List of usage examples for javax.servlet ServletContext getInitParameter
public String getInitParameter(String name);
String
containing the value of the named context-wide initialization parameter, or null
if the parameter does not exist. From source file:org.acoustid.server.ApplicationContextListener.java
@Override public void contextInitialized(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); String configFileName = servletContext.getInitParameter("config"); logger.info("Loading configuration from " + configFileName); XMLConfiguration config;/* w w w . jav a 2s . c om*/ try { config = new XMLConfiguration(configFileName); } catch (ConfigurationException ex) { throw new RuntimeException("Couldn't load configuration file", ex); } Injector injector = Guice.createInjector(new ServerModule(config)); logger.debug("Setting injector"); servletContext.setAttribute(INJECTOR_ATTRIBUTE_NAME, injector); }
From source file:com.almende.eve.deploy.EveListener.java
@Override public void contextInitialized(ServletContextEvent sce) { final ServletContext sc = sce.getServletContext(); // Get the eve.yaml file: String path = sc.getInitParameter("eve_config"); if (path != null && !path.isEmpty()) { final String fullname = "/WEB-INF/" + path; LOG.info("loading configuration file '" + sc.getRealPath(fullname) + "'..."); final InputStream is = sc.getResourceAsStream(fullname); if (is == null) { LOG.warning("Can't find the given configuration file:" + sc.getRealPath(fullname)); return; }/*from w w w. ja v a2s . c o m*/ myConfig = Boot.boot(is); } }
From source file:com.ocpsoft.pretty.faces.config.spi.ContextSpecifiedConfigurationProvider.java
private List<String> getConfigFilesList(ServletContext context) { final String configFiles = context.getInitParameter(PrettyContext.CONFIG_KEY); final List<String> configFilesList = new ArrayList<String>(); if (configFiles != null) { final StringTokenizer st = new StringTokenizer(configFiles, ",", false); while (st.hasMoreTokens()) { final String systemId = st.nextToken().trim(); if (DefaultXMLConfigurationProvider.DEFAULT_PRETTY_FACES_CONFIG.equals(systemId)) { log.warn("The file [" + DefaultXMLConfigurationProvider.DEFAULT_PRETTY_FACES_CONFIG + "] has been specified in the [" + PrettyContext.CONFIG_KEY + "] context parameter of " + "the deployment descriptor; this is unecessary and will be ignored."); } else { configFilesList.add(systemId); }/*from w ww . j a v a 2s . com*/ } } return configFilesList; }
From source file:org.sakaiproject.context.util.LocatorServletContextListener.java
public void contextInitialized(ServletContextEvent sce) { try {//from w ww .j a v a 2s . c om locator = (ServletContextLocator) ComponentManager.getInstance().get(ServletContextLocator.class); if (locator == null) { M_log.error(error); return; } } catch (Exception e) { M_log.error(error, e); } ServletContext context = sce.getServletContext(); String name = context.getInitParameter("sakai-context-name"); if (name == null) { name = ServletUtil.computeContextName(context); name = name.substring(0, name.length() - 1); } locator.registerContext(name, context); contextName = name; }
From source file:org.guzz.web.context.ContextLoader.java
public GuzzContext initGuzzContext(ServletContext sc) throws Exception { String configFile = sc.getInitParameter(CONFIG_LOCATION_PARAM); if (configFile == null) { configFile = "/WEB-INF/guzz.xml"; }//ww w . jav a 2 s. c om String name = sc.getRealPath(configFile); FileResource fr = new FileResource(name); try { GuzzContext gf = new Configuration(fr).newGuzzContext(); return initGuzzContext(sc, gf); } finally { CloseUtil.close(fr); } }
From source file:org.shangridocs.services.stringdb.StringDBResource.java
public StringDBResource(@Context ServletContext sc) { this.baseUrl = sc.getInitParameter(BASE_URL_KEY); }
From source file:de.highbyte_le.weberknecht.request.ModelHelper.java
public ModelHelper(HttpServletRequest request, ServletContext context) { this.request = request; String mp = context.getInitParameter("model_prefix"); this.modelPrefix = (mp != null ? mp : DEFAULT_MODEL_PREFIX); if (log.isDebugEnabled()) log.debug("using model prefix " + modelPrefix); }
From source file:xbdd.webapp.factory.ServletContextMongoClientFactory.java
public ServletContextMongoClientFactory(@Context final ServletContext context) { this.host = Objects.toString(context.getInitParameter(XBDD_MONGO_HOSTNAME_INIT_PARAMETER), ServerAddress.defaultHost()); this.username = context.getInitParameter(XBDD_MONGO_USERNAME_INIT_PARAMETER); this.password = context.getInitParameter(XBDD_MONGO_PASSWORD_INIT_PARAMETER) != null ? context.getInitParameter(XBDD_MONGO_PASSWORD_INIT_PARAMETER).toCharArray() : null;//from w w w . java2 s . co m this.port = NumberUtils.isNumber(context.getInitParameter(XBDD_MONGO_PORT_INIT_PARAMETER)) ? Integer.parseInt(context.getInitParameter(XBDD_MONGO_PORT_INIT_PARAMETER)) : ServerAddress.defaultPort(); }
From source file:org.wso2.carbon.device.mgt.extensions.feature.mgt.lifecycle.listener.FeatureManagementLifecycleListener.java
@Override public void lifecycleEvent(LifecycleEvent lifecycleEvent) { if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType())) { StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); ServletContext servletContext = context.getServletContext(); String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); if (isManagedApi) { try { AnnotationProcessor annotationProcessor = new AnnotationProcessor(context); Set<String> annotatedAPIClasses = annotationProcessor .scanStandardContext(DeviceType.class.getName()); Map<String, List<Feature>> features = annotationProcessor.extractFeatures(annotatedAPIClasses); if (features != null && !features.isEmpty()) { GenericFeatureManager.getInstance().addFeatures(features); }//from w ww .ja v a 2 s. c o m } catch (IOException e) { log.error("Error enconterd while discovering annotated classes.", e); } catch (ClassNotFoundException e) { log.error("Error while scanning class for annotations.", e); } } } }
From source file:com.athena.sqs.MessageDispatchListener.java
public void contextInitialized(ServletContextEvent sce) { ServletContext servletContext = sce.getServletContext(); sqsConfigLocation = servletContext.getInitParameter("sqsConfigLocation"); String realPath = servletContext.getRealPath(sqsConfigLocation); if (logger.isDebugEnabled()) { logger.debug("****************** SQS Config ******************"); logger.debug("LOCATION : " + sqsConfigLocation); logger.debug("REAL LOCATION : " + realPath); logger.debug("************************************************"); }//from w w w . j ava2 s. com ApplicationContext applicationContext = (ApplicationContext) servletContext .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); // TODO : You can load your own application config here }