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 2012/12/06 18:42:15 UTC
[3/52] [partial] ISIS-188: moving framework/ subdirs up to parent
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ad06b51..54359dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,15 +8,14 @@ logs/
.project
.classpath
-framework/component/objectstore/sql/sql-tests-common/hsql-db/
-framework/component/objectstore/sql/sql-tests-common/xml/
+component/objectstore/sql/sql-tests-common/hsql-db/
+component/objectstore/sql/sql-tests-common/xml/
-framework/component/objectstore/xml/tmp/objects/
-framework/component/objectstore/xml/xml/objects/
-framework/component/objectstore/xml/tmp/tests/
+component/objectstore/xml/tmp/objects/
+component/objectstore/xml/xml/objects/
+component/objectstore/xml/tmp/tests/
-framework/component/security/sql/hsql-db/
-framework/component/runtimes/dflt/objectstores/jdo/jdo-datanucleus/hsql-db/
+component/security/sql/hsql-db/
# log files
datanucleus.log
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e6e77b0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..0a76071
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2012 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/STATUS
----------------------------------------------------------------------
diff --git a/STATUS b/STATUS
new file mode 100644
index 0000000..a4649ae
--- /dev/null
+++ b/STATUS
@@ -0,0 +1,64 @@
+Web site: http://isis.apache.org/
+
+Project Status
+
+ Description
+
+ Isis is an ASL 2.0 licensed implementation of the Naked Objects pattern and
+ also an implementation of the Restful Objects specification. It is based on
+ contributions of the original Naked Objects Framework along with a number
+ of sister projects that were developed for the book "Domain Driven Design
+ using Naked Objects " (pragprog 2009).
+
+ Isis was accepted into the Incubator in 2010, September 7th.
+
+ Isis graduated from the Incubator in 2012, October 17th.
+
+ To participate in Isis, please join the mailing lists. Send an empty
+ message to users-subscribe@isis.apache.org (for users)
+ or to dev-subscribe@isis.apache.org (for developers).
+
+Project info
+
+ As a subproject of the Apache Incubator project, Isis follows the direction
+ of the Apache Incubator PMC. Significant contributions over a sustained
+ period of time can earn a contributor commit access to the codebase.
+
+Official releases:
+ * 0.1.2-incubating : Release July 2011
+ * 0.2.0-incubating : Release January 2012
+
+Other releases:
+ * snapshot releases to repository.apache.org (snapshots repo)
+
+Resources:
+
+ item type URL
+ ------------- ----- -----------------------------------------------------
+ Source code git https://git.apache.org/repos/asf/isis.git
+ Source code gitrw https://git-wip-us.apache.org/repos/asf/isis.git
+ Status file www https://git-wip-us.apache.org/repos/asf/isis/repo?p=isis.git;a=blob_plain;f=STATUS;hb=HEAD
+ Website www http://isis.apache.org
+ Mailing list dev dev@isis.apache.org
+ Mailing list users users@isis.apache.org
+ JIRA www http://issues.apache.org/jira/browse/ISIS
+ Wiki www http://cwiki.apache.org/confluence/display/ISIS/Index
+ CI www http://builds.apache.org/hudson/job/isis-trunk-windows
+ Fisheye www https://fisheye6.atlassian.com/graph/isis
+
+
+Team:
+
+ role(s) user id name
+ ----------------- ----- -------------------------------------
+ Mentor, Committer struberg Mark Struberg
+ Mentor, Committer bimargulies Benson Margulies
+ Mentor, Committer mnour Mohammad Nour El-Din (CLA on file)
+ Mentor, Committer sgoeschl Siegfried Goeschl
+ Committer danhaywood Daniel Keir Haywood (CLA on file)
+ Committer rmatthews Robert Charles Matthews (CLA on file)
+ Committer kevin Kevin Meyer (CLA on file)
+ Committer themalkolm Alexander Krasnukhin (CLA on file)
+ Committer dslaughter David Slaughter (CLA on file)
+ Committer jvanderwal Jeroen van der Wal (CLA on file)
+ Committer uli Ulrich St�rk (CLA on file)
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/NOTICE
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/NOTICE b/component/objectstore/jdo/jdo-applib/NOTICE
new file mode 100644
index 0000000..d391f54
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/NOTICE
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/pom.xml
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/pom.xml b/component/objectstore/jdo/jdo-applib/pom.xml
new file mode 100644
index 0000000..14c32a1
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/pom.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>jdo</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>jdo-applib</artifactId>
+ <name>JDO ObjectStore AppLib</name>
+
+ <properties>
+ <siteBaseDir>..</siteBaseDir>
+ <relativeUrl>jdo-applib/</relativeUrl>
+ </properties>
+
+ <!-- used in Site generation for relative references. -->
+ <url>http://incubator.apache.org/isis/${relativeUrl}</url>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>maven-datanucleus-plugin</artifactId>
+ <version>3.1.1</version>
+ <configuration>
+ <fork>false</fork>
+ <verbose>true</verbose>
+ <!--
+ <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
+ <props>${basedir}/datanucleus.properties</props>
+ -->
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.datanucleus
+ </groupId>
+ <artifactId>
+ maven-datanucleus-plugin
+ </artifactId>
+ <versionRange>
+ [3.0.2,)
+ </versionRange>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- for DataNucleus, see below -->
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>jdo</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.isis</groupId>
+ <artifactId>applib</artifactId>
+ </dependency>
+
+ <!-- DataNucleus (horrid, but needed to run the enhancer)-->
+ <dependency>
+ <groupId>javax.jdo</groupId>
+ <artifactId>jdo-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <!-- use geronimo-jta_1.1_spec instead -->
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-enhancer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-jodatime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-api-jdo</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditService.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditService.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditService.java
new file mode 100644
index 0000000..93cf643
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditService.java
@@ -0,0 +1,28 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.applib;
+
+import org.apache.isis.applib.annotation.Hidden;
+
+public interface AuditService {
+
+ @Hidden
+ public void audit(String user, long currentTimestampEpoch, String objectType, String identifier, String preValue, String postValue);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditServiceLogging.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditServiceLogging.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditServiceLogging.java
new file mode 100644
index 0000000..7dd8297
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/AuditServiceLogging.java
@@ -0,0 +1,35 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.applib;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.log4j.Logger;
+
+public class AuditServiceLogging extends AbstractFactoryAndRepository implements AuditService {
+
+ private static Logger LOG = Logger.getLogger(AuditServiceLogging.class);
+
+ @Hidden
+ public void audit(String user, long currentTimestampEpoch, String objectType, String identifier, String preValue, String postValue) {
+ String auditMessage = objectType + ":" + identifier + " by " + user + ": " + preValue + " -> " + postValue;
+ LOG.info(auditMessage);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/Auditable.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/Auditable.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/Auditable.java
new file mode 100644
index 0000000..96fe2ef
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/Auditable.java
@@ -0,0 +1,26 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.applib;
+
+/**
+ * Marker interface to indicate that an entity should be audited.
+ */
+public interface Auditable {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/annotations/Auditable.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/annotations/Auditable.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/annotations/Auditable.java
new file mode 100644
index 0000000..24444a6
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/applib/annotations/Auditable.java
@@ -0,0 +1,39 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.applib.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that the entity is auditable.
+ *
+ * <p>
+ * Alternatively, the type can implement the
+ * {@link org.apache.isis.runtimes.dflt.objectstores.jdo.applib.Auditable Auditable} marker interface.
+ */
+@Inherited
+@Target({ ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Auditable {
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/main/resources/plugin.xml
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/resources/plugin.xml b/component/objectstore/jdo/jdo-applib/src/main/resources/plugin.xml
new file mode 100644
index 0000000..426a18b
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/resources/plugin.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<plugin>
+
+ <extension point="org.datanucleus.java_type">
+ <java-type
+ name="org.apache.isis.applib.value.Date"
+ persistent="true"
+ dfg="true"
+ embedded="true"
+ long-converter="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisDateConverter"/>
+ <java-type
+ name="org.apache.isis.applib.value.DateTime"
+ persistent="true"
+ dfg="true"
+ embedded="true"
+ long-converter="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisDateTimeConverter"/>
+
+ <java-type
+ name="org.apache.isis.applib.value.Blob"
+ persistent="true"
+ dfg="false"
+ embedded="true"
+ string-converter="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisBlobConverter"/>
+ <java-type
+ name="org.apache.isis.applib.value.Clob"
+ persistent="true"
+ dfg="false"
+ embedded="true"
+ string-converter="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisClobConverter"/>
+ </extension>
+
+ <extension point="org.datanucleus.store_mapping">
+ <mapping
+ java-type="org.apache.isis.applib.value.Date"
+ mapping-class="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisDateMapping"/>
+ <mapping
+ java-type="org.apache.isis.applib.value.DateTime"
+ mapping-class="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisDateTimeMapping"/>
+
+ <mapping
+ java-type="org.apache.isis.applib.value.Blob"
+ mapping-class="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisBlobMapping"/>
+ <mapping
+ java-type="org.apache.isis.applib.value.Clob"
+ mapping-class="org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes.IsisClobMapping"/>
+
+ </extension>
+</plugin>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/site/apt/index.apt b/component/objectstore/jdo/jdo-applib/src/site/apt/index.apt
new file mode 100644
index 0000000..e6b8a19
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/site/apt/index.apt
@@ -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.
+
+Application Library
+
+ The JPA objectstore applib ...
+
+Further Info
+
+ See this module's {{{./apidocs/index.html}Javadoc}} and the {{{../docbkx/html/guide/isis-jpa-objectstore.html}user guide}} for more information.
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/site/apt/jottings.apt b/component/objectstore/jdo/jdo-applib/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/site/apt/jottings.apt
@@ -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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-applib/src/site/site.xml
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/site/site.xml b/component/objectstore/jdo/jdo-applib/src/site/site.xml
new file mode 100644
index 0000000..461e451
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/site/site.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="${project.name}">
+
+ <body>
+ <breadcrumbs>
+ <item name="Applib" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="JDO Applib">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="JDO Modules">
+ <item name="Applib" href="../jdo-applib/index.html" />
+ <item name="Metamodel" href="../jdo-metamodel/index.html" />
+ <item name="DataNucleus" href="../jdo-datanucleus/index.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/NOTICE
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/NOTICE b/component/objectstore/jdo/jdo-datanucleus/NOTICE
new file mode 100644
index 0000000..d391f54
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/NOTICE
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/lib/.gitignore
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/lib/.gitignore b/component/objectstore/jdo/jdo-datanucleus/lib/.gitignore
new file mode 100644
index 0000000..4c21459
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/lib/.gitignore
@@ -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.
+#
+
+#
+# explicitly ignoring Microsoft JDBC4 jar
+# (cannot redistribute, licensing)
+#
+sqljdbc4.jar
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/pom.xml
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/pom.xml b/component/objectstore/jdo/jdo-datanucleus/pom.xml
new file mode 100644
index 0000000..2185b18
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>jdo</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>jdo-datanucleus</artifactId>
+ <name>JDO DataNucleus ObjectStore</name>
+
+ <properties>
+ <siteBaseDir>..</siteBaseDir>
+ <relativeUrl>jdo-datanucleus/</relativeUrl>
+ </properties>
+
+ <!-- used in Site generation for relative references. -->
+ <url>http://incubator.apache.org/isis/${relativeUrl}</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!--
+ -->
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>jdo-metamodel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jdo</groupId>
+ <artifactId>jdo-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <!-- use geronimo-jta_1.1_spec instead -->
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-enhancer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-api-jdo</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-rdbms</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-unittestsupport</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>isis-integtestsupport</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>com.microsoft.sqlserver</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>4.0</version>
+ <scope>system</scope>
+ <optional>true</optional>
+ <systemPath>${basedir}/lib/sqljdbc4.jar</systemPath>
+ </dependency>
+ -->
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusApplicationComponents.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusApplicationComponents.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusApplicationComponents.java
new file mode 100644
index 0000000..b051e3f
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusApplicationComponents.java
@@ -0,0 +1,161 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.datanucleus;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import org.datanucleus.NucleusContext;
+import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
+import org.datanucleus.store.schema.SchemaAwareStoreManager;
+
+import org.apache.isis.core.commons.components.ApplicationScopedComponent;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.FrameworkSynchronizer;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.IsisLifecycleListener;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly.JdoEmbeddedOnlyFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoNamedQuery;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoQueryFacet;
+
+public class DataNucleusApplicationComponents implements ApplicationScopedComponent {
+
+ private final PersistenceManagerFactory persistenceManagerFactory;
+ private final Map<String, JdoNamedQuery> namedQueryByName;
+
+ private final IsisLifecycleListener lifecycleListener;
+ private final FrameworkSynchronizer synchronizer;
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ public DataNucleusApplicationComponents(final Map<String, String> props, final Collection<ObjectSpecification> objectSpecs) {
+ persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(props);
+
+ final Set<String> classesToBePersisted = catalogClassesToBePersisted(objectSpecs);
+
+ createSchema(props, classesToBePersisted);
+
+ namedQueryByName = Collections.unmodifiableMap(catalogNamedQueries(objectSpecs));
+
+ synchronizer = new FrameworkSynchronizer();
+ lifecycleListener = new IsisLifecycleListener(synchronizer);
+ }
+
+ private void createSchema(final Map<String, String> props, final Set<String> classesToBePersisted) {
+ final JDOPersistenceManagerFactory jdopmf = (JDOPersistenceManagerFactory)persistenceManagerFactory;
+ final NucleusContext nucleusContext = jdopmf.getNucleusContext();
+ final SchemaAwareStoreManager storeManager = (SchemaAwareStoreManager) nucleusContext.getStoreManager();
+ storeManager.createSchema(classesToBePersisted, asProperties(props));
+ }
+
+ private static Set<String> catalogClassesToBePersisted(Collection<ObjectSpecification> objectSpecs) {
+ Set<String> classNames = Sets.newTreeSet();
+ for (final ObjectSpecification spec : objectSpecs) {
+ if(spec.containsFacet(JdoPersistenceCapableFacet.class) || spec.containsFacet(JdoEmbeddedOnlyFacet.class)) {
+ classNames.add(spec.getFullIdentifier());
+ }
+ }
+ return Collections.unmodifiableSet(classNames);
+ }
+
+ private static Properties asProperties(Map<String, String> props) {
+ Properties properties = new Properties();
+ properties.putAll(props);
+ return properties;
+ }
+
+ private static Map<String, JdoNamedQuery> catalogNamedQueries(Collection<ObjectSpecification> objectSpecs) {
+ final Map<String, JdoNamedQuery> namedQueryByName = Maps.newHashMap();
+ for (final ObjectSpecification spec : objectSpecs) {
+ final JdoQueryFacet facet = spec.getFacet(JdoQueryFacet.class);
+ if (facet == null) {
+ continue;
+ }
+ for (final JdoNamedQuery namedQuery : facet.getNamedQueries()) {
+ namedQueryByName.put(namedQuery.getName(), namedQuery);
+ }
+ }
+ return namedQueryByName;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void shutdown() {
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // FrameworkSynchronizer
+ ///////////////////////////////////////////////////////////////////////////
+
+ public FrameworkSynchronizer getFrameworkSynchronizer() {
+ return synchronizer;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ public PersistenceManager createPersistenceManager() {
+ PersistenceManager persistenceManager = persistenceManagerFactory.getPersistenceManager();
+
+ persistenceManager.addInstanceLifecycleListener(lifecycleListener, (Class[])null);
+ return persistenceManager;
+ }
+
+ public JdoNamedQuery getNamedQuery(String queryName) {
+ return namedQueryByName.get(queryName);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void suspendListener() {
+ lifecycleListener.setSuspended(true);
+ }
+
+ public void resumeListener() {
+ lifecycleListener.setSuspended(false);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusException.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusException.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusException.java
new file mode 100644
index 0000000..fa2d302
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.datanucleus;
+
+import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
+
+public class DataNucleusException extends ObjectPersistenceException {
+
+ private static final long serialVersionUID = 1L;
+
+ public DataNucleusException() {
+ super();
+ }
+
+ public DataNucleusException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DataNucleusException(String message) {
+ super(message);
+ }
+
+ public DataNucleusException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusObjectStore.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusObjectStore.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusObjectStore.java
new file mode 100644
index 0000000..2e3711a
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusObjectStore.java
@@ -0,0 +1,723 @@
+/*
+ * 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.isis.runtimes.dflt.objectstores.jdo.datanucleus;
+
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatContext;
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+
+import java.sql.Connection;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.spi.PersistenceCapable;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.FrameworkSynchronizer;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.FrameworkSynchronizer.CalledFrom;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.commands.DataNucleusDeleteObjectCommand;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.commands.DataNucleusUpdateObjectCommand;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.PersistenceQueryFindByPatternProcessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.PersistenceQueryFindByTitleProcessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.PersistenceQueryProcessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.queries.QueryUtil;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi.JdoObjectIdSerializer;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoNamedQuery;
+import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.runtimes.dflt.runtime.persistence.UnsupportedFindException;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindAllInstances;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByPattern;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindUsingApplibQueryDefault;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+
+public class DataNucleusObjectStore implements ObjectStoreSpi {
+
+ private static final Logger LOG = Logger.getLogger(DataNucleusObjectStore.class);
+
+ static enum State {
+ NOT_YET_OPEN, OPEN, CLOSED;
+ }
+
+ /**
+ * @see #isFixturesInstalled()
+ */
+ public static final String INSTALL_FIXTURES_KEY = ConfigurationConstants.ROOT + "persistor.datanucleus.install-fixtures";
+ public static final boolean INSTALL_FIXTURES_DEFAULT = false;
+
+ static enum TransactionMode {
+ /**
+ * Requires transactions to be started explicitly.
+ */
+ UNCHAINED,
+ /**
+ * Transactions are started automatically if not already in progress.
+ */
+ CHAINED;
+ }
+
+ private final ObjectAdapterFactory adapterFactory;
+ private final DataNucleusApplicationComponents applicationComponents;
+
+ private final Map<ObjectSpecId, RootOid> registeredServices = Maps.newHashMap();
+
+ private PersistenceManager persistenceManager;
+
+ private final Map<Class<?>, PersistenceQueryProcessor<?>> persistenceQueryProcessorByClass = Maps.newHashMap();
+ private final FrameworkSynchronizer frameworkSynchronizer;
+
+ private State state;
+ private TransactionMode transactionMode;
+
+
+ public DataNucleusObjectStore(ObjectAdapterFactory adapterFactory, DataNucleusApplicationComponents applicationComponents) {
+ ensureThatArg(adapterFactory, is(notNullValue()));
+ ensureThatArg(applicationComponents, is(notNullValue()));
+
+ this.state = State.NOT_YET_OPEN;
+ this.transactionMode = TransactionMode.UNCHAINED;
+
+ this.adapterFactory = adapterFactory;
+ this.applicationComponents = applicationComponents;
+ this.frameworkSynchronizer = applicationComponents.getFrameworkSynchronizer();
+ }
+
+ @Override
+ public String name() {
+ return "datanucleus";
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // open, close
+ // ///////////////////////////////////////////////////////////////////////
+
+ public void open() {
+ ensureNotYetOpen();
+
+ openSession();
+ ensureThatState(persistenceManager, is(notNullValue()));
+
+ addPersistenceQueryProcessors(persistenceManager);
+
+ state = State.OPEN;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Automatically {@link IsisTransactionManager#endTransaction() ends
+ * (commits)} the current (Isis) {@link Transaction}. This in turn
+ * {@link DataNucleusObjectStore#commitJdoTransaction() commits the underlying
+ * JPA transaction}.
+ * <p>
+ * The corresponding DataNucleus {@link Entity} is then
+ * {@link EntityManager#close() close}d.
+ */
+ public void close() {
+ ensureOpened();
+ ensureThatState(persistenceManager, is(notNullValue()));
+
+ final IsisTransaction currentTransaction = getTransactionManager().getTransaction();
+ if (currentTransaction != null && currentTransaction.getState().canCommit()) {
+ getTransactionManager().endTransaction();
+ }
+
+ persistenceManager.close();
+ state = State.CLOSED;
+ }
+
+ private PersistenceManager openSession() {
+ this.persistenceManager = applicationComponents.createPersistenceManager();
+ return this.persistenceManager;
+ }
+
+ private void addPersistenceQueryProcessors(final PersistenceManager persistenceManager) {
+ persistenceQueryProcessorByClass.put(PersistenceQueryFindAllInstances.class, new PersistenceQueryFindAllInstancesProcessor(persistenceManager, frameworkSynchronizer));
+ persistenceQueryProcessorByClass.put(PersistenceQueryFindByTitle.class, new PersistenceQueryFindByTitleProcessor(persistenceManager, frameworkSynchronizer));
+ persistenceQueryProcessorByClass.put(PersistenceQueryFindByPattern.class, new PersistenceQueryFindByPatternProcessor(persistenceManager, frameworkSynchronizer));
+ persistenceQueryProcessorByClass.put(PersistenceQueryFindUsingApplibQueryDefault.class, new PersistenceQueryFindUsingApplibQueryProcessor(persistenceManager, frameworkSynchronizer));
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // isFixturesInstalled
+ // ///////////////////////////////////////////////////////////////////////
+
+ /**
+ * Implementation looks for the {@link #INSTALL_FIXTURES_KEY} in the
+ * {@link #getConfiguration() configuration}.
+ * <p>
+ * By default this is not expected to be there, but utilities can add in on
+ * the fly during bootstrapping if required.
+ */
+ public boolean isFixturesInstalled() {
+ return ! getConfiguration().getBoolean(INSTALL_FIXTURES_KEY, INSTALL_FIXTURES_DEFAULT);
+ }
+
+
+ // ///////////////////////////////////////////////////////////////////////
+ // reset
+ // ///////////////////////////////////////////////////////////////////////
+
+ public void reset() {
+ // does nothing.
+ }
+
+ /**
+ * Non-API.
+ */
+ public Connection getJavaSqlConnection() {
+ return (Connection) persistenceManager.getDataStoreConnection().getNativeConnection();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // TransactionMode (not API)
+ // ///////////////////////////////////////////////////////////////////////
+
+ public TransactionMode getTransactionMode() {
+ return transactionMode;
+ }
+
+ public void setTransactionMode(final TransactionMode transactionMode) {
+ ensureNotInTransaction();
+ this.transactionMode = transactionMode;
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Transactions
+ // ///////////////////////////////////////////////////////////////////////
+
+ public void startTransaction() {
+ beginJdoTransaction();
+ }
+
+ public void endTransaction() {
+ commitJdoTransaction();
+ }
+
+ public void abortTransaction() {
+ rollbackJpaTransaction();
+ }
+
+ private void beginJdoTransaction() {
+ final javax.jdo.Transaction transaction = getPersistenceManager().currentTransaction();
+ if (transaction.isActive()) {
+ throw new IllegalStateException("Transaction already active");
+ }
+ transaction.begin();
+ }
+
+ private void commitJdoTransaction() {
+ final javax.jdo.Transaction transaction = getPersistenceManager().currentTransaction();
+ if (transaction.isActive()) {
+ transaction.commit();
+ }
+ }
+
+ private void rollbackJpaTransaction() {
+ final javax.jdo.Transaction transaction = getPersistenceManager().currentTransaction();
+ if (transaction.isActive()) {
+ transaction.rollback();
+ }
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Command Factory
+ // ///////////////////////////////////////////////////////////////////////
+
+ public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter adapter) {
+ ensureOpened();
+ ensureInSession();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("create object - creating command for: " + adapter);
+ }
+ if (adapter.representsPersistent()) {
+ throw new IllegalArgumentException("Adapter is persistent; adapter: " + adapter);
+ }
+ return new DataNucleusCreateObjectCommand(adapter, getPersistenceManager());
+ }
+
+ public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter adapter) {
+ ensureOpened();
+ ensureInSession();
+
+ if (!adapter.representsPersistent()) {
+ throw new IllegalArgumentException("Adapter is not persistent; adapter: " + adapter);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("save object - creating command for: " + adapter);
+ }
+ return new DataNucleusUpdateObjectCommand(adapter, getPersistenceManager());
+ }
+
+ public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter adapter) {
+ ensureOpened();
+ ensureInSession();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("destroy object - creating command for: " + adapter);
+ }
+ if (!adapter.representsPersistent()) {
+ throw new IllegalArgumentException("Adapter is not persistent; adapter: " + adapter);
+ }
+ return new DataNucleusDeleteObjectCommand(adapter, getPersistenceManager());
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Execute
+ // ///////////////////////////////////////////////////////////////////////
+
+ public void execute(final List<PersistenceCommand> commands) {
+ ensureOpened();
+ ensureInTransaction();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("execute " + commands.size() + " commands");
+ }
+
+ if (commands.size() <= 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("no commands");
+ }
+ return;
+ }
+
+ executeCommands(commands);
+ }
+
+ private void executeCommands(final List<PersistenceCommand> commands) {
+ try {
+ for (final PersistenceCommand command : commands) {
+ command.execute(null);
+ }
+ getPersistenceManager().flush();
+ } catch (final RuntimeException e) {
+ LOG.warn("Failure during execution", e);
+ throw e;
+ }
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // loadMappedObject, resolveImmediately, resolveField
+ // ///////////////////////////////////////////////////////////////////////
+
+ public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid) {
+ ensureOpened();
+ ensureInTransaction();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("getObject; oid=" + oid);
+ }
+
+ final Object pojo = loadPojo(oid);
+ return getPersistenceSession().mapRecreatedPojo(oid, pojo);
+ }
+
+
+
+ /////////////////////////////////////////////////////////////
+ // delegated to by PojoRecreator
+ /////////////////////////////////////////////////////////////
+
+ public Object loadPojo(final TypedOid oid) {
+
+ // REVIEW: does it make sense to get these directly? not sure, so for now have decided to fail fast.
+ if(oid instanceof AggregatedOid) {
+ throw new UnsupportedOperationException("Cannot retrieve aggregated objects directly, oid: " + oid.enString(getOidMarshaller()));
+ }
+
+ final RootOid rootOid = (RootOid) oid;
+
+ Object result = null;
+ try {
+ final Class<?> cls = clsOf(rootOid);
+ final Object jdoObjectId = JdoObjectIdSerializer.toJdoObjectId(rootOid);
+ result = getPersistenceManager().getObjectById(cls, jdoObjectId);
+ } catch (final RuntimeException e) {
+ throw e;
+ }
+
+ if (result == null) {
+ throw new ObjectNotFoundException(oid);
+ }
+ return result;
+ }
+
+
+ public ObjectAdapter lazilyLoaded(Object pojo) {
+ if(!(pojo instanceof PersistenceCapable)) {
+ return null;
+ }
+ final PersistenceCapable persistenceCapable = (PersistenceCapable) pojo;
+ return frameworkSynchronizer.lazilyLoaded(persistenceCapable, CalledFrom.OS_LAZILYLOADED);
+ }
+
+
+
+ /**
+ * Will do nothing if object is already resolved or if object is transient.
+ * <p>
+ * TODO:
+ * The final {@link ResolveState} of the adapter is set using
+ * {@link NakedLoadPostEventListener#onPostLoad(org.hibernate.event.PostLoadEvent)}
+ * Note: this is the same behaviour as MemoryObjectStore, XmlObjectStore
+ * and HibernateObjectStore.
+ * <p>
+ * REVIEW: if the initial state is RESOLVING_PART, then the
+ * {@link ResolveState} is not changed. Is this right?
+ */
+ public void resolveImmediately(final ObjectAdapter adapter) {
+ ensureOpened();
+ ensureInTransaction();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("resolveImmediately; oid=" + adapter.getOid().enString(getOidMarshaller()));
+ }
+
+ if (adapter.isResolved()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("; already resolved - ignoring");
+ }
+ return;
+ }
+ if (!adapter.representsPersistent()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("; not persistent - ignoring");
+ }
+ return;
+ }
+
+ final Oid oid = adapter.getOid();
+ if (oid instanceof AggregatedOid) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("; aggregated - resolving parent");
+ }
+ final AggregatedOid aggregatedOid = (AggregatedOid) oid;
+ final TypedOid parentOid = aggregatedOid.getParentOid();
+ final ObjectAdapter parentAdapter = loadInstanceAndAdapt(parentOid);
+ resolveImmediately(parentAdapter);
+ return;
+ }
+
+ // REVIEW: is this possible?
+ final Object domainObject = adapter.getObject();
+ if (domainObject == null) {
+ throw new ObjectNotFoundException(adapter.getOid());
+ }
+
+ try {
+ getPersistenceManager().refresh(domainObject);
+ } catch (final RuntimeException e) {
+ throw new ObjectNotFoundException(adapter.getOid(), e);
+ }
+
+ // possibly redundant because also called in the post-load event
+ // listener, but (with JPA impl) found it was required if we were ever to
+ // get an eager left-outer-join as the result of a refresh (sounds possible).
+
+ frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) domainObject, CalledFrom.OS_RESOLVE);
+ }
+
+ /**
+ * Walking the graph.
+ */
+ public void resolveField(final ObjectAdapter object, final ObjectAssociation association) {
+ ensureOpened();
+ ensureInTransaction();
+
+ final ObjectAdapter referencedCollectionAdapter = association.get(object);
+
+ // this code originally brought in from the JPA impl, but seems reasonable.
+ if (association.isOneToManyAssociation()) {
+ ensureThatState(referencedCollectionAdapter, is(notNullValue()));
+
+ final Object referencedCollection = referencedCollectionAdapter.getObject();
+ ensureThatState(referencedCollection, is(notNullValue()));
+
+ // if a proxy collection, then force it to initialize. just 'touching' the object is sufficient.
+ // REVIEW: I wonder if this is actually needed; does JDO use proxy collections?
+ referencedCollection.hashCode();
+ }
+
+ // the JPA impl used to also call its lifecycle listener on the referenced collection object, eg List,
+ // itself. I don't think this makes sense to do for JDO (the collection is not a PersistenceCapable).
+ }
+
+
+ // ///////////////////////////////////////////////////////////////////////
+ // getInstances, hasInstances
+ // ///////////////////////////////////////////////////////////////////////
+
+ public List<ObjectAdapter> loadInstancesAndAdapt(final PersistenceQuery persistenceQuery) {
+ ensureOpened();
+ ensureInTransaction();
+
+ final PersistenceQueryProcessor<? extends PersistenceQuery> processor = persistenceQueryProcessorByClass.get(persistenceQuery.getClass());
+ if (processor == null) {
+ throw new UnsupportedFindException(MessageFormat.format("Unsupported criteria type: {0}", persistenceQuery.getClass().getName()));
+ }
+ return processPersistenceQuery(processor, persistenceQuery);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <Q extends PersistenceQuery> List<ObjectAdapter> processPersistenceQuery(final PersistenceQueryProcessor<Q> persistenceQueryProcessor, final PersistenceQuery persistenceQuery) {
+ return persistenceQueryProcessor.process((Q)persistenceQuery);
+ }
+
+ public boolean hasInstances(final ObjectSpecification specification) {
+ ensureOpened();
+ ensureInTransaction();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("hasInstances: class=" + specification.getFullIdentifier());
+ }
+
+ if (!specification.persistability().isPersistable()) {
+ LOG.warn("hasInstances: trying to run for non-persistent class " + specification);
+ return false;
+ }
+
+ final Query query = QueryUtil.createQuery(getPersistenceManager(), "o", "select o.id", specification, null);
+ throw new NotYetImplementedException();
+ //query.set.setMaxResults(1);
+ //return !query.getResultList().isEmpty();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Helpers (loadObjects)
+ // ///////////////////////////////////////////////////////////////////////
+
+ @SuppressWarnings("unused")
+ private List<ObjectAdapter> loadObjects(final ObjectSpecification specification, final List<?> listOfPojs, final AdapterManagerSpi adapterManager) {
+ final List<ObjectAdapter> adapters = Lists.newArrayList();
+ int i = 0;
+ for (final Object pojo : listOfPojs) {
+ // REVIEW: cannot just load adapter for object - if Naked Objects
+ // has
+ // already loaded the object
+ // then object won't match it (e.g. if getInstances has been called
+ // and an instance has
+ // been loaded) - so need to use Hibernate session to get an Oid to
+ // do a lookup in that case
+ adapters.add(adapterManager.getAdapterFor(pojo));
+ }
+ return adapters;
+ }
+
+
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Services
+ // ///////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void registerService(RootOid rootOid) {
+ ensureOpened();
+ this.registeredServices.put(rootOid.getObjectSpecId(), rootOid);
+ }
+
+ @Override
+ public RootOid getOidForService(ObjectSpecification serviceSpec) {
+ ensureOpened();
+ return this.registeredServices.get(serviceSpec.getSpecId());
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Helpers: ensure*
+ // ///////////////////////////////////////////////////////////////////////
+
+ private void ensureNotYetOpen() {
+ ensureStateIs(State.NOT_YET_OPEN);
+ }
+
+ private void ensureOpened() {
+ ensureStateIs(State.OPEN);
+ }
+
+ private void ensureInSession() {
+ ensureThatContext(IsisContext.inSession(), is(true));
+ }
+
+ private void ensureNotInTransaction() {
+ ensureInSession();
+ ensureThatContext(IsisContext.inTransaction(), is(false));
+ }
+
+ private void ensureInTransaction() {
+ if (transactionMode == TransactionMode.UNCHAINED) {
+ ensureThatContext(IsisContext.inTransaction(), is(true));
+ ensureInHibernateTransaction();
+ } else {
+ ensureInSession();
+ if (IsisContext.inTransaction()) {
+ ensureInHibernateTransaction();
+ } else {
+ getTransactionManager().startTransaction();
+ }
+ }
+ }
+
+ private void ensureInHibernateTransaction() {
+ javax.jdo.Transaction currentTransaction = getPersistenceManager().currentTransaction();
+ ensureThatState(currentTransaction, is(notNullValue()));
+ ensureThatState(currentTransaction.isActive(), is(true));
+ }
+
+ private void ensureStateIs(final State stateRequired) {
+ if (state == stateRequired) {
+ return;
+ }
+ throw new IllegalStateException("State is: " + state + "; should be: " + stateRequired);
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Debugging
+ // ///////////////////////////////////////////////////////////////////////
+
+ public void debugData(final DebugBuilder debug) {
+ throw new NotYetImplementedException();
+ }
+
+ public String debugTitle() {
+ throw new NotYetImplementedException();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // non-API
+ // ///////////////////////////////////////////////////////////////////////
+
+ public JdoNamedQuery getNamedQuery(String queryName) {
+ return applicationComponents.getNamedQuery(queryName);
+ }
+
+ /**
+ * For testing purposes, to allow fixtures to use JDO to initialize the
+ * database without triggering the objectstore.
+ *
+ * @see #resumeListener()
+ */
+ public void suspendListener() {
+ applicationComponents.suspendListener();
+ }
+
+ /**
+ * For testing purposes, to allow fixtures to use JDO to initialize the
+ * database without triggering the objectstore.
+ *
+ * @see #suspendListener()
+ */
+ public void resumeListener() {
+ applicationComponents.resumeListener();
+ }
+
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Helpers
+ // ///////////////////////////////////////////////////////////////////////
+
+ private Class<?> clsOf(final TypedOid oid) {
+ final ObjectSpecification objectSpec = getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
+ return objectSpec.getCorrespondingClass();
+ }
+
+ /**
+ * Intended for internal and test use only.
+ */
+ public PersistenceManager getPersistenceManager() {
+ return persistenceManager;
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Dependencies (from constructor)
+ // ///////////////////////////////////////////////////////////////////////
+
+ public ObjectAdapterFactory getAdapterFactory() {
+ return adapterFactory;
+ }
+
+
+ // ///////////////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////////////
+
+ public IsisConfiguration getConfiguration() {
+ return IsisContext.getConfiguration();
+ }
+
+ protected SpecificationLoaderSpi getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+ protected PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected AdapterManager getAdapterManager() {
+ return getPersistenceSession().getAdapterManager();
+ }
+
+ protected IsisTransactionManager getTransactionManager() {
+ return IsisContext.getTransactionManager();
+ }
+
+ protected OidMarshaller getOidMarshaller() {
+ return IsisContext.getOidMarshaller();
+ }
+
+
+}