Initialization method that parses the URL template config file to
get the URL templates and template reference groups.

@param servletContext the current ServletContext.
197576
public void load( ServletContext servletContext )
    {
        _urlTemplates = new URLTemplates();
        InputStream xmlInputStream = null;
        InputStream xsdInputStream = null;

        try
        {
            xmlInputStream = servletContext.getResourceAsStream( _configFilePath );
            if ( xmlInputStream != null ) {
                /* load the XSD input stream */
                xsdInputStream = SCHEMA_RESOLVER.getInputStream();

                final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
                final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
                final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";

                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setValidating(true);
                dbf.setNamespaceAware(true);
                dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                dbf.setAttribute(JAXP_SCHEMA_SOURCE, xsdInputStream);

                DocumentBuilder db = dbf.newDocumentBuilder();

                /* add an ErrorHandler that just logs validation problems */
                db.setErrorHandler(new ErrorHandler() {
                    public void warning(SAXParseException exception) {
                        _log.info("Validation warning validating config file \"" + _configFilePath + "\" against XML Schema \"" + SCHEMA_RESOLVER.getResourcePath());
                    }

                    public void error(SAXParseException exception) {
                        _log.error("Validation errors occurred parsing the config file \"" + _configFilePath + "\".  Cause: " + exception, exception);
                    }

                    public void fatalError(SAXParseException exception) {
                        _log.error("Validation errors occurred parsing the config file \"" + _configFilePath + "\".  Cause: " + exception, exception);
                    }
                });

                db.setEntityResolver(new EntityResolver() {
                    public InputSource resolveEntity(String publicId, String systemId) {
                        if(systemId.endsWith("/url-template-config.xsd")) {
                            InputStream inputStream = DefaultURLTemplatesFactory.class.getClassLoader().getResourceAsStream(CONFIG_SCHEMA);
                            return new InputSource(inputStream);
                        }
                        else return null;
                    }
                });

                Document document = db.parse(xmlInputStream);
                Element root = document.getDocumentElement();
                loadTemplates( root );
                loadTemplateRefGroups( root );
       }
       else
       {
           if ( _log.isInfoEnabled() )
               _log.info( "Running without URL template descriptor, " + _configFilePath );
       }
   }
   catch ( ParserConfigurationException pce )
   {
       _log.error( "Problem loading URL template descriptor file " + _configFilePath, pce );
   }
   catch ( SAXException se )
   {
       _log.error( "Problem parsing URL template descriptor in " + _configFilePath, se );
   }
   catch ( IOException ioe )
   {
       _log.error( "Problem reading URL template descriptor file " + _configFilePath, ioe );
   }
   finally
   {
       // Close the streams
       try { if ( xmlInputStream != null ) xmlInputStream.close(); } catch ( Exception ignore ) {}
       try { if ( xsdInputStream != null ) xsdInputStream.close(); } catch( IOException ignore ) {}
   }
}
182610
public void init(FilterConfig filterConfig) throws ServletException {
		// need the Context for Logging, instantiating ClassLoader, etc
		ServletContextAccess sca=new ServletContextAccess(filterConfig); 
		if(access==null) {
			access = sca;
		}
		
		// Set Protected getter with base Access, for internal class instantiations
		init(new FCGet(access, sca.context(), filterConfig));
	}
941842
public void init(FilterConfig filterConfig) throws ServletException {
		// need the Context for Logging, instantiating ClassLoader, etc
		context = filterConfig.getServletContext();
		StringBuilder sb = new StringBuilder();
		StringBuilder err = new StringBuilder(); 
		Object attr = context.getAttribute(Config.PATHFILTER_NS);
		if(attr==null) {
			err.append("PathFilter - pathfilter_ns is not set");
		} else {
			sb.append(attr.toString()); 
		}

		attr = context.getAttribute(Config.PATHFILTER_STACK);
		if(attr==null) {
			log.info("PathFilter - No pathfilter_stack set, ignoring");
		} else {
			sb.append('.');
			sb.append(attr.toString());
		}

		attr = context.getAttribute(Config.PATHFILTER_URLPATTERN);
		if(attr==null) {
			log.info("PathFilter - No pathfilter_urlpattern set, defaulting to 'urlpattern'");
			sb.append(".urlpattern");
		} else {
			sb.append('.');
			sb.append(attr.toString());
		}

		log.info("PathFilter - AAF Permission Type is",sb.toString());
		
		sb.append('|');
		
		aaf_type = sb.toString();

		attr = context.getAttribute(Config.PATHFILTER_NOT_AUTHORIZED_MSG);
		if(attr==null) {
			not_authorized_msg = "Forbidden - Not Authorized to access this Path";
		} else {
			not_authorized_msg = attr.toString();
		}

		if(err.length()>0) {
			throw new ServletException(err.toString());
		}
	}
467352
public static void init(ExternalContext context)
    {
        WebXmlParser parser = new WebXmlParser(context);
        WebXml webXml = parser.parse();
        context.getApplicationMap().put(WEB_XML_ATTR, webXml);
        MyfacesConfig mfconfig = MyfacesConfig.getCurrentInstance(context);
        long configRefreshPeriod = mfconfig.getConfigRefreshPeriod();
        webXml.setParsingTime(System.currentTimeMillis());
        webXml.setDelegateFacesServlet(mfconfig.getDelegateFacesServlet());
        refreshPeriod = (configRefreshPeriod * 1000);
    }
122645
public void init(ServletConfig config) throws ServletException {        
        try {
            String idlPath = config.getInitParameter("idl");
            if (idlPath == null) {
                throw new ServletException("idl init param is required. Set to path to .json file, or classpath:/mycontract.json");
            }

            if (idlPath.startsWith("classpath:")) {
                idlPath = idlPath.substring(10);
                contract = Contract.load(getClass().getResourceAsStream(idlPath));
            }
            else {
                contract = Contract.load(new File(idlPath));
            }
            
            server = new Server(contract);

            int handlerCount = 0;
            Enumeration params = config.getInitParameterNames();
            while (params.hasMoreElements()) {
                String key = params.nextElement().toString();
                if (key.indexOf("handler.") == 0) {
                    String val = config.getInitParameter(key);
                    int pos = val.indexOf("=");
                    if (pos == -1) {
                        throw new ServletException("Invalid init param: key=" + key + 
                                                   " value=" + val +
                                                   " -- should be: interfaceClass=implClass");
                    }

                    String ifaceCname = val.substring(0, pos);
                    String implCname  = val.substring(pos+1);

                    Class ifaceClazz = Class.forName(ifaceCname);
                    Class implClazz  = Class.forName(implCname);
                    server.addHandler(ifaceClazz, implClazz.newInstance());
                    handlerCount++;
                }
            }

            if (handlerCount == 0) {
                throw new ServletException("At least one handler.x init property is required");
            }
        }
        catch (ServletException e) {
            throw e;
        }
        catch (Exception e) {
            throw new ServletException(e);
        }
    }
860965
public void initDocument()
    throws TemplateInitException
    {
        /*
         *  send an empty InternalContextAdapter down into the AST to initialize it
         */

        InternalContextAdapterImpl ica = new InternalContextAdapterImpl(  new VelocityContext() );

        try
        {
            /*
             *  put the current template name on the stack
             */

            ica.pushCurrentTemplateName( name );
            ica.setCurrentResource( this );

            /*
             *  init the AST
             */

            ((SimpleNode)data).init( ica, rsvc);

            String property = scopeName+'.'+RuntimeConstants.PROVIDE_SCOPE_CONTROL;
            provideScope = rsvc.getBoolean(property, provideScope);
        }
        finally
        {
            /*
             *  in case something blows up...
             *  pull it off for completeness
             */

            ica.popCurrentTemplateName();
            ica.setCurrentResource( null );
        }

    }
925388
public static void init( ServletContext servletContext )
    {
        PageFlowFactoriesConfig factoriesBean = ConfigUtil.getConfig().getPageFlowFactories();
        FlowControllerFactory factory = null;

        if ( factoriesBean != null )
        {
            PageFlowFactoryConfig fcFactoryBean = factoriesBean.getPageFlowFactory();
            factory = ( FlowControllerFactory ) FactoryUtils.getFactory( servletContext, fcFactoryBean, FlowControllerFactory.class );
        }

        if ( factory == null )
            factory = new FlowControllerFactory();

        factory.reinit( servletContext );

        servletContext.setAttribute( CONTEXT_ATTR, factory );
    }
934796
public void init(ServletConfig config) throws ServletException
    {
        super.init(config);
        ServletTask.initServlet(this, BasicServlet.SERVLET_TYPE.HTML);
    }
169582
public void init(FilterConfig filterConfig) throws ServletException {

    this.filterConfig = filterConfig;
    this.encoding = filterConfig.getInitParameter("encoding");
    String value = filterConfig.getInitParameter("ignore");
    if (value == null)
      this.ignore = true;
    else if (value.equalsIgnoreCase("true"))
      this.ignore = true;
    else if (value.equalsIgnoreCase("yes"))
      this.ignore = true;
    else
      this.ignore = false;

  }
925786
@Override
	public void init() throws ServletException {
		super.init();
		try {
			config = new Config("/config/serfj.properties");
		} catch (ConfigFileIOException e) {
			LOGGER.error("Can't load framework configuration", e);
			throw new ServletException(e);
		}
		urlInspector = new UrlInspector(config);
	}
1169741
public void init(ServletConfig config)
        throws ServletException
    {
        super.init(config);

        try {
            if (_service == null) {
                String className = getInitParameter("service-class");
                Class<?> serviceClass = null;

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        serviceClass = Class.forName(className, false, loader);
                    else
                        serviceClass = Class.forName(className);
                }
                else {
                    if (getClass().equals(BurlapServlet.class))
                        throw new ServletException("server must extend BurlapServlet");

                    serviceClass = getClass();
                }

                _service = serviceClass.newInstance();

                if (_service instanceof BurlapServlet)
                    ((BurlapServlet) _service).setService(this);
                if (_service instanceof Service)
                    ((Service) _service).init(getServletConfig());
                else if (_service instanceof Servlet)
                    ((Servlet) _service).init(getServletConfig());
            }

            if (_apiClass == null) {
                String className = getInitParameter("api-class");

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        _apiClass = Class.forName(className, false, loader);
                    else
                        _apiClass = Class.forName(className);
                }
                else
                    _apiClass = _service.getClass();
            }

            _skeleton = new BurlapSkeleton(_service, _apiClass);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
1232948
protected void initServlet(XmlParser.Node node) throws ClassNotFoundException,UnavailableException,IOException,
            MalformedURLException
    {
        String name=node.getString("servlet-name",false,true);
        String className=node.getString("servlet-class",false,true);
        String jspFile=null;
        Holder template=null;
        if(className==null)
        {
            // There is no class, so look for a jsp file
            jspFile=node.getString("jsp-file",false,true);
            if(jspFile!=null)
            {
                Map.Entry entry=getWebApplicationHandler().getHolderEntry(jspFile);
                if(entry!=null)
                {
                    template = (Holder)entry.getValue();
                    className=template.getClassName();  
                }
            }
            if(className==null)
            {
                log.warn("Missing servlet-class|jsp-file in "+node);
                return;
            }
        }
        if(name==null)
            name=className;
        ServletHolder holder=getWebApplicationHandler().newServletHolder(name,className,jspFile);

        // handle JSP configuration
        if(jspFile!=null)
        {
            Enumeration e=template.getInitParameterNames();
            
            while(e.hasMoreElements())
            {   
                String p=(String)e.nextElement();
                holder.setInitParameter(p, template.getInitParameter(p));
            }
            if (holder.getInitParameter("classpath")==null)
                holder.setInitParameter("classpath",getWebApplicationContext().getFileClassPath());
        }
       
        // handle init params
        Iterator iParamsIter=node.iterator("init-param");
        while(iParamsIter.hasNext())
        {
            XmlParser.Node paramNode=(XmlParser.Node)iParamsIter.next();
            String pname=paramNode.getString("param-name",false,true);
            String pvalue=paramNode.getString("param-value",false,true);
            holder.put(pname,pvalue);
        }
        XmlParser.Node startup=node.get("load-on-startup");
        if(startup!=null)
        {
            String s=startup.toString(false,true).toLowerCase();
            if(s.startsWith("t"))
            {
                log.warn("Deprecated boolean load-on-startup.  Please use integer");
                holder.setInitOrder(1);
            }
            else
            {
                int order=0;
                try
                {
                    if(s!=null&&s.trim().length()>0)
                        order=Integer.parseInt(s);
                }
                catch(Exception e)
                {
                    log.warn("Cannot parse load-on-startup "+s+". Please use integer");
                    LogSupport.ignore(log,e);
                }
                holder.setInitOrder(order);
            }
        }
        Iterator sRefsIter=node.iterator("security-role-ref");
        while(sRefsIter.hasNext())
        {
            XmlParser.Node securityRef=(XmlParser.Node)sRefsIter.next();
            String roleName=securityRef.getString("role-name",false,true);
            String roleLink=securityRef.getString("role-link",false,true);
            if(roleName!=null&&roleName.length()>0&&roleLink!=null&&roleLink.length()>0)
            {
                if(log.isDebugEnabled())
                    log.debug("link role "+roleName+" to "+roleLink+" for "+this);
                holder.setUserRoleLink(roleName,roleLink);
            }
            else
            {
                log.warn("Ignored invalid security-role-ref element: "+"servlet-name="+name+", "+securityRef);
            }
        }
        XmlParser.Node run_as=node.get("run-as");
        if(run_as!=null)
        {
            String roleName=run_as.getString("role-name",false,true);
            if(roleName!=null)
                holder.setRunAs(roleName);
        }
    }
185361
private void initTemplateEngineCfg() {
        configuration = new Configuration();
        configuration.setDefaultEncoding("UTF-8");
        final ServletContext servletContext = AbstractServletListener.getServletContext();

        configuration.setServletContextForTemplateLoading(servletContext, "/plugins/" + dirName);
        LOGGER.log(Level.DEBUG, "Initialized template configuration");
    }
1097856
@Override
    public void init(final ServletConfig config) throws ServletException {
        super.init(config);
        contextDirPath = getServletContext().getRealPath("/");

    }
442317
@SuppressWarnings("unchecked")
	public void init(FilterConfig c) throws ServletException {

		Properties p = new Properties();
		ServletContext sc = c.getServletContext();
		for (Enumeration e = sc.getInitParameterNames(); e.hasMoreElements();) {
			String key = (String) e.nextElement();
			p.put(key, sc.getInitParameter(key));
		}
		for (Enumeration e = c.getInitParameterNames(); e.hasMoreElements();) {
			String key = (String) e.nextElement();
			p.put(key, c.getInitParameter(key));
		}
		
		String cfgName = INCOMING_PATH;
		String incomingPath = p.getProperty(cfgName);
		if((incomingPath == null) || incomingPath.length() == 0) {
			throw new ServletException("Invalid or missing " + cfgName +
					" configuration");
		}
		incoming = new File(incomingPath);
		tmpIncoming = new File(incoming,"tmp");
		try {
			ensureDir(incoming);
			ensureDir(tmpIncoming);
		} catch (IOException e) {
			throw new ServletException(e);
		}
	}
866773
@Override
	public void contextInitialized(ServletContextEvent evt) {
		ServletContext sc = evt.getServletContext();

		// Initialize Jawr JS servlet
		ServletRegistration.Dynamic sr = sc.addServlet("JavascriptServlet",
				"net.jawr.web.servlet.JawrServlet");
		sr.setInitParameter("configLocation", "/jawr.properties");
		sr.addMapping("*.js");
		sr.setLoadOnStartup(0);

		// Initialize Jawr CSS servlet
		sr = sc.addServlet("CssServlet", "net.jawr.web.servlet.JawrServlet");
		sr.setInitParameter("configLocation", "/jawr.properties");
		sr.setInitParameter("type", JawrConstant.CSS_TYPE);
		sr.addMapping("*.css");
		sr.setLoadOnStartup(1);

		// Initialize Jawr Binary servlet
		sr = sc.addServlet("BinaryServlet", "net.jawr.web.servlet.JawrServlet");
		sr.setInitParameter("configLocation", "/jawr.properties");
		sr.setInitParameter("type", JawrConstant.BINARY_TYPE);
		sr.addMapping("*.jpg", "*.png", "*.gif", "*.woff", "*.ttf", "*.svg", "*.eot");
		sr.setLoadOnStartup(0);
	}
1312680
protected List<ServletDefinition> initJawrSpringControllers(
			ServletContext servletContext) throws ServletException {

		SpringControllerBundleProcessor springBundleProcessor = new SpringControllerBundleProcessor();
		return springBundleProcessor.initJawrSpringServlets(servletContext);
	}