@Override public TableManipulationConfiguration get() { return new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class).table() .idColumnName(this.columns.get(ID).getKey()) .idColumnType(this.columns.get(ID).getValue()) .dataColumnName(this.columns.get(DATA).getKey()) .dataColumnType(this.columns.get(DATA).getValue()) .timestampColumnName(this.columns.get(TIMESTAMP).getKey()) .timestampColumnType(this.columns.get(TIMESTAMP).getValue()) .fetchSize(this.fetchSize) .tableNamePrefix(this.prefix) .create(); } }
@Override public void accept(JdbcStringBasedStoreConfigurationBuilder builder) { builder.table().read(this.table.get()); for (TwoWayKey2StringMapper mapper : ServiceLoader.load(TwoWayKey2StringMapper.class, this.module.get().getClassLoader())) { builder.key2StringMapper(mapper.getClass()); break; } builder.dialect(this.dialect).connectionFactory(DataSourceConnectionFactoryConfigurationBuilder.class).setDataSourceDependency(this.dataSource); } }
.fetchPersistentState(true) .table() .tableNamePrefix("STRINGS_") .idColumnName("id").idColumnType("VARCHAR") .dataColumnName("datum").dataColumnType("BINARY") .timestampColumnName("version").timestampColumnType("BIGINT") .async().enable(); Configuration configuration = b.build(); JdbcStringBasedStoreConfiguration store = (JdbcStringBasedStoreConfiguration) configuration.persistence().stores().get(0);
public void testNotCreateConnectionFactory() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory .getDefaultCacheConfiguration(false); JdbcStringBasedStoreConfigurationBuilder storeBuilder = builder .persistence() .addStore(JdbcStringBasedStoreConfigurationBuilder.class) .manageConnectionFactory(false) .dialect(DatabaseType.H2) .dbMajorVersion(1) .dbMinorVersion(4); storeBuilder.table().createOnStart(false); JdbcStringBasedStore stringBasedCacheStore = new JdbcStringBasedStore(); stringBasedCacheStore.init(createContext(builder.build())); stringBasedCacheStore.start(); assertNull(stringBasedCacheStore.getConnectionFactory()); // this will make sure that if a method like stop is called on the connection then it will barf an exception ConnectionFactory connectionFactory = mock(ConnectionFactory.class); TableManager tableManager = mock(TableManager.class); tableManager.start(); tableManager.setCacheName("otherName"); stringBasedCacheStore.initializeConnectionFactory(connectionFactory); //stop should be called even if this is an external reset(tableManager, connectionFactory); tableManager.stop(); stringBasedCacheStore.stop(); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); cb.persistence() .addStore(JdbcStringBasedStoreConfigurationBuilder.class) .preload(true) .key2StringMapper(LuceneKey2StringMapper.class) .table() .idColumnName("ID_COLUMN") .idColumnType("VARCHAR(255)") .tableNamePrefix("ISPN_JDBC") .dataColumnName("DATA_COLUMN") .dataColumnType("BLOB") .timestampColumnName("TIMESTAMP_COLUMN") .timestampColumnType("BIGINT") .connectionPool() .driverClass(org.h2.Driver.class) .connectionUrl("jdbc:h2:mem:infinispan;DB_CLOSE_DELAY=0") .username("sa"); return TestCacheManagerFactory.createClusteredCacheManager(cb); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); cb.persistence() .addStore(JdbcStringBasedStoreConfigurationBuilder.class) .preload(true) .key2StringMapper(LuceneKey2StringMapper.class) .table() .idColumnName("ID_COLUMN") .idColumnType("VARCHAR(255)") .tableNamePrefix("ISPN_JDBC") .dataColumnName("DATA_COLUMN") .dataColumnType("BLOB") .timestampColumnName("TIMESTAMP_COLUMN") .timestampColumnType("BIGINT") .simpleConnection() .driverClass(org.h2.Driver.class) .connectionUrl(DB_URL) .username("sa"); return TestCacheManagerFactory.createCacheManager(cb); }
@Override public TableManipulationConfiguration get() { return new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class).table() .idColumnName(this.columns.get(ID).getKey()) .idColumnType(this.columns.get(ID).getValue()) .dataColumnName(this.columns.get(DATA).getKey()) .dataColumnType(this.columns.get(DATA).getValue()) .timestampColumnName(this.columns.get(TIMESTAMP).getKey()) .timestampColumnType(this.columns.get(TIMESTAMP).getValue()) .fetchSize(this.fetchSize) .tableNamePrefix(this.prefix) .create(); } }
@Override public Builder<?> read(JdbcStringBasedStoreConfiguration template) { super.read(template); this.table.read(template.table()); return this; }
@Override public JdbcStringBasedStoreConfiguration create() { return new JdbcStringBasedStoreConfiguration(attributes.protect(), async.create(), singletonStore.create(), connectionFactory != null ? connectionFactory.create() : null, table.create()); }
@Override public void accept(JdbcStringBasedStoreConfigurationBuilder builder) { builder.table().read(this.table.get()); for (TwoWayKey2StringMapper mapper : ServiceLoader.load(TwoWayKey2StringMapper.class, this.module.get().getClassLoader())) { builder.key2StringMapper(mapper.getClass()); break; } builder.dialect(this.dialect).connectionFactory(DataSourceConnectionFactoryConfigurationBuilder.class).setDataSourceDependency(this.dataSource); } }
static TableManipulationConfiguration createTableConfig(StoreProperties props, Element tableType, JdbcStringBasedStoreConfigurationBuilder storeBuilder) { return storeBuilder.table() .createOnStart(props.isTargetStore()) .tableNamePrefix(props.get(TABLE, tableType, TABLE_NAME_PREFIX)) .idColumnName(props.get(TABLE, tableType, ID, NAME)) .idColumnType(props.get(TABLE, tableType, ID, TYPE)) .dataColumnName(props.get(TABLE, tableType, DATA, NAME)) .dataColumnType(props.get(TABLE, tableType, DATA, TYPE)) .timestampColumnName(props.get(TABLE, tableType, TIMESTAMP, NAME)) .timestampColumnType(props.get(TABLE, tableType, TIMESTAMP, TYPE)) .segmentColumnName(props.get(TABLE, tableType, SEGMENT, NAME)) .segmentColumnType(props.get(TABLE, tableType, SEGMENT, TYPE)) .create(); }