List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:com.ucap.uccc.cmis.impl.atompub.CmisAtomPubServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); // set the binding setBinding(CallContext.BINDING_ATOMPUB); // get and CMIS version String cmisVersionStr = config.getInitParameter(CNPRM_CMIS_VERSION); if (cmisVersionStr != null) { try {//from ww w . j av a 2s. co m setCmisVersion(CmisVersion.fromValue(cmisVersionStr)); } catch (IllegalArgumentException e) { LOG.warn("CMIS version is invalid! Setting it to CMIS 1.0."); setCmisVersion(CmisVersion.CMIS_1_0); } } else { LOG.warn("CMIS version is not defined! Setting it to CMIS 1.0."); setCmisVersion(CmisVersion.CMIS_1_0); } // initialize resources addResource("", METHOD_GET, new RepositoryService.GetRepositories()); addResource(RESOURCE_TYPES, METHOD_GET, new RepositoryService.GetTypeChildren()); addResource(RESOURCE_TYPES, METHOD_POST, new RepositoryService.CreateType()); addResource(RESOURCE_TYPESDESC, METHOD_GET, new RepositoryService.GetTypeDescendants()); addResource(RESOURCE_TYPE, METHOD_GET, new RepositoryService.GetTypeDefinition()); addResource(RESOURCE_TYPE, METHOD_PUT, new RepositoryService.UpdateType()); addResource(RESOURCE_TYPE, METHOD_DELETE, new RepositoryService.DeleteType()); addResource(RESOURCE_CHILDREN, METHOD_GET, new NavigationService.GetChildren()); addResource(RESOURCE_DESCENDANTS, METHOD_GET, new NavigationService.GetDescendants()); addResource(RESOURCE_FOLDERTREE, METHOD_GET, new NavigationService.GetFolderTree()); addResource(RESOURCE_PARENTS, METHOD_GET, new NavigationService.GetObjectParents()); addResource(RESOURCE_CHECKEDOUT, METHOD_GET, new NavigationService.GetCheckedOutDocs()); addResource(RESOURCE_ENTRY, METHOD_GET, new ObjectService.GetObject()); addResource(RESOURCE_OBJECTBYID, METHOD_GET, new ObjectService.GetObject()); addResource(RESOURCE_OBJECTBYPATH, METHOD_GET, new ObjectService.GetObjectByPath()); addResource(RESOURCE_ALLOWABLEACIONS, METHOD_GET, new ObjectService.GetAllowableActions()); addResource(RESOURCE_CONTENT, METHOD_GET, new ObjectService.GetContentStream()); addResource(RESOURCE_CONTENT, METHOD_PUT, new ObjectService.SetOrAppendContentStream()); addResource(RESOURCE_CONTENT, METHOD_DELETE, new ObjectService.DeleteContentStream()); addResource(RESOURCE_CHILDREN, METHOD_POST, new ObjectService.Create()); addResource(RESOURCE_RELATIONSHIPS, METHOD_POST, new ObjectService.CreateRelationship()); addResource(RESOURCE_ENTRY, METHOD_PUT, new ObjectService.UpdateProperties()); addResource(RESOURCE_ENTRY, METHOD_DELETE, new ObjectService.DeleteObject()); addResource(RESOURCE_CHILDREN, METHOD_DELETE, new ObjectService.DeleteTree()); // 1.1 addResource(RESOURCE_DESCENDANTS, METHOD_DELETE, new ObjectService.DeleteTree()); addResource(RESOURCE_FOLDERTREE, METHOD_DELETE, new ObjectService.DeleteTree()); addResource(RESOURCE_BULK_UPDATE, METHOD_POST, new ObjectService.BulkUpdateProperties()); addResource(RESOURCE_CHECKEDOUT, METHOD_POST, new VersioningService.CheckOut()); addResource(RESOURCE_VERSIONS, METHOD_GET, new VersioningService.GetAllVersions()); addResource(RESOURCE_VERSIONS, METHOD_DELETE, new VersioningService.DeleteAllVersions()); addResource(RESOURCE_QUERY, METHOD_GET, new DiscoveryService.Query()); addResource(RESOURCE_QUERY, METHOD_POST, new DiscoveryService.Query()); addResource(RESOURCE_CHANGES, METHOD_GET, new DiscoveryService.GetContentChanges()); addResource(RESOURCE_RELATIONSHIPS, METHOD_GET, new RelationshipService.GetObjectRelationships()); addResource(RESOURCE_UNFILED, METHOD_POST, new MultiFilingService.RemoveObjectFromFolder()); addResource(RESOURCE_ACL, METHOD_GET, new AclService.GetAcl()); addResource(RESOURCE_ACL, METHOD_PUT, new AclService.ApplyAcl()); addResource(RESOURCE_POLICIES, METHOD_GET, new PolicyService.GetAppliedPolicies()); addResource(RESOURCE_POLICIES, METHOD_POST, new PolicyService.ApplyPolicy()); addResource(RESOURCE_POLICIES, METHOD_DELETE, new PolicyService.RemovePolicy()); }
From source file:org.mobicents.servlet.sip.example.SimpleSipServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { logger.info("the simple sip servlet has been started"); super.init(servletConfig); RABBITMQ_CONN_URL = servletConfig.getInitParameter("rabbitmq_conn_url"); EXCHANGE_NAME = servletConfig.getInitParameter("exchange_name"); String pool_max_active = servletConfig.getInitParameter("rabbitmq_pool_max_active"); String pool_max_idle = servletConfig.getInitParameter("rabbitmq_pool_max_idle"); String pool_min_idle = servletConfig.getInitParameter("rabbitmq_pool_min_idle"); String time_between_evication = servletConfig.getInitParameter("rabbitmq_pool_time_between_eviction"); String idle_time_before_eviction = servletConfig .getInitParameter("rabbitmq_pool_idle_time_before_eviction"); logger.info("INIT PARAM: rabbitmq_conn_url = " + RABBITMQ_CONN_URL); logger.info("INIT PARAM : exchange name = " + EXCHANGE_NAME); logger.info("INIT PARAM : pool max active = " + pool_max_active); logger.info("INIT PARAM : pool max idle = " + pool_max_idle); logger.info("INIT PARAM : pool min idle = " + pool_min_idle); logger.info("INIT PARAM : time_between_evication = " + time_between_evication); logger.info("INIT PARAM : idle_time_before_eviction = " + idle_time_before_eviction); try {//w w w .j a v a 2 s.co m POOL_MAX_ACTIVE = Integer.parseInt(pool_max_active); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool max active : " + pool_max_active, e); } try { POOL_MAX_IDLE = Integer.parseInt(pool_max_idle); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool max idle : " + pool_max_idle, e); } try { POOL_MIN_IDLE = Integer.parseInt(pool_min_idle); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool min idle : " + pool_min_idle, e); } try { TIME_BETWEEN_EVICTION = Integer.parseInt(time_between_evication); } catch (NumberFormatException e) { logger.error("Impossible to parse the time between eviction : " + time_between_evication, e); } try { IDL_TIME_BEFORE_EVICTION = Integer.parseInt(idle_time_before_eviction); } catch (NumberFormatException e) { logger.error("Impossible to parse idle time before eviction : " + idle_time_before_eviction, e); } /** * create static instance of rabbitmq connection pool */ try { GenericObjectPool.Config config = new GenericObjectPool.Config(); config.maxActive = POOL_MAX_ACTIVE; config.maxIdle = POOL_MAX_IDLE; config.minIdle = POOL_MIN_IDLE; config.timeBetweenEvictionRunsMillis = TIME_BETWEEN_EVICTION; config.minEvictableIdleTimeMillis = IDL_TIME_BEFORE_EVICTION; config.testOnBorrow = false; config.testOnReturn = false; config.lifo = GenericObjectPool.DEFAULT_LIFO; config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL; pool = new GenericObjectPool<Channel>(new ConnectionPoolableObjectFactory(RABBITMQ_CONN_URL), config); //create an initial pool instances. /* int initSize = 25; for (int i =0; i < initSize; i++) { try { pool.addObject(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } */ /* pool.setMaxActive(POOL_MAX_ACTIVE); //maximum connection allowed in the pool (100). If reached, worker thread needs to be blocked to wait. pool.setMinIdle(POOL_MIN_IDLE); //keep minimum idle connection (set to 3) in pool in all time. pool.setMaxIdle(POOL_MAX_IDLE); //No minimum to create new connection when needed (set to -1). pool.setTimeBetweenEvictionRunsMillis(TIME_BETWEEN_EVICTION); //wait up eviction thread in 10 second pool.setMinEvictableIdleTimeMillis(IDL_TIME_BEFORE_EVICTION); //kill the idle connection that is 5 second old pool.setTestOnBorrow(true); //sanity checking when getting connection from pool. pool.setTestOnReturn(true); //sanity check when returning connection to pool. */ } catch (IOException ex) { logger.error("RabbitMQ Pool failed to create. Error = " + ex.getMessage()); throw new ServletException(ex); } //logger.info("HELLO... FINISHED LOADING THE RABBITMQ CONNECTION/CHANNEL POOL"); }
From source file:com.att.cspd.SimpleSipServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { logger.info("the simple sip servlet has been started"); super.init(servletConfig); RABBITMQ_CONN_URL = servletConfig.getInitParameter("rabbitmq_conn_url"); EXCHANGE_NAME = servletConfig.getInitParameter("exchange_name"); String pool_max_active = servletConfig.getInitParameter("rabbitmq_pool_max_active"); String pool_max_idle = servletConfig.getInitParameter("rabbitmq_pool_max_idle"); String pool_min_idle = servletConfig.getInitParameter("rabbitmq_pool_min_idle"); String time_between_evication = servletConfig.getInitParameter("rabbitmq_pool_time_between_eviction"); String idle_time_before_eviction = servletConfig .getInitParameter("rabbitmq_pool_idle_time_before_eviction"); logger.info("INIT PARAM: rabbitmq_conn_url = " + RABBITMQ_CONN_URL); logger.info("INIT PARAM : exchange name = " + EXCHANGE_NAME); logger.info("INIT PARAM : pool max active = " + pool_max_active); logger.info("INIT PARAM : pool max idle = " + pool_max_idle); logger.info("INIT PARAM : pool min idle = " + pool_min_idle); logger.info("INIT PARAM : time_between_evication = " + time_between_evication); logger.info("INIT PARAM : idle_time_before_eviction = " + idle_time_before_eviction); try {//from w w w .j a v a 2 s . c o m POOL_MAX_ACTIVE = Integer.parseInt(pool_max_active); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool max active : " + pool_max_active, e); } try { POOL_MAX_IDLE = Integer.parseInt(pool_max_idle); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool max idle : " + pool_max_idle, e); } try { POOL_MIN_IDLE = Integer.parseInt(pool_min_idle); } catch (NumberFormatException e) { logger.error("Impossible to parse the pool min idle : " + pool_min_idle, e); } try { TIME_BETWEEN_EVICTION = Integer.parseInt(time_between_evication); } catch (NumberFormatException e) { logger.error("Impossible to parse the time between eviction : " + time_between_evication, e); } try { IDL_TIME_BEFORE_EVICTION = Integer.parseInt(idle_time_before_eviction); } catch (NumberFormatException e) { logger.error("Impossible to parse idle time before eviction : " + idle_time_before_eviction, e); } /** * create static instance of rabbitmq connection pool */ try { GenericObjectPool.Config config = new GenericObjectPool.Config(); config.maxActive = POOL_MAX_ACTIVE; config.maxIdle = POOL_MAX_IDLE; config.minIdle = POOL_MIN_IDLE; config.timeBetweenEvictionRunsMillis = TIME_BETWEEN_EVICTION; config.minEvictableIdleTimeMillis = IDL_TIME_BEFORE_EVICTION; config.testOnBorrow = true; config.testOnReturn = true; config.lifo = GenericObjectPool.DEFAULT_LIFO; config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL; pool = new GenericObjectPool<Channel>(new ConnectionPoolableObjectFactory(RABBITMQ_CONN_URL), config); //create an initial pool instances. /* int initSize = 25; for (int i =0; i < initSize; i++) { try { pool.addObject(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } */ /* pool.setMaxActive(POOL_MAX_ACTIVE); //maximum connection allowed in the pool (100). If reached, worker thread needs to be blocked to wait. pool.setMinIdle(POOL_MIN_IDLE); //keep minimum idle connection (set to 3) in pool in all time. pool.setMaxIdle(POOL_MAX_IDLE); //No minimum to create new connection when needed (set to -1). pool.setTimeBetweenEvictionRunsMillis(TIME_BETWEEN_EVICTION); //wait up eviction thread in 10 second pool.setMinEvictableIdleTimeMillis(IDL_TIME_BEFORE_EVICTION); //kill the idle connection that is 5 second old pool.setTestOnBorrow(true); //sanity checking when getting connection from pool. pool.setTestOnReturn(true); //sanity check when returning connection to pool. */ } catch (IOException ex) { logger.error("RabbitMQ Pool failed to create. Error = " + ex.getMessage()); throw new ServletException(ex); } //logger.info("HELLO... FINISHED LOADING THE RABBITMQ CONNECTION/CHANNEL POOL"); }
From source file:org.apache.pulsar.proxy.server.AdminProxyHandler.java
@Override protected HttpClient createHttpClient() throws ServletException { ServletConfig config = getServletConfig(); HttpClient client = newHttpClient(); client.setFollowRedirects(true);/* w w w . jav a 2s . com*/ // Must not store cookies, otherwise cookies of different clients will mix. client.setCookieStore(new HttpCookieStore.Empty()); Executor executor; String value = config.getInitParameter("maxThreads"); if (value == null || "-".equals(value)) { executor = (Executor) getServletContext().getAttribute("org.eclipse.jetty.server.Executor"); if (executor == null) throw new IllegalStateException("No server executor for proxy"); } else { QueuedThreadPool qtp = new QueuedThreadPool(Integer.parseInt(value)); String servletName = config.getServletName(); int dot = servletName.lastIndexOf('.'); if (dot >= 0) servletName = servletName.substring(dot + 1); qtp.setName(servletName); executor = qtp; } client.setExecutor(executor); value = config.getInitParameter("maxConnections"); if (value == null) value = "256"; client.setMaxConnectionsPerDestination(Integer.parseInt(value)); value = config.getInitParameter("idleTimeout"); if (value == null) value = "30000"; client.setIdleTimeout(Long.parseLong(value)); value = config.getInitParameter("requestBufferSize"); if (value != null) client.setRequestBufferSize(Integer.parseInt(value)); value = config.getInitParameter("responseBufferSize"); if (value != null) client.setResponseBufferSize(Integer.parseInt(value)); try { client.start(); // Content must not be decoded, otherwise the client gets confused. client.getContentDecoderFactories().clear(); // Pass traffic to the client, only intercept what's necessary. ProtocolHandlers protocolHandlers = client.getProtocolHandlers(); protocolHandlers.clear(); protocolHandlers.put(new RedirectProtocolHandler(client)); return client; } catch (Exception x) { throw new ServletException(x); } }
From source file:net.centro.rtb.monitoringcenter.MonitoringCenterServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); boolean disableAuthorization = Boolean.TRUE.toString() .equalsIgnoreCase(servletConfig.getInitParameter(DISABLE_AUTHORIZATION_INIT_PARAM)); if (!disableAuthorization) { String credentials = null; String username = servletConfig.getInitParameter(USERNAME_INIT_PARAM); String password = servletConfig.getInitParameter(PASSWORD_INIT_PARAM); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { credentials = username.trim() + ":" + password.trim(); } else {//w w w .j a va 2 s . c o m credentials = DEFAULT_CREDENTIALS; } this.encodedCredentials = BaseEncoding.base64().encode(credentials.getBytes()); } this.objectMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MICROSECONDS, false)) .registerModule(new HealthCheckModule()).setSerializationInclusion(JsonInclude.Include.NON_NULL) .setTimeZone(TimeZone.getDefault()).setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")); this.graphiteMetricFormatter = new GraphiteMetricFormatter(TimeUnit.SECONDS, TimeUnit.MICROSECONDS); try { this.threadDumpGenerator = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError ignore) { } ServletContext servletContext = servletConfig.getServletContext(); String servletSpecVersion = servletContext.getMajorVersion() + "." + servletContext.getMinorVersion(); this.serverInfo = ServerInfo.create(servletContext.getServerInfo(), servletSpecVersion); }
From source file:kornell.server.ProxyServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); String doLogStr = servletConfig.getInitParameter(P_LOG); if (doLogStr != null) { this.doLog = Boolean.parseBoolean(doLogStr); }/*from www . j a v a2 s . c o m*/ String doForwardIPString = servletConfig.getInitParameter(P_FORWARDEDFOR); if (doForwardIPString != null) { this.doForwardIP = Boolean.parseBoolean(doForwardIPString); } try { targetUriObj = new URI(servletConfig.getInitParameter(P_TARGET_URI)); } catch (Exception e) { throw new RuntimeException("Trying to process targetUri init parameter: " + e, e); } targetUri = targetUriObj.toString(); HttpParams hcParams = new BasicHttpParams(); readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class); proxyClient = createHttpClient(hcParams); }
From source file:org.wings.session.WingServlet.java
protected void initLookupName(ServletConfig config) { // with specified lookupname it is possible to handle different sessions // for servlet aliases/mappings lookupName = config.getInitParameter("wings.servlet.lookupname"); if (lookupName == null || lookupName.trim().length() == 0) { lookupName = "SessionServlet:" + config.getInitParameter("wings.mainclass"); }/* w w w . j a v a 2 s. com*/ log.info("use session servlet lookup name " + lookupName); }
From source file:org.xsystem.sql2.http.PageServlet2.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); this.config = config; repositoryPath = config.getInitParameter("repository"); repositoryPath = config.getServletContext().getRealPath(repositoryPath); loadRepository();/* w ww . j a v a 2s . c o m*/ }
From source file:nl.strohalm.cyclos.servlets.ImageByIdServlet.java
@Override public void init(final ServletConfig config) throws ServletException { super.init(config); final ServletContext context = getServletContext(); // Resolve dependencies SpringHelper.injectBeans(context, this); // Check if we will display thumbnails isThumbnail = "true".equals(config.getInitParameter("thumbnail")); // Check if we will use the disk cache try {/*w ww. j a v a 2 s. c o m*/ useCache = "true".equals( CyclosConfiguration.getCyclosProperties().getProperty("cyclos.imageDiskCache.enable", "true")); } catch (final Exception e) { useCache = false; } // When using the disk cache, create the directories if (useCache) { cacheDir = new File( getServletContext().getRealPath(isThumbnail ? THUMBNAILS_CACHE_PATH : IMAGES_CACHE_PATH)); LOG.debug("Using disk cache for " + (isThumbnail ? "thumbnails" : "images") + " at " + cacheDir.getAbsolutePath()); } // Add a listener for image changes SpringHelper.bean(context, CustomizedFileHandler.class).addImageChangeListener(new ImageChangeListener() { @Override public void onImageChanged(final Image image) { final File file = new File(cacheDir, image.getId().toString()); customizationHelper.deleteFile(file); } }); }
From source file:org.atomserver.server.servlet.AtomServerServlet.java
protected void loadSpringContext() { if (appContext == null) { ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); if (context != null) { logger.debug("LOADING: WebApplicationContextUtils.getRequiredWebApplicationContext(context))"); appContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context); } else {//from ww w .j a v a 2s. c om logger.debug("LOADING: new ClassPathXmlApplicationContext( .... )"); appContext = new ClassPathXmlApplicationContext( config.getInitParameter(SPRING_APPLICATION_CONTEXT_FILE)); } if (logger.isDebugEnabled()) { logger.debug("Application context set:: appContext= " + appContext); } } }