Package com.volantis.mcs.repository.jdbc

Examples of com.volantis.mcs.repository.jdbc.JDBCRepositoryFactory


    // Javadoc inherited.
    public DeviceRepository createDeviceRepository(
            JDBCDeviceRepositoryConfiguration configuration)
            throws DeviceRepositoryException {

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();
        JDBCRepositoryConfiguration repositoryConfiguration =
                factory.createJDBCRepositoryConfiguration();
        repositoryConfiguration.setDataSource(
                configuration.getDataSource());
        repositoryConfiguration.setReleaseConnectionsImmediately(false)
        repositoryConfiguration.setShortNames(configuration.isUseShortNames());

        DeviceRepositoryLocation location = new DeviceRepositoryLocationImpl(
                configuration.getDefaultProject());

        try {
            // Create the JBDC repository.
            InternalJDBCRepository repository = (InternalJDBCRepository)                
                    factory.createJDBCRepository(repositoryConfiguration);

            // Create the JDBC accessor.
            DeviceRepositoryAccessor accessor =
                    new JDBCDeviceRepositoryAccessor(repository, location);
View Full Code Here


     * @exception RepositoryException if an error occurs
     */
    private LocalRepository createJDBCRepository()
        throws RepositoryException {

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();
        MCSDriverConfiguration driverConfiguration =
                factory.createMCSDriverConfiguration();
        driverConfiguration.setHost(args.getValue(HOST));
        String port = args.getValue(PORT);
        if (port != null) {
            driverConfiguration.setPort(Integer.parseInt(port));
        }
        JDBCRepositoryType repositoryType =
                JDBCRepositoryType.getTypeForVendor(args.getValue(VENDOR));
        driverConfiguration.setDriverVendor(repositoryType.getVendor());
        driverConfiguration.setSource(args.getValue(SOURCE));

        DataSource dataSource =
                factory.createMCSDriverDataSource(driverConfiguration);

        JDBCRepositoryConfiguration configuration =
                factory.createJDBCRepositoryConfiguration();
        configuration.setUsername(args.getValue(USER));
        configuration.setPassword(args.getValue(PASSWORD));
        configuration.setShortNames(useShortNames);
        configuration.setDataSource(dataSource);

        return factory.createJDBCRepository(configuration);
//        // A repository is specified via the following args
//        // -vendor -host -port -source -user
//        Map properties = new HashMap();
//        properties.put (JDBCRepository.HOST_PROPERTY, args.getValue(HOST));
//        properties.put (JDBCRepository.PORT_PROPERTY, args.getValue(PORT));
View Full Code Here

            usage("lock/unlock/list");
        }

        PropertyConfigurator.configure("log4j.properties");

        JDBCRepositoryFactory jdbcFactory =
                JDBCRepositoryFactory.getDefaultInstance();

        MCSDriverConfiguration driverConfiguration =
                jdbcFactory.createMCSDriverConfiguration();
        driverConfiguration.setDriverVendor(JDBCDriverVendor.ORACLE8);
        driverConfiguration.setHost("haddock");
        driverConfiguration.setPort(1526);
        driverConfiguration.setSource("DEV1");
        DataSource dataSource =
                jdbcFactory.createMCSDriverDataSource(driverConfiguration);

        JDBCRepositoryConfiguration jdbcConfiguration =
                jdbcFactory.createJDBCRepositoryConfiguration();
        jdbcConfiguration.setDataSource(dataSource);
        jdbcConfiguration.setUsername("geoff");
        jdbcConfiguration.setPassword("geoff");

        InternalJDBCRepository repository = (InternalJDBCRepository)
                jdbcFactory.createJDBCRepository(jdbcConfiguration);

        LockManager manager = repository.getLockManager("project");

        String command = args[0];
        if (command.equals("lock")) {
View Full Code Here

            String defaultProject, String defaultDeviceProject)
            throws Exception {

        InternalJDBCRepository repository = null;

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();
        MCSDriverConfiguration driverConfiguration =
                factory.createMCSDriverConfiguration();
        driverConfiguration.setDriverVendor(JDBCDriverVendor.HYPERSONIC);
        driverConfiguration.setSource(source);
        DataSource dataSource =
                factory.createMCSDriverDataSource(driverConfiguration);

        JDBCRepositoryConfiguration configuration =
                factory.createJDBCRepositoryConfiguration();
        configuration.setDataSource(dataSource);
        configuration.setUsername(HypersonicManager.DEFAULT_USERNAME);
        configuration.setPassword(HypersonicManager.DEFAULT_PASSWORD);

//        HashMap properties = new HashMap();
//        properties.put(JDBCRepository.VENDOR_PROPERTY,
//                       JDBCRepository.VENDOR_HYPERSONIC);
//        properties.put(JDBCRepository.SOURCE_PROPERTY,
//                       source);
//        properties.put(JDBCRepository.USERNAME_PROPERTY,
//                       HypersonicManager.DEFAULT_USERNAME);
//        properties.put(JDBCRepository.PASSWORD_PROPERTY,
//                       HypersonicManager.DEFAULT_PASSWORD);
//        properties.put(JDBCRepository.DEFAULT_PROJECT_NAME_PROPERTY,
//                defaultProject);
//        properties.put(JDBCRepository.STANDARD_DEVICE_PROJECT_NAME_PROPERTY,
//                defaultDeviceProject);
//        repository = (InternalJDBCRepository)
//                JDBCRepository.createRepository(properties).getLocalRepository();

        repository = (InternalJDBCRepository)
                factory.createJDBCRepository(configuration);

        return repository;
    }
View Full Code Here

        connectionMock.expects.getCatalog().returns("catalog").fixed(2);
        connectionMock.expects.isReadOnly().returns(false).fixed(2);
        connectionMock.expects.getTransactionIsolation().returns(1).fixed(2);
        connectionMock.expects.getTypeMap().returns(Collections.EMPTY_MAP).fixed(2);

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();

        try {
            factory.createMCSConnectionPool(configuration, dataSourceMock);
        } catch (RepositoryException e) {
            fail("method has thrown an exception with anonymous datasource");
        }
    }
View Full Code Here

        return new DB2Repository(configuration);
    }

    public void testConstructURL() throws Exception {

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();

        MCSDriverConfiguration configuration =
                factory.createMCSDriverConfiguration();
        configuration.setHost("host");
        configuration.setPort(8086);
        configuration.setSource("source");

        VendorFactory vendorFactory = new DB2VendorFactory();
View Full Code Here

                location = REPOSITORY_LOCATION_FACTORY.createDeviceRepositoryLocation(
                        Environment.getParameter(config, "file"));
            } else {
                // Default to JDBC.

                JDBCRepositoryFactory factory =
                        JDBCRepositoryFactory.getDefaultInstance();

                MCSDriverConfiguration driverConfiguration =
                        factory.createMCSDriverConfiguration();

                driverConfiguration.setSource(
                        Environment.getParameter(config, "odbc-source"));
                String vendor = Environment.getParameter(config, "odbc-vendor");
                JDBCRepositoryType jdbcRepositoryType =
                        JDBCRepositoryType.getTypeForVendor(vendor);
                if (jdbcRepositoryType != null) {
                    driverConfiguration.setDriverVendor(
                            jdbcRepositoryType.getVendor());
                }

                driverConfiguration.setHost(Environment.getParameter(config,
                        "odbc-host"));
                String port = Environment.getParameter(config, "odbc-port");
                if (port != null) {
                    driverConfiguration.setPort(Integer.parseInt(port));
                }

                DataSource dataSource = factory.createMCSDriverDataSource(
                        driverConfiguration);

                JDBCRepositoryConfiguration configuration =
                        factory.createJDBCRepositoryConfiguration();
                configuration.setDataSource(dataSource);
                configuration.setUsername(Environment.getParameter(config,
                        "odbc-user"));
                configuration.setPassword(Environment.getParameter(config,
                        "odbc-password"));

                repository = factory.createJDBCRepository(configuration);

                location = REPOSITORY_LOCATION_FACTORY.createDeviceRepositoryLocation(
                        Environment.getParameter(config, "project"));
            }
View Full Code Here

            // Retrieve the JDBC DataSource configured in the runtime
            DataSource ds =
                    volantisBean.getLocalRepositoryJDBCDataSource();
            if (ds != null) {

                JDBCRepositoryFactory factory =
                        JDBCRepositoryFactory.getDefaultInstance();
                JDBCRepositoryConfiguration configuration =
                        factory.createJDBCRepositoryConfiguration();
                configuration.setDataSource(ds);
                configuration.setReleaseConnectionsImmediately(false);
                configuration.setShortNames(
                        volantisBean.getJDBCRepositoryUsesShortNames());

                repository = factory.createJDBCRepository(configuration);
            }
        }
        return repository;
    }
View Full Code Here

     * @param config            the NamedDataSource object.
     */
    public DataSource createDataSource(AnonymousDataSourceConfiguration config,
            JNDIConfiguration jndiConfiguration) {

        JDBCRepositoryFactory factory =
                JDBCRepositoryFactory.getDefaultInstance();

        if (logger.isDebugEnabled()) {
            logger.debug("Creating Anonymous DataSource");
        }
       
        DataSource dataSource = null;
        if (config != null) {
            DataSource delegateDataSource = null;
            AnonymousDataSource anonymousDataSource =
                config.getDataSourceConfiguration();
            if (anonymousDataSource instanceof JDBCDriverConfiguration) {
                delegateDataSource =
                    jdbcDataSourceFactory.createDataSource(
                        (JDBCDriverConfiguration)anonymousDataSource);
            } else if (
                anonymousDataSource instanceof MCSDatabaseConfiguration) {
                delegateDataSource =
                    mcsDataSourceFactory.createDataSource(
                        (MCSDatabaseConfiguration)anonymousDataSource);
            } else if (
                anonymousDataSource instanceof JNDIDataSourceConfiguration) {
                delegateDataSource =
                    jndiDataSourceFactory.createDataSource(
                        (JNDIDataSourceConfiguration)anonymousDataSource,
                        jndiConfiguration);
            }
            if (delegateDataSource != null) {
                dataSource = factory.createAnonymousDataSource(
                    delegateDataSource,config.getUser(),config.getPassword());
            }

        } else {
            if (logger.isDebugEnabled()) {
View Full Code Here

            if (dataSource != null ||
                    (deviceConnectionType ==
                     RepositoryConnectionType.JDBC_REPOSITORY_CONNECTION)) {

                JDBCRepositoryFactory factory =
                        JDBCRepositoryFactory.getDefaultInstance();

                // todo: later: refactor this config object using factory pattern
                com.volantis.mcs.repository.jdbc.JDBCRepositoryConfiguration configuration =
                        factory.createJDBCRepositoryConfiguration();
                configuration.setDataSource(dataSource);
                configuration.setReleaseConnectionsImmediately(true);
                configuration.setShortNames(getJDBCRepositoryUsesShortNames());
                configuration.setAnonymous(true);

                jdbcRepository = (LocalRepository)
                        factory.createJDBCRepository(configuration);
            } else {
                // Until datasource configuration is implemented, log a warning
                // about not being able to create a JDBC repository.
                logger.warn("local-repository-type-unknown");
            }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.repository.jdbc.JDBCRepositoryFactory

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.