@Override public UpdateableDatastoreConnection openConnection() { return new UpdateableDatastoreConnectionImpl<UpdateableDataContext>(_dataContext, this); }
/** * Alternative constructor usable only for in-memory (ie. non-persistent) * datastores, because the datastore will not be able to create new * connections. * * @param name * @param dc */ public JdbcDatastore(final String name, final UpdateableDataContext dc) { this(name, null, null, null, null, null, false, null, null); setDataContextProvider(new UpdateableDatastoreConnectionImpl<>(dc, this)); }
@Override protected UsageAwareDatastoreConnection<SalesforceDataContext> createDatastoreConnection() { final SalesforceDataContext dataContext; if (Strings.isNullOrEmpty(_endpointUrl)) { dataContext = new SalesforceDataContext(_username, _password, _securityToken); } else { dataContext = new SalesforceDataContext(_endpointUrl, _username, _password, _securityToken); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); }
@Override protected UsageAwareDatastoreConnection<UpdateableDataContext> createDatastoreConnection() { try { final UpdateableDataContext dataContext; if (_tableDefs == null || _tableDefs.length == 0) { dataContext = DataContextFactory .createMongoDbDataContext(_hostname, _port, _databaseName, _username, _password); } else { dataContext = DataContextFactory .createMongoDbDataContext(_hostname, _port, _databaseName, _hostname, _password, _tableDefs); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); } catch (final Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException("Failed to connect to MongoDB instance: " + e.getMessage(), e); } }
@Override protected UsageAwareDatastoreConnection<UpdateableDataContext> createDatastoreConnection() { final UpdateableDataContext dc; final Resource resource = getResource(); final ExcelConfiguration excelConfiguration = getExcelConfiguration(); if (resource == null) { dc = new ExcelDataContext(new File(_filename), excelConfiguration); } else { dc = new ExcelDataContext(resource, excelConfiguration); } return new UpdateableDatastoreConnectionImpl<>(dc, this); }
@Override protected UsageAwareDatastoreConnection<UpdateableDataContext> createDatastoreConnection() { final UpdateableDataContext dataContext; final Resource resource = getResource(); if (resource == null) { logger.warn("Resource was not available, a local file reference will be created with path: {}", _filename); dataContext = new CsvDataContext(new File(_filename), getCsvConfiguration()); } else { dataContext = new CsvDataContext(resource, getCsvConfiguration()); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); }
@Override protected UsageAwareDatastoreConnection<UpdateableDataContext> createDatastoreConnection() { switch (_clientType) { case NODE: case TRANSPORT: throw new UnsupportedOperationException( "Support for ElasticSearch 'node' or 'transport' clients has been dropped. " + "Please reconfigure datastore to use HTTP connection."); default: final DataContext dataContext; if (_tableDefs == null || _tableDefs.length == 0) { dataContext = new ElasticSearchRestDataContext(getClientForRestProtocol(), _indexName); } else { dataContext = new ElasticSearchRestDataContext(getClientForRestProtocol(), _indexName, _tableDefs); } return new UpdateableDatastoreConnectionImpl<>((ElasticSearchRestDataContext) dataContext, this); } }
@Override protected UsageAwareDatastoreConnection<UpdateableDataContext> createDatastoreConnection() { if (StringUtils.isNullOrEmpty(_datasourceJndiUrl)) { if (isMultipleConnections()) { final DataSource dataSource = createDataSource(); return new DataSourceDatastoreConnection(dataSource, getTableTypes(), _catalogName, this); } else { final Connection connection = createConnection(); try { connection.setAutoCommit(false); } catch (final SQLException e) { logger.error("Could not set autocommit false '{}'", _datasourceJndiUrl); throw new IllegalStateException(e); } final UpdateableDataContext dataContext = new JdbcDataContext(connection, getTableTypes(), _catalogName); return new UpdateableDatastoreConnectionImpl<>(dataContext, this); } } else { try { final Context initialContext = getJndiNamingContext(); final DataSource dataSource = (DataSource) initialContext.lookup(_datasourceJndiUrl); return new DataSourceDatastoreConnection(dataSource, getTableTypes(), _catalogName, this); } catch (final Exception e) { logger.error("Could not retrieve DataSource '{}'", _datasourceJndiUrl); throw new IllegalStateException(e); } } }
@Override protected UsageAwareDatastoreConnection<CouchDbDataContext> createDatastoreConnection() { final StdHttpClient.Builder httpClient = new StdHttpClient.Builder(); httpClient.host(getHostname()); if (_port != null) { httpClient.port(_port); } if (_username != null) { httpClient.username(_username); } if (_password != null) { httpClient.password(_password); } httpClient.enableSSL(_sslEnabled); httpClient.connectionTimeout(HTTP_TIMEOUT); httpClient.socketTimeout(HTTP_TIMEOUT); final CouchDbDataContext dataContext; if (_tableDefs != null && _tableDefs.length > 0) { dataContext = new CouchDbDataContext(httpClient, _tableDefs); } else { dataContext = new CouchDbDataContext(httpClient); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); }