Parses the BlazeDS config files and returns a populated MessagingConfiguration

@param servletConfig the servlet config for the web application
482706
@SuppressWarnings("unchecked")
    public MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig) {
        Assert.isTrue(JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15, "Spring BlazeDS Integration requires a minimum of Java 1.5");
        Assert.notNull(servletConfig, "FlexConfigurationManager requires a non-null ServletConfig - "
            + "Is it being used outside a WebApplicationContext?");

        MessagingConfiguration configuration = new MessagingConfiguration();

        configuration.getSecuritySettings().setServerInfo(servletConfig.getServletContext().getServerInfo());

        if (CollectionUtils.isEmpty(configuration.getSecuritySettings().getLoginCommands())) {
            LoginCommandSettings settings = new LoginCommandSettings();
            settings.setClassName(NoOpLoginCommand.class.getName());
            configuration.getSecuritySettings().getLoginCommands().put(LoginCommandSettings.SERVER_MATCH_OVERRIDE, settings);
        }

        if (this.parser == null) {
            this.parser = getDefaultConfigurationParser();
        }

        Assert.notNull(this.parser, "Unable to create a parser to load Flex messaging configuration.");

        this.parser.parse(this.configurationPath, new ResourceResolverAdapter(this.resourceLoader), configuration);

        return configuration;
    }
83576
@Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        m_fedoraServerHost = m_server.getParameter("fedoraServerHost");
    }
324298
public ServletConfig createServletConfig(File root, Map<String, Object> attributes, Map<String, String> params) {
	final String servletName = "";
	if (attributes == null) attributes = new HashMap<String, Object>();
	if (params == null) params = new HashMap<String, String>();
	if (root == null) root = new File("."); // working directory that the java command was called from

	final ServletContextImpl servletContext = new ServletContextImpl(root, attributes, params, 1, 0);
	final ServletConfigImpl servletConfig = new ServletConfigImpl(servletContext, servletName);
	return servletConfig;
    }
434761
public void readStacktraceConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc) {
		String stacktrace;
		if(ocelotConfigurationsStack.isUnsatisfied()) {
			stacktrace = sc.getInitParameter(Constants.Options.STACKTRACE_LENGTH);
			if(stacktrace==null) {
				stacktrace = DEFAULTSTACKTRACE;
			} else {
				logger.debug("Read '{}' option in web.xml : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktrace);
			}
		} else {
			stacktrace = ocelotConfigurationsStack.get();
			logger.debug("Read '{}' option from producer : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktrace);
		}
		int stacktracelenght = Integer.parseInt(stacktrace);
		logger.debug("'{}' value : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktracelenght);
		setStacktracelength(stacktracelenght);
	}
933321
Configuration initConfig(ServletConfig pConfig) {
        Configuration config = new Configuration(
                ConfigKey.AGENT_ID, NetworkUtil.getAgentId(hashCode(),"servlet"));
        // From ServletContext ....
        config.updateGlobalConfiguration(new ServletConfigFacade(pConfig));
        // ... and ServletConfig
        config.updateGlobalConfiguration(new ServletContextFacade(getServletContext()));

        // Set type last and overwrite anything written
        config.updateGlobalConfiguration(Collections.singletonMap(ConfigKey.AGENT_TYPE.getKeyValue(),"servlet"));
        return config;
    }
1038948
private boolean isFacesConfigPresent(ServletContext servletContext)
    {
        try
        {
            // 1. A faces-config.xml file is found in WEB-INF
            if (servletContext.getResource(FACES_CONFIG_RESOURCE) != null)
            {
                return true;
            }

            // 4. The javax.faces.CONFIG_FILES context param is declared in web.xml or web-fragment.xml.
            // check for alternate faces-config files specified by javax.faces.CONFIG_FILES
            String configFilesAttrValue = servletContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
            if (configFilesAttrValue != null)
            {
                String[] configFiles = configFilesAttrValue.split(",");
                for (String file : configFiles)
                {
                    if (servletContext.getResource(file.trim()) != null)
                    {
                        return true;
                    }
                }
            }

            // 2. A faces-config.xml file is found in the META-INF directory of a jar in the 
            //    application's classpath.
            // 3. A filename ending in .faces-config.xml is found in the META-INF directory of a jar in 
            //    the application's classpath.
            // To do this properly it is necessary to use some SPI interfaces MyFaces already has, to 
            // deal with OSGi and other
            // environments properly.
            ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, true);
            FacesConfigResourceProviderFactory factory = FacesConfigResourceProviderFactory.
                getFacesConfigResourceProviderFactory(externalContext);
            FacesConfigResourceProvider provider = factory.createFacesConfigResourceProvider(externalContext);
            Collection<URL> metaInfFacesConfigUrls =  provider.getMetaInfConfigurationResources(externalContext);
            
            if (metaInfFacesConfigUrls != null && !metaInfFacesConfigUrls.isEmpty())
            {
                return true;
            }
            
            return false;
        }
        catch (Exception e)
        {
            return false;
        }
    }
543849
@Override
    protected void configure() {
        bind(SwaggerServletContext.class).to(ServletContext.class).in(Singleton.class);
        bind(SwaggerServletConfig.class).to(ServletConfig.class).in(Singleton.class);
    }
1312680
protected List<ServletDefinition> initJawrSpringControllers(
			ServletContext servletContext) throws ServletException {

		SpringControllerBundleProcessor springBundleProcessor = new SpringControllerBundleProcessor();
		return springBundleProcessor.initJawrSpringServlets(servletContext);
	}
1191158
@SuppressWarnings("static-method")
	@Provides
	@Singleton
	public SarlConfig getSarlcConfig(ConfigurationFactory configFactory, Injector injector) {
		final SarlConfig config = SarlConfig.getConfiguration(configFactory);
		injector.injectMembers(config);
		return config;
	}
1072039
@Override
	public void configure(Configuration config) {
		super.configure(config);

		if (configured) {
			return;
		}
		
		final String fieldDelimStr = config.getString(FIELD_DELIMITER_PARAMETER, null);
		if (fieldDelimStr != null) {
			if (fieldDelimStr.length() != 1) {
				throw new IllegalArgumentException("Invalid configuration for CsvInputFormat: " +
						"Field delimiter must be a single character");
			} else {
				setFieldDelimiter(fieldDelimStr.charAt(0));
			}
		}
		
		// read number of field configured via configuration
		int numConfigFields = config.getInteger(NUM_FIELDS_PARAMETER, -1);
		if (numConfigFields != -1) {
			if (numConfigFields <= 0) {
				throw new IllegalConfigurationException("The number of fields for the CsvInputFormat is invalid.");
			}
			
			if (getNumberOfNonNullFields() > 0) {
				throw new IllegalConfigurationException("Mixing configuration via instance parameters and config parameters is not possible.");
			}
		
			int[] textPosIdx = new int[numConfigFields];
			boolean anyTextPosSet = false;
			boolean allTextPosSet = true;
			int maxTextPos = -1;
			
			// parse text positions
			for (int i = 0; i < numConfigFields; i++) {
				int pos = config.getInteger(TEXT_POSITION_PARAMETER_PREFIX + i, -1);
				if (pos == -1) {
					allTextPosSet = false;
					textPosIdx[i] = i;
					maxTextPos = i;
				} else {
					anyTextPosSet = true;
					textPosIdx[i] = pos;
					maxTextPos = pos > maxTextPos ? pos : maxTextPos;
				}
			}
			// check if either none or all text positions have been set
			if (anyTextPosSet && !allTextPosSet) {
				throw new IllegalArgumentException("Invalid configuration for CsvInputFormat: " +
						"Not all text positions set");
			}
			
			// init the array of types to be set. unify the types from the config 
			// with the types array set on the instance
			
			// make sure we have a sufficiently large types array
			@SuppressWarnings("unchecked")
			Class<? extends Value>[] types = (Class<? extends Value>[]) new Class[maxTextPos+1];
			int[] targetPos = new int[maxTextPos+1];
			
			// set the fields
			for (int i = 0; i < numConfigFields; i++) {
				int pos = textPosIdx[i];
				
				Class<? extends Value> clazz = config.getClass(FIELD_TYPE_PARAMETER_PREFIX + i, null).asSubclass(Value.class);
				if (clazz == null) {
					throw new IllegalConfigurationException("Invalid configuration for CsvInputFormat: " +
						"No field parser class for parameter " + i);
				}
				
				types[pos] = clazz;
				targetPos[pos] = i;
			}
			
			// update the field types
			setFieldTypes(types);
			
			// make a dense target pos array
			this.targetPositions = new int[numConfigFields];
			for (int i = 0, k = 0; i < targetPos.length; i++) {
				if (types[i] != null) {
					this.targetPositions[k++] = targetPos[i];
				}
			}
		}
		else {
			// not configured via config parameters
			if (this.targetPositions.length == 0) {
				this.targetPositions = new int[getNumberOfNonNullFields()];
				for (int i = 0; i < this.targetPositions.length; i++) {
					this.targetPositions[i] = i;
				}
			}
		}
		
		if (getNumberOfNonNullFields() == 0) {
			throw new IllegalConfigurationException("No fields configured in the CsvInputFormat.");
		}

		this.configured = true;
	}
784809
public void init(ServletConfig servletConfig) throws ServletException
    {
        super.init(servletConfig);
        ServletTask.initServlet(this, BasicServlet.SERVLET_TYPE.XML);
        Enumeration<?> paramNames = this.getInitParameterNames();
        while (paramNames.hasMoreElements())
        {
            String strProperty = (String)paramNames.nextElement();
            String strValue = this.getInitParameter(strProperty);
            m_initProperties.put(strProperty, strValue);
        }
    }
1051781
@Override
	public void init(ServletConfig servletConfig) throws ServletException {
		final String sourceMethod = "init"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(AbstractAggregatorImpl.class.getName(), sourceMethod, new Object[]{servletConfig});
		}
		super.init(servletConfig);

		// Default constructor for MimetypesFileTypeMap *should* read our bundle's
		// META-INF/mime.types automatically, but some older platforms (Domino)
		// don't use the right class loader, so get the input stream ourselves
		// and pass it to the constructor.
		ClassLoader cld = AbstractAggregatorImpl.class.getClassLoader();
		InputStream is = cld.getResourceAsStream("META-INF/mime.types"); //$NON-NLS-1$

		// Initialize the type maps (see getContentType)
		fileTypeMap = new MimetypesFileTypeMap(is);
		fileNameMap = URLConnection.getFileNameMap();

		final ServletContext context = servletConfig.getServletContext();

		// Set servlet context attributes for access though the request
		context.setAttribute(IAggregator.AGGREGATOR_REQATTRNAME, this);
		try {
			webContentUri = AbstractAggregatorImpl.class.getClassLoader().getResource("WebContent").toURI(); //$NON-NLS-1$
		} catch (URISyntaxException e) {
			throw new ServletException(e);
		}

		if (isTraceLogging) {
			log.exiting(AbstractAggregatorImpl.class.getName(), sourceMethod);
		}
	}
1209565
private ServletHandler configureHandler(String servletClassName) {
        ServletHandler handler = new ServletHandler();
        handler.addServletWithMapping(servletClassName, "/*");
        return handler;
    }
23181
private void parseLoggingConfig(final Node node, final ConfigSettings config)
	{

		String name;
		String value;
		Node nnode;
		NodeList list = node.getChildNodes();

		int length = list.getLength();
		for (int i = 0; i < length; i++) {
			nnode = list.item(i);

			name = nnode.getNodeName().toUpperCase();
			if (name.equals(KEY_ROOT_FOLDER)) {

				value = nnode.getChildNodes().item(0).getNodeValue();
				value = value.substring(1, value.length() - 1);

				config.setConfigParameter(
						ConfigurationKeys.LOGGING_PATH_DIFFTOOL, value);

			}
			else if (name.equals(SUBSUBSECTION_DIFF_TOOL)) {

				parseLoggerConfig(nnode, config, null,
						ConfigurationKeys.LOGGING_LOGLEVEL_DIFFTOOL);

			}
		}
	}
952792
protected Properties loadConfiguration (ServletConfig config)
        throws IOException
    {
        Properties props = loadVelocityProps(config);

        // if we failed to create our application for whatever reason; bail
        if (_app == null) {
            return props;
        }

        // let the application set up velocity properties
        _app.configureVelocity(config, props);

        // if no file resource loader path has been set and a site-specific jar file path was
        // provided, wire up our site resource manager
        configureResourceManager(config, props);

        // wire up our #import directive
        props.setProperty("userdirective", ImportDirective.class.getName());

        // configure the servlet context logger
        props.put(RuntimeSingleton.RUNTIME_LOG_LOGSYSTEM_CLASS,
                  ServletContextLogger.class.getName());

        // now return our augmented properties
        return props;
    }
32653
private Resource getConfigDirectory(ServletConfig sg, ConfigServerImpl configServer, int countExistingContextes, RefBoolean isCustomSetting) throws PageServletException {
	isCustomSetting.setValue(true);
	ServletContext sc = sg.getServletContext();
	String strConfig = sg.getInitParameter("configuration");
	if (StringUtil.isEmpty(strConfig)) strConfig = sg.getInitParameter("lucee-web-directory");
	if (StringUtil.isEmpty(strConfig)) strConfig = System.getProperty("lucee.web.dir");

	if (StringUtil.isEmpty(strConfig)) {
	    isCustomSetting.setValue(false);
	    strConfig = "{web-root-directory}/WEB-INF/lucee/";
	}
	// only for backward compatibility
	else if (strConfig.startsWith("/WEB-INF/lucee/")) strConfig = "{web-root-directory}" + strConfig;

	strConfig = StringUtil.removeQuotes(strConfig, true);

	// static path is not allowed
	if (countExistingContextes > 1 && strConfig != null && strConfig.indexOf('{') == -1) {
	    String text = "static path [" + strConfig + "] for servlet init param [lucee-web-directory] is not allowed, path must use a web-context specific placeholder.";
	    System.err.println(text);
	    throw new PageServletException(new ApplicationException(text));
	}
	strConfig = SystemUtil.parsePlaceHolder(strConfig, sc, configServer.getLabels());

	ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
	Resource root = frp.getResource(ReqRspUtil.getRootPath(sc));
	Resource res;
	Resource configDir = ResourceUtil.createResource(res = root.getRealResource(strConfig), FileUtil.LEVEL_PARENT_FILE, FileUtil.TYPE_DIR);

	if (configDir == null) {
	    configDir = ResourceUtil.createResource(res = frp.getResource(strConfig), FileUtil.LEVEL_GRAND_PARENT_FILE, FileUtil.TYPE_DIR);
	}

	if (configDir == null && !isCustomSetting.toBooleanValue()) {
	    try {
		res.createDirectory(true);
		configDir = res;
	    }
	    catch (IOException e) {
		throw new PageServletException(Caster.toPageException(e));
	    }
	}
	if (configDir == null) {
	    throw new PageServletException(new ApplicationException("path [" + strConfig + "] is invalid"));
	}

	if (!configDir.exists() || ResourceUtil.isEmptyDirectory(configDir, null)) {
	    Resource railoRoot;
	    // there is a railo directory
	    if (configDir.getName().equals("lucee") && (railoRoot = configDir.getParentResource().getRealResource("railo")).isDirectory()) {
		try {
		    copyRecursiveAndRename(railoRoot, configDir);
		}
		catch (IOException e) {
		    try {
			configDir.createDirectory(true);
		    }
		    catch (IOException ioe) {}
		    return configDir;
		}
		// zip the railo-server di and delete it (optional)
		try {
		    Resource p = railoRoot.getParentResource();
		    CompressUtil.compress(CompressUtil.FORMAT_ZIP, railoRoot, p.getRealResource("railo-web-context-old.zip"), false, -1);
		    ResourceUtil.removeEL(railoRoot, true);
		}
		catch (Throwable t) {
		    ExceptionUtil.rethrowIfNecessary(t);
		}
	    }
	    else {
		try {
		    configDir.createDirectory(true);
		}
		catch (IOException e) {}
	    }
	}
	return configDir;
    }
169566
private void parseConfig(String config) {

        if (isValidConfig(config)) {
            String[] conf = config.split("x");
            if (conf[0].trim().equals("?")) {
                m_width = I_CmsFormatRestriction.DIMENSION_NOT_SET;
            } else {
                m_width = CmsClientStringUtil.parseInt(conf[0]);
                m_width = (m_width == 0) ? I_CmsFormatRestriction.DIMENSION_NOT_SET : m_width;
            }
            if (conf[1].trim().equals("?")) {
                m_height = I_CmsFormatRestriction.DIMENSION_NOT_SET;
            } else {
                m_height = CmsClientStringUtil.parseInt(conf[1]);
                m_height = (m_height == 0) ? I_CmsFormatRestriction.DIMENSION_NOT_SET : m_height;
            }
        }
    }