http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreMixin.java b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreMixin.java new file mode 100644 index 0000000..104744a --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreMixin.java @@ -0,0 +1,349 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.berkeleydb; + +import com.sleepycat.je.Cursor; +import com.sleepycat.je.Database; +import com.sleepycat.je.DatabaseConfig; +import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.Durability; +import com.sleepycat.je.Environment; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.LockMode; +import com.sleepycat.je.OperationStatus; +import com.sleepycat.je.Transaction; +import com.sleepycat.je.TransactionConfig; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import org.apache.polygene.api.common.Optional; +import org.apache.polygene.api.configuration.Configuration; +import org.apache.polygene.api.entity.EntityDescriptor; +import org.apache.polygene.api.entity.EntityReference; +import org.apache.polygene.api.injection.scope.Service; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.injection.scope.This; +import org.apache.polygene.api.injection.scope.Uses; +import org.apache.polygene.api.service.ServiceDescriptor; +import org.apache.polygene.api.structure.Application; +import org.apache.polygene.library.fileconfig.FileConfiguration; +import org.apache.polygene.library.locking.ReadLock; +import org.apache.polygene.library.locking.WriteLock; +import org.apache.polygene.spi.entitystore.EntityNotFoundException; +import org.apache.polygene.spi.entitystore.EntityStoreException; +import org.apache.polygene.spi.entitystore.helpers.MapEntityStore; + +/** + * BDB JE implementation of MapEntityStore. + */ +public class BerkeleyDBEntityStoreMixin + implements BerkeleyDBEntityStoreActivation, MapEntityStore +{ + @Optional + @Service + private FileConfiguration fileConfiguration; + + @This + private Configuration<BerkeleyDBEntityStoreConfiguration> config; + + @Uses + private ServiceDescriptor descriptor; + + @Structure + private Application application; + + private Database database; + private Environment envHandle; + + @Override + public void setUpBdbJe() + throws Exception + { + initialize(); + } + + @Override + public void tearDownBdbJe() + throws Exception + { + closeDown(); + } + + @ReadLock + @Override + public Reader get( EntityReference entityReference ) + throws EntityStoreException + { + try + { + String indexKey = entityReference.toString(); + DatabaseEntry key = new DatabaseEntry( indexKey.getBytes( "UTF-8" ) ); + DatabaseEntry result = new DatabaseEntry(); + OperationStatus operationStatus = database.get( null, key, result, LockMode.DEFAULT ); + if( operationStatus == OperationStatus.NOTFOUND ) + { + throw new EntityNotFoundException( entityReference ); + } + return new StringReader( new String( result.getData(), "UTF-8" ) ); + } + catch( IOException e ) + { + throw new EntityStoreException( e ); + } + } + + @WriteLock + @Override + public void applyChanges( MapChanges changes ) + throws IOException + { + Transaction transaction = envHandle.beginTransaction( null, TransactionConfig.DEFAULT ); + try + { + changes.visitMap( new MapChanger() + { + @Override + public Writer newEntity( EntityReference ref, EntityDescriptor descriptor ) + throws IOException + { + return new StringWriter( 1000 ) + { + @Override + public void close() + throws IOException + { + super.close(); + String indexKey = ref.toString(); + DatabaseEntry theKey = new DatabaseEntry( indexKey.getBytes( "UTF-8" ) ); + DatabaseEntry theData = new DatabaseEntry( toString().getBytes( "UTF-8" ) ); + database.put( transaction, theKey, theData ); + } + }; + } + + @Override + public Writer updateEntity( MapChange mapChange ) + throws IOException + { + return new StringWriter( 1000 ) + { + @Override + public void close() + throws IOException + { + super.close(); + String indexKey = mapChange.reference().identity().toString(); + DatabaseEntry theKey = new DatabaseEntry( indexKey.getBytes( "UTF-8" ) ); + DatabaseEntry theData = new DatabaseEntry( toString().getBytes( "UTF-8" ) ); + database.put( transaction, theKey, theData ); + } + }; + } + + @Override + public void removeEntity( EntityReference ref, EntityDescriptor descriptor ) + throws EntityNotFoundException + { + try + { + String indexKey = ref.toString(); + DatabaseEntry theKey = new DatabaseEntry( indexKey.getBytes( "UTF-8" ) ); + database.delete( transaction, theKey ); + } + catch( IOException e ) + { + throw new EntityStoreException( e ); + } + } + } ); + transaction.commit(); + } + catch( Exception e ) + { + e.printStackTrace(); + transaction.abort(); + if( ( e instanceof IOException ) ) + { + throw (IOException) e; + } + else if( !( e instanceof EntityStoreException ) ) + { + throw new IOException( e ); + } + else + { + throw (EntityStoreException) e; + } + } + } + + @Override + public Stream<Reader> entityStates() + throws IOException + { + return StreamSupport.stream( new RecordIterable( database ).spliterator(), false ); + } + + private File getDataDirectory() + { + File dataDir; + String pathname = config.get().dataDirectory().get(); + if( pathname != null ) + { + dataDir = new File( pathname ); + } + else + { + if( fileConfiguration != null ) + { + dataDir = new File( fileConfiguration.dataDirectory(), application.name() + "/" + descriptor.identity() ); + } + else + { + dataDir = new File( System.getProperty( "user.dir" ) ); + } + dataDir = new File( dataDir, "data" ); + } + //noinspection ResultOfMethodCallIgnored + dataDir.mkdirs(); + return dataDir; + } + + private void closeDown() + { + if( database != null ) + { + database.close(); + } + if( envHandle != null ) + { + envHandle.close(); + } + } + + private void initialize() + throws IOException + { + File dataDirectory = getDataDirectory(); + EnvironmentConfig configuration = createConfiguration(); + + envHandle = new Environment( dataDirectory, configuration ); + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate( configuration.getAllowCreate() ); + dbConfig.setTransactional( configuration.getTransactional() ); + database = envHandle.openDatabase( null, config.get().databaseName().get(), dbConfig ); + } + + private EnvironmentConfig createConfiguration() + { + EnvironmentConfig environmentConfig = new EnvironmentConfig(); + BerkeleyDBEntityStoreConfiguration storeConfiguration = config.get(); + Boolean allowCreate = storeConfiguration.allowCreate().get(); + environmentConfig.setAllowCreate( allowCreate ); + environmentConfig.setLocking( storeConfiguration.locking().get() ); + environmentConfig.setLockTimeout( storeConfiguration.lockTimeout().get(), TimeUnit.MILLISECONDS ); + environmentConfig.setNodeName( storeConfiguration.nodeName().get() ); + environmentConfig.setReadOnly( storeConfiguration.readOnly().get() ); + environmentConfig.setSharedCache( storeConfiguration.sharedCache().get() ); + environmentConfig.setTransactional( storeConfiguration.transactional().get() ); + environmentConfig.setTxnTimeout( storeConfiguration.txnTimeout().get(), TimeUnit.MILLISECONDS ); + environmentConfig.setTxnSerializableIsolation( storeConfiguration.txnSerializableIsolation().get() ); + environmentConfig.setCacheMode( storeConfiguration.cacheMode().get() ); + environmentConfig.setCachePercent( storeConfiguration.cachePercent().get() ); + environmentConfig.setCacheSize( storeConfiguration.cacheSize().get() ); + environmentConfig.setOffHeapCacheSize( storeConfiguration.cacheHeapCacheSize().get() ); + environmentConfig.setDurability( Durability.parse( storeConfiguration.durability().get() ) ); + return environmentConfig; + } + + private static class RecordIterable + implements Iterable<Reader>, Iterator<Reader> + { + private Cursor cursor; + private DatabaseEntry foundKey; + private DatabaseEntry foundData; + private boolean success; + + private RecordIterable( Database db ) + throws IOException + { + try + { + cursor = db.openCursor( null, null ); + foundKey = new DatabaseEntry(); + foundData = new DatabaseEntry(); + } + catch( DatabaseException e ) + { + throw new IOException( "Unknown problem in Berkeley DB", e ); + } + } + + @Override + @SuppressWarnings( "NullableProblems" ) + public Iterator<Reader> iterator() + { + forward(); + return this; + } + + @Override + public boolean hasNext() + { + return success; + } + + @Override + public Reader next() + { + byte[] data = foundData.getData(); + forward(); + try + { + return new StringReader( new String( data, "UTF-8" ) ); + } + catch( UnsupportedEncodingException e ) + { + // can not happen. + return new StringReader( "" ); + } + } + + private void forward() + { + OperationStatus status = cursor.getNext( foundKey, foundData, LockMode.DEFAULT ); + if( status == OperationStatus.NOTFOUND ) + { + // End of Cursor, and need to close. + cursor.close(); + } + success = status == OperationStatus.SUCCESS; + } + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreService.java b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreService.java new file mode 100644 index 0000000..e809c8e --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/BerkeleyDBEntityStoreService.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.berkeleydb; + +import org.apache.polygene.api.concern.Concerns; +import org.apache.polygene.api.configuration.Configuration; +import org.apache.polygene.api.mixin.Mixins; +import org.apache.polygene.library.locking.LockingAbstractComposite; +import org.apache.polygene.library.locking.ReadLockConcern; +import org.apache.polygene.library.locking.WriteLockConcern; +import org.apache.polygene.spi.entitystore.ConcurrentModificationCheckConcern; +import org.apache.polygene.spi.entitystore.EntityStateVersions; +import org.apache.polygene.spi.entitystore.EntityStore; +import org.apache.polygene.spi.entitystore.StateChangeNotificationConcern; +import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreActivation; +import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin; +import org.apache.polygene.spi.entitystore.helpers.StateStore; + +/** + * EntityStore service backed by BDB JE store. + * <p>Based on @{@link JSONMapEntityStoreMixin}.</p> + */ +@Concerns( { StateChangeNotificationConcern.class, ConcurrentModificationCheckConcern.class, ReadLockConcern.class, WriteLockConcern.class } ) +@Mixins( { JSONMapEntityStoreMixin.class, BerkeleyDBEntityStoreMixin.class } ) +public interface BerkeleyDBEntityStoreService + extends BerkeleyDBEntityStoreActivation, + JSONMapEntityStoreActivation, + EntityStore, + EntityStateVersions, + StateStore, + LockingAbstractComposite, + Configuration<BerkeleyDBEntityStoreConfiguration> +{ +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/BerkeleyDBEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/BerkeleyDBEntityStoreAssembler.java b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/BerkeleyDBEntityStoreAssembler.java new file mode 100644 index 0000000..97deffe --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/BerkeleyDBEntityStoreAssembler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.berkeleydb.assembly; + +import org.apache.polygene.bootstrap.Assemblers; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.bootstrap.ServiceDeclaration; +import org.apache.polygene.entitystore.berkeleydb.BerkeleyDBEntityStoreConfiguration; +import org.apache.polygene.entitystore.berkeleydb.BerkeleyDBEntityStoreService; + +public class BerkeleyDBEntityStoreAssembler + extends Assemblers.VisibilityIdentityConfig<BerkeleyDBEntityStoreAssembler> +{ + @Override + public void assemble( ModuleAssembly module ) + { + super.assemble( module ); + ServiceDeclaration service = module.services( BerkeleyDBEntityStoreService.class ).visibleIn( visibility() ); + if( hasIdentity() ) + { + service.identifiedBy( identity() ); + } + if( hasConfig() ) + { + configModule().entities( BerkeleyDBEntityStoreConfiguration.class ).visibleIn( configVisibility() ); + } + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/package.html ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/package.html b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/package.html new file mode 100644 index 0000000..298493f --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/assembly/package.html @@ -0,0 +1,24 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + ~ + --> +<html> + <body> + <h2>Berkeley DB (Java Edition) EntityStore Assembly.</h2> + </body> +</html> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/package.html ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/package.html b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/package.html new file mode 100644 index 0000000..17b4142 --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/main/java/org/apache/polygene/entitystore/berkeleydb/package.html @@ -0,0 +1,24 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + ~ + --> +<html> + <body> + <h2>Berkley DB (Java Edition) EntityStore.</h2> + </body> +</html> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTest.java b/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTest.java new file mode 100644 index 0000000..b85eb19 --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.berkeleydb; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.entitystore.berkeleydb.assembly.BerkeleyDBEntityStoreAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationOverride; +import org.apache.polygene.test.EntityTestAssembler; +import org.apache.polygene.test.entity.AbstractEntityStoreTest; +import org.junit.After; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +public class BdbJeEntityStoreTest + extends AbstractEntityStoreTest +{ + @Rule + public final TemporaryFolder tmpDir = new TemporaryFolder(); + + @Override + public void assemble( ModuleAssembly module ) + throws AssemblyException + { + super.assemble( module ); + + ModuleAssembly config = module.layer().module( "config" ); + new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config ); + + new FileConfigurationAssembler() + .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) ) + .assemble( module ); + new BerkeleyDBEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module ); + } + + @After + public void cleanup() + { + + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTestSuite.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTestSuite.java b/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTestSuite.java new file mode 100644 index 0000000..2bf1521 --- /dev/null +++ b/extensions/entitystore-berkeleydb/src/test/java/org/apache/polygene/entitystore/berkeleydb/BdbJeEntityStoreTestSuite.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.berkeleydb; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.entitystore.berkeleydb.assembly.BerkeleyDBEntityStoreAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationOverride; +import org.apache.polygene.test.entity.model.EntityStoreTestSuite; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +public class BdbJeEntityStoreTestSuite extends EntityStoreTestSuite +{ + @Rule + public final TemporaryFolder tmpDir = new TemporaryFolder(); + + @Override + protected void defineStorageModule( ModuleAssembly module ) + { + module.defaultServices(); + new FileConfigurationAssembler() + .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) ) + .assemble( module ); + new BerkeleyDBEntityStoreAssembler().visibleIn( Visibility.application ) + .withConfig( configModule, Visibility.application ) + .assemble( module ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/settings.gradle ---------------------------------------------------------------------- diff --git a/settings.gradle b/settings.gradle index 3fa0179..d9704ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -55,7 +55,7 @@ include 'core:api', 'libraries:uowfile', 'extensions:cache-ehcache', 'extensions:cache-memcache', - 'extensions:entitystore-bdbje', + 'extensions:entitystore-berkeleydb', 'extensions:entitystore-cassandra', 'extensions:entitystore-file', 'extensions:entitystore-geode', http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/tools/generator-polygene/app/index.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js index 565f455..32b4ef5 100644 --- a/tools/generator-polygene/app/index.js +++ b/tools/generator-polygene/app/index.js @@ -103,6 +103,7 @@ module.exports = generators.Base.extend( type: 'list', name: 'entitystore', choices: [ + 'BerkeleyDB', 'Cassandra', 'File', 'DerbySQL', @@ -112,7 +113,6 @@ module.exports = generators.Base.extend( 'JClouds', 'Jdbm', 'LevelDB', - 'MariaDbSQL', 'Memory', 'MongoDB', 'MySQL', http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl index 7a0174e..453a598 100644 --- a/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl +++ b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap-test.tmpl @@ -126,6 +126,12 @@ if( polygene.entitystore === 'Cassandra' ) { .waitForTimeout( 120 ) .waitFor( WaitFor.logMessageSequence( "Starting listening for CQL clients" ) ) ); <% } +if( polygene.entitystore === 'BerkeleyDB' ) { +%> + private void entityStoreSetup(ApplicationAssembly assembly ) + { + } +<% } if( polygene.entitystore === 'DerbySQL' ) { %> private void entityStoreSetup(ApplicationAssembly assembly ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/tools/generator-polygene/app/templates/buildtool/gradle-root.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-root.tmpl b/tools/generator-polygene/app/templates/buildtool/gradle-root.tmpl index 6d2a6bf..e128f16 100644 --- a/tools/generator-polygene/app/templates/buildtool/gradle-root.tmpl +++ b/tools/generator-polygene/app/templates/buildtool/gradle-root.tmpl @@ -70,6 +70,8 @@ allprojects() { maven { name 'restlet-repo'; url 'http://maven.restlet.org/' } <% if( polygene.entitystore == 'Jdbm' ) { -%> maven { name 'clojure-repo'; url 'http://clojars.org/repo/' }<% } -%> +<% if( polygene.entitystore == 'BerkeleyDB' ) { +-%> maven { name 'oracle-repo'; url 'http://download.oracle.com/maven/' }<% } -%> } dependencies { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/78dbe60c/tools/generator-polygene/test/generator_test.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/test/generator_test.js b/tools/generator-polygene/test/generator_test.js index 1afd9a1..5c045dd 100644 --- a/tools/generator-polygene/test/generator_test.js +++ b/tools/generator-polygene/test/generator_test.js @@ -32,6 +32,7 @@ var appTypes = [ ]; var entityStores = [ + 'BerkeleyDB', 'Cassandra', 'File', 'DerbySQL',