Package org.apache.synapse.commons.datasource

Examples of org.apache.synapse.commons.datasource.DataSourceInformation


        }
    }

    private void readCustomDataSourceConfig(OMElement pool, AbstractDBMediator mediator) {

        DataSourceInformation dataSourceInformation = new DataSourceInformation();

        dataSourceInformation.setDriver(getValue(pool, DRIVER_Q));
        dataSourceInformation.setUrl(getValue(pool, URL_Q));

        SecretInformation secretInformation = new SecretInformation();
        secretInformation.setUser(getValue(pool, USER_Q));
        secretInformation.setAliasSecret(getValue(pool, PASS_Q));
        dataSourceInformation.setSecretInformation(secretInformation);

        // Save element configuration for later de-serialization
        saveElementConfig(pool, DRIVER_Q, mediator);
        saveElementConfig(pool, URL_Q, mediator);
        saveElementConfig(pool, USER_Q, mediator);
View Full Code Here


        for (String dsName : dataSourcesNames) {

            if (dsName == null) {
                continue;
            }
            DataSourceInformation information =
                    DataSourceInformationFactory.
                            createDataSourceInformation(dsName, dsProperties);
            if (information == null) {
                continue;
            }
View Full Code Here

        if (url == null) {
            handleException(prefix + DataSourceConstants.PROP_URL +
                    " cannot be found.");
        }

        DataSourceInformation datasourceInformation = new DataSourceInformation();
        datasourceInformation.setAlias(dsName);

        datasourceInformation.setDriver(driver);
        datasourceInformation.setUrl(url);

        String dataSourceName = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_DS_NAME, dsName,
                String.class);
        datasourceInformation.setDatasourceName(dataSourceName);

        String dsType = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_TYPE,
                DataSourceConstants.PROP_BASIC_DATA_SOURCE, String.class);

        datasourceInformation.setType(dsType);

        String repositoryType = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_REGISTRY,
                DataSourceConstants.PROP_REGISTRY_MEMORY, String.class);

        datasourceInformation.setRepositoryType(repositoryType);

        Integer maxActive = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_ACTIVE,
                GenericObjectPool.DEFAULT_MAX_ACTIVE, Integer.class);
        datasourceInformation.setMaxActive(maxActive);

        Integer maxIdle = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_IDLE,
                GenericObjectPool.DEFAULT_MAX_IDLE, Integer.class);
        datasourceInformation.setMaxIdle(maxIdle);

        Long maxWait = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_WAIT,
                GenericObjectPool.DEFAULT_MAX_WAIT, Long.class);

        datasourceInformation.setMaxWait(maxWait);

        // Construct DriverAdapterCPDS reference
        String suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_CLASS_NAME;
        String className = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
        datasourceInformation.addParameter(suffix, className);
        suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_FACTORY;
        String factory = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
        datasourceInformation.addParameter(suffix, factory);
        suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_NAME;
        String name = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                "cpds");
        datasourceInformation.addParameter(suffix, name);

        boolean defaultAutoCommit = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_AUTO_COMMIT, true,
                Boolean.class);

        boolean defaultReadOnly = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_READ_ONLY, false,
                Boolean.class);

        boolean testOnBorrow = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_ON_BORROW, true,
                Boolean.class);

        boolean testOnReturn = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_ON_RETURN, false,
                Boolean.class);

        long timeBetweenEvictionRunsMillis = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, Long.class);

        int numTestsPerEvictionRun = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_NUM_TESTS_PER_EVICTION_RUN,
                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, Integer.class);

        long minEvictableIdleTimeMillis = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MIN_EVICTABLE_IDLE_TIME_MILLIS,
                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, Long.class);

        boolean testWhileIdle = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_WHILE_IDLE, false,
                Boolean.class);

        String validationQuery = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_VALIDATION_QUERY, null);

        int minIdle = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MIN_IDLE,
                GenericObjectPool.DEFAULT_MIN_IDLE,
                Integer.class);

        int initialSize = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_INITIAL_SIZE, 0,
                Integer.class);

        int defaultTransactionIsolation = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_TRANSACTION_ISOLATION, -1,
                Integer.class);

        String defaultCatalog = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_DEFAULT_CATALOG, null);

        boolean accessToUnderlyingConnectionAllowed =
                MiscellaneousUtil.getProperty(properties,
                        prefix +
                                DataSourceConstants.
                                        PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED,
                        false, Boolean.class);

        boolean removeAbandoned = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_REMOVE_ABANDONED, false,
                Boolean.class);

        int removeAbandonedTimeout = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_REMOVE_ABANDONED_TIMEOUT, 300,
                Integer.class);

        boolean logAbandoned = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_LOG_ABANDONED, false,
                Boolean.class);

        boolean poolPreparedStatements = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_POOL_PREPARED_STATEMENTS, false,
                Boolean.class);

        int maxOpenPreparedStatements = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MAX_OPEN_PREPARED_STATEMENTS,
                GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, Integer.class);

        datasourceInformation.setDefaultAutoCommit(defaultAutoCommit);
        datasourceInformation.setDefaultReadOnly(defaultReadOnly);
        datasourceInformation.setTestOnBorrow(testOnBorrow);
        datasourceInformation.setTestOnReturn(testOnReturn);
        datasourceInformation.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
        datasourceInformation.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
        datasourceInformation.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
        datasourceInformation.setTestWhileIdle(testWhileIdle);
        datasourceInformation.setMinIdle(minIdle);
        datasourceInformation.setDefaultTransactionIsolation(defaultTransactionIsolation);
        datasourceInformation.setAccessToUnderlyingConnectionAllowed(
                accessToUnderlyingConnectionAllowed);
        datasourceInformation.setRemoveAbandoned(removeAbandoned);
        datasourceInformation.setRemoveAbandonedTimeout(removeAbandonedTimeout);
        datasourceInformation.setLogAbandoned(logAbandoned);
        datasourceInformation.setPoolPreparedStatements(poolPreparedStatements);
        datasourceInformation.setMaxOpenPreparedStatements(maxOpenPreparedStatements);
        datasourceInformation.setInitialSize(initialSize);

        if (validationQuery != null && !"".equals(validationQuery)) {
            datasourceInformation.setValidationQuery(validationQuery);
        }

        if (defaultCatalog != null && !"".equals(defaultCatalog)) {
            datasourceInformation.setDefaultCatalog(defaultCatalog);
        }

        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_IC_FACTORY,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_IC_FACTORY,
                        null));
        //Provider URL
        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_PROVIDER_URL,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_PROVIDER_URL,
                        null));

        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_PROVIDER_PORT,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_PROVIDER_PORT,
                        null));

        String passwordPrompt = MiscellaneousUtil.getProperty(
                properties, prefix + SecurityConstants.PROP_PASSWORD_PROMPT,
                "Password for datasource " + dsName, String.class);

        SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(
                properties, prefix, passwordPrompt);
        secretInformation.setToken(dsName + "." + SecurityConstants.PROP_PASSWORD);
        datasourceInformation.setSecretInformation(secretInformation);

        return datasourceInformation;
    }
View Full Code Here

        }
    }

    private void readCustomDataSourceConfig(OMElement pool, AbstractDBMediator mediator) {

        DataSourceInformation dataSourceInformation = new DataSourceInformation();

        dataSourceInformation.setDriver(getValue(pool, DRIVER_Q));
        dataSourceInformation.setUrl(getValue(pool, URL_Q));

        SecretInformation secretInformation = new SecretInformation();
        secretInformation.setUser(getValue(pool, USER_Q));
        secretInformation.setAliasSecret(getValue(pool, PASS_Q));
        dataSourceInformation.setSecretInformation(secretInformation);

        // Save element configuration for later de-serialization
        saveElementConfig(pool, DRIVER_Q, mediator);
        saveElementConfig(pool, URL_Q, mediator);
        saveElementConfig(pool, USER_Q, mediator);
View Full Code Here

        }
    }

    private void readCustomDataSourceConfig(OMElement pool, AbstractDBMediator mediator) {

        DataSourceInformation dataSourceInformation = new DataSourceInformation();

        dataSourceInformation.setDriver(getValue(pool, DRIVER_Q));
        dataSourceInformation.setUrl(getValue(pool, URL_Q));

        SecretInformation secretInformation = new SecretInformation();
        secretInformation.setUser(getValue(pool, USER_Q));
        secretInformation.setAliasSecret(getValue(pool, PASS_Q));
        dataSourceInformation.setSecretInformation(secretInformation);

        // Save element configuration for later de-serialization
        saveElementConfig(pool, DRIVER_Q, mediator);
        saveElementConfig(pool, URL_Q, mediator);
        saveElementConfig(pool, USER_Q, mediator);
View Full Code Here

        if (url == null) {
            handleException(prefix + DataSourceConstants.PROP_URL +
                    " cannot be found.");
        }

        DataSourceInformation datasourceInformation = new DataSourceInformation();
        datasourceInformation.setAlias(dsName);

        datasourceInformation.setDriver(driver);
        datasourceInformation.setUrl(url);

        String dataSourceName = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_DS_NAME, dsName,
                String.class);
        datasourceInformation.setDatasourceName(dataSourceName);

        String dsType = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_TYPE,
                DataSourceConstants.PROP_BASIC_DATA_SOURCE, String.class);

        datasourceInformation.setType(dsType);

        String repositoryType = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_REGISTRY,
                DataSourceConstants.PROP_REGISTRY_MEMORY, String.class);

        datasourceInformation.setRepositoryType(repositoryType);

        Integer maxActive = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_ACTIVE,
                GenericObjectPool.DEFAULT_MAX_ACTIVE, Integer.class);
        datasourceInformation.setMaxActive(maxActive);

        Integer maxIdle = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_IDLE,
                GenericObjectPool.DEFAULT_MAX_IDLE, Integer.class);
        datasourceInformation.setMaxIdle(maxIdle);

        Long maxWait = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_MAX_WAIT,
                GenericObjectPool.DEFAULT_MAX_WAIT, Long.class);

        datasourceInformation.setMaxWait(maxWait);

        // Construct DriverAdapterCPDS reference
        String suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_CLASS_NAME;
        String className = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
        datasourceInformation.addParameter(suffix, className);
        suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_FACTORY;
        String factory = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
        datasourceInformation.addParameter(suffix, factory);
        suffix = DataSourceConstants.PROP_CPDS_ADAPTER +
                DataSourceConstants.DOT_STRING +
                DataSourceConstants.PROP_NAME;
        String name = MiscellaneousUtil.getProperty(properties, prefix + suffix,
                "cpds");
        datasourceInformation.addParameter(suffix, name);

        boolean defaultAutoCommit = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_AUTO_COMMIT, true,
                Boolean.class);

        boolean defaultReadOnly = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_READ_ONLY, false,
                Boolean.class);

        boolean testOnBorrow = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_ON_BORROW, true,
                Boolean.class);

        boolean testOnReturn = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_ON_RETURN, false,
                Boolean.class);

        long timeBetweenEvictionRunsMillis = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, Long.class);

        int numTestsPerEvictionRun = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_NUM_TESTS_PER_EVICTION_RUN,
                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, Integer.class);

        long minEvictableIdleTimeMillis = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MIN_EVICTABLE_IDLE_TIME_MILLIS,
                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, Long.class);

        boolean testWhileIdle = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_TEST_WHILE_IDLE, false,
                Boolean.class);

        String validationQuery = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_VALIDATION_QUERY, null);

        int minIdle = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MIN_IDLE,
                GenericObjectPool.DEFAULT_MIN_IDLE,
                Integer.class);

        int initialSize = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_INITIAL_SIZE, 0,
                Integer.class);

        int defaultTransactionIsolation = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_DEFAULT_TRANSACTION_ISOLATION, -1,
                Integer.class);

        String defaultCatalog = MiscellaneousUtil.getProperty(
                properties, prefix + DataSourceConstants.PROP_DEFAULT_CATALOG, null);

        boolean accessToUnderlyingConnectionAllowed =
                MiscellaneousUtil.getProperty(properties,
                        prefix +
                                DataSourceConstants.
                                        PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED,
                        false, Boolean.class);

        boolean removeAbandoned = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_REMOVE_ABANDONED, false,
                Boolean.class);

        int removeAbandonedTimeout = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_REMOVE_ABANDONED_TIMEOUT, 300,
                Integer.class);

        boolean logAbandoned = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_LOG_ABANDONED, false,
                Boolean.class);

        boolean poolPreparedStatements = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_POOL_PREPARED_STATEMENTS, false,
                Boolean.class);

        int maxOpenPreparedStatements = MiscellaneousUtil.getProperty(properties,
                prefix + DataSourceConstants.PROP_MAX_OPEN_PREPARED_STATEMENTS,
                GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, Integer.class);

        datasourceInformation.setDefaultAutoCommit(defaultAutoCommit);
        datasourceInformation.setDefaultReadOnly(defaultReadOnly);
        datasourceInformation.setTestOnBorrow(testOnBorrow);
        datasourceInformation.setTestOnReturn(testOnReturn);
        datasourceInformation.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
        datasourceInformation.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
        datasourceInformation.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
        datasourceInformation.setTestWhileIdle(testWhileIdle);
        datasourceInformation.setMinIdle(minIdle);
        datasourceInformation.setDefaultTransactionIsolation(defaultTransactionIsolation);
        datasourceInformation.setAccessToUnderlyingConnectionAllowed(
                accessToUnderlyingConnectionAllowed);
        datasourceInformation.setRemoveAbandoned(removeAbandoned);
        datasourceInformation.setRemoveAbandonedTimeout(removeAbandonedTimeout);
        datasourceInformation.setLogAbandoned(logAbandoned);
        datasourceInformation.setPoolPreparedStatements(poolPreparedStatements);
        datasourceInformation.setMaxOpenPreparedStatements(maxOpenPreparedStatements);
        datasourceInformation.setInitialSize(initialSize);

        if (validationQuery != null && !"".equals(validationQuery)) {
            datasourceInformation.setValidationQuery(validationQuery);
        }

        if (defaultCatalog != null && !"".equals(defaultCatalog)) {
            datasourceInformation.setDefaultCatalog(defaultCatalog);
        }

        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_IC_FACTORY,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_IC_FACTORY,
                        null));
        //Provider URL
        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_PROVIDER_URL,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_PROVIDER_URL,
                        null));

        datasourceInformation.addProperty(
                prefix + DataSourceConstants.PROP_PROVIDER_PORT,
                MiscellaneousUtil.getProperty(
                        properties, prefix + DataSourceConstants.PROP_PROVIDER_PORT,
                        null));

        String passwordPrompt = MiscellaneousUtil.getProperty(
                properties, prefix + SecurityConstants.PROP_PASSWORD_PROMPT,
                "Password for datasource " + dsName, String.class);

        SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(
                properties, prefix, passwordPrompt);
        secretInformation.setToken(dsName + "." + SecurityConstants.PROP_PASSWORD);
        datasourceInformation.setSecretInformation(secretInformation);

        return datasourceInformation;
    }
View Full Code Here

                    String alias = getResourceName(ds.trim());
                    if (alias == null || "".equals(alias)) {
                        return;
                    }

                    DataSourceInformation information = MiscellaneousHelper.
                            validateAndCreateDataSourceInformation(alias, in);

                    if (repository == null) {
                        repository =
                                DataSourceInformationRepositoryFactory.
View Full Code Here

        }
        if (properties.isEmpty()) {
            handleException("Empty property");
        }

        DataSourceInformation information =
                DataSourceInformationFactory.createDataSourceInformation(name, properties);
        validateDataSourceDescription(information);
        if (log.isDebugEnabled()) {
            log.debug("DataSource Description : " + information);
        }
View Full Code Here

        }
    }

    public void addDataSourceInformation(String name,
                                         OMElement element) throws DataSourceManagementException {
        DataSourceInformation information =
                MiscellaneousHelper.validateAndCreateDataSourceInformation(name, element);

        if (isContains(information.getAlias())) {
            throw new DataSourceManagementException("A data source with name " +
                    information.getAlias() + " is already there.");
        }

        try {
            dataSourceInformationManager.addDataSourceInformation(information);
            dataSourceInformationManager.persistDataSourceInformation(name.trim(), element);
View Full Code Here

    }

    public OMElement getDataSourceInformation(String name) throws DataSourceManagementException {
        MiscellaneousHelper.validateName(name);
        try {
            DataSourceInformation information =
                    dataSourceInformationManager.getDataSourceInformation(name);
            MiscellaneousHelper.validateDataSourceDescription(information);
            Properties properties = DataSourceInformationSerializer.serialize(information);
            if (properties.isEmpty()) {
                handleException("Empty Properties");
View Full Code Here

TOP

Related Classes of org.apache.synapse.commons.datasource.DataSourceInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.