Construct the WsLocationAdminService singleton based on a set of initial
properties provided by the bundle context when running in an osgi
framework.

@param initProps
@return WsLocationAdmin
516458
public static WsLocationAdminImpl createLocations(final BundleContext ctx) {
        if (instance.get() == null) {
            SymbolRegistry.getRegistry().clear();
            Callable<WsLocationAdminImpl> initializer = new Callable<WsLocationAdminImpl>() {
                @Override
                public WsLocationAdminImpl call() throws Exception {
                    return new WsLocationAdminImpl(new BundleContextMap(ctx));
                }
            };
            instance = StaticValue.mutateStaticValue(instance,initializer);
        }

        return instance.get();
    }
834170
public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
    ensureNotNull("Cannot start process instance, initial activity where the process instance should start is null", "initial", initial);

    PvmExecutionImpl processInstance = newProcessInstance();

    processInstance.setProcessDefinition(this);

    processInstance.setProcessInstance(processInstance);

    // always set the process instance to the initial activity, no matter how deeply it is nested;
    // this is required for firing history events (cf start activity) and persisting the initial activity
    // on async start
    processInstance.setActivity(initial);

    return processInstance;
  }
777108
@SneakyThrows
    public static ClientConfiguration buildClientConfiguration(final BaseAmazonWebServicesProperties props) {
        val cfg = new ClientConfiguration();
        cfg.setConnectionTimeout(props.getConnectionTimeout());
        cfg.setMaxConnections(props.getMaxConnections());
        cfg.setRequestTimeout(props.getRequestTimeout());
        cfg.setSocketTimeout(props.getSocketTimeout());
        cfg.setUseGzip(props.isUseGzip());
        cfg.setUseReaper(props.isUseReaper());
        cfg.setUseThrottleRetries(props.isUseThrottleRetries());
        cfg.setUseTcpKeepAlive(props.isUseTcpKeepAlive());
        cfg.setProtocol(Protocol.valueOf(props.getProtocol().toUpperCase()));
        cfg.setClientExecutionTimeout(props.getClientExecutionTimeout());
        if (props.getMaxErrorRetry() > 0) {
            cfg.setMaxErrorRetry(props.getMaxErrorRetry());
        }
        cfg.setProxyHost(props.getProxyHost());
        cfg.setProxyPassword(props.getProxyPassword());
        if (props.getProxyPort() > 0) {
            cfg.setProxyPort(props.getProxyPort());
        }
        cfg.setProxyUsername(props.getProxyUsername());
        cfg.setCacheResponseMetadata(props.isCacheResponseMetadata());

        if (StringUtils.isNotBlank(props.getLocalAddress())) {
            LOGGER.trace("Creating DynamoDb client local address [{}]", props.getLocalAddress());
            cfg.setLocalAddress(InetAddress.getByName(props.getLocalAddress()));
        }

        return cfg;
    }
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();
    }
1180960
public void initialize(Map<String, Object> configProps) throws WIMException {

        iReposId = (String) configProps.get(KEY_ID);

        /*
         * Set ldapTimeout
         */
        if (configProps.containsKey(CONFIG_PROP_SEARCH_TIME_OUT)) {
            long val = Long.parseLong(String.valueOf(configProps.get(CONFIG_PROP_SEARCH_TIME_OUT)));
            iTimeLimit = (int) val;
        }

        /*
         * Set ldapCountLimit
         */
        if (configProps.containsKey(CONFIG_PROP_SEARCH_COUNT_LIMIT)) {
            iCountLimit = (int) configProps.get(CONFIG_PROP_SEARCH_COUNT_LIMIT);
        }

        /*
         * Set search page size
         */
        if (configProps.containsKey(CONFIG_PROP_SEARCH_PAGE_SIZE)) {
            iPageSize = (int) configProps.get(CONFIG_PROP_SEARCH_PAGE_SIZE);
        } else {
            if (LdapConstants.AD_LDAP_SERVER.equalsIgnoreCase(iLdapConfigMgr.getLdapType())) {
                iPageSize = 1000;
            }
        }

        /*
         * Set attribute range step
         */
        if (configProps.containsKey(CONFIG_PROP_ATTRIBUTE_RANGE_STEP)) {
            iAttrRangeStep = Integer.parseInt((String) configProps.get(CONFIG_PROP_ATTRIBUTE_RANGE_STEP));
        } else {
            if (LdapConstants.AD_LDAP_SERVER.equalsIgnoreCase(iLdapConfigMgr.getLdapType())) {
                iAttrRangeStep = 1000;
            }
        }

        /*
         * Ignore case.
         */
        ignoreDNCase = (Boolean) configProps.get(CONFIG_IGNORE_CASE);
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Set ignoreDNCase as [" + ignoreDNCase + "]");

        /*
         * Initialize the ContextManager and the caches.
         */
        initializeContextManager(configProps);
        initializeCaches(configProps);
    }
615759
public B getInstance()
            throws BackendInitializationException, BackendNewInstanceException {
        B backend = backendSpec.newBackendInstance();
        backend.initialize(this);
        return backend;
    }
866551
private boolean initPropertyService() {
        if (propertyService == null && appContext.containsBean("propertyService")) {
            propertyService = appContext.getBean("propertyService", IPropertyService.class);
        }
        
        return propertyService != null;
    }
819949
public T build(final boolean init) {
    final T cacheManager = newCacheManager(services, configBuilder.build());
    if(init) {
      cacheManager.init();
    }
    return cacheManager;
  }
1153701
private SSLSocketFactory initSslSocketFactory(KeyManager[] kms, TrustManager[] tms)
			throws InitializationException {

		SSLContext ctx = null;

		String verify = System.getProperty(VERIFY_PEER_CERT_PROPERTY);


		// If VERIFY_PEER_PROPERTY is set to false, we don't want verification
		// of the other sides certificate
		if (verify != null &&  verify.equals("false")) {
			tms = getTrustAllKeystore();
		} else if (verify == null || verify != null && verify.equals("true")) {
			// use the given tms
		} else {
			throw new InitializationException("Bad value for "
					+ VERIFY_PEER_CERT_PROPERTY +  " property. Expected: true|false");
		}

		if (!isBasicAuth() && kms == null) {
			throw new InitializationException("certificate-based auth needs a KeyManager");
		}


		try {
			ctx = SSLContext.getInstance("TLS");
			ctx.init(kms, tms, new SecureRandom());
		} catch (Exception e) {
			/* catch all */
			IfmapJLog.error("Could not initialize SSLSocketFactory ["
								  + e.getMessage() + "]");
			throw new InitializationException(e);
		}
		return ctx.getSocketFactory();
	}
928694
public Object startupService(BundleContext bundleContext)
    {
        Map<String,Object> props = this.getServiceProperties();
	    return Environment.getEnvironment(props);	// There is no need to check if it is already up (only 1 can run)
    }
1161520
private void initializeStaticPolicy(List<ProGradePolicyEntry> grantEntriesList) throws Exception {

        // grant codeBase "file:${{java.ext.dirs}}/*" {
        // permission java.security.AllPermission;
        // };
        ProGradePolicyEntry p1 = new ProGradePolicyEntry(true, debug);
        Certificate[] certificates = null;
        URL url = new URL(expandStringWithProperty("file:${{java.ext.dirs}}/*"));
        CodeSource cs = new CodeSource(adaptURL(url), certificates);
        p1.setCodeSource(cs);
        p1.addPermission(new AllPermission());
        grantEntriesList.add(p1);

        // grant {
        // permission java.lang.RuntimePermission "stopThread";
        // permission java.net.SocketPermission "localhost:1024-", "listen";
        // permission java.util.PropertyPermission "java.version", "read";
        // permission java.util.PropertyPermission "java.vendor", "read";
        // permission java.util.PropertyPermission "java.vendor.url", "read";
        // permission java.util.PropertyPermission "java.class.version", "read";
        // permission java.util.PropertyPermission "os.name", "read";
        // permission java.util.PropertyPermission "os.version", "read";
        // permission java.util.PropertyPermission "os.arch", "read";
        // permission java.util.PropertyPermission "file.separator", "read";
        // permission java.util.PropertyPermission "path.separator", "read";
        // permission java.util.PropertyPermission "line.separator", "read";
        // permission java.util.PropertyPermission "java.specification.version", "read";
        // permission java.util.PropertyPermission "java.specification.vendor", "read";
        // permission java.util.PropertyPermission "java.specification.name", "read";
        // permission java.util.PropertyPermission "java.vm.specification.version", "read";
        // permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
        // permission java.util.PropertyPermission "java.vm.specification.name", "read";
        // permission java.util.PropertyPermission "java.vm.version", "read";
        // permission java.util.PropertyPermission "java.vm.vendor", "read";
        // permission java.util.PropertyPermission "java.vm.name", "read";
        // };
        ProGradePolicyEntry p2 = new ProGradePolicyEntry(true, debug);
        p2.addPermission(new RuntimePermission("stopThread"));
        p2.addPermission(new SocketPermission("localhost:1024-", "listen"));
        p2.addPermission(new PropertyPermission("java.version", "read"));
        p2.addPermission(new PropertyPermission("java.vendor", "read"));
        p2.addPermission(new PropertyPermission("java.vendor.url", "read"));
        p2.addPermission(new PropertyPermission("java.class.version", "read"));
        p2.addPermission(new PropertyPermission("os.name", "read"));
        p2.addPermission(new PropertyPermission("os.version", "read"));
        p2.addPermission(new PropertyPermission("os.arch", "read"));
        p2.addPermission(new PropertyPermission("file.separator", "read"));
        p2.addPermission(new PropertyPermission("path.separator", "read"));
        p2.addPermission(new PropertyPermission("line.separator", "read"));
        p2.addPermission(new PropertyPermission("java.specification.version", "read"));
        p2.addPermission(new PropertyPermission("java.specification.vendor", "read"));
        p2.addPermission(new PropertyPermission("java.specification.name", "read"));
        p2.addPermission(new PropertyPermission("java.vm.specification.version", "read"));
        p2.addPermission(new PropertyPermission("java.vm.specification.vendor", "read"));
        p2.addPermission(new PropertyPermission("java.vm.specification.name", "read"));
        p2.addPermission(new PropertyPermission("java.vm.version", "read"));
        p2.addPermission(new PropertyPermission("java.vm.vendor", "read"));
        p2.addPermission(new PropertyPermission("java.vm.name", "read"));
        grantEntriesList.add(p2);

    }
129928
public Object createInstance(StoreConfiguration storeConfiguration) {
      for(CacheStoreFactory factory : factories) {
         Object instance = factory.createInstance(storeConfiguration);
         if(instance != null) {
            return instance;
         }
      }
      throw log.unableToInstantiateClass(storeConfiguration.getClass());
   }
1332045
public IStorageProvider build()
    {
        if ( appInfoRepo == null ) {
            throw new IllegalStateException( "Undefined application information repository" );
        }
        if ( userCredentialsRepo == null ) {
            throw new IllegalStateException( "Undefined user credentials repository" );
        }

        try {
            Constructor providerConstructor = providerClass.getConstructor( StorageBuilder.class );
            StorageProvider providerInstance = ( StorageProvider ) providerConstructor.newInstance( this );
            return providerInstance;

        } catch ( InvocationTargetException itex ) {
            Throwable cause = itex.getCause();
            if ( cause instanceof RuntimeException ) {
                throw ( RuntimeException ) cause;
            }
            // should not happen, providers constructors do not throw checked exceptions:
            throw new UnsupportedOperationException( "Error instantiating the provider " + providerClass.getSimpleName(), itex );
        } catch ( Exception ex ) {
            throw new UnsupportedOperationException( "Error instantiating the provider " + providerClass.getSimpleName(), ex );
        }
    }
868495
private void initializeContextManager(Map<String, Object> configProps) throws WIMException {

        iContextManager = new ContextManager();

        /*
         * Set SSL configuration
         */
        iContextManager.setSSLAlias((String) configProps.get("sslRef"));
        iContextManager.setSSLEnabled((Boolean) configProps.get(CONFIG_PROP_SSL_ENABLED));

        /*
         * Set the primary server.
         */
        iContextManager.setPrimaryServer((String) configProps.get(CONFIG_PROP_HOST), (Integer) configProps.get(CONFIG_PROP_PORT));

        /*
         * Set fail-over servers and fail-over behavior.
         */
        for (Map<String, Object> serverConfig : Nester.nest(FAILOVER_SERVERS, configProps)) {
            List<Map<String, Object>> servers = Nester.nest(SERVER2, serverConfig);
            for (Map<String, Object> server : servers) {
                iContextManager.addFailoverServer((String) server.get(CONFIG_PROP_HOST), (Integer) server.get(CONFIG_PROP_PORT));
            }
        }
        iContextManager.setWriteToSecondary(Boolean.getBoolean((String) configProps.get(CONFIG_PROP_ALLOW_WRITE_TO_SECONDARY_SERVERS)));
        iContextManager.setReturnToPrimary((Boolean) configProps.get(CONFIG_PROP_RETURN_TO_PRIMARY_SERVER));
        iContextManager.setQueryInterval((Integer) configProps.get(CONFIG_PROP_PRIMARY_SERVER_QUERY_TIME_INTERVAL) * 60);

        /*
         * Set the simple authentication credentials.
         */
        iContextManager.setSimpleCredentials((String) configProps.get(CONFIG_PROP_BIND_DN), (SerializableProtectedString) configProps.get(CONFIG_PROP_BIND_PASSWORD));

        /*
         * Set the connection timeout.
         */
        iContextManager.setConnectTimeout((Long) configProps.get(CONFIG_PROP_CONNECT_TIMEOUT));

        /*
         * Set the connection timeout.
         */
        iContextManager.setReadTimeout((Long) configProps.get(CONFIG_PROP_READ_TIMEOUT));

        /*
         * Determine referral handling behavior. Initially the attribute was spelled missing an 'r' so
         * for backwards compatibility, support customers who might still be using it. The "referal"
         * attribute has no default so unless it is set we won't use it.
         */
        String referal = (String) configProps.get(CONFIG_PROP_REFERAL);
        String referral = (String) configProps.get(CONFIG_PROP_REFERRAL);
        referral = referal != null ? referal : referral;
        iContextManager.setReferral(referral.toLowerCase());

        /*
         * Set binary attribute names.
         */
        iContextManager.setBinaryAttributeNames(getBinaryAttributes());

        /*
         * Configure the context pool.
         */
        boolean enableContextPool = true;

        List<Map<String, Object>> poolConfigs = Nester.nest(CONFIG_CONTEXT_POOL, configProps);

        Map<String, Object> poolConfig = null;
        if (!poolConfigs.isEmpty()) {
            poolConfig = poolConfigs.get(0);
        }

        /*
         * Enable the context pool if the context pool is enabled and the
         * stand-alone LDAP property reuseConnection has not been set to false.
         */
        boolean reuseConn = (Boolean) configProps.get(CONFIG_REUSE_CONNECTION);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Set reuseConnection as [" + reuseConn + "]");
        }
        if (poolConfig != null) {
            enableContextPool = (Boolean) poolConfig.get(CONFIG_PROP_ENABLED);
        }
        if (!reuseConn) {
            enableContextPool = false;
        }

        Integer initPoolSize = null;
        Integer maxPoolSize = null;
        Integer prefPoolSize = null;
        Long poolTimeOut = null;
        Long poolWaitTime = null;

        if (enableContextPool) {
            if (poolConfig != null) {
                if (poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE) != null) {
                    initPoolSize = (Integer) poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE) != null) {
                    maxPoolSize = (Integer) poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE) != null) {
                    prefPoolSize = (Integer) poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE);
                }

                if (poolConfig.get(CONFIG_PROP_POOL_TIME_OUT) != null) {
                    poolTimeOut = (Long) poolConfig.get(CONFIG_PROP_POOL_TIME_OUT);

                    /**
                     * The metatype is set to long for this property and all
                     * values will be passed as milliseconds.
                     * A value of 0 means no timeout, leave at 0
                     * Between 0 and 1000ms, round up to 1s
                     * Otherwise round to nearest second
                     */
                    if (poolTimeOut > 0 && poolTimeOut <= 1000) {
                        poolTimeOut = 1l; // override to 1 second
                    } else {
                        poolTimeOut = roundToSeconds(poolTimeOut);
                    }
                }
                if (poolConfig.get(CONFIG_PROP_POOL_WAIT_TIME) != null) {
                    poolWaitTime = (Long) poolConfig.get((CONFIG_PROP_POOL_WAIT_TIME));
                }
            }
        }

        /*
         * Set the configuration on the ContextManager.
         */
        iContextManager.setContextPool(enableContextPool, initPoolSize, prefPoolSize, maxPoolSize, poolTimeOut, poolWaitTime);

        /*
         * Initialize the ContextManager.
         *
         * Only need to check for missing password as the configuration for LDAP would catch a missing
         * primary server. The password is optional and only required when the bind DN is configured.
         */
        InitializeResult result = iContextManager.initialize();
        if (result == InitializeResult.MISSING_PASSWORD) {
            String msg = Tr.formatMessage(tc, WIMMessageKey.MISSING_INI_PROPERTY, WIMMessageHelper.generateMsgParms(CONFIG_PROP_BIND_PASSWORD));
            throw new MissingInitPropertyException(WIMMessageKey.MISSING_INI_PROPERTY, msg);
        }
    }
396272
protected Object getLdpComponent(final T config, final boolean initialize) {
        final TrellisHttpResource ldpResource = new TrellisHttpResource(getServiceBundler(), config.getBaseUrl());
        if (initialize) {
            ldpResource.initialize();
        }
        return ldpResource;
    }
571929
public Object startupService(BundleContext bundleContext)
    {
        // Good, Environment activator is up. Time to start up http services trackers
        
        for (String alias : getAliases())
        {
            Dictionary<String, String> properties = new Hashtable<String, String>();
            ServiceTracker serviceTracker = this.makeServletTracker(alias, properties);
            ((ServiceTracker)serviceTracker).open();
            context.registerService(ServiceTracker.class.getName(), serviceTracker, properties);    // Why isn't this done automatically?
        }

        return null;
    }
445333
public static function getInstance() {

		if( !isset( self::$instance ) ) {

			self::$instance	= new AdminProperties();

			self::$instance->init( CoreGlobal::CONFIG_ADMIN );
		}

		return self::$instance;
	}