initialize the RestDoc Generator

@param classes the array of JAX-RS classes
@param globalHeader the global headers
@param baseURI an optional base uri like "/api"
483114
public void init(final Class<?>[] classes, final GlobalHeader globalHeader, final String baseURI) {
		if (!this.initialized.compareAndSet(false, true)) {
			throw new RestDocException("Generator already initialized");
		}
		this.logger.info("Starting generation of RestDoc");
		this.logger.info("Searching for RestDoc API classes");
		
		if (globalHeader != null) {
			if (globalHeader.getRequestHeader() != null) {
				this.requestHeaderMap.putAll(globalHeader.getRequestHeader());
			}
			if (globalHeader.getResponseHeader() != null) {
				this.responseHeaderMap.putAll(globalHeader.getResponseHeader());
			}
			if ((globalHeader.getAdditionalFields() != null) && !globalHeader.getAdditionalFields().isEmpty()) {
				this.globalAdditional.putAll(globalHeader.getAdditionalFields());
			}
		}
		
		for (final Class<?> apiClass : classes) {
			// check if class provides predefined RestDoc
			boolean scanNeeded = true;
			if (Arrays.asList(apiClass.getInterfaces()).contains(IProvideRestDoc.class)) {
				try {
					this.logger.info("Class {} provides predefined RestDoc", apiClass.getCanonicalName());
					final IProvideRestDoc apiObject = (IProvideRestDoc) apiClass.newInstance();
					final RestResource[] restDocResources = apiObject.getRestDocResources();
					for (final RestResource restResource : restDocResources) {
						this.resources.put(restResource.getPath(), restResource);
					}
					this.schemaMap.putAll(apiObject.getRestDocSchemas());
					scanNeeded = false;
				} catch (final Exception e) {
					// ignore it and fall back to annotation scan
				}
			}
			if (scanNeeded) {
				this.addResourcesOfClass(apiClass, baseURI);
			}
		}
	}
650438
public static void initServletRequest(ServletRequest servletRequest, TemplatedURLFormatter formatter)
    {
        assert servletRequest != null : "The ServletRequest cannot be null.";

        if (servletRequest == null) {
            throw new IllegalArgumentException("The ServletRequest cannot be null.");
        }

        servletRequest.setAttribute(TEMPLATED_URL_FORMATTER_ATTR, formatter);
    }
295864
public DocumentSource createDocumentSource(URL base, String urlstring)
    {
        try
        {
            Constructor<? extends DocumentSource> constr = getDocumentSourceClass().getConstructor(URL.class, String.class);
            return constr.newInstance(base, urlstring);
        } catch (Exception e) {
            log.warn("Could not create the DocumentSource instance: " + e.getMessage());
            return null;
        }
    }
37943
public static void globalClassesAbsent(Class<?> aClass){
		throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorRelationalException3, aClass.getSimpleName()));
	}
1354328
private void initRequestHandler(ServletContext context, Properties configProps) throws ServletException {

		long initialTime = System.currentTimeMillis();
		if (LOGGER.isInfoEnabled())
			LOGGER.info("Initializing jawr config for request handler named " + getInitParameter("handlerName"));

		this.servletContext = context;
		this.overrideProperties = configProps;
		resourceType = getInitParameter("type");
		resourceType = null == resourceType ? "js" : resourceType;

		if (resourceType.equals("img")) {
			throw new BundlingProcessException(
					"The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead.");
		}

		// Check if the resource type is a valid one
		if (!(resourceType.equals(JawrConstant.JS_TYPE) || resourceType.equals(JawrConstant.CSS_TYPE)
				|| resourceType.equals(JawrConstant.BINARY_TYPE))) {
			throw new BundlingProcessException("Unknown resource Type:" + resourceType);
		}

		// Initialize the config properties source that will provide with all
		// configuration options.
		ConfigPropertiesSource propsSrc = initConfigPropertiesSource(context, configProps);

		// Read properties from properties source
		Properties props = propsSrc.getConfigProperties();
		// override the properties if needed
		if (this.overrideProperties != null) {
			props.putAll(overrideProperties);
		}

		// hang onto the propertiesSource for manual reloads
		this.propertiesSource = propsSrc;

		// Initialize the ConfigPropertyResolver
		initConfigPropertyResolver(context);

		initializeJawrContext(props);

		// Initialize the properties reloading checker daemon if specified
		if (!ThreadLocalJawrContext.isBundleProcessingAtBuildTime()
				&& null != props.getProperty(CONFIG_RELOAD_INTERVAL)) {
			int interval = Integer.parseInt(props.getProperty(CONFIG_RELOAD_INTERVAL));
			LOGGER.warn("Jawr started with configuration auto reloading on. "
					+ "Be aware that a daemon thread will be checking for changes to configuration every " + interval
					+ " seconds.");

			this.configChangeListenerThread = new ConfigChangeListenerThread(this.resourceType, propsSrc,
					this.overrideProperties, this, this.bundlesHandler, interval);
			configChangeListenerThread.start();
		}

		if (this.bundlesHandler != null && jawrConfig.getUseSmartBundling()) {

			this.watcher = new ResourceWatcher(this.bundlesHandler, this.rsReaderHandler);
			this.bundlesHandler.setResourceWatcher(watcher);
			try {
				this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getGlobalBundles());
				this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getContextBundles());
			} catch (IOException e) {
				throw new BundlingProcessException("Impossible to initialize Jawr Resource Watcher", e);
			}

			this.watcher.start();
		}

		if (LOGGER.isInfoEnabled()) {
			long totaltime = System.currentTimeMillis() - initialTime;
			LOGGER.info("Init method successful. jawr started in " + (totaltime / 1000) + " seconds....");
		}

		// Reset ThreadLocalJawrContext
		ThreadLocalJawrContext.reset();
	}
843285
public void init(HttpInboundServiceContext sc, BNFHeaders hdrs) {
        setOwner(sc);
        setBinaryParseState(HttpInternalConstants.PARSING_BINARY_VERSION);
        if (null != hdrs) {
            hdrs.duplicate(this);
        }
        initVersion();
    }
220953
@Override
    public void init(FilterConfig filterConfig) throws ServletException {
        LOG.info("AtlasAuthenticationFilter initialization started");
        final FilterConfig globalConf = filterConfig;
        final Map<String, String> params = new HashMap<>();
        try {
            configuration = ApplicationProperties.get();
        } catch (Exception e) {
            throw new ServletException(e);
        }

        if (configuration != null) {
            headerProperties = ConfigurationConverter.getProperties(configuration.subset("atlas.headers"));
        }

        FilterConfig filterConfig1 = new FilterConfig() {
            @Override
            public ServletContext getServletContext() {
                if (globalConf != null) {
                    return globalConf.getServletContext();
                } else {
                    return nullContext;
                }
            }

            @SuppressWarnings("unchecked")
            @Override
            public Enumeration<String> getInitParameterNames() {
                return new IteratorEnumeration(params.keySet().iterator());
            }

            @Override
            public String getInitParameter(String param) {
                return params.get(param);
            }

            @Override
            public String getFilterName() {
                return "AtlasAuthenticationFilter";
            }
        };

        super.init(filterConfig1);

        optionsServlet = new HttpServlet() {
        };
        optionsServlet.init();
    }
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);
        }
    }
198574
private static void initFactory() {
    if (jsonFactory == null) {
      try {
        // We use reflection because the server side should not
        // depend on gwt-servlet nor gwt-dev. Hence if GWT is not
        // in our classpath means that we are in server side, otherwise
        // we use GWT to figure out if we are running devmode.
        // This is run once, so no performance issues to worry about.
        Class.forName("com.google.gwt.core.shared.GWTBridge");
        Class<?> gwt = Class.forName("com.google.gwt.core.shared.GWT");
        Method method = gwt.getMethod("isClient");
        Object ret = method.invoke(null);
        if (ret instanceof Boolean && ((Boolean) ret)) {
          // We are running DevMode, so create Js versions of the factories
          method = gwt.getMethod("create", Class.class);
          ret = method.invoke(null,
              new Object[] {JsonFactory.class});
          jsonFactory = (JsonFactory) ret;
          ajaxTransport = new AjaxTransportJs();
          return;
        }
      } catch (ClassNotFoundException ignore) {
      } catch (NoSuchMethodException ignore) {
      } catch (SecurityException ignore) {
      } catch (IllegalAccessException ignore) {
      } catch (IllegalArgumentException ignore) {
      } catch (InvocationTargetException ignore) {
      }
      // We are running in the JVM, so create Jre versions.
      jsonFactory = new JsonFactoryJre();
      ajaxTransport = new AjaxTransportJre();
    }
  }
277946
public static void configureThriftServices(
            ServerBuilder server, List<ThriftServiceRegistrationBean> beans,
            @Nullable MeterIdPrefixFunctionFactory meterIdPrefixFunctionFactory,
            @Nullable String docsPath) {
        requireNonNull(server, "server");
        requireNonNull(beans, "beans");

        final List<TBase<?, ?>> docServiceRequests = new ArrayList<>();
        final Map<String, Collection<HttpHeaders>> docServiceHeaders = new HashMap<>();
        beans.forEach(bean -> {
            Service<HttpRequest, HttpResponse> service = bean.getService();
            for (Function<Service<HttpRequest, HttpResponse>, ? extends Service<HttpRequest, HttpResponse>>
                    decorator : bean.getDecorators()) {
                service = service.decorate(decorator);
            }
            service = setupMetricCollectingService(service, bean, meterIdPrefixFunctionFactory);
            server.service(bean.getPath(), service);
            docServiceRequests.addAll(bean.getExampleRequests());
            ThriftServiceUtils.serviceNames(bean.getService())
                              .forEach(serviceName -> docServiceHeaders
                                      .put(serviceName,
                                           bean.getExampleHeaders()));
        });

        if (!Strings.isNullOrEmpty(docsPath)) {
            final DocServiceBuilder docServiceBuilder = new DocServiceBuilder();
            docServiceBuilder.exampleRequest(docServiceRequests);
            for (Entry<String, Collection<HttpHeaders>> entry : docServiceHeaders.entrySet()) {
                docServiceBuilder.exampleHttpHeaders(entry.getKey(), entry.getValue());
            }
            server.serviceUnder(docsPath, docServiceBuilder.build());
        }
    }
962680
public void setDocumentURI(String arg0) {
	// dynamic load to support jre 1.4 and 1.5
	try {
	    Method m = doc.getClass().getMethod("setDocumentURI", new Class[] { arg0.getClass() });
	    m.invoke(doc, new Object[] { arg0 });
	}
	catch (Exception e) {
	    throw new PageRuntimeException(Caster.toPageException(e));
	}

    }
23153
@Deprecated
    public static synchronized void initializeFromResource(
            final ClassLoader classLoader,
            final String name) {

        try {
            regionMetadata = loadMetadataFromResource(classLoader, name);
        } catch (IOException exception) {
            throw new SdkClientException(
                    "Error parsing region metadata from resource " + name,
                    exception);
        }
    }
679186
@Override
    public IDocumentStore initialize() {
        if (initialized) {
            return this;
        }

        assertValidConfiguration();

        try {
            if (getConventions().getDocumentIdGenerator() == null) { // don't overwrite what the user is doing
                MultiDatabaseHiLoIdGenerator generator = new MultiDatabaseHiLoIdGenerator(this, getConventions());
                _multiDbHiLo = generator;

                getConventions().setDocumentIdGenerator(generator::generateDocumentId);
            }

            getConventions().freeze();
            initialized = true;
        } catch (Exception e) {
            close();
            throw ExceptionsUtils.unwrapException(e);
        }

        return this;
    }
1312007
private final void init() {
        InputStream in = null;

        try {
            URL url =
                this.getClass()
                    .getClassLoader()
                    .getResource("padawan.conf.xml");

            if (url != null) {
                URLConnection conn = url.openConnection();
                in = conn.getInputStream();

                long newModified = conn.getLastModified();

                if ((lastModified != newModified) && (newModified != 0)) {
                    lastModified = newModified;
                    Document xmlDoc =
                        CDocumentBuilderFactory.newParser()
                                               .newDocumentBuilder()
                                               .parse(in);
                    parseDocument(xmlDoc);
                }
            }
        } catch (Exception ignore) {
            ignore.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
    }
241006
@SuppressWarnings("rawtypes")
	public List<ServletDefinition> initJawrSpringServlets(ServletContext servletContext) throws ServletException{
		
		List<ServletDefinition> jawrServletDefinitions = new ArrayList<ServletDefinition>();
		ContextLoader contextLoader = new ContextLoader();
		WebApplicationContext applicationCtx = contextLoader.initWebApplicationContext(servletContext);
		Map<?, ?> jawrControllersMap = applicationCtx.getBeansOfType(JawrSpringController.class);
		
		Iterator<?> entrySetIterator = jawrControllersMap.entrySet().iterator();
		while(entrySetIterator.hasNext()){
			
			JawrSpringController jawrController = (JawrSpringController) ((Map.Entry) entrySetIterator.next()).getValue();
			Map<String, Object> initParams = new HashMap<String, Object>();
			initParams.putAll(jawrController.getInitParams());
			ServletConfig servletConfig = new MockServletConfig(SPRING_DISPATCHER_SERVLET,servletContext, initParams);
			MockJawrSpringServlet servlet = new MockJawrSpringServlet(jawrController, servletConfig);
			ServletDefinition servletDefinition = new ServletDefinition(servlet, servletConfig) ;
			jawrServletDefinitions.add(servletDefinition);
		}
		
		contextLoader.closeWebApplicationContext(servletContext);
		return jawrServletDefinitions;
	}
147377
private static void initURLTemplates( ServletContext servletContext )
    {
        TemplatedURLFormatter formatter = TemplatedURLFormatter.getTemplatedURLFormatter( servletContext );
        if ( formatter == null )
        {
            // get the default template formatter class name from the config file
            formatter = getTemplatedURLFormatter();

            assert formatter != null : "Found a non-null URL formatter";

            // set the TemplatedURLFormatter attribute on the context.
            TemplatedURLFormatter.initServletContext( servletContext, formatter );
        }

        URLTemplatesFactory templatesFactory = URLTemplatesFactory.getURLTemplatesFactory( servletContext );
        if ( templatesFactory == null )
        {
            // URLTemplatesFactory has not been initialized,
            // get a URLTemplatesFactory object from the containerAdapter.
            templatesFactory = PageFlowUtils.createURLTemplatesFactory( servletContext );

            // get the known/req tokens from the default formatter for the factory to use to verify templates
            templatesFactory.setKnownTokens( formatter.getKnownTokens() );
            templatesFactory.setRequiredTokens( formatter.getRequiredTokens() );
            templatesFactory.load( servletContext );

            // set the URLTemplatesFactory attribute on the context.
            URLTemplatesFactory.initServletContext( servletContext, templatesFactory );
        }
    }
492751
@Override
    public void init() throws InitializationException {
        engine = Engine.createCachingEngine();
        JMTEDateRendrer dateRendrer = new JMTEDateRendrer();
        dateRendrer.setDateFormat(dateFormat);
        engine.registerRenderer(Date.class, dateRendrer);
    }