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:InitParamServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/plain"); PrintWriter out = res.getWriter(); String url = getInitParameter("URL"); ServletConfig config = getServletConfig(); ServletContext context = getServletContext(); String uid = config.getInitParameter("UID"); String pwd = config.getInitParameter("PWD"); String port = context.getInitParameter("some-port"); out.println("Values retrieved for the init parameters are: "); out.println("URL: " + url); out.println("UID: " + uid); out.println("PWD: " + pwd); out.println("some-port: " + port); }
From source file:org.lightadmin.core.config.StandardLightAdminConfiguration.java
public StandardLightAdminConfiguration(ServletContext servletContext) { this.basePackage = servletContext.getInitParameter(LIGHT_ADMINISTRATION_BASE_PACKAGE); this.applicationBaseUrl = servletContext.getInitParameter(LIGHT_ADMINISTRATION_BASE_URL); this.applicationBaseNoEndSeparator = urlWithoutEndSeparator(this.applicationBaseUrl); this.backToSiteUrl = backToSiteUrl(servletContext); this.helpUrl = helpUrl(servletContext); this.fileStorageDirectory = fileStorageDirectory(servletContext); this.fileStreaming = BooleanUtils .toBoolean(servletContext.getInitParameter(LIGHT_ADMINISTRATION_FILE_STREAMING)); this.demoMode = BooleanUtils.toBoolean(servletContext.getInitParameter(LIGHT_ADMINISTRATION_DEMO_MODE)); this.securityEnabled = BooleanUtils .toBoolean(servletContext.getInitParameter(LIGHT_ADMINISTRATION_SECURITY)); if (securityEnabled) { this.securityLogoutUrl = servletContext.getContextPath() + this.applicationBaseNoEndSeparator + LIGHT_ADMIN_SECURITY_LOGOUT_URL_DEFAULT; } else {//from w w w.ja v a 2 s. c om this.securityLogoutUrl = servletContext.getContextPath() + defaultIfBlank( servletContext.getInitParameter(LIGHT_ADMINISTRATION_SECURITY_LOGOUT_URL), "#"); } }
From source file:org.pentaho.platform.web.http.context.HsqldbStartupListener.java
private Map<String, String> getDatabases(ServletContext ctx) { HashMap<String, String> map = new LinkedHashMap<String, String>(); String dbs = ctx.getInitParameter("hsqldb-databases"); //$NON-NLS-1$ String[] dbEntries = dbs.split(","); //$NON-NLS-1$ for (int i = 0; i < dbEntries.length; i++) { String[] entry = dbEntries[i].split("@"); //$NON-NLS-1$ if ((entry.length != 2) || (StringUtils.isEmpty(entry[0])) || (StringUtils.isEmpty(entry[1]))) { logger.equals(/*from ww w . j av a 2 s. com*/ Messages.getErrorString("HsqlDatabaseStartupListener.ERROR_0001_HSQLDB_ENTRY_MALFORMED")); //$NON-NLS-1$ continue; } map.put(entry[0], entry[1]); } return map; }
From source file:org.jbpm.bpel.integration.server.IntegrationConfigurator.java
public void contextInitialized(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); String configResource = servletContext.getInitParameter(JBPM_CONFIG_RESOURCE_PARAM); JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(configResource); JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try {/*w w w .j av a2s .c o m*/ // read the app descriptor from a classpath resource DeploymentDescriptor deploymentDescriptor = DeploymentDescriptor.readDeploymentDescriptor(jbpmContext); // obtain the integration control for the process definition referenced in the descriptor BpelProcessDefinition processDefinition = deploymentDescriptor.findProcessDefinition(jbpmContext); JmsIntegrationServiceFactory integrationServiceFactory = JmsIntegrationServiceFactory .getConfigurationInstance(jbpmConfiguration); IntegrationControl integrationControl = integrationServiceFactory .getIntegrationControl(processDefinition); // make app descriptor available to message activities integrationControl.setDeploymentDescriptor(deploymentDescriptor); // start receiving requests integrationControl.enableInboundMessageActivities(jbpmContext); // make integration control available to jax-rpc handlers servletContext.setAttribute(SoapHandler.INTEGRATION_CONTROL_ATTR, integrationControl); log.info("message reception enabled for process: " + deploymentDescriptor.getName()); } catch (RuntimeException e) { jbpmContext.setRollbackOnly(); throw e; } catch (NamingException e) { jbpmContext.setRollbackOnly(); throw new BpelException("could not start bpel application", e); } catch (JMSException e) { jbpmContext.setRollbackOnly(); throw new BpelException("could not start bpel application", e); } finally { jbpmContext.close(); } }
From source file:com.curl.orb.context.ApplicationContextFactory.java
protected ApplicationContextFactory(ServletContext context) throws ApplicationContextException { try {/*from w ww.j ava 2 s .co m*/ String applicationContextClassName = context.getInitParameter(APPLICATION_CONTEXT_CLASS); if (applicationContextClassName != null) { Class<?> applicationContextClass = Class.forName(applicationContextClassName); applicationContext = (AbstractApplicationContext) (applicationContextClass .getDeclaredConstructor(ServletContext.class).newInstance(context)); } } catch (ClassNotFoundException e) { throw new ApplicationContextException(e); } catch (NoSuchMethodException e) { throw new ApplicationContextException(e); } catch (IllegalAccessException e) { throw new ApplicationContextException(e); } catch (InvocationTargetException e) { throw new ApplicationContextException(e); } catch (InstantiationException e) { throw new ApplicationContextException(e); } if (applicationContext == null) applicationContext = new ServletApplicationContext(context); }
From source file:org.tangram.guice.DefaultTangramContextListener.java
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { LOG.info("contextInitialized()"); ServletContext context = servletContextEvent.getServletContext(); String webModuleClassName = context.getInitParameter(SHIRO_WEB_MODULE_CLASS); String dispatcherPath = context.getInitParameter(DISPATCHER_PATH); dispatcherPath = dispatcherPath == null ? "/s" : dispatcherPath; if (StringUtils.isNotBlank(webModuleClassName)) { try {/*from w w w . ja v a 2s. c o m*/ Class<?> forName = Class.forName(webModuleClassName); Object[] args = { context, dispatcherPath }; shiroWebModule = (Module) forName.getConstructors()[0].newInstance(args); } catch (Exception e) { LOG.error("contextInitialized() cannot obtain shiro web module", e); } // try/catch } // if LOG.info("contextInitialized() shiro web module: {} :{}", shiroWebModule, webModuleClassName); String servletModuleClassName = context.getInitParameter(SERVLET_MODULE_CLASS); if (StringUtils.isNotBlank(servletModuleClassName)) { try { Class<?> forName = Class.forName(servletModuleClassName); servletModule = (ServletModule) forName.getConstructors()[0].newInstance(new Object[0]); } catch (Exception e) { LOG.error("contextInitialized() cannot obtain servlet module", e); } // try/catch } // if servletModule = servletModule == null ? new TangramServletModule() : servletModule; LOG.info("contextInitialized() servlet module: {} :{}", servletModule, servletModuleClassName); super.contextInitialized(servletContextEvent); }
From source file:com.github.persapiens.jsfboot.butterfaces.ButterfacesServletContextInitializerIT.java
public void testOnStartup() throws ServletException { ButterfacesServletContextInitializer butterfacesServletContextInitializer = new ButterfacesServletContextInitializer( this.butterfacesProperties); ServletContext servletContext = new MockServletContext(); butterfacesServletContextInitializer.onStartup(servletContext); assertThat(//www . ja va 2 s . c o m servletContext.getInitParameter(WebXmlParameters.CTX_PARAM_AJAX_DISABLE_RENDER_REGIONS_ON_REQUEST)) .isEqualTo("true"); }
From source file:org.joinfaces.butterfaces.ButterfacesServletContextInitializerIT.java
@Test public void testOnStartup() throws ServletException { ButterfacesServletContextInitializer butterfacesServletContextInitializer = new ButterfacesServletContextInitializer( this.butterfacesProperties); ServletContext servletContext = new MockServletContext(); butterfacesServletContextInitializer.onStartup(servletContext); assertThat(// ww w .j a v a 2s .com servletContext.getInitParameter(WebXmlParameters.CTX_PARAM_AJAX_DISABLE_RENDER_REGIONS_ON_REQUEST)) .isEqualTo("true"); }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.AbstractFilter.java
private void initTimeoutParameters(ServletContext context) { String page = context.getInitParameter(PARAM_TIMEOUT_PAGE); if (StringUtils.isNotEmpty(page)) { timeoutPage = page;/*from w w w . java 2 s . c om*/ } }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.AbstractFilter.java
private void initErrorParameters(ServletContext context) { String page = context.getInitParameter(PARAM_ERROR_PAGE); if (StringUtils.isNotEmpty(page)) { errorPage = page;//from w w w .j a va2 s . co m } }