You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2011/05/25 17:46:29 UTC

svn commit: r1127566 [1/4] - in /incubator/wookie/trunk: ./ modules/ modules/jcr/ modules/jcr/src-tests/ modules/jcr/src-tests/org/ modules/jcr/src-tests/org/apache/ modules/jcr/src-tests/org/apache/wookie/ modules/jcr/src-tests/org/apache/wookie/beans...

Author: scottbw
Date: Wed May 25 15:46:26 2011
New Revision: 1127566

URL: http://svn.apache.org/viewvc?rev=1127566&view=rev
Log:
Separated out JCR persistence implementation from the core server into a separate module and added a decoupled loader mechanism.

Added:
    incubator/wookie/trunk/modules/
    incubator/wookie/trunk/modules/jcr/
    incubator/wookie/trunk/modules/jcr/build.properties
    incubator/wookie/trunk/modules/jcr/build.xml
    incubator/wookie/trunk/modules/jcr/ivy.xml
    incubator/wookie/trunk/modules/jcr/src/
    incubator/wookie/trunk/modules/jcr/src-tests/
    incubator/wookie/trunk/modules/jcr/src-tests/org/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/
    incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/JCRPersistenceTest.java
    incubator/wookie/trunk/modules/jcr/src/org/
    incubator/wookie/trunk/modules/jcr/src/org/apache/
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IIdElement.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IInverseRelationship.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPathBean.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPersistenceListener.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IUuidBean.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IdCollection.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRModule.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRPersistenceManager.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/PersistenceListenerAdapter.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/AccessRequestImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/ApiKeyImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/DescriptionImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/FeatureImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/LicenseImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/LocalizedBeanImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/NameImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/ParamImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/ParticipantImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/PreferenceDefaultImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/PreferenceImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/SharedDataImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/StartFileImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/TokenImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WhitelistImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetDefaultImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetIconImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetInstanceImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetServiceImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/impl/WidgetTypeImpl.java
    incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/wookie-schema.cnd
    incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/JPAModule.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/util/IModule.java
Removed:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/beans/JCRPersistenceTest.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IIdElement.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IInverseRelationship.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IPathBean.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IPersistenceListener.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IUuidBean.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/IdCollection.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/JCRPersistenceManager.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/PersistenceListenerAdapter.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/AccessRequestImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/ApiKeyImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/DescriptionImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/FeatureImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/LicenseImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/LocalizedBeanImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/NameImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/ParamImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/ParticipantImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/PreferenceDefaultImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/PreferenceImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/SharedDataImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/StartFileImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/TokenImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WhitelistImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetDefaultImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetIconImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetInstanceImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetServiceImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetTypeImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd
Modified:
    incubator/wookie/trunk/build.xml
    incubator/wookie/trunk/ivy.xml
    incubator/wookie/trunk/src/org/apache/wookie/server/Start.java

Modified: incubator/wookie/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/build.xml?rev=1127566&r1=1127565&r2=1127566&view=diff
==============================================================================
--- incubator/wookie/trunk/build.xml (original)
+++ incubator/wookie/trunk/build.xml Wed May 25 15:46:26 2011
@@ -157,6 +157,8 @@
   </target>
 
   <target name="post-deploy-webapp-jcr" if="deploy.webapp.jcr">
+  	<ant dir="modules/jcr" target="deploy-module" inheritAll="false"/>
+  	
     <!-- configure JCR web.xml resource ref -->
 	<copy file="${project.webapp.dir}/WEB-INF/web.xml"
           todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF"

Modified: incubator/wookie/trunk/ivy.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/ivy.xml?rev=1127566&r1=1127565&r2=1127566&view=diff
==============================================================================
--- incubator/wookie/trunk/ivy.xml (original)
+++ incubator/wookie/trunk/ivy.xml Wed May 25 15:46:26 2011
@@ -29,6 +29,12 @@
         </dependency>
         <dependency org="org.apache.incubator" name="wookieW3CParser" rev="latest.integration" conf="deploy->default">
         </dependency>
+        
+        <!--  Uncomment to include JCR persistence manager -->
+ 		<!--  
+        <dependency org="org.apache.incubator" name="wookie-jcr" rev="latest.integration" conf="deploy->default">  
+		</dependency>    --> 
+
         <dependency org="com.ibm.icu" name="icu4j" rev="4_6_0" conf="deploy->default">
         </dependency>
         <dependency org="org.apache.commons" name="commons-email" rev="1.1" conf="deploy->default">
@@ -83,14 +89,6 @@
         </dependency>
         <dependency org="commons-pool" name="commons-pool" rev="1.3" conf="deploy->default">
 		</dependency>        
-        <dependency org="javax.jcr" name="jcr" rev="1.0" conf="deploy->default">
-        </dependency>
-        <dependency org="org.apache.jackrabbit" name="jackrabbit-core" rev="1.5.3" conf="deploy->default">
-        </dependency>
-        <dependency org="org.apache.jackrabbit" name="jackrabbit-jcr-commons" rev="1.5.3" conf="deploy->default">
-        </dependency>
-        <dependency org="org.apache.jackrabbit" name="jackrabbit-ocm" rev="1.5.3" conf="deploy->default">
-        </dependency>
 
         <!-- Libraries used in a development/test environment but not in deployment -->
         <dependency org="javax.servlet" name="servlet-api" rev="2.5" conf="dev->default">

Added: incubator/wookie/trunk/modules/jcr/build.properties
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/build.properties?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/build.properties (added)
+++ incubator/wookie/trunk/modules/jcr/build.properties Wed May 25 15:46:26 2011
@@ -0,0 +1,5 @@
+version=0.9.1-SNAPSHOT
+
+# build configuration properties
+build.dir=../../build
+ivy.repository.dir=../../ant

Added: incubator/wookie/trunk/modules/jcr/build.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/build.xml?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/build.xml (added)
+++ incubator/wookie/trunk/modules/jcr/build.xml Wed May 25 15:46:26 2011
@@ -0,0 +1,44 @@
+<?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.
+-->
+<project default="compile-core" basedir="." name="wookie-jcr" xmlns:ivy="antlib:org.apache.ivy.ant">
+	<description>
+      Ivy based build system for Apache Wookie JCR persistence.
+    </description>
+	
+  	<!-- build JCR component -->
+	<!-- put in post-deploy-webapp-jcr
+  	<ant dir="modules/jcr" target="deploy-module" inheritAll="false"/>
+	
+	-->
+	
+	<property file="local.build.properties" />
+	<property file="build.properties" />
+	<property file="../../build.properties" />
+
+	<import file="../../ant/ivy-java-common.xml" />
+
+	<target name="pre-compile-core" description="Run before compile-core. intended to be overridden if your project needs any post compile processing"/>
+	
+	<target name="deploy-module" depends="publish-local">
+		<ivy:cachepath pathid="project.core.class.path" conf="dev" />
+		<copy file="dist/wookie-jcr-0.1.0-SNAPSHOT.jar" todir="../../${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/lib"></copy>
+
+		<ivy:retrieve conf="deploy" pattern="../../${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/lib/[artifact]-[revision].[ext]"/>
+		
+	</target>
+</project>
\ No newline at end of file

Added: incubator/wookie/trunk/modules/jcr/ivy.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/ivy.xml?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/ivy.xml (added)
+++ incubator/wookie/trunk/modules/jcr/ivy.xml Wed May 25 15:46:26 2011
@@ -0,0 +1,48 @@
+<!--
+  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.
+-->
+<ivy-module version="2.0">
+    <info organisation="org.apache.incubator" module="wookie-jcr" revision="0.9.1-SNAPSHOT"/>
+    
+    <configurations>
+      <conf name="deploy" description="Provide the necessary files and libraries to deploy in a production environment"/>
+	  <conf name="dev" extends="deploy" description="Provide the necessary files and libraries to run in standalone (development) mode"/>
+	  <conf name="test" extends="dev" visibility="private" description="for our testing frameowrk"/>
+	</configurations>
+    
+    <dependencies>
+    	<dependency org="org.apache.incubator" name="wookie" rev="latest.integration" conf="deploy->default">
+    	</dependency>
+        <dependency org="commons-pool" name="commons-pool" rev="1.3" conf="deploy->default">
+		</dependency>   
+		<dependency org="commons-configuration" name="commons-configuration" rev="1.4" conf="deploy->default">
+        </dependency>
+        
+               
+        <dependency org="javax.jcr" name="jcr" rev="1.0" conf="deploy->default">
+        </dependency>
+        <dependency org="org.apache.jackrabbit" name="jackrabbit-core" rev="1.5.3" conf="deploy->default">
+        </dependency>
+        <dependency org="org.apache.jackrabbit" name="jackrabbit-jcr-commons" rev="1.5.3" conf="deploy->default">
+        </dependency>
+        <dependency org="org.apache.jackrabbit" name="jackrabbit-ocm" rev="1.5.3" conf="deploy->default">
+        </dependency>
+        
+        <dependency org="org.mortbay.jetty" name="jetty-plus" rev="6.1.3" conf="dev->default">
+        </dependency>
+
+    </dependencies>
+</ivy-module>

Added: incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/JCRPersistenceTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/JCRPersistenceTest.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/JCRPersistenceTest.java (added)
+++ incubator/wookie/trunk/modules/jcr/src-tests/org/apache/wookie/beans/jcr/tests/JCRPersistenceTest.java Wed May 25 15:46:26 2011
@@ -0,0 +1,130 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr.tests;
+
+import java.io.File;
+
+import javax.jcr.Repository;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.jackrabbit.core.TransientRepository;
+import org.apache.wookie.beans.jcr.JCRPersistenceManager;
+import org.apache.wookie.beans.util.PersistenceManagerFactory;
+import org.apache.wookie.tests.beans.AbstractPersistenceTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * JCRPersistenceTest - JCR persistence implementation tests.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class JCRPersistenceTest extends AbstractPersistenceTest
+{
+    private static final Logger logger = LoggerFactory.getLogger(JCRPersistenceTest.class);
+    
+    public static final String REPOSITORY_USER_PROPERTY_NAME = "wookie.test.repository.user";
+    public static final String REPOSITORY_PASSWORD_PROPERTY_NAME = "wookie.test.repository.password";
+    public static final String REPOSITORY_DIRECTORY_PROPERTY_NAME = "wookie.test.repository.dir";
+    public static final String REPOSITORY_ROOT_PATH_PROPERTY_NAME = "wookie.test.repository.rootpath";
+    public static final String REPOSITORY_WORKSPACE_PROPERTY_NAME = "wookie.test.repository.workspace";
+    
+    private String repositoryDir;
+    private String repositoryUser;
+    private String repositoryPassword;
+    private String repositoryRootPath;
+    private String repositoryWorkspace;
+    private Context rootContext;
+    
+    /**
+     * Set up JCR persistence runtime test environment.
+     * 
+     * @throws Exception
+     */
+    @Before
+    public void setUpPerTest() throws Exception
+    {
+        logger.info("JCR set up test");
+
+        // load repository configuration from environment
+        String testRepositoryDir = System.getProperty("user.dir")+"/build/test-repository";
+        repositoryDir = getSystemProperty(REPOSITORY_DIRECTORY_PROPERTY_NAME, testRepositoryDir);
+        repositoryUser = getSystemProperty(REPOSITORY_USER_PROPERTY_NAME, "java");
+        repositoryPassword = getSystemProperty(REPOSITORY_PASSWORD_PROPERTY_NAME, "java");
+        repositoryRootPath = getSystemProperty(REPOSITORY_ROOT_PATH_PROPERTY_NAME, "/wookie");
+        repositoryWorkspace = getSystemProperty(REPOSITORY_WORKSPACE_PROPERTY_NAME, "default");
+        
+        // construct JCR remote client repository instance
+        File repositoryDirFile = new File(repositoryDir);
+        if (!repositoryDirFile.exists())
+        {
+            repositoryDirFile.mkdirs();
+        }
+        String derbyLog = repositoryDir+File.separator+"derby.log";
+        System.setProperty("derby.stream.error.file", derbyLog);
+        String repositoryConfig = repositoryDir+File.separator+"repository.xml";
+        Repository repository = new TransientRepository(repositoryConfig, repositoryDir);
+        
+        // create JNDI context
+        rootContext = new InitialContext();
+        Context namingContext = lookupOrCreateNamingContext(rootContext, "java:comp");
+        namingContext = lookupOrCreateNamingContext(namingContext, "env");
+        lookupOrCreateNamingContext(namingContext, "jcr");
+        
+        // bind datasource to JNDI context
+        rootContext.rebind(JCRPersistenceManager.WIDGET_REPOSITORY_JNDI_REPOSITORY_FULL_NAME, repository);
+
+        // initialize persistence manager factory and persistence manager;
+        // truncate and initialize persistent store
+        Configuration configuration = new PropertiesConfiguration();
+        configuration.setProperty(PersistenceManagerFactory.PERSISTENCE_MANAGER_CLASS_NAME_PROPERTY_NAME, JCRPersistenceManager.class.getName());
+        configuration.setProperty(PersistenceManagerFactory.PERSISTENCE_MANAGER_INITIALIZE_STORE_PROPERTY_NAME, "true");
+        configuration.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_USER_PROPERTY_NAME, repositoryUser);
+        configuration.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_PASSWORD_PROPERTY_NAME, repositoryPassword);
+        configuration.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_ROOT_PATH_PROPERTY_NAME, repositoryRootPath);
+        configuration.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_WORKSPACE_PROPERTY_NAME, repositoryWorkspace);
+        PersistenceManagerFactory.initialize(configuration);
+
+        logger.info("JCR test set up");
+        configured = true;
+    }
+
+    /**
+     * Tear down JCR persistence runtime test environment.
+     * 
+     * @throws Exception
+     */
+    @After
+    public void tearDownPerTest() throws Exception
+    {
+        configured = false;
+        logger.info("JCR tear down test");
+
+        // terminate persistence manager factory
+        PersistenceManagerFactory.terminate();
+
+        // unbind repository from JNDI context
+        rootContext.unbind(JCRPersistenceManager.WIDGET_REPOSITORY_JNDI_REPOSITORY_FULL_NAME);
+        
+        logger.info("JCR test torn down");
+    }
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IIdElement.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IIdElement.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IIdElement.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IIdElement.java Wed May 25 15:46:26 2011
@@ -0,0 +1,38 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+/**
+ * IIdElement - interface to manage collection element ids.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface IIdElement
+{
+    /**
+     * Get collection element id.
+     * 
+     * @return element id
+     */
+    long getElementId();
+    
+    /**
+     * Set collection element id.
+     * 
+     * @param elementId element id
+     */
+    void setElementId(long elementId);
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IInverseRelationship.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IInverseRelationship.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IInverseRelationship.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IInverseRelationship.java Wed May 25 15:46:26 2011
@@ -0,0 +1,31 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+/**
+ * IInverseRelationship - interface to manage inverse relationships.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface IInverseRelationship<O extends IUuidBean>
+{
+    /**
+     * Update inverse relationship.
+     * 
+     * @param parentObject parent object
+     */
+    void updateInverseRelationship(O parentObject);
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPathBean.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPathBean.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPathBean.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPathBean.java Wed May 25 15:46:26 2011
@@ -0,0 +1,39 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+/**
+ * IPathBean - base JCR bean with node path.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface IPathBean
+{
+    /**
+     * Get JCR node path.
+     * 
+     * @return node path
+     */
+    String getNodePath();
+
+    /**
+     * Set JCR node path if not previously set.
+     *
+     * @param nodeRootPath node root path for instance class
+     * @return new or exiting node path
+     */
+    String setNodePath(String nodeRootPath);
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPersistenceListener.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPersistenceListener.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPersistenceListener.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IPersistenceListener.java Wed May 25 15:46:26 2011
@@ -0,0 +1,54 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+import org.apache.wookie.beans.util.IPersistenceManager;
+
+/**
+ * IPersistenceListener - persistence operation notifications listener interface.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface IPersistenceListener
+{
+    /**
+     * Pre-save persistence operation notification.
+     * 
+     * @param persistenceManager persistence manager
+     */
+    boolean preSave(IPersistenceManager persistenceManager);
+    
+    /**
+     * Post-save persistence operation notification.
+     * 
+     * @param persistenceManager persistence manager
+     */
+    boolean postSave(IPersistenceManager persistenceManager);
+    
+    /**
+     * Pre-delete persistence operation notification.
+     * 
+     * @param persistenceManager persistence manager
+     */
+    boolean preDelete(IPersistenceManager persistenceManager);
+
+    /**
+     * Post-delete persistence operation notification.
+     * 
+     * @param persistenceManager persistence manager
+     */
+    boolean postDelete(IPersistenceManager persistenceManager);
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IUuidBean.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IUuidBean.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IUuidBean.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IUuidBean.java Wed May 25 15:46:26 2011
@@ -0,0 +1,38 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+/**
+ * IUuidBean - base JCR bean with a reference UUID field.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface IUuidBean
+{
+    /**
+     * Get JCR referenceable node UUID.
+     * 
+     * @return node UUID
+     */
+    String getUuid();
+
+    /**
+     * Get JCR referenceable node UUID.
+     * 
+     * @return node UUID
+     */
+    void setUuid(String uuid);
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IdCollection.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IdCollection.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IdCollection.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/IdCollection.java Wed May 25 15:46:26 2011
@@ -0,0 +1,122 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * IdCollection - collection that manages collection element ids.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class IdCollection<I extends IIdElement,M> extends AbstractCollection<M>
+{
+    private Collection<I> managedCollection;
+    
+    /**
+     * Construct managing collection.
+     * 
+     * @param managedCollection managed collection
+     */
+    public IdCollection(Collection<I> managedCollection)
+    {
+        this.managedCollection = managedCollection;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#add(java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+    public boolean add(M member)
+    {
+        long maxElementId = -1;
+        for (I idElement : managedCollection)
+        {
+            if (idElement.getElementId() > maxElementId)
+            {
+                maxElementId = idElement.getElementId();
+            }
+        }
+        I idElement = (I)member;
+        idElement.setElementId(maxElementId+1);
+        return managedCollection.add(idElement);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#iterator()
+     */
+    public Iterator<M> iterator()
+    {
+        return new Iterator<M>()
+        {
+            Iterator<I> idElementIter = managedCollection.iterator();
+            I lastIdElement = null;
+            
+            /* (non-Javadoc)
+             * @see java.util.Iterator#hasNext()
+             */
+            public boolean hasNext()
+            {
+                return idElementIter.hasNext();
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#next()
+             */
+            @SuppressWarnings("unchecked")
+            public M next()
+            {
+                lastIdElement = idElementIter.next();
+                M member = (M)lastIdElement;
+                return member;
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#remove()
+             */
+            public void remove()
+            {
+                idElementIter.remove();
+                lastIdElement.setElementId(-1);
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#remove(java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+    public boolean remove(Object member)
+    {
+        I idElement = (I)member;
+        if (managedCollection.remove(idElement))
+        {
+            idElement.setElementId(-1);
+            return true;
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#size()
+     */
+    public int size()
+    {
+        return managedCollection.size();
+    }    
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/InverseRelationshipCollection.java Wed May 25 15:46:26 2011
@@ -0,0 +1,118 @@
+/*
+ *  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.
+ */
+
+package org.apache.wookie.beans.jcr;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * InverseRelationshipCollection - collection that manages inverse relationships.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class InverseRelationshipCollection<O extends IUuidBean,I extends IInverseRelationship<O>,M> extends AbstractCollection<M>
+{
+    private O owningObject;
+    private Collection<I> inverseCollection;
+
+    /**
+     * Construct managing collection.
+     * 
+     * @param owningObject owning object
+     * @param inverseCollection managed inverse collection
+     */
+    public InverseRelationshipCollection(O owningObject, Collection<I> inverseCollection)
+    {
+        super();
+        this.owningObject = owningObject;
+        this.inverseCollection = inverseCollection;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#add(java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+    public boolean add(M member)
+    {
+        I inverse = (I)member;
+        inverse.updateInverseRelationship(owningObject);
+        return inverseCollection.add(inverse);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#iterator()
+     */
+    public Iterator<M> iterator()
+    {
+        return new Iterator<M>()
+        {
+            Iterator<I> inverseIter = inverseCollection.iterator();
+            I lastInverse = null;
+            
+            /* (non-Javadoc)
+             * @see java.util.Iterator#hasNext()
+             */
+            public boolean hasNext()
+            {
+                return inverseIter.hasNext();
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#next()
+             */
+            @SuppressWarnings("unchecked")
+            public M next()
+            {
+                lastInverse = inverseIter.next();
+                M member = (M)lastInverse;
+                return member;
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#remove()
+             */
+            public void remove()
+            {
+                inverseIter.remove();
+                lastInverse.updateInverseRelationship(null);
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#remove(java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+    public boolean remove(Object member)
+    {
+        I inverse = (I)member;
+        if (inverseCollection.remove(inverse))
+        {
+            inverse.updateInverseRelationship(null);
+            return true;
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#size()
+     */
+    public int size()
+    {
+        return inverseCollection.size();
+    }  
+}

Added: incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRModule.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRModule.java?rev=1127566&view=auto
==============================================================================
--- incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRModule.java (added)
+++ incubator/wookie/trunk/modules/jcr/src/org/apache/wookie/beans/jcr/JCRModule.java Wed May 25 15:46:26 2011
@@ -0,0 +1,98 @@
+/*
+ * 
+ * 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.
+ * 
+ */
+
+package org.apache.wookie.beans.jcr;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.naming.NamingException;
+
+import org.apache.wookie.beans.util.IModule;
+import org.apache.wookie.beans.util.PersistenceManagerFactory;
+import org.apache.jackrabbit.core.TransientRepository;
+import javax.jcr.Repository;
+import org.mortbay.jetty.plus.naming.Resource;
+
+/**
+ * Persistence module for JCR
+ */
+public class JCRModule implements IModule {
+  
+  public static final String REPOSITORY_USER_PROPERTY_NAME = "wookie.repository.user";
+  public static final String REPOSITORY_PASSWORD_PROPERTY_NAME = "wookie.repository.password";
+  public static final String REPOSITORY_ROOT_PATH_PROPERTY_NAME = "wookie.repository.rootpath";
+  public static final String REPOSITORY_WORKSPACE_PROPERTY_NAME = "wookie.repository.workspace";
+
+  public static final String PERSISTENCE_MANAGER_TYPE_JCR = "jcr";
+  
+  private static String repositoryUser;
+  private static String repositoryPassword;
+  private static String repositoryRootPath;
+  private static String repositoryWorkspace;
+
+  /* (non-Javadoc)
+   * @see org.apache.wookie.beans.util.IModule#configure()
+   */
+  public void configure() {
+    repositoryUser = getSystemProperty(REPOSITORY_USER_PROPERTY_NAME, "java");
+    repositoryPassword = getSystemProperty(REPOSITORY_PASSWORD_PROPERTY_NAME, "java");
+    repositoryRootPath = getSystemProperty(REPOSITORY_ROOT_PATH_PROPERTY_NAME, "/wookie");
+    repositoryWorkspace = getSystemProperty(REPOSITORY_WORKSPACE_PROPERTY_NAME, "default");
+    
+    System.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_USER_PROPERTY_NAME, repositoryUser);
+    System.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_PASSWORD_PROPERTY_NAME, repositoryPassword);
+    System.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_ROOT_PATH_PROPERTY_NAME, repositoryRootPath);
+    System.setProperty(JCRPersistenceManager.PERSISTENCE_MANAGER_WORKSPACE_PROPERTY_NAME, repositoryWorkspace);
+    
+    System.setProperty(PersistenceManagerFactory.PERSISTENCE_MANAGER_CLASS_NAME_PROPERTY_NAME, JCRPersistenceManager.class.getName());
+    
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.wookie.beans.util.IModule#setup()
+   */
+  public void setup() throws NamingException, IOException {
+    // setup repository directory and derby logging properties
+    File repositoryDirFile = new File("widgetRepository");
+    if (!repositoryDirFile.exists()) {
+        repositoryDirFile.mkdirs();
+    }
+    String derbyLog = repositoryDirFile.getAbsolutePath()+File.separator+"derby.log";
+    System.setProperty("derby.stream.error.file", derbyLog);
+
+    // setup Jackrabbit JCR repository JNDI resource
+    String repositoryConfig = repositoryDirFile.getAbsolutePath()+File.separator+"repository.xml";
+    Repository repository = new TransientRepository(repositoryConfig, repositoryDirFile.getAbsolutePath());
+    new Resource(JCRPersistenceManager.WIDGET_REPOSITORY_JNDI_REPOSITORY_NAME, repository);
+    
+  }
+
+  
+  /**
+   * Get configuration system property.
+   * 
+   * @param name property name
+   * @param defaultValue default property value
+   * @return property value
+   */
+  private static String getSystemProperty(String name, String defaultValue)
+  {
+      String value = System.getProperty(name);
+      return (((value != null) && (value.length() > 0) && !value.startsWith("$")) ? value : defaultValue);
+  }
+}