You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/07/08 01:45:17 UTC
[1/2] isis git commit: ISIS-1163: less hacky way to accommodate
schema-aware (rdbms with 'create schema') vs non-schema-aware datastores
(neo4j)
Repository: isis
Updated Branches:
refs/heads/master a79eb83ad -> 1a763a517
ISIS-1163: less hacky way to accommodate schema-aware (rdbms with 'create schema') vs non-schema-aware datastores (neo4j)
also: improved some of the boilerplate text in simpleapp.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0eb5f820
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0eb5f820
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0eb5f820
Branch: refs/heads/master
Commit: 0eb5f8206308c82023d1f2886878dd2eaf40392c
Parents: a79eb83
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Jul 8 00:44:10 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Jul 8 00:44:10 2015 +0100
----------------------------------------------------------------------
.../DataNucleusApplicationComponents.java | 108 +++++++++++++------
example/application/simpleapp/webapp/pom.xml | 11 --
.../resources/domainapp/webapp/welcome.html | 10 +-
.../webapp/src/main/webapp/about/index.html | 18 ++--
4 files changed, 87 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/0eb5f820/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusApplicationComponents.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusApplicationComponents.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusApplicationComponents.java
index a048942..63821dc 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusApplicationComponents.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusApplicationComponents.java
@@ -29,9 +29,8 @@ import javax.jdo.PersistenceManagerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.Maps;
-import org.datanucleus.NucleusContext;
+import org.datanucleus.PersistenceNucleusContext;
import org.datanucleus.PropertyNames;
-import org.datanucleus.StoreNucleusContext;
import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
import org.datanucleus.metadata.MetaDataListener;
import org.datanucleus.metadata.MetaDataManager;
@@ -108,48 +107,85 @@ public class DataNucleusApplicationComponents implements ApplicationScopedCompon
}
private void initialize() {
- final String persistableClassNames = Joiner.on(',').join(persistableClassNameSet);
+ createSchemaIfRequired();
- final String url = datanucleusProps.get("javax.jdo.option.ConnectionURL");
- if(url != null && url.startsWith("neo4j")) {
- // eagerly load
- datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MECHANISM, "Classes");
- datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MODE, "Checked");
- datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_CLASSNAMES, persistableClassNames);
- } else {
- // need to lazily load to ensure that any DB containing schema is created via our MetadataListener.
+ namedQueryByName = catalogNamedQueries(persistableClassNameSet);
+ }
+
+ private static boolean isSchemaAwareStoreManager(Map<String,String> datanucleusProps) {
+
+ // we create a throw-away instance of PMF so that we can probe whether DN has
+ // been configured with a schema-aware store manager or not.
+ final JDOPersistenceManagerFactory probePmf =
+ (JDOPersistenceManagerFactory)JDOHelper.getPersistenceManagerFactory(datanucleusProps);
+ try {
+ final PersistenceNucleusContext nucleusContext = probePmf.getNucleusContext();
+ final StoreManager storeManager = nucleusContext.getStoreManager();
+ return storeManager instanceof SchemaAwareStoreManager;
+ } finally {
+ probePmf.close();
}
+ }
- // ref: http://www.datanucleus.org/products/datanucleus/jdo/autostart.html
- persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(datanucleusProps);
+ // REF: http://www.datanucleus.org/products/datanucleus/jdo/schema.html
+ private void createSchemaIfRequired() {
- final boolean createSchema = (Boolean.parseBoolean( datanucleusProps.get(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_SCHEMA) ) ||
- Boolean.parseBoolean( datanucleusProps.get(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL) ));
- if(createSchema) {
- createSchema();
- }
+ if(isSchemaAwareStoreManager(datanucleusProps)) {
- namedQueryByName = catalogNamedQueries(persistableClassNameSet);
+ // we *don't* use DN's eager loading (autoStart), because doing so means that it attempts to
+ // create the table before the schema (for any entities annotated @PersistenceCapable(schema=...)
- }
-
+ // ref: http://www.datanucleus.org/products/datanucleus/jdo/autostart.html
+ // datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MECHANISM, "Classes");
+ // datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MODE, "Checked");
+ // datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_CLASSNAMES,
+ // Joiner.on(',').join(persistableClassNameSet));
+
+ persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(datanucleusProps);
+
+
+ //
+ // instead, we manually create the schema ourselves
+ // (if the configured StoreMgr supports it, and if requested in isis.properties)
+ //
+ JDOPersistenceManagerFactory jdopmf = (JDOPersistenceManagerFactory)persistenceManagerFactory;
+ final PersistenceNucleusContext nucleusContext = jdopmf.getNucleusContext();
+ final SchemaAwareStoreManager storeManager = (SchemaAwareStoreManager)nucleusContext.getStoreManager();
- private void createSchema() {
- //REF: http://www.datanucleus.org/products/datanucleus/jdo/schema.html
-
- final JDOPersistenceManagerFactory jdopmf = (JDOPersistenceManagerFactory)persistenceManagerFactory;
- final NucleusContext nucleusContext = jdopmf.getNucleusContext();
-
- if (nucleusContext instanceof StoreNucleusContext) {
-
- final StoreManager storeManager = ((StoreNucleusContext)nucleusContext).getStoreManager();
final MetaDataManager metaDataManager = nucleusContext.getMetaDataManager();
-
- registerMetadataListener(metaDataManager);
- if (storeManager instanceof SchemaAwareStoreManager) {
- ((SchemaAwareStoreManager)storeManager).createSchemaForClasses(persistableClassNameSet, asProperties(datanucleusProps));
+
+ // rather than reinvent too much of the wheel, we reuse the same properties that DN would check
+ // for if it were doing the auto-creation itself (read from isis.properties)
+ final boolean createSchema =
+ isSet(this.datanucleusProps, PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_SCHEMA) ||
+ isSet(this.datanucleusProps, PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL);
+ if (!createSchema) {
+ return;
}
+
+ final SchemaAwareStoreManager schemaAwareStoreManager = (SchemaAwareStoreManager) storeManager;
+ registerMetadataListener(metaDataManager);
+ schemaAwareStoreManager.createSchemaForClasses(persistableClassNameSet, asProperties(datanucleusProps));
+
+ } else {
+
+ // we *DO* use DN's eager loading (autoStart), because it seems that DN requires this (for neo4j at least)
+ // otherwise NPEs occur later.
+
+ final String persistableClassNames = Joiner.on(',').join(persistableClassNameSet);
+
+ // ref: http://www.datanucleus.org/products/datanucleus/jdo/autostart.html
+ datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MECHANISM, "Classes");
+ datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_MODE, "Checked");
+ datanucleusProps.put(PropertyNames.PROPERTY_AUTOSTART_CLASSNAMES, persistableClassNames);
+
+ persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(datanucleusProps);
}
+
+ }
+
+ private boolean isSet(final Map<String, String> props, final String key) {
+ return Boolean.parseBoolean( props.get(key) );
}
private void registerMetadataListener(final MetaDataManager metaDataManager) {
@@ -161,6 +197,10 @@ public class DataNucleusApplicationComponents implements ApplicationScopedCompon
if(listener instanceof DataNucleusPropertiesAware) {
((DataNucleusPropertiesAware) listener).setDataNucleusProperties(datanucleusProps);
}
+
+
+ // and install the listener for any classes that are lazily loaded subsequently
+ // (shouldn't be any, this is mostly backwards compatibility with previous design).
metaDataManager.registerListener(listener);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/0eb5f820/example/application/simpleapp/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/pom.xml b/example/application/simpleapp/webapp/pom.xml
index 6676982..1112924 100644
--- a/example/application/simpleapp/webapp/pom.xml
+++ b/example/application/simpleapp/webapp/pom.xml
@@ -355,18 +355,7 @@
</plugins>
</build>
</profile>
- <profile>
- <id>neo4j</id>
- <dependencies>
- <dependency>
- <groupId>org.datanucleus</groupId>
- <artifactId>datanucleus-neo4j</artifactId>
- <version>4.0.4</version>
- </dependency>
- </dependencies>
- </profile>
</profiles>
-
</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/0eb5f820/example/application/simpleapp/webapp/src/main/resources/domainapp/webapp/welcome.html
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/src/main/resources/domainapp/webapp/welcome.html b/example/application/simpleapp/webapp/src/main/resources/domainapp/webapp/welcome.html
index 49cfbcd..a87d673 100644
--- a/example/application/simpleapp/webapp/src/main/resources/domainapp/webapp/welcome.html
+++ b/example/application/simpleapp/webapp/src/main/resources/domainapp/webapp/welcome.html
@@ -22,14 +22,14 @@
domain-driven apps in Java.
<br/>
<br/>
- This app has been generated using Isis'
+ This app has been generated using Apache Isis'
<a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
- which configures Isis' most commonly used components as part of a very simple and purposefully minimal application.
+ to create a purposefully minimal application that nevertheless includes fixture data, integration tests and BDD specs.
<br/>
<br/>
- The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank">SimpleObject</a>,
- along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank">SimpleObjects</a>.
+ The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
+ along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
<br/>
<br/>
- For more details, see the <a href="http://isis.apache.org/documentation.html" target="_blank">Isis website</a>.
+ For more details, see the <a href="http://isis.apache.org/documentation.html" target="_blank">Apache Isis website</a>.
</p>
http://git-wip-us.apache.org/repos/asf/isis/blob/0eb5f820/example/application/simpleapp/webapp/src/main/webapp/about/index.html
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/src/main/webapp/about/index.html b/example/application/simpleapp/webapp/src/main/webapp/about/index.html
index 29bc108..070651a 100644
--- a/example/application/simpleapp/webapp/src/main/webapp/about/index.html
+++ b/example/application/simpleapp/webapp/src/main/webapp/about/index.html
@@ -57,15 +57,13 @@ th, td {
<img alt="Isis Logo" src="about/images/isis-logo.png" />
<p>
- <a href="http://isis.apache.org" target="_blank">Apache Isis</a>™ is a framework to let you rapidly develop
- domain-driven apps in Java. This app has been generated using Isis'
- <a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
- which configures Isis to run a very simple and purposefully minimal application.
-
- <p>
- The app itself consists of a single domain class,
- <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/domainapp/dom/module/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
- along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/domainapp/dom/module/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
+ This app has been generated using Apache Isis'
+ <a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
+ to create a purposefully minimal application that nevertheless includes fixture data, integration tests and BDD specs.
+ <br/>
+ <br/>
+ The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
+ along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
</p>
<p>To access the app:</p>
@@ -88,7 +86,7 @@ th, td {
</p>
<p>
provides access to a RESTful API conformant with the
- <a href="http://restfulobjects.org">Restful Objects</a> spec</td>. This is part of Isis Core. The
+ <a href="http://restfulobjects.org">Restful Objects</a> spec</td>. This is part of Apache Isis Core. The
implementation technology is JBoss RestEasy.
</p>
</li>
[2/2] isis git commit: ISIS-1052: recreating simpleapp archetype
Posted by da...@apache.org.
ISIS-1052: recreating simpleapp archetype
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/1a763a51
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/1a763a51
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/1a763a51
Branch: refs/heads/master
Commit: 1a763a517ca4751408ec7840e539734065c57739
Parents: 0eb5f82
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Jul 8 00:44:38 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Jul 8 00:44:38 2015 +0100
----------------------------------------------------------------------
.../resources/archetype-resources/webapp/pom.xml | 11 -----------
.../main/resources/domainapp/webapp/welcome.html | 10 +++++-----
.../webapp/src/main/webapp/about/index.html | 18 ++++++++----------
.../resources/projects/basic/archetype.properties | 2 +-
4 files changed, 14 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/1a763a51/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/pom.xml b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/pom.xml
index 5eac9e2..da107f7 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/pom.xml
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/pom.xml
@@ -346,18 +346,7 @@
</plugins>
</build>
</profile>
- <profile>
- <id>neo4j</id>
- <dependencies>
- <dependency>
- <groupId>org.datanucleus</groupId>
- <artifactId>datanucleus-neo4j</artifactId>
- <version>4.0.4</version>
- </dependency>
- </dependencies>
- </profile>
</profiles>
-
</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/1a763a51/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/resources/domainapp/webapp/welcome.html
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/resources/domainapp/webapp/welcome.html b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/resources/domainapp/webapp/welcome.html
index 4661b68..14c9c85 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/resources/domainapp/webapp/welcome.html
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/resources/domainapp/webapp/welcome.html
@@ -25,14 +25,14 @@
domain-driven apps in Java.
<br/>
<br/>
- This app has been generated using Isis'
+ This app has been generated using Apache Isis'
<a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
- which configures Isis' most commonly used components as part of a very simple and purposefully minimal application.
+ to create a purposefully minimal application that nevertheless includes fixture data, integration tests and BDD specs.
<br/>
<br/>
- The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank">SimpleObject</a>,
- along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank">SimpleObjects</a>.
+ The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
+ along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
<br/>
<br/>
- For more details, see the <a href="http://isis.apache.org/documentation.html" target="_blank">Isis website</a>.
+ For more details, see the <a href="http://isis.apache.org/documentation.html" target="_blank">Apache Isis website</a>.
</p>
http://git-wip-us.apache.org/repos/asf/isis/blob/1a763a51/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/webapp/about/index.html
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/webapp/about/index.html b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/webapp/about/index.html
index 8c575a1..98b2e62 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/webapp/about/index.html
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/webapp/src/main/webapp/about/index.html
@@ -60,15 +60,13 @@ ${symbol_pound}wrapper {
<img alt="Isis Logo" src="about/images/isis-logo.png" />
<p>
- <a href="http://isis.apache.org" target="_blank">Apache Isis</a>™ is a framework to let you rapidly develop
- domain-driven apps in Java. This app has been generated using Isis'
- <a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
- which configures Isis to run a very simple and purposefully minimal application.
-
- <p>
- The app itself consists of a single domain class,
- <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/domainapp/dom/module/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
- along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/domainapp/dom/module/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
+ This app has been generated using Apache Isis'
+ <a href="http://isis.apache.org/intro/getting-started/simple%61pp-archetype.html" target="_blank">SimpleApp</a> archetype,
+ to create a purposefully minimal application that nevertheless includes fixture data, integration tests and BDD specs.
+ <br/>
+ <br/>
+ The app itself consists of a single domain class, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObject.java" target="_blank"><tt>SimpleObject</tt></a>,
+ along with an equally simple (factory/repository) domain service, <a href="https://github.com/apache/isis/blob/master/example/application/simple%61pp/dom/src/main/java/dom/simple/SimpleObjects.java" target="_blank"><tt>SimpleObjects</tt></a>.
</p>
<p>To access the app:</p>
@@ -91,7 +89,7 @@ ${symbol_pound}wrapper {
</p>
<p>
provides access to a RESTful API conformant with the
- <a href="http://restfulobjects.org">Restful Objects</a> spec</td>. This is part of Isis Core. The
+ <a href="http://restfulobjects.org">Restful Objects</a> spec</td>. This is part of Apache Isis Core. The
implementation technology is JBoss RestEasy.
</p>
</li>
http://git-wip-us.apache.org/repos/asf/isis/blob/1a763a51/example/archetype/simpleapp/src/test/resources/projects/basic/archetype.properties
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/test/resources/projects/basic/archetype.properties b/example/archetype/simpleapp/src/test/resources/projects/basic/archetype.properties
index 459eea2..843f345 100644
--- a/example/archetype/simpleapp/src/test/resources/projects/basic/archetype.properties
+++ b/example/archetype/simpleapp/src/test/resources/projects/basic/archetype.properties
@@ -1,4 +1,4 @@
-#Tue Jul 07 07:57:37 BST 2015
+#Wed Jul 08 00:44:31 BST 2015
package=it.pkg
version=0.1-SNAPSHOT
groupId=archetype.it