diff --git a/src/main/java/com/avaje/ebean/DocStoreQueueEntry.java b/src/main/java/com/avaje/ebean/DocStoreQueueEntry.java
index 95fb94776..88ff882fd 100644
--- a/src/main/java/com/avaje/ebean/DocStoreQueueEntry.java
+++ b/src/main/java/com/avaje/ebean/DocStoreQueueEntry.java
@@ -39,13 +39,13 @@ public final class DocStoreQueueEntry {
}
}
- final Action type;
+ private final Action type;
- final String queueId;
+ private final String queueId;
- final String path;
+ private final String path;
- final Object beanId;
+ private final Object beanId;
/**
* Construct for an INDEX or DELETE action.
diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java
index 374b4083e..e594400d5 100644
--- a/src/main/java/com/avaje/ebean/config/ServerConfig.java
+++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java
@@ -132,6 +132,11 @@ public class ServerConfig {
*/
private DocStoreConfig docStoreConfig = new DocStoreConfig();
+ /**
+ * Set to true when the EbeanServer only uses Document store.
+ */
+ private boolean docStoreOnly;
+
/**
* This is used to populate @WhoCreated, @WhoModified and
* support other audit features (who executed a query etc).
@@ -1210,6 +1215,20 @@ public class ServerConfig {
this.namingConvention = namingConvention;
}
+ /**
+ * Return true if this EbeanServer is a Document store only instance (has no JDBC DB).
+ */
+ public boolean isDocStoreOnly() {
+ return docStoreOnly;
+ }
+
+ /**
+ * Set to true if this EbeanServer is Document store only instance (has no JDBC DB).
+ */
+ public void setDocStoreOnly(boolean docStoreOnly) {
+ this.docStoreOnly = docStoreOnly;
+ }
+
/**
* Return the configuration for the ElasticSearch integration.
*/
@@ -2405,6 +2424,7 @@ public class ServerConfig {
dbTypeConfig.setGeometrySRID(srid);
}
+ docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly);
disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache);
explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode);
autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode);
diff --git a/src/main/java/com/avaje/ebean/plugin/BeanType.java b/src/main/java/com/avaje/ebean/plugin/BeanType.java
index 71fb1936a..fb2afc74f 100644
--- a/src/main/java/com/avaje/ebean/plugin/BeanType.java
+++ b/src/main/java/com/avaje/ebean/plugin/BeanType.java
@@ -73,6 +73,11 @@ public interface BeanType
* Looks first at the field and then at the getter method.
* repeatable annotation class is specified and the annotation is platform
* specific(see {@link #getPlatformMatchingAnnotation(Set, Class)}), then the platform specific
* annotation is returned. Otherwise the first annotation is retured. Note that you must no longer
- * handle "java 1.6 repeatable containers" like {@link JoinColumn} / {@link JoinColumns} yourself.
+ * handle "java 1.6 repeatable containers" like {@link JoinColumn} / {@link JoinColumns} yourself.
*
*/ @@ -94,8 +94,7 @@ public abstract class AnnotationBase { } return ret; } - - + /** * Return the annotation for the property. *
@@ -170,10 +169,10 @@ public abstract class AnnotationBase {
}
/**
- * Finds the first annotation of a type for this platform. (if annotation is platform specific, otherwise first
+ * Finds the first annotation of a type for this platform. (if annotation is platform specific, otherwise first
* found annotation is returned)
*/
- public static A findAnnotation(AnnotatedElement annotatedElement, Class annotationType,
+ public static A findAnnotation(AnnotatedElement annotatedElement, Class annotationType,
Class extends DatabasePlatform> databasePlatform) {
if (annotationType == null) {
return null;
@@ -205,7 +204,7 @@ public abstract class AnnotationBase {
}
return null;
}
-
+
/**
* Find all {@link Annotation}s of {@code annotationType} on the supplied {@link AnnotatedElement}.
*
@@ -232,7 +231,7 @@ public abstract class AnnotationBase {
Annotation[] anns = annotatedElement.getAnnotations();
for (Annotation ann : anns) {
- if (!isInJavaLangAnnotationPackage(ann) && visited.add(ann)) {
+ if (!isInJavaLangAnnotationPackage(ann) && visited.add(ann)) {
if (ann.annotationType() == annotationType) {
ret.add((A) ann);
} else {
@@ -263,18 +262,18 @@ public abstract class AnnotationBase {
return null;
}
}
-
+
private static final ConcurrentMap
*
+ * There is no underlying JDBC DataSource etc
+ */
+public class DocStoreTransactionManager extends TransactionManager {
+
+ private final String prefix = "";
+
+ /**
+ * Create the TransactionManager
+ */
+ public DocStoreTransactionManager(boolean localL2Caching, ServerConfig config, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor,
+ DocStoreUpdateProcessor docStoreUpdateProcessor, BeanDescriptorManager descMgr) {
+ super(localL2Caching, config, clusterManager, backgroundExecutor, docStoreUpdateProcessor, descMgr);
+ }
+
+ @Override
+ public SpiTransaction createTransaction(boolean explicit, int isolationLevel) {
+ long id = transactionCounter.incrementAndGet();
+ return createTransaction(explicit, null, id);
+ }
+
+ @Override
+ public SpiTransaction createQueryTransaction() {
+ return new DocStoreOnlyTransaction("", false, this);
+ }
+
+ @Override
+ protected SpiTransaction createTransaction(boolean explicit, Connection c, long id) {
+ return new DocStoreOnlyTransaction(prefix + id, explicit, this);
+ }
+}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java
index 9a13bbe8e..a2d217847 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java
@@ -15,6 +15,7 @@ import com.avaje.ebeaninternal.server.core.PersistRequest;
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
import com.avaje.ebeaninternal.server.lib.util.Str;
import com.avaje.ebeaninternal.server.persist.BatchControl;
+import com.avaje.ebeanservice.docstore.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -164,6 +165,8 @@ public class JdbcTransaction implements SpiTransaction {
*/
protected final boolean skipCacheAfterWrite;
+ protected DocStoreTransaction docStoreTxn;
+
/**
* Create a new JdbcTransaction.
*/
@@ -1079,6 +1082,15 @@ public class JdbcTransaction implements SpiTransaction {
getEvent().add(tableName, inserts, updates, deletes);
}
+ @Override
+ public DocStoreTransaction getDocStoreTransaction() {
+ if (docStoreTxn == null) {
+ queryOnly = false;
+ docStoreTxn = manager.createDocStoreTransaction(docStoreBatchSize);
+ }
+ return docStoreTxn;
+ }
+
@Override
public void putUserObject(String name, Object value) {
if (userObjects == null) {
diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java
index 9afe59a23..89dbb3b16 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java
@@ -13,6 +13,7 @@ import com.avaje.ebeaninternal.api.TransactionEventTable;
import com.avaje.ebeaninternal.api.TransactionEventTable.TableIUD;
import com.avaje.ebeaninternal.server.cluster.ClusterManager;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
+import com.avaje.ebeanservice.docstore.api.DocStoreTransaction;
import com.avaje.ebeanservice.docstore.api.DocStoreUpdateProcessor;
import com.avaje.ebeanservice.docstore.api.DocStoreUpdates;
import org.avaje.datasource.DataSourcePool;
@@ -144,6 +145,10 @@ public class TransactionManager {
return docStoreActive;
}
+ public DocStoreTransaction createDocStoreTransaction(int docStoreBatchSize) {
+ return docStoreUpdateProcessor.createTransaction(docStoreBatchSize);
+ }
+
public boolean isSkipCacheAfterWrite() {
return skipCacheAfterWrite;
}
@@ -433,4 +438,5 @@ public class TransactionManager {
beanDescriptorManager.processViewInvalidation(viewInvalidation);
}
}
+
}
diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreTransaction.java b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreTransaction.java
new file mode 100644
index 000000000..ea2e81a77
--- /dev/null
+++ b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreTransaction.java
@@ -0,0 +1,29 @@
+package com.avaje.ebeanservice.docstore.api;
+
+/**
+ * A document store transaction.
+ *
+ * This might just be a buffer to batch persist requests to the document store and may not
+ * support transactional semantics (like rollback).
+ */
+public interface DocStoreTransaction {
+
+ /**
+ * Obtain a context to persist to (like a buffer).
+ */
+ DocStoreUpdateContext obtain();
+
+ /**
+ * Add changes that should be queued to the DocStoreUpdates.
+ *
+ * This mostly means nested/embedded updates that need to be processed after the source
+ * persist event has propagated.
+ *
+ * The batch size can be set via {@link com.avaje.ebean.Transaction#setDocStoreBatchSize(int)}
+ */
+ DocStoreTransaction createTransaction(int batchSize);
+
+ /**
+ * Perform commit/flush of the changes made via the document store transaction.
+ */
+ void commit(DocStoreTransaction docStoreTransaction);
}
diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java
index 7fa9f4e83..949d98a12 100644
--- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java
+++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java
@@ -174,9 +174,12 @@ public abstract class DocStoreBeanBaseAdaptervalue() method for a possible containerAnnotation.
- * Method is retuned only, if its signature is array of containingType.
+ * Method is retuned only, if its signature is array of containingType.
*/
private static Method getRepeatableValueMethod(
Annotation containerAnnotation, Class containingType) {
-
+
Method method = valueMethods.get(containerAnnotation);
if (method == null) {
try {
@@ -295,11 +294,11 @@ public abstract class AnnotationBase {
}
return null;
}
-
+
/**
* Finds a suitable annotation from Set for this platform.
- * To distinguish between platforms, annotation type T must define
- * a method withthis signature:
+ * To distinguish between platforms, annotation type T must define
+ * a method withthis signature:
* Class extends DatabasePlatform>[] platforms() default {};
*