/*
This function is used to initialize a connectionType object that gets
added to the connectionTypes array.
966997
function createDeviceConnectionObj(dt, ct, id) {
            var obj = {
                'dt': dt,
                'ct': ct,
                'id': id,
                'connectionType': ct,
                'connectionTypeStr': driver_const.DRIVER_CONNECTION_TYPE_NAMES[ct],
                'connectionTypeName': driver_const.CONNECTION_TYPE_NAMES[ct],
                'name': driver_const.CONNECTION_TYPE_NAMES[ct],
                'isVerified': false,
                'verified': false,
                'isScanned': false,
                'insertionMethod': 'unknown',
                'foundByAttribute': false,
                'isActive': false,
                'isMockDevice': false,
            };
            var usbCT = driver_const.connectionTypes.usb;
            var ethCT = driver_const.connectionTypes.ethernet;
            var wifiCT = driver_const.connectionTypes.wifi;

            if((ct == ethCT)||(ct == wifiCT)) {
                obj.ip = id;
                obj.ipAddress = id;
                // Define the port as the modbus 502 port.
                obj.port = driver_const.LJM_MODBUS_PORT;
            } else if(ct == usbCT) {
                obj.ip = '0.0.0.0';
                obj.ipAddress = '0.0.0.0';
                obj.port = 0;
            }
            return obj;
        }
153476
@Override
    public void init(String jsonString) throws AuthenticationException {
        try {
            setConfig(new JsonSimpleConfig(jsonString));
        } catch (UnsupportedEncodingException e) {
            throw new AuthenticationException(e);
        } catch (IOException e) {
            throw new AuthenticationException(e);
        }
    }
1088597
@Override
  public void init(PlayerConfig config) throws InitializationFailedException {
    super.init(config);
    PoolingClientConnectionManager connectionManager = (PoolingClientConnectionManager) HTTP_CLIENT_INSTANCE
        .getConnectionManager();
    if (config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY) != null
        && !config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY).isEmpty()) {
      connectionManager.setDefaultMaxPerRoute(Integer.parseInt(config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY)));
    }
    if (config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY) != null && !config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY).isEmpty()) {
      connectionManager.setMaxTotal(Integer.parseInt(config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY)));
    }
  }
1868
@PostConstruct
    public void acquireConnections() throws JMSException {
        LOGGER.debug("Initializing: {}", this.getClass().getCanonicalName());

        connection = connectionFactory.createConnection();
        connection.start();
        jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        producer = jmsSession.createProducer(createDestination());
        eventBus.register(this);
    }
362141
public static void initialize() {

        if (initialized) return;

        SniffyConfiguration.INSTANCE.addTopSqlCapacityListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                ConcurrentLinkedHashMap<String, Timer> oldValues = globalSqlStats;
                globalSqlStats =
                        new ConcurrentLinkedHashMap.Builder<String, Timer>().
                                maximumWeightedCapacity(SniffyConfiguration.INSTANCE.getTopSqlCapacity()).
                                build();
                globalSqlStats.putAll(oldValues);
            }

        });


        if (SniffyConfiguration.INSTANCE.isMonitorSocket()) {

            try {
                SnifferSocketImplFactory.install();
            } catch (IOException e) {
                e.printStackTrace();
            }

        } else {

            SniffyConfiguration.INSTANCE.addMonitorSocketListener(new PropertyChangeListener() {

                private boolean sniffySocketImplFactoryInstalled = false;

                @Override
                public synchronized void propertyChange(PropertyChangeEvent evt) {
                    if (sniffySocketImplFactoryInstalled) return;
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        try {
                            SnifferSocketImplFactory.install();
                            sniffySocketImplFactoryInstalled = true;
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }

            });

        }

        initialized = true;

    }
218351
@PostConstruct
    public void init(Map<String,String> properties) {

        vmTransportUrl = properties.getOrDefault(KEY_VM_TRANSPORT_URL, KEY_VM_TRANSPORT_URL_DEFAULT);
        memberInteractionsQueueName = properties.getOrDefault(KEY_MEMBER_INTERACTIONS_QUEUE,
                KEY_MEMBER_INTERACTIONS_QUEUE_DEFAULT);

        jmsConnectionFactory = new ActiveMQConnectionFactory(vmTransportUrl);

        try {
            jmsConnection = jmsConnectionFactory.createConnection();
        } catch (JMSException e) {
            LOG.error("Unable to create connection", e);
            throw new RuntimeException(e);
        }

        try {
            jmsConnection.start();
        } catch (JMSException e) {
            LOG.error("Unable to start connection", e);
            closeSafely(jmsConnection);
            jmsConnection = null;
        }
    }
775384
public void init(final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap) {
        for (Entry<TransactionType, ShardingTransactionManager> entry : transactionManagerMap.entrySet()) {
            entry.getValue().init(databaseType, getResourceDataSources(dataSourceMap));
        }
    }
1171892
function initServiceModel(connectionUrl) {
  log.logger.debug("initServiceModel ", {connectionUrl: connectionUrl});
  if (!connectionUrl) {
    log.logger.error("No Connection Url Specified");
    return null;
  }

  //If the connection has not already been created, create it and initialise the Service Schema For That Domain
  if (!domainMongooseConnections[connectionUrl]) {
    log.logger.debug("No Connection Exists for " + connectionUrl + ", creating a new one");
    domainMongooseConnections[connectionUrl] = mongoose.createConnection(connectionUrl);
    domainMongooseConnections[connectionUrl].model(SERVICE_MODEL, ServiceSchema);

    //Setting Up Event Listeners
    domainMongooseConnections[connectionUrl].on('connecting', function(msg){
      log.logger.debug("Mongoose Connecting", {msg: msg, connectionUrl: connectionUrl});
    });

    domainMongooseConnections[connectionUrl].on('error', function(msg){
      log.logger.error("Mongoose Connection Error", {msg: msg, connectionUrl: connectionUrl});
    });

    domainMongooseConnections[connectionUrl].on('connected', function(msg){
      log.logger.debug("Mongoose Connected", {msg: msg, connectionUrl: connectionUrl});
    });
  } else {
    log.logger.debug("Connection Already Exists.");
  }

  return domainMongooseConnections[connectionUrl];
}
177255
public void setInboundConnectionInfo(Map<String, Object> connectionInfo) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "setInboundConnectionInfo");
        this.inboundConnectionInfo = connectionInfo;
    }
1042738
protected function initConnectionData()
    {
        if ($this->connectionData) {
            return;
        }

        if (!$this->connectionUrl) {
            throw new \UnexpectedValueException(
                'Expected a connectionUrl, got nowt.'
            );
        }

        $parsed = parse_url($this->connectionUrl);
        if ($parsed === false) {
            throw new UnexpectedValueException(
                'Expected a sensible connectionUrl, got nowt but rubbish.'
            );
        }
        $this->connectionData = $parsed;
    }
1171530
private void initializeDefaults() {
        String keyStoreType = getProperty(Constants.SSLPROP_KEY_STORE_TYPE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "keyStoreType: " + keyStoreType);

        if (keyStoreType == null && getProperty(Constants.SYSTEM_SSLPROP_KEY_STORE_TYPE) == null) {
            setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.TRUE);
            setProperty(Constants.SSLPROP_KEY_STORE_TYPE, Constants.KEYSTORE_TYPE_PKCS12);
            keyStoreType = Constants.KEYSTORE_TYPE_PKCS12;
        } else {
            if (keyStoreType != null &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_JKS) &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_JCEKS) &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_PKCS12)) {
                setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.FALSE);
            } else {
                setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.TRUE);
            }
        }

        String trustStoreType = getProperty(Constants.SSLPROP_TRUST_STORE_TYPE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "trustStoreType: " + trustStoreType);

        if (trustStoreType == null && getProperty(Constants.SYSTEM_SSLPROP_TRUST_STORE_TYPE) == null) {
            setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.TRUE);
            setProperty(Constants.SSLPROP_TRUST_STORE_TYPE, Constants.KEYSTORE_TYPE_PKCS12);
            trustStoreType = Constants.KEYSTORE_TYPE_PKCS12;
        } else {
            if (trustStoreType != null &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_JKS) &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_JCEKS) &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_PKCS12)) {
                setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.FALSE);
            } else {
                setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.TRUE);
            }
        }

        JSSEProvider defaultProvider = JSSEProviderFactory.getInstance();

        if (getProperty(Constants.SSLPROP_KEY_MANAGER) == null)
            setProperty(Constants.SSLPROP_KEY_MANAGER, JSSEProviderFactory.getKeyManagerFactoryAlgorithm());

        if (getProperty(Constants.SSLPROP_KEY_STORE_PROVIDER) == null
            && null != defaultProvider.getKeyStoreProvider())
            setProperty(Constants.SSLPROP_KEY_STORE_PROVIDER, defaultProvider.getKeyStoreProvider());

        if (getProperty(Constants.SSLPROP_PROTOCOL) == null)
            setProperty(Constants.SSLPROP_PROTOCOL, defaultProvider.getDefaultProtocol());

        if (getProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION) == null)
            setProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION, Constants.FALSE);

        if (getProperty(Constants.SSLPROP_CONTEXT_PROVIDER) == null)
            setProperty(Constants.SSLPROP_CONTEXT_PROVIDER, defaultProvider.getContextProvider());

        if (getProperty(Constants.SSLPROP_SECURITY_LEVEL) == null)
            setProperty(Constants.SSLPROP_SECURITY_LEVEL, Constants.SECURITY_LEVEL_HIGH);

        if (getProperty(Constants.SSLPROP_TRUST_MANAGER) == null)
            setProperty(Constants.SSLPROP_TRUST_MANAGER, JSSEProviderFactory.getTrustManagerFactoryAlgorithm());

        if (getProperty(Constants.SSLPROP_TRUST_STORE_PROVIDER) == null
            && null != defaultProvider.getKeyStoreProvider())
            setProperty(Constants.SSLPROP_TRUST_STORE_PROVIDER, defaultProvider.getKeyStoreProvider());

        if (getProperty(Constants.SSLPROP_VALIDATION_ENABLED) == null)
            setProperty(Constants.SSLPROP_VALIDATION_ENABLED, Constants.FALSE);

        if (getProperty(Constants.SSLPROP_TOKEN_ENABLED) == null)
            setProperty(Constants.SSLPROP_TOKEN_ENABLED, Constants.FALSE);

        String keyStore = getProperty(Constants.SSLPROP_KEY_STORE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "keyStore: " + keyStore);
        }
        String keyStoreName = getProperty(Constants.SSLPROP_KEY_STORE_NAME);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "keyStoreName: " + keyStoreName);
        }
        String keyStorePassword = getProperty(Constants.SSLPROP_KEY_STORE_PASSWORD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "keyStorePassword: " + SSLConfigManager.mask(keyStorePassword));

        String trustStore = getProperty(Constants.SSLPROP_TRUST_STORE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "trustStore: " + trustStore);
        }
        String trustStoreName = getProperty(Constants.SSLPROP_TRUST_STORE_NAME);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "trustStoreName: " + trustStoreName);
        }
        String trustStorePassword = getProperty(Constants.SSLPROP_TRUST_STORE_PASSWORD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "trustStorePassword: " + SSLConfigManager.mask(trustStorePassword));

        // When only a trust store is specified, use it as the key store as well.
        if (keyStore == null && trustStore != null && trustStorePassword != null && trustStoreType != null) {
            setProperty(Constants.SSLPROP_KEY_STORE, trustStore);
            setProperty(Constants.SSLPROP_KEY_STORE_NAME, trustStoreName);
            setProperty(Constants.SSLPROP_KEY_STORE_PASSWORD, trustStorePassword);
            setProperty(Constants.SSLPROP_KEY_STORE_TYPE, trustStoreType);
        }
        // When only a key store is specified, use it as the trust store as well.
        else if (trustStore == null && keyStore != null && keyStorePassword != null && keyStoreType != null) {
            setProperty(Constants.SSLPROP_TRUST_STORE, keyStore);
            setProperty(Constants.SSLPROP_TRUST_STORE_NAME, keyStoreName);
            setProperty(Constants.SSLPROP_TRUST_STORE_PASSWORD, keyStorePassword);
            setProperty(Constants.SSLPROP_TRUST_STORE_TYPE, keyStoreType);
        }
    }
702551
@Override
    public void initWithDefaultProperties(Properties properties) throws ConnectorInitException {

        log.debug("Starting to initWithDefaultProperties RabbitMQ connector in php plugin...");

        ConnectionFactory factory = new ConnectionFactory();

        factory.setHost(properties.getProperty("connector.host"));
        factory.setPort(
                Integer.valueOf(properties.getProperty("connector.port"))
        );
        factory.setUsername(properties.getProperty("connector.username"));
        factory.setPassword(properties.getProperty("connector.password"));

        try {
            connection = factory.newConnection();
            channel = connection.createChannel();
            channel.queueDeclare(properties.getProperty("connector.queue-name"),
                    false, false, false, null);
            channel.basicConsume(
                    properties.getProperty("connector.queue-name"),
                    true, new MoskitoPHPConsumer(channel)
            );
            enabledInTimestamp = System.currentTimeMillis();
        } catch (IOException | TimeoutException e) {
            deinit();
            throw new ConnectorInitException("Failed to open connection to RabbitMQ", e);
        }


    }
1308734
protected void postInit(Connection connection) throws SQLException
   {
      String select =
         "select * from " + DBInitializerHelper.getItemTableName(containerConfig) + " where ID='"
            + Constants.ROOT_PARENT_UUID + "' and PARENT_ID='" + Constants.ROOT_PARENT_UUID + "'";

      if (!connection.createStatement().executeQuery(select).next())
      {
         String insert = DBInitializerHelper.getRootNodeInitializeScript(containerConfig);
         connection.createStatement().executeUpdate(insert);
      }
   }
784304
private static void initJmxConn() throws IOException {
        if (jmxUrl != null) {
            JMXServiceURL url = new JMXServiceURL(jmxUrl);
            Map<String, String[]> env = null;
            if (jmxUsername != null) {
                env = Maps.newHashMap();
                String[] credentials = new String[]{jmxUsername, jmxPassword};
                env.put(JMXConnector.CREDENTIALS, credentials);
            }
            JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
            conn = jmxc.getMBeanServerConnection();
        }
    }
1076820
private function initFieldsTypes()
    {
        $this->fieldTypes = [];

        $fieldTypes = $this->loadFieldTypes();

        foreach ($fieldTypes as $fieldType) {
            if (!$fieldType instanceof FieldTypeInterface) {
                throw new DataSourceException(sprintf('Expected instance of FieldTypeInterface, "%s" given.', get_class($fieldType)));
            }

            if (isset($this->fieldTypes[$fieldType->getType()])) {
                throw new DataSourceException(sprintf('Error during field types loading. Name "%s" already in use.', $fieldType->getType()));
            }

            $this->fieldTypes[$fieldType->getType()] = $fieldType;
        }
    }
506617
@Initialize
    public void init() {
        logger.info("Initializing dictionary: {}", this);
        Datastore datastore = getDatastore();
        DatastoreConnection dataContextProvider = datastore.openConnection();
        getDatastoreConnections().add(dataContextProvider);
    }
550998
def init_db_conn(connection_name, connection_string, scopefunc=None):
    
    engine = create_engine(connection_string)
    session = scoped_session(sessionmaker(), scopefunc=scopefunc)
    session.configure(bind=engine)
    pool.connections[connection_name] = Connection(engine, session)