move this module to a better place

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk@1446702 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modello-plugin-redback-registry/pom.xml b/modello-plugin-redback-registry/pom.xml
new file mode 100644
index 0000000..3344f5c
--- /dev/null
+++ b/modello-plugin-redback-registry/pom.xml
@@ -0,0 +1,193 @@
+<?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 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">
+  <parent>
+    <groupId>org.apache.archiva.redback.components.modello</groupId>
+    <artifactId>modello-plugins</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>modello-plugin-redback-registry</artifactId>
+  <name>Redback Registry Reader/Writer</name>
+
+  <url>http://archiva.apache.org/redback/components/spring-registry/${project.artifactId}</url>
+
+  <distributionManagement>
+    <site>
+      <id>apache.website</id>
+      <url>file://${user.home}/redback-components-site-deploy/spring-registry/${project.artifactId}</url>
+    </site>
+  </distributionManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.archiva.redback.components.modello</groupId>
+      <artifactId>modello-plugin-store</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-component-api</artifactId>
+        </exclusion>
+      </exclusions>      
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.modello</groupId>
+      <artifactId>modello-test</artifactId>
+      <version>${modelloVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.modello</groupId>
+      <artifactId>modello-core</artifactId>
+      <version>${modelloVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.modello</groupId>
+      <artifactId>modello-plugin-java</artifactId>
+      <version>${modelloVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva.redback.components.registry</groupId>
+      <artifactId>spring-registry-api</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva.redback.components.registry</groupId>
+      <artifactId>spring-registry-commons</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-component-api</artifactId>
+      <version>1.0-alpha-33</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-33</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-compiler-api</artifactId>
+      <version>2.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-compiler-javac</artifactId>
+      <version>2.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- dependencies needed by AbstractRegistryGeneratorTestCase -->
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4jVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+      <version>${commons-configuration.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging-api</artifactId>
+      <version>1.0.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+      <version>2.9.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <registryVersion>${project.version}</registryVersion>
+            <slf4jVersion>${slf4jVersion}</slf4jVersion>
+            <springVersion>${springVersion}</springVersion>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>2.1</version>
+        <executions>
+          <execution>
+            <id>copy-test-libs</id>
+            <phase>process-test-resources</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.directory}/test-libs</outputDirectory>
+              <excludeTransitive>false</excludeTransitive>
+              <stripVersion>true</stripVersion>
+              <includeScope>test</includeScope>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
new file mode 100644
index 0000000..8205943
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
@@ -0,0 +1,60 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.components.modello.plugin.store.AbstractVelocityModelloGenerator;
+import org.apache.velocity.context.Context;
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.model.Model;
+
+import java.util.Properties;
+
+public abstract class AbstractRegistryGenerator
+    extends AbstractVelocityModelloGenerator
+{
+    protected void generate( Model model, Properties parameters, String outputType )
+        throws ModelloException
+    {
+        initialize( model, parameters );
+
+        // Initialize the Velocity context
+
+        String packageName;
+        if ( isPackageWithVersion() )
+        {
+            packageName = model.getDefaultPackageName( true, getGeneratedVersion() );
+        }
+        else
+        {
+            packageName = model.getDefaultPackageName( false, null );
+        }
+
+        packageName += ".io.registry";
+
+        Context context = makeStubVelocityContext( model, getGeneratedVersion(), packageName );
+
+
+        // Generate the reader
+        String className = model.getName() + outputType;
+
+        writeClass( getClass().getPackage().getName().replaceAll( "\\.", "/" ) + "/" + outputType + ".java.vm",
+                    getOutputDirectory(), packageName, className, context );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGenerator.java b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGenerator.java
new file mode 100644
index 0000000..e6974fd
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGenerator.java
@@ -0,0 +1,39 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.model.Model;
+
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryReaderGenerator
+    extends AbstractRegistryGenerator
+{
+    public void generate( Model model, Properties parameters )
+        throws ModelloException
+    {
+        generate( model, parameters, "RegistryReader" );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGenerator.java b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGenerator.java
new file mode 100644
index 0000000..d051370
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGenerator.java
@@ -0,0 +1,39 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.model.Model;
+
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryWriterGenerator
+    extends AbstractRegistryGenerator
+{
+    public void generate( Model model, Properties parameters )
+        throws ModelloException
+    {
+        generate( model, parameters, "RegistryWriter" );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/main/resources/META-INF/plexus/components.xml b/modello-plugin-redback-registry/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..50c8615
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,45 @@
+<?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.
+  -->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>registry-reader</role-hint>
+      <implementation>org.apache.archiva.redback.components.registry.modello.RegistryReaderGenerator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.velocity.VelocityComponent</role>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>registry-writer</role-hint>
+      <implementation>org.apache.archiva.redback.components.registry.modello.RegistryWriterGenerator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.velocity.VelocityComponent</role>
+        </requirement>
+      </requirements>
+    </component>
+  </components>
+</component-set>
diff --git a/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm b/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
new file mode 100644
index 0000000..9bfd6e6
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
@@ -0,0 +1,141 @@
+#*
+ * 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 ${package};
+
+import org.apache.archiva.redback.components.registry.Registry;
+
+// Util imports
+import java.util.*;
+
+// Model class imports
+#foreach ( $class in $classes )
+#if ( ${class.packageName} != ${package} )
+import ${class.packageName}.${class.name};
+#end
+#end
+
+## TODO! make it possible to change property name via metadata
+## TODO! handle other types
+
+#macro ( handlePrimitive $localVar $registryVar $name $type $getter )
+#if ( $type == "boolean" )
+        $type $localVar = ${registryVar}.getBoolean( prefix + "${name}", $getter );
+#elseif ( $type == "char" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "double" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "float" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "int" )
+    $type $localVar = ${registryVar}.getInt( prefix + "${name}", $getter );
+#elseif ( $type == "long" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "short" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "String" )
+    //$type $localVar = ${registryVar}.getString( prefix + "${name}", $getter );
+
+    List<String> ${localVar}List = registry.getList( prefix + "${name}" );
+    String ${name} = $getter;
+    if (${localVar}List != null && !${localVar}List.isEmpty() )
+    {
+        StringBuilder sb = new StringBuilder(  );
+        for (int i = 0,size = ${localVar}List.size();i<size;i++)
+        {
+            sb.append( ${localVar}List.get( i ) );
+            if (i<size - 1)
+            {
+                sb.append( ',' );
+            }
+        }
+        ${name} = sb.toString();
+    }
+
+#elseif ( $type == "Boolean" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "Date" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "DOM" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#else
+    $javaTool.fail( "Unknown type: $type" )
+#end
+#end
+
+#macro ( fillCollection $uncapFieldName $to )
+#set ( $singularFieldName = $javaTool.singular($uncapFieldName) )
+#if ( $model.hasClass( $to, $version ) )
+## TODO! make it possible to have unwrapped lists via metadata
+        List ${uncapFieldName}Subsets = registry.getSubsetList( prefix + "${uncapFieldName}.${singularFieldName}" );
+        for ( Iterator i = ${uncapFieldName}Subsets.iterator(); i.hasNext(); )
+        {
+            $to v = read${to}( "", (Registry) i.next() );
+            ${uncapFieldName}.add( v );
+        }
+#else
+        ${uncapFieldName}.addAll( registry.getList( prefix + "${uncapFieldName}.${singularFieldName}" ) );
+#end
+#end
+
+/**
+ * Generate Redback Registry input mechanism for model '${model.name}'.
+ */
+public class ${model.name}RegistryReader
+{
+    public ${model.name} read( Registry registry )
+    {
+#set ( $root = $model.getClass( $model.getRoot( $version ), $version ) )
+        return read${root.name}( "", registry );
+    }
+
+#foreach ( $class in $classes )
+    private ${class.name} read${class.name}( String prefix, Registry registry )
+    {
+        ${class.name} value = new ${class.name}();
+
+#foreach ( $field in $class.getAllFields( $version, true ) )
+## TODO: handle aliases
+## TODO: handle required (and optional for those that cry when the registry item is not found)
+#set ( $uncapFieldName = $javaTool.uncapitalise($field.name) )
+#if ( $field.primitive )
+#handlePrimitive( $uncapFieldName "registry" $field.name $field.type "value.${javaTool.makeGetter( $field )}()" )
+#else
+#set ( $assoc = $field )
+#if ( $assoc.multiplicity == "1" )
+        $assoc.to $uncapFieldName = read${assoc.to}( prefix + "${uncapFieldName}.", registry );
+#else
+#if ( $assoc.type == "java.util.List" || $assoc.type == "java.util.Set" )
+        $assoc.type $uncapFieldName = $assoc.defaultValue;
+#fillCollection( $uncapFieldName $assoc.to )
+#elseif ( $assoc.type == "java.util.Map" || $assoc.type == "java.util.Properties" )
+## TODO! make it possible to have exploded maps in xml via metadata
+        $assoc.type $uncapFieldName = registry.getProperties( prefix + "${uncapFieldName}" );
+#else
+    $javaTool.fail( "Unknown collection type: $assoc.type" )
+#end
+#end
+#end
+        value.${javaTool.makeSetter( $field )}( $uncapFieldName );
+#end
+
+        return value;
+    }
+    
+#end
+}
diff --git a/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryWriter.java.vm b/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryWriter.java.vm
new file mode 100644
index 0000000..f3abc55
--- /dev/null
+++ b/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryWriter.java.vm
@@ -0,0 +1,161 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
+package ${package};
+
+import org.apache.archiva.redback.components.registry.Registry;
+
+// Util imports
+import java.util.*;
+
+// Model class imports
+#foreach ( $class in $classes )
+#if ( ${class.packageName} != ${package} )
+import ${class.packageName}.${class.name};
+#end
+#end
+
+## TODO! make it possible to change property name via metadata
+## TODO! handle other types
+
+#macro ( writePrimitive $type $value $name )
+#if ( $type == "boolean" )
+                registry.setBoolean( prefix + $name, $value );
+#elseif ( $type == "char" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "double" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "float" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "int" )
+                registry.setInt( prefix + $name, $value );
+#elseif ( $type == "long" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "short" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "String" )
+                registry.setString( prefix + $name, $value );
+#elseif ( $type == "Boolean" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "Date" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#elseif ( $type == "DOM" )
+    $javaTool.fail( "Type not yet handled: $type" )
+#else
+    $javaTool.fail( "Unknown type: $type" )
+#end
+#end
+
+#macro ( writeValueChecker $type $value $field )
+#if ( $type == "double" || $type == "float" || $type == "int" || $type == "long" || $type == "short" )
+$value != $field.defaultValue
+#elseif ( $type == "boolean" )
+
+#elseif ( $type == "char" )
+$value != '$field.defaultValue'
+#elseif ( $type == "java.util.List" || $type == "java.util.Set" || $type == "java.util.Map" || $type == "java.util.Properties" )
+$value != null && ${value}.size() > 0
+#elseif ( $type == "String" && $field.defaultValue )
+$value != null && !${value}.equals( "$field.defaultValue" )
+#elseif ( $type == "Date" && $field.defaultValue )
+$value != null && !${value}.equals( "$field.defaultValue" )
+#else
+$value != null
+#end
+#end
+
+/**
+ * Generate Plexus Registry output mechanism for model '${model.name}'.
+ */
+public class ${model.name}RegistryWriter
+{
+    public void write( ${model.name} model, Registry registry )
+    {
+#set ( $root = $model.getClass( $model.getRoot( $version ), $version ) )
+        write${root.name}( "", model, registry );
+    }
+
+#foreach ( $class in $classes )
+    private void write${class.name}( String prefix, ${class.name} value, Registry registry )
+    {
+        if ( value != null )
+        {
+#foreach ( $field in $class.getAllFields( $version, true ) )
+#set ( $uncapFieldName = $javaTool.uncapitalise($field.name) )
+#set ( $value = "value.${javaTool.makeGetter( $field )}()" )
+#if ( $field.primitive )
+      #if ($field.type != "boolean")
+            if ( #writeValueChecker( $field.type $value $field ) )
+            {
+      #end
+                String $uncapFieldName = "$uncapFieldName";
+#writePrimitive( $field.type $value $uncapFieldName )
+      #if ($field.type != "boolean")
+            }
+      #end
+#else
+#set ( $assoc = $field )
+#if ( $assoc.multiplicity == "1" )
+            if ( #writeValueChecker( $field.type $value $field ) )
+            {
+                write${assoc.to}( prefix + "${uncapFieldName}.", $value, registry );
+            }
+#else
+            if ( #writeValueChecker( $assoc.type $value $field ) )
+            {
+#if ( $assoc.type == "java.util.List" || $assoc.type == "java.util.Set" )
+## TODO! make it possible to have unwrapped lists via metadata
+                registry.removeSubset( prefix + "${uncapFieldName}" );
+
+                int count = 0;
+                for ( Iterator iter = ${value}.iterator(); iter.hasNext(); count++ )
+                {
+#set ( $singularFieldName = $javaTool.singular($uncapFieldName) )
+                    String name = "${uncapFieldName}.${singularFieldName}(" + count + ")";
+#if ( $model.hasClass( $assoc.to, $version ) )
+                    $assoc.to o = ( $assoc.to ) iter.next();
+                    write${assoc.to}( prefix + name + ".", o, registry );
+#else
+                    $assoc.to $singularFieldName = ( $assoc.to ) iter.next();
+    #writePrimitive( $assoc.to $singularFieldName "name" )
+#end
+                }
+#elseif ( $assoc.type == "java.util.Map" || $assoc.type == "java.util.Properties" )
+## TODO! make it possible to have exploded maps in xml via metadata
+## TODO! make it possible to have unwrapped lists via metadata
+                registry.removeSubset( prefix + "${uncapFieldName}" );
+                
+                for ( Iterator iter = ${value}.keySet().iterator(); iter.hasNext(); )
+                {
+                    String key = (String) iter.next();
+                    String v = (String) ${value}.get( key );
+
+                    registry.setString( prefix + "${uncapFieldName}." + key, v );
+                }
+#else
+    $javaTool.fail( "Unknown collection type: $assoc.type" )
+#end
+            }
+#end
+#end
+#end
+        }
+    }
+    
+#end    
+}
\ No newline at end of file
diff --git a/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
new file mode 100644
index 0000000..b3ae073
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
@@ -0,0 +1,157 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.modello.AbstractModelloJavaGeneratorTest;
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.core.ModelloCore;
+import org.codehaus.modello.model.Model;
+import org.codehaus.modello.model.ModelValidationException;
+import org.codehaus.plexus.compiler.CompilerConfiguration;
+import org.codehaus.plexus.compiler.CompilerException;
+import org.codehaus.plexus.compiler.CompilerMessage;
+import org.codehaus.plexus.compiler.javac.JavacCompiler;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.ReaderFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+public abstract class AbstractRegistryGeneratorTestCase
+    extends AbstractModelloJavaGeneratorTest
+{
+    public AbstractRegistryGeneratorTestCase( String name )
+    {
+        super( name );
+    }
+
+
+
+    protected void prepareTest( String outputType )
+        throws ComponentLookupException, ModelloException, ModelValidationException, IOException, CompilerException
+    {
+        ModelloCore modello = (ModelloCore) container.lookup( ModelloCore.ROLE );
+
+        Model model = modello.loadModel( ReaderFactory.newXmlReader( getTestFile( "src/test/resources/model.mdo" ) ) );
+
+        File generatedSources = getTestFile( "target/" + outputType + "/sources" );
+
+        File classes = getOutputDirectory();
+
+        FileUtils.deleteDirectory( generatedSources );
+
+        FileUtils.deleteDirectory( classes );
+
+        generatedSources.mkdirs();
+
+        classes.mkdirs();
+
+        Properties parameters = new Properties();
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, generatedSources.getAbsolutePath() );
+
+        parameters.setProperty( ModelloParameterConstants.VERSION, "1.0.0" );
+
+        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.toString( false ) );
+
+        modello.generate( model, "java", parameters );
+
+        modello.generate( model, outputType, parameters );
+
+        String registryVersion = System.getProperty( "registryVersion" );
+
+        addDependency( "org.codehaus.modello", "modello-core" );//, getModelloVersion() );
+        addDependency( "org.apache.archiva.redback.components.registry", "spring-registry-api" );//, registryVersion );
+        addDependency( "org.apache.archiva.redback.components.registry",
+                       "spring-registry-commons" );//, registryVersion );
+        addDependency( "org.codehaus.plexus", "plexus-container-default" );//, "1.0-alpha-33" );
+        addDependency( "commons-collections", "commons-collections" );//, "3.1" );
+        addDependency( "commons-configuration", "commons-configuration" );//, "1.8" );
+        addDependency( "commons-lang", "commons-lang" );//, "2.6" );
+        addDependency( "commons-logging", "commons-logging-api" );//, "1.0.4" );
+        addDependency( "org.springframework", "spring-context" );//, System.getProperty( "springVersion" ) );
+        addDependency( "org.codehaus.plexus", "plexus-interpolation" );//, "1.14" );
+        addDependency( "org.slf4j", "slf4j-api" );//, System.getProperty( "slf4jVersion" ) );
+        addDependency( "org.slf4j", "slf4j-simple" );//, System.getProperty( "slf4jVersion" ) );
+
+        if ( "1.5".compareTo( System.getProperty( "java.specification.version" ) ) <= 0 )
+        {
+            // causes a conflict with JDK 1.4 => add this dependency only with JDK 1.5+
+            addDependency( "xerces", "xercesImpl" );//, "2.9.1" );
+        }
+
+        compile( generatedSources, classes );
+    }
+
+    protected void compile( File generatedSources, File destinationDirectory )
+        throws IOException, CompilerException
+    {
+
+        addDependency( "junit", "junit" );//, "3.8.1" );
+
+        addDependency( "org.codehaus.plexus", "plexus-utils" );//, "1.4.5" );
+
+        addDependency( "org.codehaus.modello", "modello-test" );//, getModelloVersion() );
+
+        List<String> classPathElements = new ArrayList<String>( getClasspath().size() + 2 );
+
+        classPathElements.add( getTestPath( "target/classes" ) );
+
+        classPathElements.add( getTestPath( "target/test-classes" ) );
+
+        for ( int i = 0; i < getClasspath().size(); i++ )
+        {
+            classPathElements.add( getClasspath().get( i ).getAbsolutePath() );
+        }
+
+        org.codehaus.plexus.compiler.Compiler compiler = new JavacCompiler();
+
+        CompilerConfiguration configuration = new CompilerConfiguration();
+        configuration.setClasspathEntries( classPathElements );
+        configuration.setSourceLocations(
+            Arrays.asList( getTestPath( "src/test/verifiers/" + getName() ), generatedSources.getAbsolutePath() ) );
+        configuration.setOutputLocation( getOutputClasses().getAbsolutePath() );// destinationDirectory.getAbsolutePath() );
+        configuration.setDebug( true );
+        configuration.setSourceVersion( "1.5" );
+        configuration.setTargetVersion( "1.5" );
+
+        List<CompilerMessage> messages = compiler.performCompile( configuration ).getCompilerMessages();
+
+        int error = 0;
+
+        for ( CompilerMessage message : messages )
+        {
+            System.out.println( message.getFile() + "[" + message.getStartLine() + "," + message.getStartColumn() +
+                                    "]: " + message.getMessage() );
+            if ( message.getKind() == CompilerMessage.Kind.ERROR )
+            {
+                error++;
+            }
+        }
+
+        assertEquals( "There was compilation errors.:" + messages, 0, error );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGeneratorTest.java b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGeneratorTest.java
new file mode 100644
index 0000000..07fb8b6
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryReaderGeneratorTest.java
@@ -0,0 +1,41 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryReaderGeneratorTest
+    extends AbstractRegistryGeneratorTestCase
+{
+    public RegistryReaderGeneratorTest()
+    {
+        super( "registry-reader" );
+    }
+
+    public void testRegistryReader()
+        throws Throwable
+    {
+        prepareTest( "registry-reader" );
+
+        verifyCompiledGeneratedSources( "org.apache.archiva.redback.components.registry.modello.RegistryReaderVerifier" );//, "registry-reader" );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGeneratorTest.java b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGeneratorTest.java
new file mode 100644
index 0000000..3326e70
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/RegistryWriterGeneratorTest.java
@@ -0,0 +1,41 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryWriterGeneratorTest
+    extends AbstractRegistryGeneratorTestCase
+{
+    public RegistryWriterGeneratorTest()
+    {
+        super( "registry-writer" );
+    }
+
+    public void testRegistryWriter()
+        throws Throwable
+    {
+        prepareTest( "registry-writer" );
+
+        verifyCompiledGeneratedSources( "org.apache.archiva.redback.components.registry.modello.RegistryWriterVerifier" );//, "registry-writer" );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/test/resources/model.mdo b/modello-plugin-redback-registry/src/test/resources/model.mdo
new file mode 100644
index 0000000..9c12768
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/resources/model.mdo
@@ -0,0 +1,155 @@
+<!--
+  ~ 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.
+  -->
+
+<model>
+  <id>model</id>
+  <name>Model</name>
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.apache.archiva.redback.components.registry.modello.test.model</value>
+    </default>
+  </defaults>
+  <classes>
+    <class rootElement="true">
+      <name>Model</name>
+      <version>1.0.0+</version>
+      <fields>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>repository</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>numeric</name>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>defString</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+          <defaultValue>def</defaultValue>
+        </field>
+        <field>
+          <name>defNumeric</name>
+          <version>1.0.0+</version>
+          <type>int</type>
+          <defaultValue>8080</defaultValue>
+        </field>
+        <field>
+          <name>defBoolean</name>
+          <version>1.0.0+</version>
+          <type>boolean</type>
+          <defaultValue>true</defaultValue>
+        </field>
+        <field>
+          <name>reference</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>Reference</type>
+          </association>
+        </field>
+        <field>
+          <name>missingReference</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>Reference</type>
+          </association>
+        </field>
+        <field>
+          <name>emptyReference</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>EmptyReference</type>
+          </association>
+        </field>
+        <field>
+          <name>listReferences</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>Reference</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>setReferences</name>
+          <version>1.0.0+</version>
+          <type>Set</type>
+          <association>
+            <type>Reference</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>stringReferences</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>map</name>
+          <version>1.0.0+</version>
+          <type>Map</type>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>properties</name>
+          <version>1.0.0+</version>
+          <type>Properties</type>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>baseDn</name>
+          <description>The LDAP base dn.</description>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+      </fields>
+    </class>
+    <class>
+      <name>Reference</name>
+      <version>1.0.0+</version>
+      <fields>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+      </fields>
+    </class>
+    <class>
+      <name>EmptyReference</name>
+      <version>1.0.0+</version>
+    </class>
+  </classes>
+</model>
diff --git a/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
new file mode 100644
index 0000000..11ad084
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
@@ -0,0 +1,97 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry;
+import org.apache.archiva.redback.components.registry.modello.test.model.Model;
+import org.apache.archiva.redback.components.registry.modello.test.model.Reference;
+import org.apache.archiva.redback.components.registry.modello.test.model.io.registry.ModelRegistryReader;
+import org.codehaus.modello.verifier.Verifier;
+import org.apache.archiva.redback.components.registry.Registry;
+
+import junit.framework.Assert;
+
+import java.io.File;
+import java.lang.AssertionError;
+import java.lang.System;
+import java.util.*;
+
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryReaderVerifier
+    extends Verifier
+{
+    public void verify()
+        throws Exception
+    {
+        Registry registry = new CommonsConfigurationRegistry();
+        registry.initialize();
+        registry.addConfigurationFromFile( new File( "src/test/verifiers/registry-reader/test.properties" ) );
+        registry.addConfigurationFromFile( new File( "src/test/verifiers/registry-reader/test.xml" ) );
+
+        ModelRegistryReader modelReader = new ModelRegistryReader();
+
+        Model model = modelReader.read( registry );
+
+        Assert.assertEquals( "Name", model.getName() );
+        Assert.assertEquals( System.getProperty( "user.home" ) + "/.m2/repository", model.getRepository() );
+        Assert.assertEquals( 1, model.getNumeric() );
+        Assert.assertEquals( "RefName", model.getReference().getName() );
+        Assert.assertNull( model.getMissingReference().getName() );
+        Assert.assertNotNull( model.getEmptyReference() );
+        Assert.assertEquals( "ListName1", ((Reference)model.getListReferences().get( 0 )).getName() );
+        Assert.assertEquals( "ListName2", ((Reference)model.getListReferences().get( 1 )).getName() );
+        Assert.assertEquals( "ListName3", ((Reference)model.getListReferences().get( 2 )).getName() );
+        Set set = model.getSetReferences();
+        List names = new ArrayList( set.size() );
+        for ( Iterator i = set.iterator(); i.hasNext(); )
+        {
+            Reference ref = (Reference) i.next();
+            names.add( ((Reference)ref).getName() );
+        }
+        Collections.sort( names );
+        Assert.assertEquals( Arrays.asList( new String[] { "SetName1", "SetName2" } ), names );
+        Assert.assertEquals( Arrays.asList( new String[] { "S1", "S2", "S3", "S4", "S5" } ), model.getStringReferences() );
+
+        Map map = model.getMap();
+        Assert.assertEquals( 3, map.size() );
+        Assert.assertEquals( "value1", map.get( "property" ) );
+        Assert.assertEquals( "value2", map.get( "property2" ) );
+        Assert.assertEquals( "value3", map.get( "something.else" ) );
+
+        Properties properties = model.getProperties();
+        Assert.assertEquals( 3, properties.size() );
+        Assert.assertEquals( "value1", properties.getProperty( "property" ) );
+        Assert.assertEquals( "value2", properties.getProperty( "property2" ) );
+        Assert.assertEquals( "value3", properties.getProperty( "something.else" ) );
+
+        // test defaults
+        Assert.assertEquals( "def", model.getDefString() );
+        Assert.assertEquals( 8080, model.getDefNumeric() );
+        Assert.assertEquals( true, model.isDefBoolean() );
+
+        System.out.println("baseDn:" + model.getBaseDn());
+
+        Assert.assertEquals( "ou=People,dc=archiva,dc=apache,dc=org", model.getBaseDn() );
+    }
+}
diff --git a/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.properties b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.properties
new file mode 100644
index 0000000..56b84dc
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.properties
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name=Name
+repository=${user.home}/.m2/repository
+numeric=1
+reference.name=RefName
+stringReferences.stringReference=S1, S2, S3, S4, S5
+map.property=value1
+map.property2=value2
+map.something.else=value3
\ No newline at end of file
diff --git a/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml
new file mode 100644
index 0000000..914aac7
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml
@@ -0,0 +1,51 @@
+<!--
+  ~ 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.
+  -->
+
+<configuration>
+  <listReferences>
+    <listReference>
+      <name>ListName1</name>
+    </listReference>
+    <listReference>
+      <name>ListName2</name>
+    </listReference>
+    <listReference>
+      <name>ListName3</name>
+    </listReference>
+  </listReferences>
+  <setReferences>
+    <setReference>
+      <name>SetName1</name>
+    </setReference>
+    <setReference>
+      <name>SetName2</name>
+    </setReference>
+  </setReferences>
+  <properties>
+    <property>value1</property>
+    <property2>value2</property2>
+    <something>
+      <else>value3</else>
+    </something>
+  </properties>
+  <baseDn>ou=People</baseDn>
+  <baseDn>dc=archiva</baseDn>
+  <baseDn>dc=apache</baseDn>
+  <baseDn>dc=org</baseDn>
+</configuration>
diff --git a/modello-plugin-redback-registry/src/test/verifiers/registry-writer/RegistryWriterVerifier.java b/modello-plugin-redback-registry/src/test/verifiers/registry-writer/RegistryWriterVerifier.java
new file mode 100644
index 0000000..0d9c249
--- /dev/null
+++ b/modello-plugin-redback-registry/src/test/verifiers/registry-writer/RegistryWriterVerifier.java
@@ -0,0 +1,150 @@
+package org.apache.archiva.redback.components.registry.modello;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry;
+import org.apache.archiva.redback.components.registry.modello.test.model.Model;
+import org.apache.archiva.redback.components.registry.modello.test.model.Reference;
+import org.apache.archiva.redback.components.registry.modello.test.model.EmptyReference;
+import org.apache.archiva.redback.components.registry.modello.test.model.io.registry.ModelRegistryWriter;
+import org.codehaus.modello.verifier.Verifier;
+import org.apache.archiva.redback.components.registry.Registry;
+
+import junit.framework.Assert;
+
+import java.lang.AssertionError;
+import java.util.*;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ *
+ */
+public class RegistryWriterVerifier
+    extends Verifier
+{
+    private static Reference createReference( String name )
+    {
+        Reference reference = new Reference();
+        reference.setName( name );
+        return reference;
+    }
+
+    public void verify()
+        throws Exception
+    {
+        Registry registry = new CommonsConfigurationRegistry();
+        registry.initialize();
+
+        Model model = new Model();
+        model.setName( "name" );
+        model.setNumeric( 9 );
+        model.setReference( createReference( "ref-name" ) );
+        model.setEmptyReference( new EmptyReference() );
+        model.setListReferences( new ArrayList( Arrays.asList( new Reference[] {
+            createReference( "list-name1" ),
+            createReference( "list-name2" ),
+            createReference( "list-name3" )
+        })));
+        model.setSetReferences( new HashSet( Arrays.asList( new Reference[] {
+            createReference( "set-name1" ),
+            createReference( "set-name2" ),
+        })));
+        model.setStringReferences( Arrays.asList( new String[] { "S1", "S2", "S3", "S4", "S5" } ) );
+
+        Map map = new HashMap();
+        map.put( "property", "value1" );
+        map.put( "property2", "value2" );
+        map.put( "something.else", "value3" );
+        model.setMap( map );
+
+        Properties properties = new Properties();
+        properties.setProperty( "property", "value1" );
+        properties.setProperty( "property2", "value2" );
+        properties.setProperty( "something.else", "value3" );
+        model.setProperties( properties );
+
+        ModelRegistryWriter modelWriter = new ModelRegistryWriter();
+
+        modelWriter.write( model, registry );
+
+        Assert.assertEquals( "name", registry.getString( "name" ) );
+        Assert.assertEquals( 9, registry.getInt( "numeric" ) );
+        Assert.assertEquals( "ref-name", registry.getString( "reference.name" ) );
+        Assert.assertNull( registry.getString( "missingReference" ) );
+        Assert.assertNull( registry.getString( "missingReference.name" ) );
+        Assert.assertNull( registry.getString( "emptyReference" ) );
+        Assert.assertNull( registry.getString( "emptyReference.name" ) );
+        Assert.assertEquals( "list-name1", registry.getString( "listReferences.listReference(0).name" ) );
+        Assert.assertEquals( "list-name2", registry.getString( "listReferences.listReference(1).name" ) );
+        Assert.assertEquals( "list-name3", registry.getString( "listReferences.listReference(2).name" ) );
+        List names = new ArrayList( 2 );
+        names.add( registry.getString( "setReferences.setReference(0).name" ) );
+        names.add( registry.getString( "setReferences.setReference(1).name" ) );
+        Collections.sort( names );
+        Assert.assertEquals( Arrays.asList( new String[] { "set-name1", "set-name2" } ), names );
+        Assert.assertEquals( Arrays.asList( new String[] { "S1", "S2", "S3", "S4", "S5" } ),
+                             registry.getList( "stringReferences.stringReference" ) );
+
+        map = registry.getProperties( "map" );
+        Assert.assertEquals( 3, map.size() );
+        Assert.assertEquals( "value1", map.get( "property" ) );
+        Assert.assertEquals( "value2", map.get( "property2" ) );
+        Assert.assertEquals( "value3", map.get( "something.else" ) );
+
+        properties = registry.getProperties( "properties" );
+        Assert.assertEquals( 3, properties.size() );
+        Assert.assertEquals( "value1", properties.getProperty( "property" ) );
+        Assert.assertEquals( "value2", properties.getProperty( "property2" ) );
+        Assert.assertEquals( "value3", properties.getProperty( "something.else" ) );
+
+        // test defaults
+        Assert.assertNull( registry.getString( "defString" ) );
+
+        try
+        {
+            registry.getInt( "defNumeric" );
+            Assert.fail();
+        }
+        catch ( NoSuchElementException e )
+        {
+            // expected
+        }
+
+
+        Assert.assertTrue( registry.getBoolean( "defBoolean" ) );
+
+
+        // test removing an element from a list [MODELLO-84]
+        model.getListReferences().remove( 0 );
+        modelWriter.write( model, registry );
+        Assert.assertEquals( "list-name2", registry.getString( "listReferences.listReference(0).name" ) );
+        Assert.assertEquals( "list-name3", registry.getString( "listReferences.listReference(1).name" ) );
+        Assert.assertNull( registry.getString( "listReferences.listReference(2).name" ) );
+
+        // test removing an element from a map
+        model.getMap().remove( "property2" );
+        modelWriter.write( model, registry );
+        map = registry.getProperties( "map" );
+        Assert.assertEquals( 2, map.size() );
+        Assert.assertEquals( "value1", map.get( "property" ) );
+        Assert.assertNull( "value2", map.get( "property2" ) );
+        Assert.assertEquals( "value3", map.get( "something.else" ) );
+    }
+}
diff --git a/pom.xml b/pom.xml
index 4736f1d..cfe0e8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,11 @@
         <artifactId>plexus-utils</artifactId>
         <version>3.0.8</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.archiva.redback.components.modello</groupId>
+        <artifactId>modello-plugin-store</artifactId>
+        <version>${project.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>