Package org.apache.geronimo.datasource

Examples of org.apache.geronimo.datasource.DataSourceDescription


        EARContext earContext = module.getEarContext();

        AbstractName dataSourceAbstractName = earContext.getNaming().createChildName(module.getModuleName(), name, "GBean");

        DataSourceDescription dsDescription = createDataSourceDescription(ds);
        String osgiJndiName = null;
        if (dsDescription.getProperties() != null) {
            osgiJndiName = dsDescription.getProperties().get(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME);
        }
        if (osgiJndiName == null) {
            osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(dataSourceAbstractName);
        }
        dsDescription.setOsgiServiceName(osgiJndiName);

        try {
            Object ref = DataSourceService.buildReference(dsDescription);
            put(jndiName, ref, ReferenceType.DATA_SOURCE, module.getJndiContext(), Collections.<InjectionTarget>emptySet(), sharedContext);
        } catch (IOException e) {
View Full Code Here


        }
        return null;
    }

    private DataSourceDescription createDataSourceDescription(DataSource ds) {
        DataSourceDescription dsDescription = new DataSourceDescription();

        dsDescription.setName(ds.getName());
        dsDescription.setClassName(ds.getClassName());

        if (ds.getDescription() != null) {
            dsDescription.setDescription(ds.getDescription().trim());
        }

        if (ds.getUrl() != null) {
            dsDescription.setUrl(ds.getUrl().trim());
        }

        if (ds.getUser() != null) {
            dsDescription.setUser(ds.getUser().trim());
        }

        if (ds.getPassword() != null) {
            dsDescription.setPassword(ds.getPassword().trim());
        }

        if (ds.getDatabaseName() != null) {
            dsDescription.setDatabaseName(ds.getDatabaseName().trim());
        }

        if (ds.getServerName() != null) {
            dsDescription.setServerName(ds.getServerName().trim());
        }

        if (ds.getPortNumber() != null) {
            dsDescription.setPortNumber(ds.getPortNumber());
        }

        if (ds.getLoginTimeout() != null) {
            dsDescription.setLoginTimeout(ds.getLoginTimeout());
        }

        List<Property> props = ds.getProperty();
        if (props != null) {
            Map<String, String> properties = new HashMap<String, String>();
            for (Property prop : props) {
                properties.put(prop.getName().trim(),
                               prop.getValue().trim());
            }
            dsDescription.setProperties(properties);
        }

        // transaction properties

        if (ds.getTransactional()) {
            dsDescription.setTransactional(ds.getTransactional());
        }

        if (ds.getIsolationLevel() != null) {
            switch (ds.getIsolationLevel()) {
            case TRANSACTION_READ_COMMITTED:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
                break;
            case TRANSACTION_READ_UNCOMMITTED:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED);
                break;
            case TRANSACTION_REPEATABLE_READ:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ);
                break;
            case TRANSACTION_SERIALIZABLE:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
                break;
            }
        }

        // pool properties

        if (ds.getInitialPoolSize() != null) {
            dsDescription.setInitialPoolSize(ds.getInitialPoolSize());
        }

            dsDescription.setMaxPoolSize(ds.getMaxPoolSize() != null? ds.getMaxPoolSize(): defaultMaxSize);

            dsDescription.setMinPoolSize(ds.getMinPoolSize() != null? ds.getMinPoolSize(): defaultMinSize);

        if (ds.getMaxStatements() != null) {
            dsDescription.setMaxStatements(ds.getMaxStatements());
        }

            dsDescription.setMaxIdleTime(ds.getMaxIdleTime() != null? ds.getMaxIdleTime(): defaultIdleTimeoutMinutes);

        //geronimo specific properties
        dsDescription.setBlockingTimeoutMilliseconds(defaultBlockingTimeoutMilliseconds);
        dsDescription.setXaThreadCaching(defaultXAThreadCaching);
        dsDescription.setXaTransactionCaching(defaultXATransactionCaching);

        return dsDescription;
    }
View Full Code Here

                      
        AbstractName dataSourceAbstractName = earContext.getNaming().createChildName(module.getModuleName(), name, "GBean");

        GBeanData dataSourceGBean = new GBeanData(dataSourceAbstractName, DataSourceGBean.class);
       
        DataSourceDescription dsDescription = createDataSourceDescription(ds);
        dataSourceGBean.setAttribute("dataSourceDescription", dsDescription);
       
        dataSourceGBean.setAttribute("defaultMaxSize", defaultMaxSize);
        dataSourceGBean.setAttribute("defaultMinSize", defaultMinSize);
        dataSourceGBean.setAttribute("defaultBlockingTimeoutMilliseconds", defaultBlockingTimeoutMilliseconds);
View Full Code Here

        }
        return null;       
    }
   
    private DataSourceDescription createDataSourceDescription(DataSourceType ds) {
        DataSourceDescription dsDescription = new DataSourceDescription();
       
        dsDescription.setName(ds.getName().getStringValue());
        dsDescription.setClassName(ds.getClassName().getStringValue());
       
        if (ds.isSetDescription()) {
            dsDescription.setDescription(ds.getDescription().getStringValue().trim());
        }
       
        if (ds.isSetUrl()) {
            dsDescription.setUrl(ds.getUrl().getStringValue().trim());
        }
       
        if (ds.isSetUser()) {
            dsDescription.setUser(ds.getUser().getStringValue().trim());
        }
       
        if (ds.isSetPassword()) {
            dsDescription.setPassword(ds.getPassword().getStringValue().trim());
        }
       
        if (ds.isSetDatabaseName()) {
            dsDescription.setDatabaseName(ds.getDatabaseName().getStringValue().trim());
        }
       
        if (ds.isSetServerName()) {
            dsDescription.setServerName(ds.getServerName().getStringValue().trim());
        }
       
        if (ds.isSetPortNumber()) {
            dsDescription.setPortNumber(ds.getPortNumber().getBigIntegerValue().intValue());
        }
               
        if (ds.isSetLoginTimeout()) {
            dsDescription.setLoginTimeout(ds.getLoginTimeout().getBigIntegerValue().intValue());     
        }
       
        PropertyType[] props = ds.getPropertyArray();
        if (props != null) {
            Map<String, String> properties = new HashMap<String, String>();
            for (PropertyType prop : props) {
                properties.put(prop.getName().getStringValue().trim(),
                               prop.getValue().getStringValue().trim());
            }
            dsDescription.setProperties(properties);
        }
       
        // transaction properties
       
        if (ds.isSetTransactional()) {
            dsDescription.setTransactional(ds.getTransactional().getBooleanValue());
        }
       
        if (ds.isSetIsolationLevel()) {
            switch (ds.getIsolationLevel().intValue()) {
            case IsolationLevelType.INT_TRANSACTION_READ_COMMITTED:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
                break;
            case IsolationLevelType.INT_TRANSACTION_READ_UNCOMMITTED:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED);
                break;
            case IsolationLevelType.INT_TRANSACTION_REPEATABLE_READ:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ);
                break;
            case IsolationLevelType.INT_TRANSACTION_SERIALIZABLE:
                dsDescription.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
                break;
            }
        }
       
        // pool properties
       
        if (ds.isSetInitialPoolSize()) {
            dsDescription.setInitialPoolSize(ds.getInitialPoolSize().getBigIntegerValue().intValue());
        }
       
        if (ds.isSetMaxPoolSize()) {
            dsDescription.setMaxPoolSize(ds.getMaxPoolSize().getBigIntegerValue().intValue());
        }
       
        if (ds.isSetMinPoolSize()) {
            dsDescription.setMinPoolSize(ds.getMinPoolSize().getBigIntegerValue().intValue());
        }
       
        if (ds.isSetMaxStatements()) {
            dsDescription.setMaxStatements(ds.getMaxStatements().getBigIntegerValue().intValue());
        }
       
        if (ds.isSetMaxIdleTime()) {
            dsDescription.setMaxIdleTime(ds.getMaxIdleTime().getBigIntegerValue().intValue());
        }
       
        return dsDescription;
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.datasource.DataSourceDescription

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.