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.kuali.ext.mm.web.listener.StandaloneInitializeListener.java
/** * Configures the default config location by first checking the init params for default locations and then falling back to the * standard default config location./*from ww w .j a v a2 s. co m*/ */ protected void addDefaultConfigLocation(ServletContext context, List<String> configLocations) { String defaultConfigLocation = context.getInitParameter(KEWConstants.DEFAULT_CONFIG_LOCATION_PARAM); if (!StringUtils.isEmpty(defaultConfigLocation)) { String[] locations = defaultConfigLocation.split(","); for (String location : locations) { configLocations.add(location); } } else { configLocations.add(KEWConstants.DEFAULT_SERVER_CONFIG_LOCATION); } }
From source file:com.dien.upload.server.UploadAction.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext ctx = config.getServletContext(); removeSessionFiles = "true".equalsIgnoreCase(ctx.getInitParameter("removeSessionFiles")); removeData = "true".equalsIgnoreCase(ctx.getInitParameter("removeData")); logger.info("UPLOAD-ACTION init: removeSessionFiles=" + removeSessionFiles + ", removeData=" + removeData); }
From source file:com.haulmont.cuba.web.sys.singleapp.SingleAppWebContextLoader.java
@Override protected String getAppPropertiesConfig(ServletContext sc) { return sc.getInitParameter("appPropertiesConfigWeb"); }
From source file:org.jbpm.bpel.tutorial.shipping.ShippingPT_Impl.java
public void init(Object context) throws ServiceException { // initialize jms administered objects try {//from w w w . j ava2 s .c o m initJmsObjects(); } catch (Exception e) { throw new ServiceException("Could not initialize jms objects", e); } // retrieve servlet context ServletEndpointContext endpointContext = (ServletEndpointContext) context; ServletContext servletContext = endpointContext.getServletContext(); // initialize shipping price parameter String shippingPriceString = servletContext.getInitParameter(SHIPPING_PRICE_PARAM); if (shippingPriceString == null) { throw new ServiceException("Required parameter not found: " + SHIPPING_PRICE_PARAM); } NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(); try { shippingPrice = currencyFormat.parse(shippingPriceString).floatValue(); log.debug("Set parameter: " + SHIPPING_PRICE_PARAM + ", value=" + shippingPrice); } catch (ParseException e) { throw new ServiceException("Invalid parameter: " + SHIPPING_PRICE_PARAM, e); } }
From source file:gwtupload.server.UploadAction.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext ctx = config.getServletContext(); removeSessionFiles = Boolean.valueOf(ctx.getInitParameter("removeSessionFiles")); removeData = Boolean.valueOf(ctx.getInitParameter("removeData")); logger.info("UPLOAD-ACTION init: removeSessionFiles=" + removeSessionFiles + ", removeData=" + removeData); }
From source file:org.apache.shindig.common.servlet.GuiceServletContextListener.java
public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); //HNN setting all system.properties specified in the web.xml setSystemProperties(context);//from w ww . ja v a2s.com String moduleNames = context.getInitParameter(MODULES_ATTRIBUTE); List<Module> modules = Lists.newLinkedList(); if (moduleNames != null) { for (String moduleName : StringUtils.split(moduleNames, ':')) { try { moduleName = moduleName.trim(); if (moduleName.length() > 0) { modules.add((Module) Class.forName(moduleName).newInstance()); } } catch (InstantiationException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } Injector injector = Guice.createInjector(Stage.PRODUCTION, modules); context.setAttribute(INJECTOR_ATTRIBUTE, injector); try { if (!jmxInitialized) { Manager.manage("ShindigGuiceContext", injector); jmxInitialized = true; } } catch (Exception e) { // Ignore errors } }
From source file:org.kuali.coeus.sys.framework.service.KcServiceLocatorListener.java
/** * Translates context parameters from the web.xml into entries in a Properties file. *//*from www .j ava 2s . c om*/ protected Properties getContextParameters(ServletContext context) { Properties properties = new Properties(); for (String paramName : CollectionUtils.toIterable(context.getInitParameterNames())) { properties.put(paramName, context.getInitParameter(paramName)); } return properties; }
From source file:org.apache.juddi.v3.client.config.WebHelperTest.java
@Test public void testGetUDDIClientRandom() throws Exception { System.out.println("testGetUDDIClientRandom"); String random = UUID.randomUUID().toString(); ServletContext req = createNiceMock(ServletContext.class); req.setAttribute(UDDI_CLIENT_NAME, random); req.setAttribute(JUDDI_CLIENT_NAME, null); expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 1); expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(random).times(0, 1); //using default config // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); // expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 2); //using default config // expect(req.getAttribute(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); //expect(req.getAttribute(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); replay(req);/*from ww w .java 2 s . c om*/ UDDIClient result = WebHelper.getUDDIClient(req); Assert.assertNotNull(result); }
From source file:org.pentaho.platform.web.http.context.HsqldbStartupListener.java
public void contextInitialized(ServletContextEvent sce) { ServletContext ctx = sce.getServletContext(); logger.debug("Starting HSQLDB Embedded Listener"); //$NON-NLS-1$ HsqlDatabaseStarterBean starterBean = new HsqlDatabaseStarterBean(); String port = ctx.getInitParameter("hsqldb-port"); //$NON-NLS-1$ int portNum = -1; if (port != null) { logger.debug(String.format("Port override specified: %s", port)); //$NON-NLS-1$ try {// ww w . ja va2 s.co m portNum = Integer.parseInt(port); starterBean.setPort(portNum); } catch (NumberFormatException ex) { logger.error(Messages.getErrorString("HsqldbStartupListener.ERROR_0004_INVALID_PORT", "9001")); //$NON-NLS-1$ port = null; // force check default port } } starterBean.setDatabases(getDatabases(ctx)); String sampleDataAllowPortFailover = ctx.getInitParameter("hsqldb-allow-port-failover"); //$NON-NLS-1$ if ((sampleDataAllowPortFailover != null) && (sampleDataAllowPortFailover.equalsIgnoreCase("true"))) { //$NON-NLS-1$ logger.debug(String.format("Allow Port Failover specified")); //$NON-NLS-1$ starterBean.setAllowPortFailover(true); } if (starterBean.start()) { ctx.setAttribute("hsqldb-starter-bean", starterBean); //$NON-NLS-1$ } }
From source file:net.sourceforge.safr.jaas.web.spring.SecureContextLoader.java
@Override public WebApplicationContext initWebApplicationContext(ServletContext sc) throws IllegalStateException, BeansException { WebApplicationContext context = super.initWebApplicationContext(sc); // identify authentication service and put into holder class String authenticationServiceName = sc.getInitParameter("authenticationServiceName"); AuthenticationService service = (AuthenticationService) context.getBean(authenticationServiceName); AuthenticationServiceHolder.getInstance().setAuthenticationService(service); // identify instance policy and set as global policy String instancePolicyName = sc.getInitParameter("instancePolicyName"); InstancePolicy policy = (InstancePolicy) context.getBean(instancePolicyName); installInstancePolicy(policy);//from w w w . j av a 2 s . c o m return context; }