List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:com.sonicle.webtop.core.app.JaxRsServiceApplication.java
private void configureServiceApis(WebTopApp wta, ServletConfig servletConfig) { ServiceManager svcMgr = wta.getServiceManager(); String serviceId = servletConfig.getInitParameter(RestApi.INIT_PARAM_WEBTOP_SERVICE_ID); if (StringUtils.isBlank(serviceId)) throw new WTRuntimeException( "Invalid servlet init parameter [" + RestApi.INIT_PARAM_WEBTOP_SERVICE_ID + "]"); ServiceDescriptor desc = svcMgr.getDescriptor(serviceId); if (desc == null) throw new WTRuntimeException("Service descriptor not found [{0}]", serviceId); if (desc.hasOpenApiDefinitions()) { for (ServiceDescriptor.OpenApiDefinition apiDefinition : desc.getOpenApiDefinitions()) { // Register resources for (Class clazz : apiDefinition.resourceClasses) { javax.ws.rs.Path pathAnnotation = (javax.ws.rs.Path) ClassHelper .getClassAnnotation(clazz.getSuperclass(), javax.ws.rs.Path.class); String resourcePath = "/" + PathUtils.concatPathParts(apiDefinition.context, pathAnnotation.value()); logger.debug("[{}] Registering JaxRs resource [{}] -> [{}]", servletConfig.getServletName(), clazz.toString(), resourcePath); registerResources(Resource.builder(clazz).path(resourcePath).build()); }/*from w w w .ja va 2s . c o m*/ // Configure OpenApi listing OpenAPI oa = new OpenAPI(); oa.info(desc.buildOpenApiInfo(apiDefinition)); SwaggerConfiguration oaConfig = new SwaggerConfiguration().openAPI(oa).prettyPrint(true) .resourcePackages(Stream.of(apiDefinition.implPackage).collect(Collectors.toSet())); try { new JaxrsOpenApiContextBuilder().servletConfig(servletConfig).application(this) .ctxId(apiDefinition.context).openApiConfiguration(oaConfig).buildContext(true); } catch (OpenApiConfigurationException ex) { logger.error("Unable to init swagger", ex); } } } }
From source file:com.autentia.common.util.web.ClasspathServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String[] arrayOfExtensions = { ".css", ".js", ".png", ".gif", ".jpg" }; final String extensions = config.getInitParameter("ALLOWED_EXTENSIONS"); if (extensions != null) { arrayOfExtensions = extensions.split(","); }/*from w w w. j a va 2s . com*/ allowedExtensions = new ArrayList<String>(Arrays.asList(arrayOfExtensions)); }
From source file:com.videobox.web.util.dwr.DwrVideoboxServlet.java
@Override protected Container createContainer(ServletConfig servletConfig) { if (logger.isDebugEnabled()) { logger.debug("Creating container for Custom DWR servlet"); }//from w w w .java 2 s . co m try { String packageList = servletConfig.getInitParameter("packages"); ServletContext ctx = servletConfig.getServletContext(); AutoAnnotationDiscoveryContainer container = new AutoAnnotationDiscoveryContainer(); String classNames = container.findAnnotatedClasses(packageList, ctx); if (logger.isDebugEnabled()) { logger.debug("discovered @RemoteProxy annotated classes: " + classNames); } container.addParameter("classes", classNames); StartupUtil.setupDefaultContainer(container, servletConfig); return container; } catch (Exception e) { e.printStackTrace(); return null; } finally { logger.info("Creation of Custom DWR servlet container done."); } }
From source file:be.fedict.eid.dss.webapp.AbstractProtocolServiceServlet.java
protected String getRequiredInitParameter(ServletConfig config, String initParamName) throws ServletException { String value = config.getInitParameter(initParamName); if (null == value) { throw new ServletException(initParamName + " init-param required"); }/*from w w w . j av a2s . c o m*/ return value; }
From source file:be.fedict.eid.idp.sp.protocol.openid.AuthenticationResponseServlet.java
private String getRequiredInitParameter(String parameterName, ServletConfig config) throws ServletException { String value = config.getInitParameter(parameterName); if (null == value) { throw new ServletException(parameterName + " init-param is required"); }/* w w w. j a v a2 s . c om*/ return value; }
From source file:com.sun.socialsite.web.rest.servlets.ImageServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); if ((defaultImage = config.getInitParameter("default-image")) == null) { throw new ServletException("Missing required parameter: default-image"); }//from w ww . j a va 2 s. co m String s; s = config.getInitParameter("handle-conditional-get"); if (s != null) handleConditionalGets = Boolean.parseBoolean(s); s = config.getInitParameter("image-width"); if (s != null) imageWidth = Integer.parseInt(s); s = config.getInitParameter("image-height"); if (s != null) imageHeight = Integer.parseInt(s); }
From source file:edu.gmu.csiss.automation.pacs.servlet.FileUploadServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); relativePath = config.getInitParameter("filepath"); tempPath = config.getInitParameter("temppath"); javax.servlet.ServletContext context = getServletContext(); filePath = context.getRealPath(relativePath); tempPath = context.getRealPath(tempPath); }
From source file:org.shredzone.shariff.ShariffServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String hosts = config.getInitParameter("host"); if (hosts != null) { hostPattern = Pattern.compile(hosts, Pattern.CASE_INSENSITIVE); }//from w w w .j a v a2 s .co m String cs = config.getInitParameter("cacheSize"); if (cs != null) { cacheSize = Integer.parseInt(cs); } String ttl = config.getInitParameter("cacheTimeToLiveMs"); if (ttl != null) { timeToLiveMs = Long.parseLong(ttl); } String trg = config.getInitParameter("targets"); if (trg != null) { targets = trg.split("[,:;]+"); for (int ix = 0; ix < targets.length; ix++) { targets[ix] = targets[ix].trim(); } } String thr = config.getInitParameter("threads"); if (thr != null) { threads = Integer.parseInt(thr); } }
From source file:org.pentaho.platform.web.servlet.ProxyServlet.java
@Override public void init(final ServletConfig servletConfig) throws ServletException { proxyURL = servletConfig.getInitParameter("ProxyURL"); //$NON-NLS-1$ if ((proxyURL == null)) { error(Messages.getInstance().getString("ProxyServlet.ERROR_0001_NO_PROXY_URL_SPECIFIED")); //$NON-NLS-1$ } else {/*from ww w. j a va 2 s. c o m*/ proxyURL.trim(); try { URL url = new URL(proxyURL); // Just doing this to verify // it's good info(Messages.getInstance().getString("ProxyServlet.INFO_0001_URL_SELECTED", url.toExternalForm())); // using 'url' to get rid of unused var compiler warning //$NON-NLS-1$ } catch (Throwable t) { error(Messages.getInstance().getErrorString("ProxyServlet.ERROR_0002_INVALID_URL", proxyURL)); //$NON-NLS-1$ proxyURL = null; } } errorURL = servletConfig.getInitParameter("ErrorURL"); super.init(servletConfig); }
From source file:org.moneta.MonetaServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return;//from ww w . j a v a 2 s.com String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if (!StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset = 0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } }