Author: dleangen
Date: Sun Aug  6 02:12:50 2017
New Revision: 1804217

URL: http://svn.apache.org/viewvc?rev=1804217&view=rev
Log:
Spun out new project: Persister

Added:
    felix/trunk/converter/persister/
    felix/trunk/converter/persister/pom.xml   (with props)
    felix/trunk/converter/persister/readme.txt   (with props)
    felix/trunk/converter/persister/src/
    felix/trunk/converter/persister/src/main/
    felix/trunk/converter/persister/src/main/java/
    felix/trunk/converter/persister/src/main/java/org/
    felix/trunk/converter/persister/src/main/java/org/apache/
    felix/trunk/converter/persister/src/main/java/org/apache/felix/
    felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java
   (with props)
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java
   (with props)
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutCommand.java
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java
   (with props)
    
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java
   (with props)
    felix/trunk/converter/persister/src/test/
    felix/trunk/converter/persister/src/test/java/
    felix/trunk/converter/persister/src/test/java/org/
    felix/trunk/converter/persister/src/test/java/org/apache/
    felix/trunk/converter/persister/src/test/java/org/apache/felix/
    felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java
   (with props)
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java
   (with props)
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/CommandDTO.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/ClearCommand.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Repository.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleMiddleEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleTopEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexTopEntity.java
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java
   (with props)
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
    
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java
   (contents, props changed)
      - copied, changed from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/SerializerAdapter.java
Removed:
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexTop.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleMiddle.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleTop.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexMiddleEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleMiddleEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleTopEntity.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/ClearCommand.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Command.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/CommandDTO.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerBackedRepository.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerSerializer.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutAllCommand.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutCommand.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/RemoveCommand.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Repository.java
    
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/SerializerAdapter.java
Modified:
    felix/trunk/converter/pom.xml
    
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
    
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java

Added: felix/trunk/converter/persister/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/pom.xml?rev=1804217&view=auto
==============================================================================
--- felix/trunk/converter/persister/pom.xml (added)
+++ felix/trunk/converter/persister/pom.xml Sun Aug  6 02:12:50 2017
@@ -0,0 +1,170 @@
+<!--
+    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.felix</groupId>
+        <artifactId>felix-parent</artifactId>
+        <version>4</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Persister Service</name>
+    <artifactId>org.apache.felix.persister</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <scm>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/converter/persister</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/converter/persister</developerConnection>
+        
<url>http://svn.apache.org/viewvc/felix/trunk/converter/persister/</url>
+    </scm>
+
+    <properties>
+        <felix.java.version>8</felix.java.version>
+        
<felix.java.signature.artifactId>java18</felix.java.signature.artifactId>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>3.2.0</version>
+                <executions>
+                    <execution>
+                        <id>bundle</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>bundle</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>baseline</id>
+                        <goals>
+                            <goal>baseline</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <instructions>
+                        
<Bundle-Activator>org.apache.felix.persister.impl.Activator</Bundle-Activator>
+                        <Private-Package>
+                            org.apache.felix.persister.*,
+                            org.apache.felix.serializer.impl.*,
+                            org.yaml.snakeyaml.*,
+                            org.apache.felix.utils.*
+                        </Private-Package>
+                        <Export-Package>
+                            org.apache.felix.persister;
+                            
uses:="org.osgi.util.converter,org.osgi.util.function,org.osgi.dto,org.osgi.framework"
+                        </Export-Package>
+                        <Import-Package>
+                            org.osgi.util.converter,
+                            org.osgi.service.serializer,
+                            org.osgi.service.schematizer,
+                            *
+                        </Import-Package>
+                        <Provide-Capability>
+                            
osgi.service;objectClass:List&lt;String&gt;="org.apache.felix.persister.Persister,org.osgi.service.serializer.Serializer";
+                            
uses:="org.apache.felix.persister,org.osgi.service.serializer,org.osgi.util.converter,org.osgi.util.function"
+                        </Provide-Capability>
+                        <_sources>true</_sources>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <includes>
+                        <include>src/**</include>
+                    </includes>
+                    <excludes>
+                        
<exclude>src/main/resources/META-INF/services/org.apache.felix.persister.Persister</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.converter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.serializer</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.schematizer</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.annotation</artifactId>
+            <version>6.0.1</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <version>6.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.9.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.json</artifactId>
+            <version>2.0.16</version>
+            <scope>test</scope>            
+        </dependency>
+    </dependencies>
+</project>

Propchange: felix/trunk/converter/persister/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/trunk/converter/persister/readme.txt
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/readme.txt?rev=1804217&view=auto
==============================================================================
--- felix/trunk/converter/persister/readme.txt (added)
+++ felix/trunk/converter/persister/readme.txt Sun Aug  6 02:12:50 2017
@@ -0,0 +1,71 @@
+# Apache Felix Converter - Schematizer module
+
+## Overview
+
+The Schematizer follows the concept of "DTO-as-Schema", meaning the idea that
+the DTO describes the data schema, and using this idea to make the schema a
+first-class citizen in the design and implementation of a domain model.
+
+## DTO-as-Schema
+
+DTO-as-Schema (DaS) takes a step away from common Object Oriented (OO) design 
principles.
+When learning OO programming, common convention was to "hide away" the data in 
+order to "protect" it from the wild. Instead of accessing a field directly, the
+idea was to make a field private, and provide "getters" and "setters". The 
getters
+and setters were supposed to ensure the invariants of the object. Often, 
however,
+we would end up with code like this:
+
+```java
+public class SomeClass {
+    private String value;
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue( String aValue ) {
+        value = aValue;
+    }
+}
+```
+
+The above is really just a complicated and misleading way of doing this:
+
+```java
+public class SomeClass {
+    public String value;
+}
+```
+
+Even when OO-style classes are well written, it can be argued that the idea of 
data-hiding
+is a farce anyway when dealing with distributed systems. The reason is because 
the classes
+need to be serialized before they are put on the wire, and deserialzed again 
by the remote system.
+This requires exposing the system in the form of an "API", these days usually 
as a REST API.
+So, when the system is seen as a whole, we recognize that it is simply not 
possible to have
+a working complex system while "hiding" the core data.
+
+DaS is based on this admission. We admit that there are really *two* 
interfaces: 
+a *programmatic API* and a *data API*.
+
+In the [WHICH?] OSGi specification, DTOs were introduced as a convention for 
describing objects
+and transferring their state between system sub-parts. It so happens that the 
rules for DTOs
+describe a schema, in Java code, for the data objects being transferred. By 
taking advantage of this
+schema and elevating it as a first-class citizen during the design and 
implementation of domain
+objects, we can elegantly expose both the programmatic API and the data API in 
code, and reap a few
+other benefits as well, as described below.
+
+Building also on other ideas, notably some of the ideas emerging from 
functional programming,
+it is possible to develop domain models with a leaner--and thus more 
productive--code base.
+
+# STATUS
+
+This module is highly experimental and is *not* recommended for production.
+
+# Coding conventions
+
+[TODO]
+
+# Topics to Explore
+
+## Schema transforms
+## Lenses
\ No newline at end of file

Propchange: felix/trunk/converter/persister/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java
 (added)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) OSGi Alliance (2016). All Rights Reserved.
+ * 
+ * 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.felix.persister;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * The Persister is backed by the Felix Converter, Serializer, and Schematizer.
+ * Its purpose is to provide a simple integration into a persistence mechanism.
+ * The "DTO-type" entity is persisted as JSON data. The Entity is repopulated 
by
+ * this JSON data, with a little help from its Schema.
+ * 
+ * @author dleangen
+ *
+ * @param <E> The type of the Entity to persist
+ */
+public interface Persister<E> {
+    void serialize(OutputStream out, E entity);
+    E deserialize(InputStream in);
+}

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/Persister.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java?p2=felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java
 (original)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java
 Sun Aug  6 02:12:50 2017
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects;
+package org.apache.felix.persister;
 
-public interface Middle
-{
-    String getId();
-    String getSomeValue();
+public interface PersisterFactory {
+
+    <D>Persister<D> newPersister(Class<D> forType);
 }

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/PersisterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java
 (added)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,70 @@
+/*
+ * 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.felix.persister.impl;
+
+import org.apache.felix.persister.PersisterFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.serializer.Serializer;
+
+public class Activator implements ServiceListener, BundleActivator {
+
+    private PersisterFactoryService factory;
+    private ServiceRegistration<PersisterFactory> registration;
+    private BundleContext context;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        this.context = context;
+        context.addServiceListener(this, "(objectclass=" + 
Serializer.class.getName() + ")");
+    }
+
+    private void activate() {
+        ServiceReference<Serializer> sr = 
context.getServiceReference(Serializer.class);
+        Serializer serializer = context.getService(sr);
+        factory = new PersisterFactoryService(serializer);
+        registration = context.registerService(PersisterFactory.class, 
factory, null);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        this.context = null;
+    }
+
+    private void deactivate() {
+        registration.unregister();
+        factory = null;
+    }
+
+    @Override
+    public void serviceChanged(ServiceEvent event) {
+
+        switch(event.getType()) {
+            case ServiceEvent.REGISTERED :
+                activate();
+                break;
+
+            case ServiceEvent.UNREGISTERING :
+                deactivate();
+                break;
+        }
+    }
+}

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutCommand.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java?p2=felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutCommand.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/PutCommand.java
 (original)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java
 Sun Aug  6 02:12:50 2017
@@ -14,27 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.prevayler;
+package org.apache.felix.persister.impl;
 
-import java.util.Date;
-import java.util.Map;
-import java.util.Optional;
+import org.apache.felix.persister.Persister;
+import org.apache.felix.persister.PersisterFactory;
+import org.osgi.service.serializer.Serializer;
 
-public class PutCommand<E>
-    extends CommandDTO<E>
-{
-    public String key;
-    public E entity;
+public class PersisterFactoryService implements PersisterFactory {
 
-    public PutCommand()
-    {
-        this.command = Command.put;
+    private Serializer serializer;
+
+    public PersisterFactoryService(Serializer aSerializer) {
+        serializer = aSerializer;
     }
 
-    public Optional<Exception> executeAndQuery( Map<String, E> 
prevalentSystem, Date executionTime )
-                    throws Exception
-    {
-        prevalentSystem.put( key, entity );
-        return Optional.empty();
+    public <D>Persister<D> newPersister(Class<D> forDataType) {
+        return new StandardPersister<>(forDataType, serializer);
     }
 }

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/PersisterFactoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java
 (added)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,68 @@
+/*
+ * 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.felix.persister.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.felix.persister.Persister;
+import org.apache.felix.schematizer.Schematizer;
+import org.apache.felix.schematizer.StandardSchematizer;
+import org.osgi.service.serializer.Serializer;
+import org.osgi.util.converter.Converter;
+
+public class StandardPersister<D> implements Persister<D> {
+
+    private final Class<D> dataType;
+    private final Serializer serializer;
+    private Converter converter;
+
+    public StandardPersister(Class<D> aDataType, Serializer aSerializer) {
+        dataType = aDataType;
+        serializer = aSerializer;
+    }
+
+    @Override
+    public void serialize(OutputStream out, D entity) {
+        try {
+            serializer.serialize(entity).with(getConverter()).to( out );
+        } catch ( IOException e ) {
+            // TODO: Handle this
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public D deserialize(InputStream in) {
+      return (D)serializer
+              .deserialize(dataType)
+              .with(getConverter())
+              .from(in);
+    }
+
+    private Converter getConverter() {
+        if (converter == null) {
+            String name = dataType.getName();
+            Schematizer s = new StandardSchematizer();
+            s.schematize(name, dataType).get(name);
+            converter = s.converterFor(name);
+        }
+
+        return converter;
+    }
+}

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/impl/StandardPersister.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java
 (added)
+++ 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) OSGi Alliance (2016). All Rights Reserved.
+ * 
+ * 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.
+ */
+
+/**
+ * Persister Package Version 1.0.
+ * 
+ * @author $Id$
+ */
+@org.osgi.annotation.versioning.Version("1.0")
+package org.apache.felix.persister;
\ No newline at end of file

Propchange: 
felix/trunk/converter/persister/src/main/java/org/apache/felix/persister/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java
 (added)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,85 @@
+/*
+ * 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.felix.persister.impl;
+
+
+import org.apache.felix.serializer.impl.json.JsonSerializerImpl;
+import org.apache.felix.persister.Persister;
+import org.apache.felix.persister.PersisterFactory;
+import org.apache.felix.persister.test.backend.Persistence;
+import org.apache.felix.persister.test.inmemory.MockInMemoryPersistence;
+import org.apache.felix.persister.test.objects.Bottom;
+import org.apache.felix.persister.test.objects.SimpleMiddle;
+import org.apache.felix.persister.test.objects.SimpleTop;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.serializer.Serializer;
+
+import static org.junit.Assert.*;
+
+public class InMemoryPersisterTest {
+    private PersisterFactory factory;
+
+    @Before
+    public void setUp() {
+        Serializer serializer = new JsonSerializerImpl();
+        factory = new PersisterFactoryService(serializer);
+    }
+
+    @After
+    public void tearDown() {
+        factory = null;
+    }
+
+    @Test
+    public void testInMemoryPersister() {
+        Persister<SimpleTop.SimpleTopDTO> persister = 
factory.newPersister(SimpleTop.SimpleTopDTO.class);
+        Persistence<SimpleTop.SimpleTopDTO> p = new 
MockInMemoryPersistence<>(persister);
+        SimpleTop.SimpleTopDTO top = newMockSimpleTop();
+        p.put(top.id, top);
+        SimpleTop.SimpleTopDTO result = p.get(top.id);
+
+        assertEquals(top.id,result.id);
+        assertEquals(top.value1,result.value1);
+        assertEquals(top.value2,result.value2);
+        assertEquals(top.embedded.id,result.embedded.id);
+        assertEquals(top.embedded.value,result.embedded.value);
+        assertEquals(top.embedded.embedded.id,result.embedded.embedded.id);
+        assertEquals(top.embedded.embedded.cul,result.embedded.embedded.cul);
+    }
+
+    private SimpleTop.SimpleTopDTO newMockSimpleTop() {
+        SimpleTop.SimpleTopDTO top = new SimpleTop.SimpleTopDTO();
+        top.id = "TOP";
+        top.value1 = "top-value1";
+        top.value2 = "top-value2";
+
+        SimpleMiddle.SimpleMiddleDTO mid = new SimpleMiddle.SimpleMiddleDTO();
+        mid.id = "MID";
+        mid.value = "mid-value";
+
+        Bottom.BottomDTO bum = new Bottom.BottomDTO();
+        bum.id = "BUM";
+        bum.cul = "moncul";
+
+        mid.embedded = bum;
+        top.embedded = mid;
+
+        return top;
+    }
+}

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/impl/InMemoryPersisterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java
 Sun Aug  6 02:12:50 2017
@@ -14,23 +14,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects;
+package org.apache.felix.persister.test.backend;
 
 import java.util.List;
-import java.util.Optional;
+import java.util.Map;
 
-import org.apache.felix.serializer.test.prevayler.Repository;
+/**
+ * Represents the interface to some persistence mechanism, such as 
+ * a generic Repository, Datastore, or Database.
+ * It could be a key/value store, or something else, and the actual methods
+ * exposed may be different. But in any case we consider some basic CRUD 
+ * operations, which will require serialization and of course deserialization.
+ */
+public interface Persistence<E> {
 
-public interface SimpleManager
-{
     List<String> keys();
-    List<SimpleTop> list();
-    Optional<SimpleTop> get( String key );
 
-    void add( SimpleTop top );
-    void delete( String key );
-    void clear();
+    List<E> list();
+
+    E get(String key);
+
+    int size();
 
-    // This is only for testing. It would normally not be part of an API.
-    Repository<SimpleTop> repository();
+    void put(String key, E entity);
+
+    void putAll(Map<String, E> entityMap);
+
+    void remove(String key);
+
+    void clear();
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/backend/Persistence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java
 (added)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,99 @@
+/*
+ * 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.felix.persister.test.inmemory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.felix.persister.Persister;
+import org.apache.felix.persister.test.backend.Persistence;
+
+public class MockInMemoryPersistence<E> implements Persistence<E> {
+
+    private final Map<String, String> store = new HashMap<>();
+    private final Persister<E> persister;
+
+    public MockInMemoryPersistence(Persister<E> aPersister) {
+        persister = aPersister;
+    }
+
+    @Override
+    public List<String> keys() {
+        return store.keySet().stream()
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<E> list() {
+        return store.values().stream()
+                .map(s -> deserialize(s))
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public E get( String key ) {
+        return deserialize(store.get(key));
+    }
+
+    @Override
+    public int size() {
+        return store.size();
+    }
+
+    @Override
+    public void put(String key, E entity) {
+        store.put(key, serialize(entity));
+    }
+
+    @Override
+    public void putAll(Map<String, E> entityMap) {
+        entityMap.entrySet().stream()
+            .forEach(e -> store.put(e.getKey(),null));
+    }
+
+    @Override
+    public void remove(String key) {
+        store.remove(key);
+    }
+
+    @Override
+    public void clear() {
+        store.clear();
+    }
+
+    private E deserialize(String json) {
+        InputStream in = new 
ByteArrayInputStream(json.getBytes(Charset.forName("UTF-8")));
+        return persister.deserialize( in );
+    }
+
+    private String serialize(E entity) {
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            persister.serialize(out, entity);
+            return out.toString("UTF-8");
+        } catch ( UnsupportedEncodingException e ) {
+            return "ERROR";
+        }
+    }
+}

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/inmemory/MockInMemoryPersistence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/CommandDTO.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/CommandDTO.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/CommandDTO.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java
 Sun Aug  6 02:12:50 2017
@@ -14,12 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.prevayler;
+package org.apache.felix.persister.test.objects;
 
 import org.osgi.dto.DTO;
 
-public abstract class CommandDTO<E>
-    extends DTO
-{
-    public Command command;
+public interface Bottom {
+    String id();
+    String cul();
+
+    public static class BottomDTO extends DTO {
+        public String id;
+        public String cul;
+    }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Bottom.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java
 Sun Aug  6 02:12:50 2017
@@ -14,25 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects;
+package org.apache.felix.persister.test.objects;
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Optional;
 
-import org.apache.felix.serializer.test.prevayler.Repository;
-
-public interface ComplexManager
-{
+public interface ComplexManager {
     List<String> keys();
     List<ComplexTop> list();
-    Optional<ComplexTop> get( String key );
+    ComplexTop get(String key);
 
-    void add( ComplexTop top );
-    void addAll( Collection<ComplexTop> tops );
-    void delete( String key );
+    void add(ComplexTop top);
+    void addAll(Collection<ComplexTop> tops);
+    void delete(String key);
     void clear();
 
-    // This is only for testing. It would normally not be part of an API.
-    Repository<ComplexTop> repository();
+//    // This is only for testing. It would normally not be part of an API.
+//    Repository<ComplexTop> repository();
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java
 Sun Aug  6 02:12:50 2017
@@ -14,12 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects;
+package org.apache.felix.persister.test.objects;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
-public interface ComplexMiddle
-    extends Middle
-{
-    Collection<Bottom> getEmbeddedValue();
+import org.apache.felix.persister.test.objects.Bottom.BottomDTO;
+import org.osgi.dto.DTO;
+
+public interface ComplexMiddle extends Middle {
+    Collection<Bottom> embeddedValue();
+
+    public static class ComplexMiddleDTO extends DTO {
+        public String id;
+        public String value;
+        public List<BottomDTO> embedded = new ArrayList<>();
+    }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexMiddle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/ClearCommand.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/ClearCommand.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/ClearCommand.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java
 Sun Aug  6 02:12:50 2017
@@ -14,24 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.prevayler;
+package org.apache.felix.persister.test.objects;
 
-import java.util.Date;
-import java.util.Map;
-import java.util.Optional;
+import org.apache.felix.persister.test.objects.ComplexMiddle.ComplexMiddleDTO;
+import org.osgi.dto.DTO;
 
-public class ClearCommand<E>
-    extends CommandDTO<E>
-{
-    public ClearCommand()
-    {
-        this.command = Command.clear;
-    }
+public interface ComplexTop {
+       String id();
+    String directValue();
+    String calculatedValue();
+    ComplexMiddle embeddedValue();
 
-    public Optional<Exception> executeAndQuery( Map<String, E> 
prevalentSystem, Date executionTime )
-                    throws Exception
-    {
-        prevalentSystem.clear();
-        return Optional.empty();
+    public static class ComplexTopDTO extends DTO {
+        public String id;
+        public String value1;
+        public String value2;
+        public ComplexMiddleDTO embedded;
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/ComplexTop.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java
 Sun Aug  6 02:12:50 2017
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects;
+package org.apache.felix.persister.test.objects;
 
-public interface Bottom
-{
-    String getId();
-    String getBum();
+public interface Middle {
+    String id();
+    String value();
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/Middle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Repository.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Repository.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/Repository.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java
 Sun Aug  6 02:12:50 2017
@@ -14,26 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.prevayler;
+package org.apache.felix.persister.test.objects;
 
 import java.util.List;
-import java.util.Map;
-import java.util.Optional;
 
-public interface Repository<E> {
+public interface SimpleManager {
     List<String> keys();
+    List<SimpleTop> list();
+    SimpleTop get(String key);
 
-    List<E> list();
-
-    Optional<E> get(String key);
-
-    int size();
-
-    void put(String key, E entity);
-
-    void putAll(Map<String, E> entityMap);
-
-    void remove(String key);
-
+    void add(SimpleTop top);
+    void delete(String key);
     void clear();
+
+//    // This is only for testing. It would normally not be part of an API.
+//    Repository<SimpleTop> repository();
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java
 Sun Aug  6 02:12:50 2017
@@ -14,25 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects;
 
-import org.apache.felix.serializer.test.objects.Bottom;
+import org.apache.felix.persister.test.objects.Bottom.BottomDTO;
 import org.osgi.dto.DTO;
 
-public class BottomEntity
-    extends DTO
-       implements Bottom
-{
-       public String id;
-       public String bum;
+public interface SimpleMiddle extends Middle {
+    Bottom embeddedValue();
 
-    public String getId()
-    {
-        return id;
-    }
-
-    public String getBum()
-    {
-        return bum;
+    public static class SimpleMiddleDTO extends DTO {
+        public String id;
+        public String value;
+        public BottomDTO embedded;
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleMiddle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleMiddleEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleMiddleEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleMiddleEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java
 Sun Aug  6 02:12:50 2017
@@ -14,19 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects;
 
-import org.apache.felix.serializer.test.objects.SimpleMiddle;
+import org.apache.felix.persister.test.objects.SimpleMiddle.SimpleMiddleDTO;
+import org.osgi.dto.DTO;
 
+public interface SimpleTop {
+    String id();
+    String directValue();
+    String calculatedValue();
+    Middle embeddedValue();
 
-public class SimpleMiddleEntity
-       extends AbstractMiddleEntity
-    implements SimpleMiddle
-{
-       public BottomEntity embeddedValue;
-
-    public BottomEntity getEmbeddedValue()
-    {
-        return embeddedValue;
+    public static class SimpleTopDTO extends DTO {
+        public String id;
+        public String value1;
+        public String value2;
+        public SimpleMiddleDTO embedded;
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/SimpleTop.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java
 Sun Aug  6 02:12:50 2017
@@ -14,25 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects.provider;
 
-import org.apache.felix.serializer.test.objects.Middle;
-import org.osgi.dto.DTO;
+import org.apache.felix.persister.test.objects.Bottom;
 
-public class AbstractMiddleEntity
-    extends DTO
-       implements Middle
-{
-    public String id;
-    public String someValue;
+public class BottomEntity extends Bottom.BottomDTO implements Bottom {
 
-    public String getId()
-    {
+    public BottomEntity(BottomDTO dto) {
+        this.id = dto.id;
+        this.cul = dto.cul;
+    }
+
+    public String id() {
         return id;
     }
 
-    public String getSomeValue()
-    {
-        return someValue;
+    public String cul() {
+        return cul;
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/BottomEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java
 Sun Aug  6 02:12:50 2017
@@ -14,30 +14,32 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects.provider;
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Optional;
 import java.util.stream.Collectors;
 
-import org.apache.felix.serializer.test.objects.ComplexManager;
-import org.apache.felix.serializer.test.objects.ComplexTop;
-import 
org.apache.felix.serializer.test.prevayler.MockPrevaylerBackedRepository;
-import org.apache.felix.serializer.test.prevayler.Repository;
-
-public class ComplexManagerService
-       implements ComplexManager
-{
-    private final Repository<ComplexTopEntity> repository;
+import org.apache.felix.persister.test.backend.Persistence;
+import org.apache.felix.persister.test.objects.ComplexManager;
+import org.apache.felix.persister.test.objects.ComplexTop;
+
+/**
+ * Represents a service or perhaps a domain aggregate or service that
+ * acts on the entity to be persisted. In this example the persistence 
mechanism
+ * is injected directly into this service.
+ */
+public class ComplexManagerService implements ComplexManager {
+
+    private final Persistence<ComplexTopEntity> persistence;
 
-    public ComplexManagerService() {
-        repository = new 
MockPrevaylerBackedRepository<>(ComplexTopEntity.class);
+    public ComplexManagerService(Persistence<ComplexTopEntity> aBackend) {
+        persistence = aBackend;
     }
 
     @Override
        public void add(ComplexTop top) {
-        repository.put(top.getId(), (ComplexTopEntity)top);
+        persistence.put(top.id(), (ComplexTopEntity)top);
        }
 
        @Override
@@ -47,33 +49,27 @@ public class ComplexManagerService
 
        @Override
     public List<String> keys() {
-        return repository.keys();
+        return persistence.keys();
     }
 
     @Override
        public List<ComplexTop> list()
        {
-           return repository.list().stream().map(e -> 
e).collect(Collectors.toList());
+           return persistence.list().stream().map(e -> 
e).collect(Collectors.toList());
        }
 
        @Override
-       public Optional<ComplexTop> get(String key) {
-               return Optional.of( repository.get( key ).get() );
+       public ComplexTop get(String key) {
+               return persistence.get(key);
        }
 
     @Override
        public void delete(String key) {
-        repository.remove(key);
+        persistence.remove(key);
        }
 
        @Override
        public void clear() {
-           repository.clear();
+           persistence.clear();
        }
-
-    @SuppressWarnings( { "unchecked", "rawtypes" } )
-    @Override
-    public Repository<ComplexTop> repository() {
-        return (Repository)repository;
-    }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexManagerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleTopEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleTopEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleTopEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java
 Sun Aug  6 02:12:50 2017
@@ -14,35 +14,36 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects.provider;
 
-import org.apache.felix.serializer.test.objects.Middle;
-import org.apache.felix.serializer.test.objects.SimpleTop;
-import org.osgi.dto.DTO;
-
-public class SimpleTopEntity
-    extends DTO
-       implements SimpleTop
-{
-    public String id;
-    public String value;
-    public SimpleMiddleEntity embeddedValue;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import org.apache.felix.persister.test.objects.Bottom;
+import org.apache.felix.persister.test.objects.ComplexMiddle;
+
+public class ComplexMiddleEntity extends ComplexMiddle.ComplexMiddleDTO 
implements ComplexMiddle {
+
+    public ComplexMiddleEntity(ComplexMiddleDTO dto) {
+        this.id = dto.id;
+        this.value = dto.value;
+        this.embedded = dto.embedded;
+    }
 
     @Override
-    public String getId()
-    {
+    public String id() {
         return id;
     }
 
     @Override
-    public String getValue()
-    {
+    public String value() {
         return value;
     }
 
     @Override
-    public Middle getEmbeddedValue()
-    {
-        return embeddedValue;
+    public Collection<Bottom> embeddedValue() {
+        return embedded.stream()
+                .map(e -> new BottomEntity(e))
+                .collect(Collectors.toList());
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexMiddleEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexTopEntity.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexTopEntity.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexTopEntity.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/ComplexTopEntity.java
 Sun Aug  6 02:12:50 2017
@@ -14,35 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects.provider;
 
-import org.apache.felix.serializer.test.objects.ComplexMiddle;
-import org.apache.felix.serializer.test.objects.ComplexTop;
-import org.osgi.dto.DTO;
-
-public class ComplexTopEntity
-    extends DTO
-       implements ComplexTop
-{
-       public String id;
-    public String value;
-    public ComplexMiddleEntity embeddedValue;
+import org.apache.felix.persister.test.objects.ComplexMiddle;
+import org.apache.felix.persister.test.objects.ComplexTop;
+
+public class ComplexTopEntity extends ComplexTop.ComplexTopDTO implements 
ComplexTop {
+
+    public ComplexTopEntity(ComplexTopDTO dto) {
+        this.id = dto.id;
+        this.value1 = dto.value1;
+        this.value2 = dto.value2;
+        this.embedded = dto.embedded;
+    }
 
     @Override
-    public String getId()
-    {
+    public String id() {
         return id;
     }
 
     @Override
-    public String getValue()
-    {
-        return value;
+    public String directValue() {
+        return value1;
+    }
+
+    @Override
+    public String calculatedValue() {
+        return value2 == null ? null : value2.toUpperCase();
     }
 
     @Override
-    public ComplexMiddle getEmbeddedValue()
-    {
-        return embeddedValue;
+    public ComplexMiddle embeddedValue() {
+        return new ComplexMiddleEntity(embedded);
     }
 }

Added: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java?rev=1804217&view=auto
==============================================================================
--- 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java
 (added)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java
 Sun Aug  6 02:12:50 2017
@@ -0,0 +1,68 @@
+/*
+ * 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.felix.persister.test.objects.provider;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.felix.persister.test.backend.Persistence;
+import org.apache.felix.persister.test.objects.SimpleManager;
+import org.apache.felix.persister.test.objects.SimpleTop;
+
+/**
+ * Represents a service or perhaps a domain aggregate or service that
+ * acts on the entity to be persisted. In this example the persistence 
mechanism
+ * is injected directly into this service.
+ */
+public class SimpleManagerService implements SimpleManager {
+
+       private final Persistence<SimpleTopEntity> persistence;
+
+       public SimpleManagerService(Persistence<SimpleTopEntity> aBackend) {
+           persistence = aBackend;
+    }
+
+       @Override
+       public void add(SimpleTop top) {
+        persistence.put(top.id(), (SimpleTopEntity)top);
+       }
+
+       @Override
+    public List<String> keys() {
+        return persistence.keys();
+    }
+
+    @Override
+       public List<SimpleTop> list() {
+           return persistence.list().stream().collect(Collectors.toList());
+       }
+
+       @Override
+       public SimpleTop get(String key) {
+           return persistence.get(key);
+       }
+
+       @Override
+       public void delete(String key) {
+        persistence.remove(key);
+       }
+
+       @Override
+       public void clear() {
+        persistence.clear();
+       }
+}

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleManagerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java
 Sun Aug  6 02:12:50 2017
@@ -14,35 +14,31 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.objects.provider;
+package org.apache.felix.persister.test.objects.provider;
 
-import org.apache.felix.serializer.test.objects.ComplexMiddle;
-import org.apache.felix.serializer.test.objects.ComplexTop;
-import org.osgi.dto.DTO;
-
-public class ComplexTopEntity
-    extends DTO
-       implements ComplexTop
-{
-       public String id;
-    public String value;
-    public ComplexMiddleEntity embeddedValue;
+import org.apache.felix.persister.test.objects.Bottom;
+import org.apache.felix.persister.test.objects.SimpleMiddle;
+
+public class SimpleMiddleEntity extends SimpleMiddle.SimpleMiddleDTO 
implements SimpleMiddle {
+
+    public SimpleMiddleEntity(SimpleMiddleDTO dto) {
+        this.id = dto.id;
+        this.value = dto.value;
+        this.embedded = dto.embedded;
+    }
 
     @Override
-    public String getId()
-    {
+    public String id() {
         return id;
     }
 
     @Override
-    public String getValue()
-    {
+    public String value() {
         return value;
     }
 
     @Override
-    public ComplexMiddle getEmbeddedValue()
-    {
-        return embeddedValue;
+    public Bottom embeddedValue() {
+        return new BottomEntity(embedded);
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleMiddleEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java
 (from r1804216, 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/SerializerAdapter.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java?p2=felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java&p1=felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/SerializerAdapter.java&r1=1804216&r2=1804217&rev=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/SerializerAdapter.java
 (original)
+++ 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java
 Sun Aug  6 02:12:50 2017
@@ -14,35 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.serializer.test.prevayler;
+package org.apache.felix.persister.test.objects.provider;
 
-import java.io.InputStream;
-import java.io.OutputStream;
+import org.apache.felix.persister.test.objects.Middle;
+import org.apache.felix.persister.test.objects.SimpleTop;
 
-public class SerializerAdapter
-    implements MockPrevaylerSerializer
-{
-    private final DTOSerializer<CommandDTO<?>> delegate;
-
-    public SerializerAdapter( DTOSerializer<CommandDTO<?>> aDelegate )
-    {
-        delegate = aDelegate;
+public class SimpleTopEntity extends SimpleTop.SimpleTopDTO implements 
SimpleTop {
+
+    public SimpleTopEntity(SimpleTopDTO dto) {
+        this.id = dto.id;
+        this.value1 = dto.value1;
+        this.value2 = dto.value2;
+        this.embedded = dto.embedded;
+    }
+
+    @Override
+    public String id() {
+        return id;
     }
 
     @Override
-    public Object readObject( InputStream in )
-            throws Exception
-    {
-        return delegate.deserialize( in );
+    public String directValue() {
+        return value1;
     }
 
     @Override
-    public void writeObject( OutputStream out, Object object )
-            throws Exception
-    {
-        if( !( object instanceof CommandDTO ))
-            throw new ClassCastException( "Cannot cast " + object.getClass() + 
" to CommandDTO" );
+    public String calculatedValue() {
+        return value2 == null ? null : value2.toUpperCase();
+    }
 
-        delegate.serialize( out, (CommandDTO<?>)object );
+    @Override
+    public Middle embeddedValue() {
+        return new SimpleMiddleEntity(embedded);
     }
 }

Propchange: 
felix/trunk/converter/persister/src/test/java/org/apache/felix/persister/test/objects/provider/SimpleTopEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: felix/trunk/converter/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/pom.xml?rev=1804217&r1=1804216&r2=1804217&view=diff
==============================================================================
--- felix/trunk/converter/pom.xml (original)
+++ felix/trunk/converter/pom.xml Sun Aug  6 02:12:50 2017
@@ -41,5 +41,6 @@
         <module>converter</module>
         <module>serializer</module>
         <module>schematizer</module>
+        <module>persister</module>
     </modules>
 </project>

Modified: 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java?rev=1804217&r1=1804216&r2=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
 (original)
+++ 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
 Sun Aug  6 02:12:50 2017
@@ -237,7 +237,7 @@ public class SchematizerImpl implements
                         node.add(childNodes);
                     }
                 }
-                else if (asDTO(fieldClass)) {
+                else if (asDTO(fieldClass) || Util.isDTOType(fieldClass)) {
 //                    newSchematizer.typeRules.put(path, rules);
 //                    if (!rules.containsKey(path))
 //                        newSchematizer.rule(path, path, fieldClass);

Modified: 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java?rev=1804217&r1=1804216&r2=1804217&view=diff
==============================================================================
--- 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java
 (original)
+++ 
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java
 Sun Aug  6 02:12:50 2017
@@ -225,7 +225,7 @@ public class Util {
     public static Map<String, NodeImpl> extractChildren(String path, 
Map<String, NodeImpl> allNodes) {
         final Map<String, NodeImpl> children = new HashMap<>();
         for (String key : allNodes.keySet()) {
-            String newKey = key.replace(path, "");
+            String newKey = key.replaceFirst(path, "");
             if (!newKey.substring(1).contains("/"))
                 children.put( newKey, allNodes.get(key));
         }


Reply via email to