Overrides the servlet init method and loads sets the InputStream necessary
to load application.properties.
@throws ServletException a general error that occurs during initialization
322991
@Override
    public void init(ServletConfig config) throws ServletException {
        LOGGER.info("Initializing filesystem resource servlet");
        super.init(config);

        final String directory = config.getInitParameter("directory");
        if (StringUtils.isNotBlank(directory)) {
            this.directory = directory;
        }

        final String absolute = config.getInitParameter("absolute");
        if (StringUtils.isNotBlank(absolute)) {
            this.absolute = BooleanUtil.valueOf(absolute);
        }
    }
578402
public void init( ServletConfig config )
            throws ServletException
    {
        super.init( config );

        // Setup logging
        _log = new Logger( config, getResourceBundle() );
        _log.addDebug( "Initializing" );

        // Get extension from Servlet configuration, or use default
        JnlpResource.setDefaultExtensions( config.getInitParameter( PARAM_JNLP_EXTENSION ),
                                           config.getInitParameter( PARAM_JAR_EXTENSION ) );

        JnlpFileHandlerHook hook = createHook( config.getInitParameter(PARAM_JNLP_FILE_HANDLER_HOOK) );
	_jnlpFileHandler = new JnlpFileHandler( config.getServletContext(), hook, _log );
        _jarDiffHandler = new JarDiffHandler( config.getServletContext(), _log );
        _resourceCatalog = new ResourceCatalog( config.getServletContext(), _log );
    }
170528
@SuppressWarnings("unchecked")
    private void loadServlets(Map<String, ServletConfiguration> servlets, Environment environment) throws ClassNotFoundException {
        if (servlets != null) {
            for (Map.Entry<String, ServletConfiguration> servletEntry : servlets.entrySet()) {
                ServletConfiguration servlet = servletEntry.getValue();

                // Create servlet holder
                ServletHolder servletHolder = new ServletHolder((Class<? extends Servlet>) Class.forName(servlet.getClazz()));

                // Set name of servlet
                servletHolder.setName(servletEntry.getKey());

                // Set params
                if (servlet.getParam() != null) {
                    for (Map.Entry<String, String> entry : servlet.getParam().entrySet()) {
                        servletHolder.setInitParameter(entry.getKey(), entry.getValue());
                    }
                }

                // Add servlet
                environment.getApplicationContext().addServlet(servletHolder, servlet.getUrl());
            }
        }
    }
709700
public void init(ServletConfig servletConfig) throws ServletException {
		super.init(servletConfig);
		// If contributing bundle has a mime.types file in the META-INF directory, then
		// add the contents to the map
		URL url = getContributingBundle().getResource("META-INF/mime.types"); //$NON-NLS-1$
		if (url != null) {
			// Some implementations of MimetypesFileTypeMap (e.g. servicemix) don't
			// implement addMimeTypes() correctly, requiring us to feed it the mime.types
			// file line-by-line.
			BufferedReader reader = null;
			try {
				reader = new BufferedReader(new InputStreamReader(url.openStream()));
				String line;
				while ((line = reader.readLine()) != null) {
					super.fileTypeMap.addMimeTypes(line);
				}
			} catch (IOException e) {
				if (log.isLoggable(Level.WARNING)) {
					log.log(Level.WARNING, e.getMessage(), e);
				}
			} finally {
				if (reader != null) {
					IOUtils.closeQuietly(reader);
				}
			}
		}
		Dictionary<String, String> dict = new Hashtable<String, String>();
		dict.put("name", getName()); //$NON-NLS-1$
		registrations.add(new ServiceRegistrationOSGi(Activator.getBundleContext().registerService(
				IAggregator.class.getName(), this, dict)));

	}
847594
public function init()
    {

        // reset the servlet request
        $httpRequest = $this->getHttpRequest();

        // initialize the parts
        foreach ($httpRequest->getParts() as $part) {
            $this->addPart(Part::fromHttpRequest($part));
        }

        // set the body content if we can find one
        if ($httpRequest->getHeader(HttpProtocol::HEADER_CONTENT_LENGTH) > 0) {
            $this->setBodyStream($httpRequest->getBodyContent());
        }

        // copy server variables to members
        $this->setServerName($this->getServerVar(ServerVars::SERVER_NAME));
        $this->setQueryString($this->getServerVar(ServerVars::QUERY_STRING));
        $this->setRequestUri($this->getServerVar(ServerVars::X_REQUEST_URI));
        $this->setDocumentRoot($this->getServerVar(ServerVars::DOCUMENT_ROOT));
        $this->setRequestUrl($this->getServerVar(ServerVars::HTTP_HOST) . $this->getServerVar(ServerVars::X_REQUEST_URI));
    }
461614
@Override
    public void init() throws ServletException {
        super.init();

        // GET
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.accessPolicies, new GetAccessPolicies());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.allPolicies, new GetAllAccessPolicies());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.html,
                Operation.allPolicies, new GetHtmlAccessRules());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.supportedPrivileges, new SupportedPrivileges());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.restrictionNames, new RestrictionNames());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.principals, new GetPrincipals());

        // POST
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.reorder, new ReorderOperation());

        // PUT
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.accessPolicy, new PutAccessPolicy());

        // DELETE
        operations.setOperation(ServletOperationSet.Method.DELETE, Extension.json,
                Operation.accessPolicy, new RemoveAccessPolicy());
    }
982752
public void init(ServletConfig config) throws ServletException {
        super.init(config);
        mServletConfig = config;
        
        config.getServletContext().log("Initializing TeaServlet...");
        
        String ver = System.getProperty("java.version");
        if (ver.startsWith("0.") || ver.startsWith("1.2") ||
            ver.startsWith("1.3")) {
            config.getServletContext()
                .log("The TeaServlet requires Java 1.4 or higher to run properly");
        }

        mServletContext = setServletContext(config);
        mServletName = setServletName(config);
        
        mProperties = new PropertyMap();
        mSubstitutions = SubstitutionFactory.getDefaults();
        mResourceFactory = 
            new TeaServletResourceFactory(config.getServletContext(), 
                                          mSubstitutions);
        
        Enumeration<?> e = config.getInitParameterNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            String value = 
                SubstitutionFactory.substitute(config.getInitParameter(key));
            
            if (key.equals("debug")) {
                mDebugEnabled = Boolean.parseBoolean(value);
                continue;
            }

            mProperties.put(key, value);
        }

        loadDefaults();
        discoverProperties();
        createListeners();
        createLog(mServletContext);
        mLog.applyProperties(mProperties.subMap("log"));
        createMemoryLog(mLog);
        
        mInstrumentationEnabled = 
            mProperties.getBoolean("instrumentation.enabled", true);
        
        Initializer initializer = new Initializer();
        if (mProperties.getBoolean("startup.background", false)) {
            mInitializer = 
                Executors.newSingleThreadExecutor().submit(initializer);
        }
        else {
            initializer.call();
        }
    }
1203849
@Override
	protected void initServletContext(ServletContext servletContext) {
		super.initServletContext(servletContext);
		super.setExposeRequestAttributes(true);
		
		initBaseTemplatePath(servletContext);
		initSharedFunction();
	}
1186880
@Override
    public void init() throws ServletException {
        super.init();

        // GET
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
            Operation.list, new ListOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.tree, new TreeOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.query, new QueryOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.filterList, new ListFiltersOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.coverage, new CoverageOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.zip,
                Operation.download, new DownloadOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.html,
                Operation.download, new DownloadOperation());

        // POST
        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.service, new ServiceOperation());

        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.create, new CreateOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.update, new UpdateOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.upload, new UploadOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.install, new InstallOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
            Operation.uninstall, new UninstallOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.deploy, new ServiceOperation());

        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.filterChange, new ChangeFilterOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.filterAdd, new AddFilterOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.filterRemove, new RemoveFilterOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.filterMoveUp, new MoveFilterOperation(true));
        operations.setOperation(ServletOperationSet.Method.POST, Extension.html,
                Operation.filterMoveDown, new MoveFilterOperation(false));

        // PUT
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.update, new JsonUpdateOperation());

        // DELETE
        operations.setOperation(ServletOperationSet.Method.DELETE, Extension.json,
                Operation.delete, new DeleteOperation());
    }
75597
@Override
  public final void init (@Nonnull final ServletConfig aSC) throws ServletException
  {
    super.init (aSC);
    m_aStatusMgr.onServletInit (getClass ());
    try
    {
      // Build init parameter map
      final ICommonsMap <String, String> aInitParams = new CommonsHashMap <> ();
      final Enumeration <String> aEnum = aSC.getInitParameterNames ();
      while (aEnum.hasMoreElements ())
      {
        final String sName = aEnum.nextElement ();
        aInitParams.put (sName, aSC.getInitParameter (sName));
      }
      // Invoke each handler for potential initialization
      m_aHandlerRegistry.forEachHandlerThrowing (x -> x.onServletInit (aInitParams));
    }
    catch (final ServletException ex)
    {
      m_aStatusMgr.onServletInitFailed (ex, getClass ());
      throw ex;
    }
  }
237921
@SuppressWarnings("unchecked")
    @Override
    public void init() throws ServletException {

        ServletConfig config = getServletConfig();

		// Load the context, if present...
		try {
	        
			// Bootstrap the servlet Grammar instance...
        	final Grammar root = XmlGrammar.getMainGrammar();
	        final InputStream inpt = CernunnosServlet.class.getResourceAsStream("servlet.grammar");	// Can't rely on classpath:// protocol handler...
            final Document doc = new SAXReader().read(inpt);
            final Task k = new ScriptRunner(root).compileTask(doc.getRootElement());
    		final RuntimeRequestResponse req = new RuntimeRequestResponse();
    		final ReturnValueImpl rslt = new ReturnValueImpl();
    		req.setAttribute(Attributes.RETURN_VALUE, rslt);
    		k.perform(req, new RuntimeRequestResponse());
    		Grammar g = (Grammar) rslt.getValue();
	        runner = new ScriptRunner(g);

            // Choose a context location & load it if it exists...
            String defaultLoc = "/WEB-INF/" + config.getServletName() + "-portlet.xml";
            URL defaultUrl = getServletConfig().getServletContext().getResource(defaultLoc);
            URL u = Settings.locateContextConfig(
                    getServletConfig().getServletContext().getResource("/").toExternalForm(),
                        config.getInitParameter(CONFIG_LOCATION_PARAM), 
                        defaultUrl);
            if (u != null) {
                // There *is* a resource mapped to this path name...
                spring_context = new FileSystemXmlApplicationContext(u.toExternalForm());
            }
			
			if (log.isDebugEnabled()) {
				log.debug("Location of spring context (null means none):  " + u);
			}

			// Load the Settings...
			Map<String,String> settingsMap = new HashMap<String,String>();	// default...
			if (spring_context != null && spring_context.containsBean("settings")) {
				settingsMap = (Map<String,String>) spring_context.getBean("settings");
			}
			settings = Settings.load(settingsMap);

		} catch (Throwable t) {
			String msg = "Failure in CernunnosServlet.init()";
			throw new ServletException(msg, t);
		}

    }
590870
public void init(FilterConfig filterConfig)
        throws ServletException
    {
        _servletContext=filterConfig.getServletContext();
        _unwrappedDispatchSupported=Boolean.valueOf(filterConfig.getInitParameter("unwrappedDispatch")).booleanValue();
    }
988315
@Override
    public void init() throws ServletException {
        super.init();

        // filter configuration
        nodeFilters.put(KEY_REFERENCEABLE, buildTreeFilter(nodesConfig.getReferenceableNodesFilter()));
        nodeFilters.put(KEY_UNFILTERD, ResourceFilter.ALL);
        nodeFilters.put(KEY_PAGE, buildTreeFilter(nodesConfig.getPageNodeFilter()));
        nodeFilters.put(KEY_DEFAULT, nodesConfig.getDefaultNodeFilter());

        // GET
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.map, new MapGetOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.tree, new TreeOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.reference, new ReferenceOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.mixins, new GetMixinsOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.filters, new ListFiltersAsJson());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.html,
                Operation.filters, new ListFiltersAsHtml());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.typeahead, new TypeaheadOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.resolve, new ResolveOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json,
                Operation.query, new JsonQueryOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.html,
                Operation.query, new HtmlQueryOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.bin,
                Operation.load, new LoadBinaryOperation());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.bin,
                Operation.download, new DownloadBinaryOperation());

        // POST
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.map, new MapPostOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.create, new CreateOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.bin,
                Operation.query, new ExportQueryOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.copy, new CopyOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.move, new MoveOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.lock,
                Operation.toggle, new ToggleLockOperation());
        operations.setOperation(ServletOperationSet.Method.POST, Extension.json,
                Operation.fileUpdate, new UpdateFileOperation());

        // PUT
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.map, new MapPutOperation());
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.create, new PutCreateOperation());
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.copy, new PutCopyOperation());
        operations.setOperation(ServletOperationSet.Method.PUT, Extension.json,
                Operation.move, new PutMoveOperation());

        // DELETE
        operations.setOperation(ServletOperationSet.Method.DELETE, Extension.json,
                Operation.delete, new DeleteOperation());
    }
1165788
public void init() throws ServletException {
		ServletContext sc = this.getServletContext();
		String configList = this.getServletConfig().getInitParameter("configList");
		String[] configs = StringUtil.split(configList, ",");
		for (int i = 0; i < configs.length; i++) {
			Debug.logVerbose("[JdonFramework] locate a configuration in web.xml :" + configs[i], module);
			css.prepare(configs[i], new ServletContextWrapper(sc));
		}
	}
688924
private void load() {
        InputStream propertiesInputStream = null;
        try {
            propertiesInputStream = propertiesInputStream();
            if (propertiesInputStream == null) {
                throw new IllegalArgumentException("The properties file could not be loaded!");
            }
            properties.load(propertiesInputStream);
        } catch (IOException e) {
            LOGGER.error("Can't load properties", e);
        } finally {
            try {
                if (propertiesInputStream != null) {
                    propertiesInputStream.close();
                }
            } catch (IOException e) {
                LOGGER.error("Can't close the properties InputStream", e);
            }
        }
    }
380755
public void init() throws UnavailableException
    {
        ServletContext config = getServletContext();
        _servletHandler = ((ServletHandler.Context) config).getServletHandler();
        _httpContext = _servletHandler.getHttpContext();

        _acceptRanges = getInitBoolean("acceptRanges");
        _dirAllowed = getInitBoolean("dirAllowed");
        _putAllowed = getInitBoolean("putAllowed");
        _delAllowed = getInitBoolean("delAllowed");
        _redirectWelcomeFiles = getInitBoolean("redirectWelcome");
        _minGzipLength = getInitInt("minGzipLength");

        String rrb = getInitParameter("relativeResourceBase");
        if (rrb != null)
        {
            try
            {
                _resourceBase = _httpContext.getBaseResource().addPath(rrb);
            }
            catch (Exception e)
            {
                log.warn(LogSupport.EXCEPTION, e);
                throw new UnavailableException(e.toString());
            }
        }

        String rb = getInitParameter("resourceBase");

        if (rrb != null && rb != null)
            throw new UnavailableException("resourceBase & relativeResourceBase");

        if (rb != null)
        {
            try
            {
                _resourceBase = Resource.newResource(rb);
            }
            catch (Exception e)
            {
                log.warn(LogSupport.EXCEPTION, e);
                throw new UnavailableException(e.toString());
            }
        }
        if (log.isDebugEnabled())
            log.debug("resource base = " + _resourceBase);

        if (_putAllowed)
            _AllowString += ", PUT";
        if (_delAllowed)
            _AllowString += ", DELETE";
        if (_putAllowed && _delAllowed)
            _AllowString += ", MOVE";
    }
474242
public void init(ServletConfig config)
        throws ServletException
    {
        super.init(config);

        try {
            if (_homeImpl != null) {
            }
            else if (getInitParameter("home-class") != null) {
                String className = getInitParameter("home-class");

                Class<?> homeClass = loadClass(className);

                _homeImpl = homeClass.newInstance();

                init(_homeImpl);
            }
            else if (getInitParameter("service-class") != null) {
                String className = getInitParameter("service-class");

                Class<?> homeClass = loadClass(className);

                _homeImpl = homeClass.newInstance();

                init(_homeImpl);
            }
            else {
                if (getClass().equals(HessianServlet.class))
                    throw new ServletException("server must extend HessianServlet");

                _homeImpl = this;
            }

            if (_homeAPI != null) {
            }
            else if (getInitParameter("home-api") != null) {
                String className = getInitParameter("home-api");

                _homeAPI = loadClass(className);
            }
            else if (getInitParameter("api-class") != null) {
                String className = getInitParameter("api-class");

                _homeAPI = loadClass(className);
            }
            else if (_homeImpl != null) {
                _homeAPI = findRemoteAPI(_homeImpl.getClass());

                if (_homeAPI == null)
                    _homeAPI = _homeImpl.getClass();

                _homeAPI = _homeImpl.getClass();
            }

            if (_objectImpl != null) {
            }
            else if (getInitParameter("object-class") != null) {
                String className = getInitParameter("object-class");

                Class<?> objectClass = loadClass(className);

                _objectImpl = objectClass.newInstance();

                init(_objectImpl);
            }

            if (_objectAPI != null) {
            }
            else if (getInitParameter("object-api") != null) {
                String className = getInitParameter("object-api");

                _objectAPI = loadClass(className);
            }
            else if (_objectImpl != null)
                _objectAPI = _objectImpl.getClass();

            _homeSkeleton = new HessianSkeleton(_homeImpl, _homeAPI);

            if (_objectAPI != null)
                _homeSkeleton.setObjectClass(_objectAPI);

            if (_objectImpl != null) {
                _objectSkeleton = new HessianSkeleton(_objectImpl, _objectAPI);
                _objectSkeleton.setHomeClass(_homeAPI);
            }
            else
                _objectSkeleton = _homeSkeleton;

            if ("true".equals(getInitParameter("debug"))) {
            }

            if ("false".equals(getInitParameter("send-collection-type")))
                setSendCollectionType(false);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }