returns instance of this factory (singelton = always the same instance) do auto update when
changes occur

@param config
@return Singelton Instance of the Factory
@throws ServletException
13443
public synchronized static CFMLEngine getInstance(final ServletConfig config) throws ServletException {

	if (singelton != null) {
	    if (factory == null) factory = singelton.getCFMLEngineFactory(); // not sure if this ever is done, but it does not hurt
	    return singelton;
	}

	if (factory == null) factory = new CFMLEngineFactory(config);

	// read init param from config
	factory.readInitParam(config);

	factory.initEngineIfNecessary();
	singelton.addServletConfig(config);

	// add listener for update
	// factory.addListener(singelton);
	return singelton;
    }
256514
public static function factory($config = array()) {
        $defaults = array(
            'base_url' => self::API_URL,
            'version' => 'v2.1',
            'command.params' => array(
                'command.on_complete' => function($command) {
                    $response = $command->getResult();

                    // We don't need the meta blocks
                    unset($response['meta']);

                    // If we're down to a single element (events, talks etc)
                    // return only this element
                    if (count($response) == 1) {
                        $command->setResult(reset($response));
                    }
                }
            )
        );

        $required = array(
            'base_url',
            'version',
        );

        $config = Collection::fromConfig($config, $defaults, $required);

        $client = new self($config->get('base_url'), $config);

        // Attach a service description to the client
        $description = ServiceDescription::factory(__DIR__ . '/client.json');
        $client->setDescription($description);

        return $client;
    }
1030127
public static Builder from(XmlMultiConfiguration config) {
    return new Builder() {
      @Override
      public Builder withManager(String identity, Configuration configuration) {
        Map<String, Config> configurations = new HashMap<>(config.configurations);
        configurations.put(identity, new SingleConfig(configuration));
        return from(new XmlMultiConfiguration(configurations));
      }

      @Override
      public Builder withoutManager(String identity) {
        Map<String, Config> configurations = config.configurations;
        configurations.remove(identity);
        return from(new XmlMultiConfiguration(configurations));
      }

      @Override
      public Variant withManager(String identity) {
        Map<String, Configuration> variants = new HashMap<>();

        Config current = config.configurations.get(identity);
        if (current instanceof VariantConfig) {
          variants.putAll(((VariantConfig) current).configs);
        } else if (current != null) {
          throw new IllegalStateException("Existing non-variant configuration cannot be replaced - it must be removed first.");
        }

        return new Variant() {
          @Override
          public Variant withoutVariant(String variant) {
            variants.remove(variant);
            return this;
          }

          @Override
          public Variant variant(String variant, Configuration configuration) {
            variants.put(variant, configuration);
            return this;
          }

          @Override
          public Builder withoutManager(String identity) {
            return from(build()).withoutManager(identity);
          }

          @Override
          public Builder withManager(String identity, Configuration configuration) {
            return from(build()).withManager(identity, configuration);
          }

          @Override
          public Variant withManager(String identity) {
            return from(build()).withManager(identity);
          }

          @Override
          public XmlMultiConfiguration build() {
            Map<String, Config> configurations = new HashMap<>(config.configurations);
            configurations.put(identity, new VariantConfig(variants));
            return new XmlMultiConfiguration(configurations);
          }
        };
      }

      @Override
      public XmlMultiConfiguration build() {
        return config;
      }
    };
  }
881361
public static final CounterFactory instance() {
        if(INSTANCE == null) throw new IllegalStateException(String.format("%s not initialized", CounterFactory.class.getSimpleName()));
        return INSTANCE;
    }
449673
public static function getInstance($config = array())
    {
        static $instance;

        if ($instance === null) {
            if (!$config instanceof AnConfig) {
                $config = new AnConfig($config);
            }

            $instance = new self($config);
        }

        return $instance;
    }
471297
protected ModuleConfig initModuleConfig( String prefix, String paths ) throws ServletException
    {

        if ( _log.isDebugEnabled() )
        {
            _log.debug( "Initializing module path '" + prefix + "' configuration from '" + paths + '\'' );
        }

        // Parse the configuration for this module
        ModuleConfig moduleConfig = null;
        InputStream input = null;
        String mapping;
        
        try
        {
            ModuleConfigFactory factoryObject =
                    ModuleConfigFactory.createFactory();
            moduleConfig = factoryObject.createModuleConfig( prefix );

            // Support for module-wide ActionMapping type override
            mapping = getServletConfig().getInitParameter( "mapping" );
            if ( mapping != null )
            {
                moduleConfig.setActionMappingClass( mapping );
            }

            // Configure the Digester instance we will use
            Digester digester = initConfigDigester();

            // Process each specified resource path
            while ( paths.length() > 0 )
            {
                digester.push( moduleConfig );
                String path;
                int comma = paths.indexOf( ',' );
                if ( comma >= 0 )
                {
                    path = paths.substring( 0, comma ).trim();
                    paths = paths.substring( comma + 1 );
                }
                else
                {
                    path = paths.trim();
                    paths = "";
                }
                if ( path.length() < 1 )
                {
                    break;
                }
                
                URL url = getConfigResource( path );
                
                //
                // THIS IS THE MAIN DIFFERENCE: we're doing a null-check here.
                //
                if ( url != null )
                {
                    URLConnection conn = url.openConnection();
                    conn.setUseCaches(false);
                    InputStream in = conn.getInputStream();
                    
                    try {
                        InputSource is = new InputSource(in);
                        is.setSystemId(url.toString());
                        input = getConfigResourceAsStream( path );
                        is.setByteStream( input );
                        
                        // also, we're not letting it fail here either.
                        try
                        {
                            digester.parse( is );
                            getServletContext().setAttribute( Globals.MODULE_KEY + prefix, moduleConfig );
                        }
                        catch ( Exception e )
                        {
                            _log.error( Bundle.getString( "PageFlow_Struts_ModuleParseError", path ), e );
                        }
                        input.close();
                    } finally {
                        in.close();
                    }
                }
                else
                {
                    //
                    // Special case.  If this is the default (root) module and the module path is one that's normally
                    // generated by the page flow compiler, then we don't want to error out if it's missing, since
                    // this probably just means that there's no root-level page flow.  Set up a default, empty,
                    // module config.
                    //
                    if ( prefix.equals( "" ) && isAutoLoadModulePath( path, prefix ) )
                    {
                        if ( _log.isInfoEnabled() )
                        {
                            _log.info( "There is no root module at " + path + "; initializing a default module." );
                        }
                        
                        //
                        // Set the ControllerConfig to a MissingRootModuleControllerConfig.  This is used by
                        // PageFlowRequestProcessor.
                        //
                        moduleConfig.setControllerConfig( new MissingRootModuleControllerConfig() );
                    }
                    else
                    {
                        _log.error( Bundle.getString( "PageFlow_Struts_MissingModuleConfig", path ) );
                    }
                }
            }

        }
        catch ( Throwable t )
        {
            _log.error( internal.getMessage( "configParse", paths ), t );
            throw new UnavailableException( internal.getMessage( "configParse", paths ) );
        }
        finally
        {
            if ( input != null )
            {
                try
                {
                    input.close();
                }
                catch ( IOException e )
                {
                    // ignore
                }
            }
        }

        // Force creation and registration of DynaActionFormClass instances
        // for all dynamic form beans we will be using
        FormBeanConfig fbs[] = moduleConfig.findFormBeanConfigs();
        for ( int i = 0; i < fbs.length; i++ )
        {
            if ( fbs[i].getDynamic() )
            {
                DynaActionFormClass.createDynaActionFormClass( fbs[i] );
            }
        }

        // Special handling for the default module (for
        // backwards compatibility only, will be removed later)
        if ( prefix.length() < 1 )
        {
            defaultControllerConfig( moduleConfig );
            defaultMessageResourcesConfig( moduleConfig );
        }

        // Return the completed configuration object
        //config.freeze();  // Now done after plugins init
        return moduleConfig;

    }
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();
        }
    }
1291944
final public static function getInstance($config = array())
    {
        static $instance;

        if ($instance === NULL)
        {
            if(!$config instanceof KObjectConfig) {
                $config = new KObjectConfig($config);
            }

            $instance = new self($config);
        }

        return $instance;
    }
717511
@Override
    public SSLServerSocketFactory getSSLServerSocketFactory(SSLConfig config) throws SSLException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getSSLServerSocketFactory");

        try {
            SSLContext context = getSSLContext(null, config);

            if (context != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "getSSLServerSocketFactory");
                return context.getServerSocketFactory();
            }
        } catch (Exception e) {
            FFDCFilter.processException(e, getClass().getName(), "getSSLServerSocketFactory", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "The following exception occurred in getSSLServerSocketFactory().", new Object[] { e });
            if (e instanceof SSLException)
                throw (SSLException) e;
            throw new SSLException(e);
        }

        throw new SSLException("SSLContext could not be created to return an SSLServerSocketFactory.");
    }
22995
public void init(ServletConfig config)
         throws ServletException
    {
        super.init(config);

        Enumeration enm = config.getInitParameterNames();
        while (enm.hasMoreElements())
        {
            String path=(String)enm.nextElement();
            String forward=config.getInitParameter(path);
            _forwardMap.put(path,forward);
        }

    }
1258803
private synchronized boolean _restart() throws ServletException {
	if (singelton != null) singelton.reset();

	initEngine();

	ConfigServer cs = getConfigServer(singelton);
	if (cs != null) {
	    Log log = cs.getLog("application");
	    log.info("loader", "Lucee restarted");
	}
	System.gc();
	return true;
    }
106530
public static <T> Retryer<T> newInstance(Config config) {
    config = config.withFallback(DEFAULTS);
    RetryType type = RetryType.valueOf(config.getString(RETRY_TYPE).toUpperCase());

    switch (type) {
      case EXPONENTIAL:
        return newExponentialRetryer(config);
      case FIXED:
        return newFixedRetryer(config);
      default:
        throw new IllegalArgumentException(type + " is not supported");
    }
  }
146568
public static function factory($config = array())
	{
		$default = array();
		$required = array('base_url');
		$config = Inspector::prepareConfig($config, $default, $required);
		$client = new self($config->get('base_url'), $config->get('token'));
		$client->setConfig($config);
		$client->getEventDispatcher()->addSubscriber(new AuthenticationObserver());
		return $client;
	}
1354941
public static function getInstance($config = null)
    {
        if (!self::$instance) {
            self::$instance = new self($config == null ? BlockCypherConfigManager::getInstance()->getConfigHashmap() : $config);
        }
        return self::$instance;
    }
926403
public static ServletContainer defaultContainer() {
        if (container != null) {
            return container;
        }
        synchronized (Servlets.class) {
            if (container != null) {
                return container;
            }
            return container = ServletContainer.Factory.newInstance();
        }
    }
1178015
public static FacesBackingBeanFactory get( ServletContext servletContext )
    {
        FacesBackingBeanFactory factory = ( FacesBackingBeanFactory ) servletContext.getAttribute( CONTEXT_ATTR );
        assert factory != null
                : FacesBackingBeanFactory.class.getName() + " was not found in ServletContext attribute " + CONTEXT_ATTR;
        factory.reinit( servletContext );
        return factory;
    }
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;
    }