You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/07/31 04:47:20 UTC

[01/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Repository: zest-java
Updated Branches:
  refs/heads/master a2d2100be -> a789141d5


http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/FragmentClassLoader.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/FragmentClassLoader.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/FragmentClassLoader.java
new file mode 100644
index 0000000..4cf4439
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/FragmentClassLoader.java
@@ -0,0 +1,852 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.qi4j.api.entity.Lifecycle;
+import org.qi4j.api.mixin.Initializable;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.util.Methods;
+import org.qi4j.functional.Iterables;
+
+import static org.objectweb.asm.Opcodes.AASTORE;
+import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.ACC_STATIC;
+import static org.objectweb.asm.Opcodes.ACC_SUPER;
+import static org.objectweb.asm.Opcodes.ACONST_NULL;
+import static org.objectweb.asm.Opcodes.ALOAD;
+import static org.objectweb.asm.Opcodes.ANEWARRAY;
+import static org.objectweb.asm.Opcodes.ARETURN;
+import static org.objectweb.asm.Opcodes.ASTORE;
+import static org.objectweb.asm.Opcodes.ATHROW;
+import static org.objectweb.asm.Opcodes.BIPUSH;
+import static org.objectweb.asm.Opcodes.CHECKCAST;
+import static org.objectweb.asm.Opcodes.DLOAD;
+import static org.objectweb.asm.Opcodes.DRETURN;
+import static org.objectweb.asm.Opcodes.DUP;
+import static org.objectweb.asm.Opcodes.FLOAD;
+import static org.objectweb.asm.Opcodes.FRETURN;
+import static org.objectweb.asm.Opcodes.GETFIELD;
+import static org.objectweb.asm.Opcodes.GETSTATIC;
+import static org.objectweb.asm.Opcodes.GOTO;
+import static org.objectweb.asm.Opcodes.ICONST_0;
+import static org.objectweb.asm.Opcodes.ICONST_1;
+import static org.objectweb.asm.Opcodes.ICONST_2;
+import static org.objectweb.asm.Opcodes.ICONST_3;
+import static org.objectweb.asm.Opcodes.ICONST_4;
+import static org.objectweb.asm.Opcodes.ICONST_5;
+import static org.objectweb.asm.Opcodes.ILOAD;
+import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
+import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
+import static org.objectweb.asm.Opcodes.INVOKESTATIC;
+import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
+import static org.objectweb.asm.Opcodes.IRETURN;
+import static org.objectweb.asm.Opcodes.LLOAD;
+import static org.objectweb.asm.Opcodes.LRETURN;
+import static org.objectweb.asm.Opcodes.POP;
+import static org.objectweb.asm.Opcodes.PUTSTATIC;
+import static org.objectweb.asm.Opcodes.RETURN;
+import static org.objectweb.asm.Type.getInternalName;
+import static org.qi4j.api.util.Classes.interfacesOf;
+
+/**
+ * Generate subclasses of mixins/modifiers that implement all interfaces not in the class itself
+ * and which delegates those calls to a given composite invoker.
+ */
+@SuppressWarnings( "raw" )
+public class FragmentClassLoader
+    extends ClassLoader
+{
+    private static final int JDK_VERSION;
+    public static final String GENERATED_POSTFIX = "_Stub";
+
+    static
+    {
+        String jdkString = System.getProperty( "java.specification.version" );
+        switch( jdkString )
+        {
+            case "1.8":
+                JDK_VERSION = Opcodes.V1_8;
+                break;
+            case "1.7":
+            default:
+                JDK_VERSION = Opcodes.V1_7;
+                break;
+        }
+    }
+
+    public FragmentClassLoader( ClassLoader parent )
+    {
+        super( parent );
+    }
+
+    @Override
+    protected Class findClass( String name )
+        throws ClassNotFoundException
+    {
+        if( name.endsWith( GENERATED_POSTFIX ) )
+        {
+            Class baseClass;
+            String baseName = name.substring( 0, name.length() - 5 );
+            try
+            {
+                baseClass = loadClass( baseName );
+            }
+            catch( ClassNotFoundException e )
+            {
+                // Try replacing the last _ with $
+                while( true )
+                {
+                    int idx = baseName.lastIndexOf( "_" );
+                    if( idx != -1 )
+                    {
+                        baseName = baseName.substring( 0, idx ) + "$" + baseName.substring( idx + 1 );
+                        try
+                        {
+                            baseClass = loadClass( baseName );
+                            break;
+                        }
+                        catch( ClassNotFoundException e1 )
+                        {
+                            // Try again
+                        }
+                    }
+                    else
+                    {
+                        throw e;
+                    }
+                }
+            }
+//  To Allow JDK classes to be composed.
+            if( name.startsWith( "java." ))
+                name = "qi4j." + name;
+
+            byte[] b = generateClass( name, baseClass );
+            return defineClass( name, b, 0, b.length, baseClass.getProtectionDomain() );
+        }
+
+        // Try the classloader of this classloader -> get classes in Zest such as CompositeInvoker
+        return getClass().getClassLoader().loadClass( name );
+    }
+
+    public static byte[] generateClass( String name, Class baseClass )
+        throws ClassNotFoundException
+    {
+        String classSlash = name.replace( '.', '/' );
+        String baseClassSlash = getInternalName( baseClass );
+
+        ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
+
+        // Class definition start
+        cw.visit( JDK_VERSION, ACC_PUBLIC + ACC_SUPER, classSlash, null, baseClassSlash, null );
+
+        // Composite reference
+        {
+            cw.visitField( ACC_PUBLIC, "_instance", "Lorg/qi4j/api/composite/CompositeInvoker;", null, null ).visitEnd();
+        }
+
+        // Static Method references
+        boolean hasProxyMethods = false;
+        {
+            int idx = 1;
+            for( Method method : baseClass.getMethods() )
+            {
+                if( isOverridden(method, baseClass) )
+                {
+                    cw.visitField( ACC_PRIVATE + ACC_STATIC, "m" + idx++, "Ljava/lang/reflect/Method;", null,
+                                        null ).visitEnd();
+                    hasProxyMethods = true;
+                }
+            }
+        }
+
+        // Constructors
+        for( Constructor constructor : baseClass.getDeclaredConstructors() )
+        {
+            if( Modifier.isPublic( constructor.getModifiers() ) || Modifier.isProtected( constructor.getModifiers() ) )
+            {
+                String desc = org.objectweb.asm.commons.Method.getMethod( constructor ).getDescriptor();
+                MethodVisitor cmv = cw.visitMethod( ACC_PUBLIC, "<init>", desc, null, null );
+                cmv.visitCode();
+                cmv.visitVarInsn(ALOAD, 0);
+
+                int idx = 1;
+                for( Class aClass : constructor.getParameterTypes() )
+                {
+                    final int opcode;
+                    if (aClass.equals(Integer.TYPE)) {
+                        opcode = ILOAD;
+                    } else if (aClass.equals(Long.TYPE)) {
+                        opcode = LLOAD;
+                    } else if (aClass.equals(Float.TYPE)) {
+                        opcode = FLOAD;
+                    } else if (aClass.equals(Double.TYPE)) {
+                        opcode = DLOAD;
+                    } else {
+                        opcode = ALOAD;
+                    }
+                    cmv.visitVarInsn(opcode, idx++);
+                }
+
+                cmv.visitMethodInsn(INVOKESPECIAL, baseClassSlash, "<init>", desc, false);
+                cmv.visitInsn(RETURN);
+                cmv.visitMaxs(idx, idx);
+                cmv.visitEnd();
+            }
+        }
+
+
+        // Overloaded and unimplemented methods
+        if( hasProxyMethods )
+        {
+            Method[] methods = baseClass.getMethods();
+            int idx = 0;
+            List<Label> exceptionLabels = new ArrayList<>();
+            for( Method method : methods )
+            {
+                if( isOverridden(method, baseClass) )
+                {
+                    idx++;
+                    String methodName = method.getName();
+                    String desc = org.objectweb.asm.commons.Method.getMethod( method ).getDescriptor();
+
+                    String[] exceptions = null;
+                    {
+                        MethodVisitor mv = cw.visitMethod( ACC_PUBLIC, methodName, desc, null, null );
+                        if( isInternalQi4jMethod( method, baseClass ) )
+                        {
+                            // generate a NoOp method...
+                            mv.visitInsn( RETURN );
+                        }
+                        else
+                        {
+                            Label endLabel = null; // Use this if return type is void
+                            if( method.getExceptionTypes().length > 0 )
+                            {
+                                exceptions = new String[ method.getExceptionTypes().length ];
+                                for( int i = 0; i < method.getExceptionTypes().length; i++ )
+                                {
+                                    Class<?> aClass = method.getExceptionTypes()[ i ];
+                                    exceptions[ i ] = getInternalName( aClass );
+                                }
+                            }
+                            mv.visitCode();
+                            Label l0 = new Label();
+                            Label l1 = new Label();
+
+                            exceptionLabels.clear();
+                            for( Class<?> declaredException : method.getExceptionTypes() )
+                            {
+                                Label ld = new Label();
+                                mv.visitTryCatchBlock( l0, l1, ld, getInternalName( declaredException ) );
+                                exceptionLabels.add( ld ); // Reuse this further down for the catch
+                            }
+
+                            Label lruntime = new Label();
+                            mv.visitTryCatchBlock( l0, l1, lruntime, "java/lang/RuntimeException" );
+                            Label lerror = new Label();
+                            mv.visitTryCatchBlock( l0, l1, lerror, "java/lang/Throwable" );
+
+                            mv.visitLabel( l0 );
+                            mv.visitVarInsn( ALOAD, 0 );
+                            mv.visitFieldInsn( GETFIELD, classSlash, "_instance",
+                                               "Lorg/qi4j/api/composite/CompositeInvoker;" );
+                            mv.visitFieldInsn( GETSTATIC, classSlash, "m" + idx, "Ljava/lang/reflect/Method;" );
+
+                            int paramCount = method.getParameterTypes().length;
+                            int stackIdx = 0;
+                            if( paramCount == 0 )
+                            {
+                                // Send in null as parameter
+                                mv.visitInsn( ACONST_NULL );
+                            }
+                            else
+                            {
+                                insn( mv, paramCount );
+                                mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" );
+                                int pidx = 0;
+                                for( Class<?> aClass : method.getParameterTypes() )
+                                {
+                                    mv.visitInsn( DUP );
+                                    insn( mv, pidx++ );
+                                    stackIdx = wrapParameter( mv, aClass, stackIdx + 1 );
+                                    mv.visitInsn( AASTORE );
+                                }
+                            }
+
+                            // Call method
+                            mv.visitMethodInsn( INVOKEINTERFACE, "org/qi4j/api/composite/CompositeInvoker",
+                                                "invokeComposite",
+                                                "(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;", true );
+
+                            // Return value
+                            if( !method.getReturnType().equals( Void.TYPE ) )
+                            {
+                                unwrapResult( mv, method.getReturnType(), l1 );
+                            }
+                            else
+                            {
+                                mv.visitInsn( POP );
+                                mv.visitLabel( l1 );
+                                endLabel = new Label();
+                                mv.visitJumpInsn( GOTO, endLabel );
+                            }
+
+                            // Increase stack to beyond method args
+                            stackIdx++;
+
+                            // Declared exceptions
+                            int exceptionIdx = 0;
+                            for( Class<?> aClass : method.getExceptionTypes() )
+                            {
+                                mv.visitLabel( exceptionLabels.get( exceptionIdx++ ) );
+                                mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ getInternalName( aClass ) } );
+                                mv.visitVarInsn( ASTORE, stackIdx );
+                                mv.visitVarInsn( ALOAD, stackIdx );
+                                mv.visitInsn( ATHROW );
+                            }
+
+                            // RuntimeException and Error catch-all
+                            mv.visitLabel( lruntime );
+                            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/RuntimeException" } );
+                            mv.visitVarInsn( ASTORE, stackIdx );
+                            mv.visitVarInsn( ALOAD, stackIdx );
+                            mv.visitInsn( ATHROW );
+
+                            mv.visitLabel( lerror );
+                            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/Throwable" } );
+                            mv.visitVarInsn( ASTORE, stackIdx );
+                            mv.visitVarInsn( ALOAD, stackIdx );
+                            mv.visitTypeInsn( CHECKCAST, "java/lang/Error" );
+                            mv.visitInsn( ATHROW );
+
+                            // Return type = void
+                            if( endLabel != null )
+                            {
+                                mv.visitLabel( endLabel );
+                                mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
+                                mv.visitInsn( RETURN );
+                            }
+
+                            mv.visitMaxs( 0, 0 );
+                            mv.visitEnd();
+                        }
+                    }
+
+                    if( !Modifier.isAbstract( method.getModifiers() ) )
+                    {
+                        // Add method with _ as prefix
+                        MethodVisitor mv;
+                        mv = cw.visitMethod( ACC_PUBLIC, "_" + method.getName(), desc, null, exceptions );
+                        mv.visitCode();
+                        mv.visitVarInsn( ALOAD, 0 );
+
+                        // Parameters
+                        int stackIdx = 1;
+                        for( Class<?> aClass : method.getParameterTypes() )
+                        {
+                            stackIdx = loadParameter( mv, aClass, stackIdx ) + 1;
+                        }
+
+                        // Call method
+                        mv.visitMethodInsn( INVOKESPECIAL, baseClassSlash, method.getName(), desc, false );
+
+                        // Return value
+                        if( !method.getReturnType().equals( Void.TYPE ) )
+                        {
+                            returnResult( mv, method.getReturnType() );
+                        }
+                        else
+                        {
+                            mv.visitInsn( RETURN );
+                        }
+
+                        mv.visitMaxs( 1, 1 );
+                        mv.visitEnd();
+                    }
+                }
+            }
+
+            // Class initializer
+            {
+                MethodVisitor mv;
+                mv = cw.visitMethod( ACC_STATIC, "<clinit>", "()V", null, null );
+                mv.visitCode();
+                Label l0 = new Label();
+                Label l1 = new Label();
+                Label l2 = new Label();
+                mv.visitTryCatchBlock( l0, l1, l2, "java/lang/NoSuchMethodException" );
+                mv.visitLabel( l0 );
+
+                // Lookup methods and store in static variables
+                int midx = 0;
+                for( Method method : methods )
+                {
+                    if( isOverridden(method, baseClass) )
+                    {
+                        method.setAccessible( true );
+                        Class methodClass;
+                        if( Modifier.isAbstract( method.getModifiers() ) )
+                        {
+                            methodClass = method.getDeclaringClass();
+                        }
+                        else
+                        {
+                            try
+                            {
+                                methodClass = getInterfaceMethodDeclaration( method,
+                                                                             baseClass ); // Overridden method lookup
+                            }
+                            catch( NoSuchMethodException e )
+                            {
+                                throw new ClassNotFoundException( name, e );
+                            }
+                        }
+
+                        midx++;
+
+                        mv.visitLdcInsn( Type.getType( methodClass ) );
+                        mv.visitLdcInsn( method.getName() );
+                        insn( mv, method.getParameterTypes().length );
+                        mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" );
+
+                        int pidx = 0;
+                        for( Class<?> aClass : method.getParameterTypes() )
+                        {
+                            mv.visitInsn( DUP );
+                            insn( mv, pidx++ );
+                            type( mv, aClass );
+                            mv.visitInsn( AASTORE );
+                        }
+
+                        mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod",
+                                            "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;", false );
+                        mv.visitFieldInsn( PUTSTATIC, classSlash, "m" + midx, "Ljava/lang/reflect/Method;" );
+                    }
+                }
+
+                mv.visitLabel( l1 );
+                Label l3 = new Label();
+                mv.visitJumpInsn( GOTO, l3 );
+                mv.visitLabel( l2 );
+                mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/NoSuchMethodException" } );
+                mv.visitVarInsn( ASTORE, 0 );
+                mv.visitVarInsn( ALOAD, 0 );
+                mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/NoSuchMethodException", "printStackTrace", "()V", false );
+                mv.visitLabel( l3 );
+                mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
+                mv.visitInsn( RETURN );
+                mv.visitMaxs( 6, 1 );
+                mv.visitEnd();
+            }
+        }
+        cw.visitEnd();
+        return cw.toByteArray();
+    }
+
+    private static boolean isOverridden(Method method, Class baseClass)
+    {
+        if( Modifier.isAbstract( method.getModifiers() ) )
+        {
+            return true; // Implement all abstract methods
+        }
+
+        if( Modifier.isFinal( method.getModifiers() ) )
+        {
+            return false; // Cannot override final methods
+        }
+
+        if( isInterfaceMethod( method, baseClass ) )
+        {
+            // if() used for clarity.
+            //noinspection RedundantIfStatement
+            if( isInternalQi4jMethod( method, baseClass ) )
+            {
+                return false; // Skip methods in Zest-internal interfaces
+            }
+            else
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    private static boolean isInternalQi4jMethod( Method method, Class baseClass )
+    {
+        return isDeclaredIn( method, Initializable.class, baseClass )
+               || isDeclaredIn( method, Lifecycle.class, baseClass );
+    }
+
+    private static boolean isDeclaredIn( Method method, Class<?> clazz, Class<?> baseClass )
+    {
+        if( !clazz.isAssignableFrom( baseClass ) )
+        {
+            return false;
+        }
+
+        try
+        {
+            clazz.getMethod( method.getName(), method.getParameterTypes() );
+            return true;
+        }
+        catch( NoSuchMethodException e )
+        {
+            return false;
+        }
+    }
+
+    private static Class getInterfaceMethodDeclaration( Method method, Class clazz )
+        throws NoSuchMethodException
+    {
+        Iterable<Class<?>> interfaces = Iterables.map( Classes.RAW_CLASS, interfacesOf( clazz ) );
+        for( Class<?> anInterface : interfaces )
+        {
+            try
+            {
+                anInterface.getMethod( method.getName(), method.getParameterTypes() );
+                return anInterface;
+            }
+            catch( NoSuchMethodException e )
+            {
+                // Try next
+            }
+        }
+
+        throw new NoSuchMethodException( method.getName() );
+    }
+
+    private static boolean isInterfaceMethod( Method method, Class<?> baseClass )
+    {
+        for( Class<?> aClass : Iterables.filter( Methods.HAS_METHODS, Iterables.map( Classes.RAW_CLASS, interfacesOf( baseClass ) ) ) )
+        {
+            try
+            {
+                Method m = aClass.getMethod( method.getName(), method.getParameterTypes() );
+                m.setAccessible( true );
+                return true;
+            }
+            catch( NoSuchMethodException e )
+            {
+                // Ignore
+            }
+        }
+        return false;
+    }
+
+    private static void type( MethodVisitor mv, Class<?> aClass )
+    {
+        if( aClass.equals( Integer.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Long.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Short.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Byte.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Double.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Float.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Boolean.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;" );
+        }
+        else if( aClass.equals( Character.TYPE ) )
+        {
+            mv.visitFieldInsn( GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;" );
+        }
+        else
+        {
+            mv.visitLdcInsn( Type.getType( aClass ) );
+        }
+    }
+
+    private static int wrapParameter( MethodVisitor mv, Class<?> aClass, int idx )
+    {
+        if( aClass.equals( Integer.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false );
+        }
+        else if( aClass.equals( Long.TYPE ) )
+        {
+            mv.visitVarInsn( LLOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false );
+            idx++; // Extra jump
+        }
+        else if( aClass.equals( Short.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false );
+        }
+        else if( aClass.equals( Byte.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false );
+        }
+        else if( aClass.equals( Double.TYPE ) )
+        {
+            mv.visitVarInsn( DLOAD, idx );
+            idx++; // Extra jump
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false );
+        }
+        else if( aClass.equals( Float.TYPE ) )
+        {
+            mv.visitVarInsn( FLOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false );
+        }
+        else if( aClass.equals( Boolean.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false );
+        }
+        else if( aClass.equals( Character.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false );
+        }
+        else
+        {
+            mv.visitVarInsn( ALOAD, idx );
+        }
+
+        return idx;
+    }
+
+    private static void unwrapResult( MethodVisitor mv, Class<?> aClass, Label label )
+    {
+        if( aClass.equals( Integer.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Integer" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false );
+            mv.visitLabel( label );
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Long.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Long" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false );
+            mv.visitLabel( label );
+            mv.visitInsn( LRETURN );
+        }
+        else if( aClass.equals( Short.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Short" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false );
+            mv.visitLabel( label );
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Byte.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Byte" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false );
+            mv.visitLabel( label );
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Double.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Double" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false );
+            mv.visitLabel( label );
+            mv.visitInsn( DRETURN );
+        }
+        else if( aClass.equals( Float.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Float" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false );
+            mv.visitLabel( label );
+            mv.visitInsn( FRETURN );
+        }
+        else if( aClass.equals( Boolean.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Boolean" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false );
+            mv.visitLabel( label );
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Character.TYPE ) )
+        {
+            mv.visitTypeInsn( CHECKCAST, "java/lang/Character" );
+            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false );
+            mv.visitLabel( label );
+            mv.visitInsn( IRETURN );
+        }
+        else
+        {
+            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
+            mv.visitLabel( label );
+            mv.visitInsn( ARETURN );
+        }
+    }
+
+    private static int loadParameter( MethodVisitor mv, Class<?> aClass, int idx )
+    {
+        if( aClass.equals( Integer.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+        }
+        else if( aClass.equals( Long.TYPE ) )
+        {
+            mv.visitVarInsn( LLOAD, idx );
+            idx++; // Extra jump
+        }
+        else if( aClass.equals( Short.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+        }
+        else if( aClass.equals( Byte.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+        }
+        else if( aClass.equals( Double.TYPE ) )
+        {
+            mv.visitVarInsn( DLOAD, idx );
+            idx++; // Extra jump
+        }
+        else if( aClass.equals( Float.TYPE ) )
+        {
+            mv.visitVarInsn( FLOAD, idx );
+        }
+        else if( aClass.equals( Boolean.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+        }
+        else if( aClass.equals( Character.TYPE ) )
+        {
+            mv.visitVarInsn( ILOAD, idx );
+        }
+        else
+        {
+            mv.visitVarInsn( ALOAD, idx );
+        }
+
+        return idx;
+    }
+
+    private static void returnResult( MethodVisitor mv, Class<?> aClass )
+    {
+        if( aClass.equals( Integer.TYPE ) )
+        {
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Long.TYPE ) )
+        {
+            mv.visitInsn( LRETURN );
+        }
+        else if( aClass.equals( Short.TYPE ) )
+        {
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Byte.TYPE ) )
+        {
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Double.TYPE ) )
+        {
+            mv.visitInsn( DRETURN );
+        }
+        else if( aClass.equals( Float.TYPE ) )
+        {
+            mv.visitInsn( FRETURN );
+        }
+        else if( aClass.equals( Boolean.TYPE ) )
+        {
+            mv.visitInsn( IRETURN );
+        }
+        else if( aClass.equals( Character.TYPE ) )
+        {
+            mv.visitInsn( IRETURN );
+        }
+        else
+        {
+            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
+            mv.visitInsn( ARETURN );
+        }
+    }
+
+    private static void insn( MethodVisitor mv, int length )
+    {
+        switch( length )
+        {
+        case 0:
+            mv.visitInsn( ICONST_0 );
+            return;
+        case 1:
+            mv.visitInsn( ICONST_1 );
+            return;
+        case 2:
+            mv.visitInsn( ICONST_2 );
+            return;
+        case 3:
+            mv.visitInsn( ICONST_3 );
+            return;
+        case 4:
+            mv.visitInsn( ICONST_4 );
+            return;
+        case 5:
+            mv.visitInsn( ICONST_5 );
+            return;
+        default:
+            mv.visitIntInsn( BIPUSH, length );
+        }
+    }
+
+    public static boolean isGenerated( Class clazz )
+    {
+        return clazz.getName().endsWith( GENERATED_POSTFIX );
+    }
+
+    public static boolean isGenerated( Object object )
+    {
+        return object.getClass().getName().endsWith( GENERATED_POSTFIX );
+    }
+
+    public Class loadFragmentClass( Class fragmentClass )
+        throws ClassNotFoundException
+    {
+        return loadClass( fragmentClass.getName().replace( '$', '_' ) + GENERATED_POSTFIX );
+    }
+
+    public static Class getSourceClass( Class fragmentClass )
+    {
+        return fragmentClass.getName().endsWith( GENERATED_POSTFIX ) ? fragmentClass.getSuperclass() : fragmentClass;
+    }
+}


[51/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
Revert "First round of changes to move to org.apache.zest namespace."

This reverts commit 8744a67f36191a66edcd6acc17eaced047349a3f.


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/a789141d
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/a789141d
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/a789141d

Branch: refs/heads/master
Commit: a789141d5af7f9137dddb9bfc0f0e0af47ebec2d
Parents: 4253d11
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Fri Jul 31 10:46:16 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Fri Jul 31 10:46:16 2015 +0800

----------------------------------------------------------------------
 .../zest/gradle/plugin/Documentation.groovy     |  240 ---
 .../plugin/ModuleReleaseSpecification.groovy    |   40 -
 .../org/qi4j/gradle/plugin/Documentation.groovy |  240 +++
 .../plugin/ModuleReleaseSpecification.groovy    |   40 +
 .../src/main/java/org/apache/zest/api/Qi4j.java |  192 --
 .../apache/zest/api/activation/Activation.java  |   55 -
 .../zest/api/activation/ActivationEvent.java    |   81 -
 .../api/activation/ActivationEventListener.java |   24 -
 .../ActivationEventListenerRegistration.java    |   33 -
 .../api/activation/ActivationException.java     |   30 -
 .../apache/zest/api/activation/Activator.java   |   54 -
 .../zest/api/activation/ActivatorAdapter.java   |   68 -
 .../api/activation/ActivatorDescriptor.java     |   25 -
 .../apache/zest/api/activation/Activators.java  |   39 -
 .../ApplicationPassivationThread.java           |  112 --
 .../api/activation/PassivationException.java    |   59 -
 .../org/apache/zest/api/activation/package.html |   26 -
 .../api/association/AbstractAssociation.java    |   22 -
 .../zest/api/association/Association.java       |   46 -
 .../api/association/AssociationDescriptor.java  |   63 -
 .../zest/api/association/AssociationMixin.java  |   52 -
 .../association/AssociationStateDescriptor.java |   53 -
 .../api/association/AssociationStateHolder.java |   77 -
 .../api/association/AssociationWrapper.java     |   79 -
 .../api/association/GenericAssociationInfo.java |   58 -
 .../zest/api/association/ManyAssociation.java   |   51 -
 .../api/association/ManyAssociationMixin.java   |   52 -
 .../api/association/ManyAssociationWrapper.java |  123 --
 .../zest/api/association/NamedAssociation.java  |   91 -
 .../api/association/NamedAssociationMixin.java  |   57 -
 .../association/NamedAssociationWrapper.java    |  122 --
 .../apache/zest/api/association/package.html    |   21 -
 .../org/apache/zest/api/cache/CacheOptions.java |   86 -
 .../java/org/apache/zest/api/cache/package.html |   40 -
 .../org/apache/zest/api/common/AppliesTo.java   |  107 -
 .../apache/zest/api/common/AppliesToFilter.java |   83 -
 .../zest/api/common/ConstructionException.java  |   55 -
 .../api/common/InvalidApplicationException.java |   36 -
 .../org/apache/zest/api/common/MetaInfo.java    |  151 --
 .../org/apache/zest/api/common/Optional.java    |   63 -
 .../apache/zest/api/common/QualifiedName.java   |  252 ---
 .../org/apache/zest/api/common/TypeName.java    |  111 --
 .../org/apache/zest/api/common/UseDefaults.java |   78 -
 .../org/apache/zest/api/common/Visibility.java  |   40 -
 .../org/apache/zest/api/common/package.html     |   81 -
 .../api/composite/AmbiguousTypeException.java   |   57 -
 .../apache/zest/api/composite/Composite.java    |   34 -
 .../zest/api/composite/CompositeContext.java    |   80 -
 .../zest/api/composite/CompositeDescriptor.java |   26 -
 .../zest/api/composite/CompositeInstance.java   |   39 -
 .../zest/api/composite/CompositeInvoker.java    |   35 -
 .../api/composite/ConstructorDescriptor.java    |   25 -
 .../zest/api/composite/DecoratorMixin.java      |  104 -
 .../api/composite/DependencyDescriptor.java     |   38 -
 .../api/composite/InjectedFieldDescriptor.java  |   26 -
 .../api/composite/InjectedMethodDescriptor.java |   25 -
 .../composite/InjectedParametersDescriptor.java |   22 -
 .../composite/InvalidCompositeException.java    |   29 -
 .../InvalidValueCompositeException.java         |   30 -
 .../zest/api/composite/MethodDescriptor.java    |   25 -
 .../api/composite/MissingMethodException.java   |   36 -
 .../zest/api/composite/ModelDescriptor.java     |   33 -
 .../api/composite/NoSuchCompositeException.java |   46 -
 .../api/composite/NoSuchTransientException.java |   28 -
 .../zest/api/composite/PropertyMapper.java      |  580 ------
 .../zest/api/composite/StateDescriptor.java     |   32 -
 .../composite/StatefulCompositeDescriptor.java  |   27 -
 .../zest/api/composite/TransientBuilder.java    |   68 -
 .../api/composite/TransientBuilderFactory.java  |   54 -
 .../zest/api/composite/TransientComposite.java  |   35 -
 .../zest/api/composite/TransientDescriptor.java |   23 -
 .../org/apache/zest/api/composite/package.html  |   21 -
 .../zest/api/concern/ConcernDescriptor.java     |   23 -
 .../org/apache/zest/api/concern/ConcernOf.java  |   44 -
 .../org/apache/zest/api/concern/Concerns.java   |   34 -
 .../zest/api/concern/ConcernsDescriptor.java    |   24 -
 .../apache/zest/api/concern/GenericConcern.java |   32 -
 .../zest/api/concern/internal/ConcernFor.java   |   62 -
 .../zest/api/concern/internal/package.html      |   25 -
 .../org/apache/zest/api/concern/package.html    |   21 -
 .../zest/api/configuration/Configuration.java   |  396 ----
 .../configuration/ConfigurationComposite.java   |   31 -
 .../apache/zest/api/configuration/Enabled.java  |   28 -
 .../NoSuchConfigurationException.java           |   48 -
 .../apache/zest/api/configuration/package.html  |   21 -
 .../apache/zest/api/constraint/Constraint.java  |   39 -
 .../api/constraint/ConstraintDeclaration.java   |   31 -
 .../api/constraint/ConstraintDescriptor.java    |   25 -
 ...nstraintImplementationNotFoundException.java |   28 -
 .../api/constraint/ConstraintViolation.java     |   52 -
 .../ConstraintViolationException.java           |  257 ---
 .../apache/zest/api/constraint/Constraints.java |   36 -
 .../api/constraint/ConstraintsDescriptor.java   |   22 -
 .../org/apache/zest/api/constraint/Name.java    |   32 -
 .../org/apache/zest/api/constraint/package.html |   21 -
 .../org/apache/zest/api/dataset/DataSet.java    |   36 -
 .../apache/zest/api/dataset/DataSetSource.java  |   27 -
 .../java/org/apache/zest/api/dataset/Query.java |   64 -
 .../api/dataset/iterable/IterableDataSet.java   |   57 -
 .../api/dataset/iterable/IterableQuery.java     |  127 --
 .../zest/api/dataset/iterable/package.html      |   21 -
 .../org/apache/zest/api/dataset/package.html    |   21 -
 .../org/apache/zest/api/entity/Aggregated.java  |   31 -
 .../apache/zest/api/entity/EntityBuilder.java   |   60 -
 .../zest/api/entity/EntityBuilderTemplate.java  |   43 -
 .../apache/zest/api/entity/EntityComposite.java |   31 -
 .../zest/api/entity/EntityDescriptor.java       |   31 -
 .../apache/zest/api/entity/EntityReference.java |  133 --
 .../org/apache/zest/api/entity/Identity.java    |   56 -
 .../zest/api/entity/IdentityGenerator.java      |   32 -
 .../org/apache/zest/api/entity/Lifecycle.java   |   85 -
 .../zest/api/entity/LifecycleException.java     |   37 -
 .../org/apache/zest/api/entity/Queryable.java   |   32 -
 .../org/apache/zest/api/entity/package.html     |   21 -
 .../java/org/apache/zest/api/event/package.html |   21 -
 .../zest/api/injection/InjectionScope.java      |   32 -
 .../org/apache/zest/api/injection/package.html  |   21 -
 .../zest/api/injection/scope/Invocation.java    |   50 -
 .../zest/api/injection/scope/Service.java       |   43 -
 .../apache/zest/api/injection/scope/State.java  |   48 -
 .../zest/api/injection/scope/Structure.java     |   49 -
 .../apache/zest/api/injection/scope/This.java   |   42 -
 .../apache/zest/api/injection/scope/Uses.java   |   40 -
 .../zest/api/injection/scope/package.html       |   21 -
 .../org/apache/zest/api/metrics/Metric.java     |   24 -
 .../apache/zest/api/metrics/MetricsCounter.java |   31 -
 .../zest/api/metrics/MetricsCounterFactory.java |   34 -
 .../apache/zest/api/metrics/MetricsFactory.java |   25 -
 .../apache/zest/api/metrics/MetricsGauge.java   |   34 -
 .../zest/api/metrics/MetricsGaugeFactory.java   |   35 -
 .../zest/api/metrics/MetricsHealthCheck.java    |   55 -
 .../api/metrics/MetricsHealthCheckFactory.java  |   36 -
 .../zest/api/metrics/MetricsHistogram.java      |   28 -
 .../api/metrics/MetricsHistogramFactory.java    |   35 -
 .../apache/zest/api/metrics/MetricsMeter.java   |   35 -
 .../zest/api/metrics/MetricsMeterFactory.java   |   38 -
 .../metrics/MetricsNotSupportedException.java   |   32 -
 .../zest/api/metrics/MetricsProvider.java       |   58 -
 .../apache/zest/api/metrics/MetricsTimer.java   |   39 -
 .../zest/api/metrics/MetricsTimerFactory.java   |   39 -
 .../org/apache/zest/api/metrics/package.html    |   21 -
 .../apache/zest/api/mixin/Initializable.java    |   32 -
 .../zest/api/mixin/InitializationException.java |   43 -
 .../zest/api/mixin/InvalidMixinException.java   |   33 -
 .../apache/zest/api/mixin/MixinDescriptor.java  |   23 -
 .../zest/api/mixin/MixinMappingException.java   |   33 -
 .../java/org/apache/zest/api/mixin/Mixins.java  |   79 -
 .../org/apache/zest/api/mixin/NoopMixin.java    |   78 -
 .../java/org/apache/zest/api/mixin/package.html |   21 -
 .../zest/api/object/NoSuchObjectException.java  |   46 -
 .../zest/api/object/ObjectDescriptor.java       |   25 -
 .../apache/zest/api/object/ObjectFactory.java   |   46 -
 .../org/apache/zest/api/object/package.html     |   21 -
 .../main/java/org/apache/zest/api/package.html  |   21 -
 .../apache/zest/api/property/DefaultValues.java |   82 -
 .../zest/api/property/GenericPropertyInfo.java  |   61 -
 .../org/apache/zest/api/property/Immutable.java |   31 -
 .../property/InvalidPropertyTypeException.java  |   40 -
 .../org/apache/zest/api/property/Numbers.java   |  156 --
 .../org/apache/zest/api/property/Property.java  |   61 -
 .../zest/api/property/PropertyDescriptor.java   |   56 -
 .../apache/zest/api/property/PropertyMixin.java |   54 -
 .../zest/api/property/PropertyWrapper.java      |   71 -
 .../apache/zest/api/property/StateHolder.java   |   37 -
 .../org/apache/zest/api/property/package.html   |   21 -
 .../query/MissingIndexingSystemException.java   |   29 -
 .../zest/api/query/NotQueryableException.java   |   88 -
 .../java/org/apache/zest/api/query/Query.java   |  138 --
 .../org/apache/zest/api/query/QueryBuilder.java |   56 -
 .../zest/api/query/QueryBuilderFactory.java     |   38 -
 .../apache/zest/api/query/QueryException.java   |   37 -
 .../zest/api/query/QueryExecutionException.java |   33 -
 .../api/query/QueryExpressionException.java     |   34 -
 .../apache/zest/api/query/QueryExpressions.java |  944 ---------
 .../api/query/grammar/AndSpecification.java     |   56 -
 .../api/query/grammar/AssociationFunction.java  |  148 --
 .../AssociationNotNullSpecification.java        |   67 -
 .../grammar/AssociationNullSpecification.java   |   67 -
 .../api/query/grammar/BinarySpecification.java  |   41 -
 .../query/grammar/ComparisonSpecification.java  |   76 -
 .../query/grammar/ContainsAllSpecification.java |   78 -
 .../query/grammar/ContainsSpecification.java    |   67 -
 .../zest/api/query/grammar/EqSpecification.java |   43 -
 .../query/grammar/ExpressionSpecification.java  |   60 -
 .../zest/api/query/grammar/GeSpecification.java |   44 -
 .../zest/api/query/grammar/GtSpecification.java |   44 -
 .../zest/api/query/grammar/LeSpecification.java |   44 -
 .../zest/api/query/grammar/LtSpecification.java |   44 -
 .../ManyAssociationContainsSpecification.java   |   65 -
 .../query/grammar/ManyAssociationFunction.java  |  117 --
 .../api/query/grammar/MatchesSpecification.java |   93 -
 ...medAssociationContainsNameSpecification.java |   65 -
 .../NamedAssociationContainsSpecification.java  |   65 -
 .../query/grammar/NamedAssociationFunction.java |  117 --
 .../zest/api/query/grammar/NeSpecification.java |   43 -
 .../api/query/grammar/NotSpecification.java     |   53 -
 .../zest/api/query/grammar/OrSpecification.java |   56 -
 .../apache/zest/api/query/grammar/OrderBy.java  |   92 -
 .../api/query/grammar/PropertyFunction.java     |  179 --
 .../grammar/PropertyNotNullSpecification.java   |   60 -
 .../grammar/PropertyNullSpecification.java      |   60 -
 .../api/query/grammar/PropertyReference.java    |   31 -
 .../api/query/grammar/QuerySpecification.java   |   71 -
 .../apache/zest/api/query/grammar/Variable.java |   43 -
 .../apache/zest/api/query/grammar/package.html  |   21 -
 .../java/org/apache/zest/api/query/package.html |   21 -
 .../apache/zest/api/service/Availability.java   |   34 -
 .../DuplicateServiceIdentityException.java      |   29 -
 .../zest/api/service/IdentityDescriptor.java    |   27 -
 .../api/service/ImportedServiceDescriptor.java  |   28 -
 .../api/service/NoSuchServiceException.java     |   30 -
 .../zest/api/service/ServiceActivation.java     |   67 -
 .../api/service/ServiceActivatorAdapter.java    |   69 -
 .../zest/api/service/ServiceComposite.java      |   27 -
 .../zest/api/service/ServiceDescriptor.java     |   29 -
 .../apache/zest/api/service/ServiceFinder.java  |   87 -
 .../zest/api/service/ServiceImporter.java       |   42 -
 .../api/service/ServiceImporterException.java   |   42 -
 .../zest/api/service/ServiceReference.java      |   47 -
 .../service/ServiceUnavailableException.java    |   35 -
 .../api/service/importer/InstanceImporter.java  |   80 -
 .../api/service/importer/NewObjectImporter.java |   46 -
 .../importer/ServiceInstanceImporter.java       |   80 -
 .../importer/ServiceSelectorImporter.java       |   78 -
 .../zest/api/service/importer/package.html      |   21 -
 .../org/apache/zest/api/service/package.html    |   21 -
 .../zest/api/service/qualifier/Active.java      |   51 -
 .../service/qualifier/AnnotationQualifier.java  |   27 -
 .../zest/api/service/qualifier/Available.java   |   49 -
 .../zest/api/service/qualifier/HasMetaInfo.java |  102 -
 .../api/service/qualifier/IdentifiedBy.java     |   53 -
 .../zest/api/service/qualifier/Qualifier.java   |   27 -
 .../api/service/qualifier/ServiceQualifier.java |  121 --
 .../zest/api/service/qualifier/ServiceTags.java |   66 -
 .../zest/api/service/qualifier/Tagged.java      |   54 -
 .../zest/api/service/qualifier/package.html     |   59 -
 .../zest/api/sideeffect/GenericSideEffect.java  |   61 -
 .../api/sideeffect/SideEffectDescriptor.java    |   23 -
 .../zest/api/sideeffect/SideEffectOf.java       |   38 -
 .../apache/zest/api/sideeffect/SideEffects.java |   33 -
 .../api/sideeffect/SideEffectsDescriptor.java   |   24 -
 .../api/sideeffect/internal/SideEffectFor.java  |   63 -
 .../zest/api/sideeffect/internal/package.html   |   25 -
 .../org/apache/zest/api/sideeffect/package.html |   21 -
 .../apache/zest/api/structure/Application.java  |   93 -
 .../api/structure/ApplicationDescriptor.java    |   37 -
 .../org/apache/zest/api/structure/Layer.java    |   31 -
 .../zest/api/structure/LayerDescriptor.java     |   31 -
 .../zest/api/structure/MetaInfoHolder.java      |   35 -
 .../org/apache/zest/api/structure/Module.java   |   80 -
 .../zest/api/structure/ModuleDescriptor.java    |   23 -
 .../api/structure/UsedLayersDescriptor.java     |   23 -
 .../org/apache/zest/api/structure/package.html  |   21 -
 .../apache/zest/api/type/CollectionType.java    |   72 -
 .../java/org/apache/zest/api/type/EnumType.java |   48 -
 .../java/org/apache/zest/api/type/HasTypes.java |   27 -
 .../java/org/apache/zest/api/type/MapType.java  |   85 -
 .../zest/api/type/MatchTypeSpecification.java   |   46 -
 .../org/apache/zest/api/type/Serialization.java |   56 -
 .../zest/api/type/ValueCompositeType.java       |   61 -
 .../org/apache/zest/api/type/ValueType.java     |  153 --
 .../java/org/apache/zest/api/type/package.html  |   21 -
 .../ConcurrentEntityModificationException.java  |   40 -
 .../EntityCompositeAlreadyExistsException.java  |   43 -
 .../unitofwork/EntityTypeNotFoundException.java |   61 -
 .../api/unitofwork/NoSuchEntityException.java   |  107 -
 .../apache/zest/api/unitofwork/UnitOfWork.java  |  429 ----
 .../zest/api/unitofwork/UnitOfWorkCallback.java |   51 -
 .../UnitOfWorkCompletionException.java          |   44 -
 .../api/unitofwork/UnitOfWorkException.java     |   45 -
 .../zest/api/unitofwork/UnitOfWorkFactory.java  |   90 -
 .../zest/api/unitofwork/UnitOfWorkOptions.java  |   43 -
 .../zest/api/unitofwork/UnitOfWorkTemplate.java |   93 -
 .../unitofwork/concern/UnitOfWorkConcern.java   |  181 --
 .../unitofwork/concern/UnitOfWorkDiscardOn.java |   67 -
 .../concern/UnitOfWorkPropagation.java          |   87 -
 .../api/unitofwork/concern/UnitOfWorkRetry.java |   44 -
 .../zest/api/unitofwork/concern/package.html    |   24 -
 .../org/apache/zest/api/unitofwork/package.html |   21 -
 .../org/apache/zest/api/usecase/Usecase.java    |   69 -
 .../apache/zest/api/usecase/UsecaseBuilder.java |   53 -
 .../org/apache/zest/api/usecase/package.html    |   21 -
 .../org/apache/zest/api/util/Annotations.java   |   92 -
 .../org/apache/zest/api/util/Base64Encoder.java |  224 ---
 .../java/org/apache/zest/api/util/Classes.java  |  699 -------
 .../org/apache/zest/api/util/Constructors.java  |   40 -
 .../java/org/apache/zest/api/util/Dates.java    |  102 -
 .../java/org/apache/zest/api/util/Fields.java   |   51 -
 .../java/org/apache/zest/api/util/ListMap.java  |   42 -
 .../java/org/apache/zest/api/util/Methods.java  |   50 -
 .../zest/api/util/NullArgumentException.java    |   56 -
 .../java/org/apache/zest/api/util/package.html  |   21 -
 .../zest/api/value/NoSuchValueException.java    |   28 -
 .../org/apache/zest/api/value/ValueBuilder.java |   56 -
 .../zest/api/value/ValueBuilderFactory.java     |  100 -
 .../zest/api/value/ValueBuilderTemplate.java    |   43 -
 .../apache/zest/api/value/ValueComposite.java   |   43 -
 .../apache/zest/api/value/ValueDescriptor.java  |   32 -
 .../zest/api/value/ValueDeserializer.java       |  152 --
 .../zest/api/value/ValueSerialization.java      |   52 -
 .../api/value/ValueSerializationException.java  |   46 -
 .../apache/zest/api/value/ValueSerializer.java  |  323 ---
 .../java/org/apache/zest/api/value/package.html |   21 -
 core/api/src/main/java/org/qi4j/api/Qi4j.java   |  193 ++
 .../org/qi4j/api/activation/Activation.java     |   55 +
 .../qi4j/api/activation/ActivationEvent.java    |   81 +
 .../api/activation/ActivationEventListener.java |   24 +
 .../ActivationEventListenerRegistration.java    |   33 +
 .../api/activation/ActivationException.java     |   30 +
 .../java/org/qi4j/api/activation/Activator.java |   54 +
 .../qi4j/api/activation/ActivatorAdapter.java   |   68 +
 .../api/activation/ActivatorDescriptor.java     |   25 +
 .../org/qi4j/api/activation/Activators.java     |   39 +
 .../ApplicationPassivationThread.java           |  112 ++
 .../api/activation/PassivationException.java    |   59 +
 .../java/org/qi4j/api/activation/package.html   |   26 +
 .../api/association/AbstractAssociation.java    |   22 +
 .../org/qi4j/api/association/Association.java   |   46 +
 .../api/association/AssociationDescriptor.java  |   63 +
 .../qi4j/api/association/AssociationMixin.java  |   52 +
 .../association/AssociationStateDescriptor.java |   53 +
 .../api/association/AssociationStateHolder.java |   77 +
 .../api/association/AssociationWrapper.java     |   79 +
 .../api/association/GenericAssociationInfo.java |   58 +
 .../qi4j/api/association/ManyAssociation.java   |   51 +
 .../api/association/ManyAssociationMixin.java   |   52 +
 .../api/association/ManyAssociationWrapper.java |  123 ++
 .../qi4j/api/association/NamedAssociation.java  |   91 +
 .../api/association/NamedAssociationMixin.java  |   57 +
 .../association/NamedAssociationWrapper.java    |  122 ++
 .../java/org/qi4j/api/association/package.html  |   21 +
 .../java/org/qi4j/api/cache/CacheOptions.java   |   86 +
 .../main/java/org/qi4j/api/cache/package.html   |   40 +
 .../java/org/qi4j/api/common/AppliesTo.java     |  107 +
 .../org/qi4j/api/common/AppliesToFilter.java    |   83 +
 .../qi4j/api/common/ConstructionException.java  |   55 +
 .../api/common/InvalidApplicationException.java |   36 +
 .../main/java/org/qi4j/api/common/MetaInfo.java |  151 ++
 .../main/java/org/qi4j/api/common/Optional.java |   63 +
 .../java/org/qi4j/api/common/QualifiedName.java |  252 +++
 .../main/java/org/qi4j/api/common/TypeName.java |  111 ++
 .../java/org/qi4j/api/common/UseDefaults.java   |   78 +
 .../java/org/qi4j/api/common/Visibility.java    |   40 +
 .../main/java/org/qi4j/api/common/package.html  |   81 +
 .../api/composite/AmbiguousTypeException.java   |   57 +
 .../java/org/qi4j/api/composite/Composite.java  |   34 +
 .../qi4j/api/composite/CompositeContext.java    |   80 +
 .../qi4j/api/composite/CompositeDescriptor.java |   26 +
 .../qi4j/api/composite/CompositeInstance.java   |   39 +
 .../qi4j/api/composite/CompositeInvoker.java    |   35 +
 .../api/composite/ConstructorDescriptor.java    |   25 +
 .../org/qi4j/api/composite/DecoratorMixin.java  |  104 +
 .../api/composite/DependencyDescriptor.java     |   38 +
 .../api/composite/InjectedFieldDescriptor.java  |   26 +
 .../api/composite/InjectedMethodDescriptor.java |   25 +
 .../composite/InjectedParametersDescriptor.java |   22 +
 .../composite/InvalidCompositeException.java    |   29 +
 .../InvalidValueCompositeException.java         |   30 +
 .../qi4j/api/composite/MethodDescriptor.java    |   25 +
 .../api/composite/MissingMethodException.java   |   36 +
 .../org/qi4j/api/composite/ModelDescriptor.java |   33 +
 .../api/composite/NoSuchCompositeException.java |   46 +
 .../api/composite/NoSuchTransientException.java |   28 +
 .../org/qi4j/api/composite/PropertyMapper.java  |  580 ++++++
 .../org/qi4j/api/composite/StateDescriptor.java |   32 +
 .../composite/StatefulCompositeDescriptor.java  |   27 +
 .../qi4j/api/composite/TransientBuilder.java    |   68 +
 .../api/composite/TransientBuilderFactory.java  |   54 +
 .../qi4j/api/composite/TransientComposite.java  |   35 +
 .../qi4j/api/composite/TransientDescriptor.java |   23 +
 .../java/org/qi4j/api/composite/package.html    |   21 +
 .../org/qi4j/api/concern/ConcernDescriptor.java |   23 +
 .../java/org/qi4j/api/concern/ConcernOf.java    |   44 +
 .../java/org/qi4j/api/concern/Concerns.java     |   34 +
 .../qi4j/api/concern/ConcernsDescriptor.java    |   24 +
 .../org/qi4j/api/concern/GenericConcern.java    |   32 +
 .../qi4j/api/concern/internal/ConcernFor.java   |   62 +
 .../org/qi4j/api/concern/internal/package.html  |   25 +
 .../main/java/org/qi4j/api/concern/package.html |   21 +
 .../qi4j/api/configuration/Configuration.java   |  396 ++++
 .../configuration/ConfigurationComposite.java   |   32 +
 .../org/qi4j/api/configuration/Enabled.java     |   28 +
 .../NoSuchConfigurationException.java           |   48 +
 .../org/qi4j/api/configuration/package.html     |   21 +
 .../org/qi4j/api/constraint/Constraint.java     |   39 +
 .../api/constraint/ConstraintDeclaration.java   |   31 +
 .../api/constraint/ConstraintDescriptor.java    |   25 +
 ...nstraintImplementationNotFoundException.java |   28 +
 .../api/constraint/ConstraintViolation.java     |   52 +
 .../ConstraintViolationException.java           |  257 +++
 .../org/qi4j/api/constraint/Constraints.java    |   36 +
 .../api/constraint/ConstraintsDescriptor.java   |   22 +
 .../main/java/org/qi4j/api/constraint/Name.java |   32 +
 .../java/org/qi4j/api/constraint/package.html   |   21 +
 .../main/java/org/qi4j/api/dataset/DataSet.java |   36 +
 .../org/qi4j/api/dataset/DataSetSource.java     |   27 +
 .../main/java/org/qi4j/api/dataset/Query.java   |   64 +
 .../api/dataset/iterable/IterableDataSet.java   |   57 +
 .../api/dataset/iterable/IterableQuery.java     |  127 ++
 .../org/qi4j/api/dataset/iterable/package.html  |   21 +
 .../main/java/org/qi4j/api/dataset/package.html |   21 +
 .../java/org/qi4j/api/entity/Aggregated.java    |   31 +
 .../java/org/qi4j/api/entity/EntityBuilder.java |   60 +
 .../qi4j/api/entity/EntityBuilderTemplate.java  |   43 +
 .../org/qi4j/api/entity/EntityComposite.java    |   31 +
 .../org/qi4j/api/entity/EntityDescriptor.java   |   31 +
 .../org/qi4j/api/entity/EntityReference.java    |  133 ++
 .../main/java/org/qi4j/api/entity/Identity.java |   56 +
 .../org/qi4j/api/entity/IdentityGenerator.java  |   32 +
 .../java/org/qi4j/api/entity/Lifecycle.java     |   85 +
 .../org/qi4j/api/entity/LifecycleException.java |   37 +
 .../java/org/qi4j/api/entity/Queryable.java     |   32 +
 .../main/java/org/qi4j/api/entity/package.html  |   21 +
 .../main/java/org/qi4j/api/event/package.html   |   21 +
 .../org/qi4j/api/injection/InjectionScope.java  |   32 +
 .../java/org/qi4j/api/injection/package.html    |   21 +
 .../qi4j/api/injection/scope/Invocation.java    |   50 +
 .../org/qi4j/api/injection/scope/Service.java   |   43 +
 .../org/qi4j/api/injection/scope/State.java     |   48 +
 .../org/qi4j/api/injection/scope/Structure.java |   49 +
 .../java/org/qi4j/api/injection/scope/This.java |   42 +
 .../java/org/qi4j/api/injection/scope/Uses.java |   40 +
 .../org/qi4j/api/injection/scope/package.html   |   21 +
 .../main/java/org/qi4j/api/metrics/Metric.java  |   24 +
 .../org/qi4j/api/metrics/MetricsCounter.java    |   31 +
 .../qi4j/api/metrics/MetricsCounterFactory.java |   34 +
 .../org/qi4j/api/metrics/MetricsFactory.java    |   25 +
 .../java/org/qi4j/api/metrics/MetricsGauge.java |   34 +
 .../qi4j/api/metrics/MetricsGaugeFactory.java   |   35 +
 .../qi4j/api/metrics/MetricsHealthCheck.java    |   55 +
 .../api/metrics/MetricsHealthCheckFactory.java  |   36 +
 .../org/qi4j/api/metrics/MetricsHistogram.java  |   28 +
 .../api/metrics/MetricsHistogramFactory.java    |   35 +
 .../java/org/qi4j/api/metrics/MetricsMeter.java |   35 +
 .../qi4j/api/metrics/MetricsMeterFactory.java   |   38 +
 .../metrics/MetricsNotSupportedException.java   |   32 +
 .../org/qi4j/api/metrics/MetricsProvider.java   |   58 +
 .../java/org/qi4j/api/metrics/MetricsTimer.java |   39 +
 .../qi4j/api/metrics/MetricsTimerFactory.java   |   39 +
 .../main/java/org/qi4j/api/metrics/package.html |   21 +
 .../java/org/qi4j/api/mixin/Initializable.java  |   32 +
 .../qi4j/api/mixin/InitializationException.java |   43 +
 .../qi4j/api/mixin/InvalidMixinException.java   |   33 +
 .../org/qi4j/api/mixin/MixinDescriptor.java     |   23 +
 .../qi4j/api/mixin/MixinMappingException.java   |   33 +
 .../main/java/org/qi4j/api/mixin/Mixins.java    |   79 +
 .../main/java/org/qi4j/api/mixin/NoopMixin.java |   78 +
 .../main/java/org/qi4j/api/mixin/package.html   |   21 +
 .../qi4j/api/object/NoSuchObjectException.java  |   46 +
 .../org/qi4j/api/object/ObjectDescriptor.java   |   25 +
 .../java/org/qi4j/api/object/ObjectFactory.java |   46 +
 .../main/java/org/qi4j/api/object/package.html  |   21 +
 .../api/src/main/java/org/qi4j/api/package.html |   21 +
 .../org/qi4j/api/property/DefaultValues.java    |   82 +
 .../qi4j/api/property/GenericPropertyInfo.java  |   61 +
 .../java/org/qi4j/api/property/Immutable.java   |   31 +
 .../property/InvalidPropertyTypeException.java  |   40 +
 .../java/org/qi4j/api/property/Numbers.java     |  156 ++
 .../java/org/qi4j/api/property/Property.java    |   61 +
 .../qi4j/api/property/PropertyDescriptor.java   |   56 +
 .../org/qi4j/api/property/PropertyMixin.java    |   54 +
 .../org/qi4j/api/property/PropertyWrapper.java  |   71 +
 .../java/org/qi4j/api/property/StateHolder.java |   37 +
 .../java/org/qi4j/api/property/package.html     |   21 +
 .../query/MissingIndexingSystemException.java   |   29 +
 .../qi4j/api/query/NotQueryableException.java   |   88 +
 .../src/main/java/org/qi4j/api/query/Query.java |  138 ++
 .../java/org/qi4j/api/query/QueryBuilder.java   |   56 +
 .../org/qi4j/api/query/QueryBuilderFactory.java |   38 +
 .../java/org/qi4j/api/query/QueryException.java |   37 +
 .../qi4j/api/query/QueryExecutionException.java |   33 +
 .../api/query/QueryExpressionException.java     |   34 +
 .../org/qi4j/api/query/QueryExpressions.java    |  944 +++++++++
 .../api/query/grammar/AndSpecification.java     |   56 +
 .../api/query/grammar/AssociationFunction.java  |  148 ++
 .../AssociationNotNullSpecification.java        |   67 +
 .../grammar/AssociationNullSpecification.java   |   67 +
 .../api/query/grammar/BinarySpecification.java  |   41 +
 .../query/grammar/ComparisonSpecification.java  |   76 +
 .../query/grammar/ContainsAllSpecification.java |   78 +
 .../query/grammar/ContainsSpecification.java    |   67 +
 .../qi4j/api/query/grammar/EqSpecification.java |   43 +
 .../query/grammar/ExpressionSpecification.java  |   60 +
 .../qi4j/api/query/grammar/GeSpecification.java |   44 +
 .../qi4j/api/query/grammar/GtSpecification.java |   44 +
 .../qi4j/api/query/grammar/LeSpecification.java |   44 +
 .../qi4j/api/query/grammar/LtSpecification.java |   44 +
 .../ManyAssociationContainsSpecification.java   |   65 +
 .../query/grammar/ManyAssociationFunction.java  |  117 ++
 .../api/query/grammar/MatchesSpecification.java |   93 +
 ...medAssociationContainsNameSpecification.java |   65 +
 .../NamedAssociationContainsSpecification.java  |   65 +
 .../query/grammar/NamedAssociationFunction.java |  117 ++
 .../qi4j/api/query/grammar/NeSpecification.java |   43 +
 .../api/query/grammar/NotSpecification.java     |   53 +
 .../qi4j/api/query/grammar/OrSpecification.java |   56 +
 .../org/qi4j/api/query/grammar/OrderBy.java     |   92 +
 .../api/query/grammar/PropertyFunction.java     |  179 ++
 .../grammar/PropertyNotNullSpecification.java   |   60 +
 .../grammar/PropertyNullSpecification.java      |   60 +
 .../api/query/grammar/PropertyReference.java    |   31 +
 .../api/query/grammar/QuerySpecification.java   |   71 +
 .../org/qi4j/api/query/grammar/Variable.java    |   43 +
 .../org/qi4j/api/query/grammar/package.html     |   21 +
 .../main/java/org/qi4j/api/query/package.html   |   21 +
 .../java/org/qi4j/api/service/Availability.java |   34 +
 .../DuplicateServiceIdentityException.java      |   29 +
 .../qi4j/api/service/IdentityDescriptor.java    |   27 +
 .../api/service/ImportedServiceDescriptor.java  |   28 +
 .../api/service/NoSuchServiceException.java     |   30 +
 .../org/qi4j/api/service/ServiceActivation.java |   67 +
 .../api/service/ServiceActivatorAdapter.java    |   69 +
 .../org/qi4j/api/service/ServiceComposite.java  |   27 +
 .../org/qi4j/api/service/ServiceDescriptor.java |   29 +
 .../org/qi4j/api/service/ServiceFinder.java     |   87 +
 .../org/qi4j/api/service/ServiceImporter.java   |   42 +
 .../api/service/ServiceImporterException.java   |   42 +
 .../org/qi4j/api/service/ServiceReference.java  |   47 +
 .../service/ServiceUnavailableException.java    |   35 +
 .../api/service/importer/InstanceImporter.java  |   80 +
 .../api/service/importer/NewObjectImporter.java |   46 +
 .../importer/ServiceInstanceImporter.java       |   80 +
 .../importer/ServiceSelectorImporter.java       |   78 +
 .../org/qi4j/api/service/importer/package.html  |   21 +
 .../main/java/org/qi4j/api/service/package.html |   21 +
 .../org/qi4j/api/service/qualifier/Active.java  |   51 +
 .../service/qualifier/AnnotationQualifier.java  |   27 +
 .../qi4j/api/service/qualifier/Available.java   |   49 +
 .../qi4j/api/service/qualifier/HasMetaInfo.java |  102 +
 .../api/service/qualifier/IdentifiedBy.java     |   53 +
 .../qi4j/api/service/qualifier/Qualifier.java   |   27 +
 .../api/service/qualifier/ServiceQualifier.java |  121 ++
 .../qi4j/api/service/qualifier/ServiceTags.java |   66 +
 .../org/qi4j/api/service/qualifier/Tagged.java  |   54 +
 .../org/qi4j/api/service/qualifier/package.html |   59 +
 .../qi4j/api/sideeffect/GenericSideEffect.java  |   61 +
 .../api/sideeffect/SideEffectDescriptor.java    |   23 +
 .../org/qi4j/api/sideeffect/SideEffectOf.java   |   38 +
 .../org/qi4j/api/sideeffect/SideEffects.java    |   33 +
 .../api/sideeffect/SideEffectsDescriptor.java   |   24 +
 .../api/sideeffect/internal/SideEffectFor.java  |   63 +
 .../qi4j/api/sideeffect/internal/package.html   |   25 +
 .../java/org/qi4j/api/sideeffect/package.html   |   21 +
 .../org/qi4j/api/structure/Application.java     |   93 +
 .../api/structure/ApplicationDescriptor.java    |   37 +
 .../main/java/org/qi4j/api/structure/Layer.java |   31 +
 .../org/qi4j/api/structure/LayerDescriptor.java |   31 +
 .../org/qi4j/api/structure/MetaInfoHolder.java  |   35 +
 .../java/org/qi4j/api/structure/Module.java     |   83 +
 .../qi4j/api/structure/ModuleDescriptor.java    |   23 +
 .../api/structure/UsedLayersDescriptor.java     |   23 +
 .../java/org/qi4j/api/structure/package.html    |   21 +
 .../java/org/qi4j/api/type/CollectionType.java  |   72 +
 .../main/java/org/qi4j/api/type/EnumType.java   |   48 +
 .../main/java/org/qi4j/api/type/HasTypes.java   |   27 +
 .../main/java/org/qi4j/api/type/MapType.java    |   85 +
 .../qi4j/api/type/MatchTypeSpecification.java   |   46 +
 .../java/org/qi4j/api/type/Serialization.java   |   56 +
 .../org/qi4j/api/type/ValueCompositeType.java   |   61 +
 .../main/java/org/qi4j/api/type/ValueType.java  |  153 ++
 .../main/java/org/qi4j/api/type/package.html    |   21 +
 .../ConcurrentEntityModificationException.java  |   40 +
 .../EntityCompositeAlreadyExistsException.java  |   43 +
 .../unitofwork/EntityTypeNotFoundException.java |   61 +
 .../api/unitofwork/NoSuchEntityException.java   |  107 +
 .../org/qi4j/api/unitofwork/UnitOfWork.java     |  429 ++++
 .../qi4j/api/unitofwork/UnitOfWorkCallback.java |   51 +
 .../UnitOfWorkCompletionException.java          |   44 +
 .../api/unitofwork/UnitOfWorkException.java     |   45 +
 .../qi4j/api/unitofwork/UnitOfWorkFactory.java  |   90 +
 .../qi4j/api/unitofwork/UnitOfWorkOptions.java  |   43 +
 .../qi4j/api/unitofwork/UnitOfWorkTemplate.java |   93 +
 .../unitofwork/concern/UnitOfWorkConcern.java   |  182 ++
 .../unitofwork/concern/UnitOfWorkDiscardOn.java |   67 +
 .../concern/UnitOfWorkPropagation.java          |   87 +
 .../api/unitofwork/concern/UnitOfWorkRetry.java |   44 +
 .../qi4j/api/unitofwork/concern/package.html    |   24 +
 .../java/org/qi4j/api/unitofwork/package.html   |   21 +
 .../main/java/org/qi4j/api/usecase/Usecase.java |   69 +
 .../org/qi4j/api/usecase/UsecaseBuilder.java    |   53 +
 .../main/java/org/qi4j/api/usecase/package.html |   21 +
 .../java/org/qi4j/api/util/Annotations.java     |   92 +
 .../java/org/qi4j/api/util/Base64Encoder.java   |  224 +++
 .../main/java/org/qi4j/api/util/Classes.java    |  699 +++++++
 .../java/org/qi4j/api/util/Constructors.java    |   40 +
 .../src/main/java/org/qi4j/api/util/Dates.java  |  102 +
 .../src/main/java/org/qi4j/api/util/Fields.java |   51 +
 .../main/java/org/qi4j/api/util/ListMap.java    |   42 +
 .../main/java/org/qi4j/api/util/Methods.java    |   50 +
 .../qi4j/api/util/NullArgumentException.java    |   56 +
 .../main/java/org/qi4j/api/util/package.html    |   21 +
 .../qi4j/api/value/NoSuchValueException.java    |   28 +
 .../java/org/qi4j/api/value/ValueBuilder.java   |   56 +
 .../org/qi4j/api/value/ValueBuilderFactory.java |  100 +
 .../qi4j/api/value/ValueBuilderTemplate.java    |   43 +
 .../java/org/qi4j/api/value/ValueComposite.java |   43 +
 .../org/qi4j/api/value/ValueDescriptor.java     |   32 +
 .../org/qi4j/api/value/ValueDeserializer.java   |  152 ++
 .../org/qi4j/api/value/ValueSerialization.java  |   52 +
 .../api/value/ValueSerializationException.java  |   46 +
 .../org/qi4j/api/value/ValueSerializer.java     |  323 +++
 .../main/java/org/qi4j/api/value/package.html   |   21 +
 .../java/org/apache/zest/api/OperatorsTest.java |  115 --
 .../api/activation/ActivationEventsTest.java    |  290 ---
 .../activation/PassivationExceptionTest.java    |  212 --
 .../apache/zest/api/annotation/MixinsTest.java  |   43 -
 .../zest/api/annotation/ModifiedByTest.java     |   43 -
 .../zest/api/annotation/scope/ModifiesTest.java |   44 -
 .../apache/zest/api/common/AppliesToTest.java   |   42 -
 .../zest/api/common/QualifiedNameTest.java      |   83 -
 .../zest/api/composite/PropertyMapperTest.java  |  238 ---
 .../zest/api/concern/DocumentationSupport.java  |  100 -
 .../api/configuration/ConfigurationTest.java    |  109 --
 .../DeclareConfigurationDefaultsTest.java       |   83 -
 .../zest/api/configuration/MailService.java     |   66 -
 .../configuration/MailServiceConfiguration.java |   29 -
 .../dataset/iterable/IterableDataSetTest.java   |   61 -
 .../zest/api/docsupport/ApplicationDocs.java    |  274 ---
 .../zest/api/docsupport/CompositionDocs.java    |   56 -
 .../org/apache/zest/api/docsupport/package.html |   21 -
 .../api/injection/scope/StateFieldTest.java     |  143 --
 .../zest/api/injection/scope/ThisTest.java      |   47 -
 .../zest/api/metrics/DocumentationSupport.java  |  112 --
 .../org/apache/zest/api/mixin/BankAccount.java  |   30 -
 .../java/org/apache/zest/api/mixin/Car.java     |   26 -
 .../org/apache/zest/api/mixin/Something.java    |   27 -
 .../apache/zest/api/mixin/SomethingMixin.java   |   32 -
 .../org/apache/zest/api/mixin/StartMixin.java   |   22 -
 .../org/apache/zest/api/mixin/Startable.java    |   28 -
 .../java/org/apache/zest/api/mixin/Vehicle.java |   31 -
 .../org/apache/zest/api/mixin/VehicleMixin.java |   22 -
 .../decoratorMixin/DecoratorMixinTest.java      |   91 -
 .../zest/api/mixin/decoratorMixin/FooModel.java |   36 -
 .../api/mixin/decoratorMixin/FooModelImpl.java  |   41 -
 .../FooModelInvocationHandler.java              |   47 -
 .../zest/api/mixin/decoratorMixin/View1.java    |   43 -
 .../zest/api/mixin/decoratorMixin/View2.java    |   40 -
 .../org/apache/zest/api/mixin/partial/Car.java  |   30 -
 .../api/mixin/partial/CrashResultMixin.java     |   23 -
 .../zest/api/mixin/partial/Crashable.java       |   23 -
 .../zest/api/mixin/partial/SpeedLocation.java   |   28 -
 .../zest/api/mixin/partial/SpeedMixin.java      |   33 -
 .../apache/zest/api/mixin/partial/Vehicle.java  |   26 -
 .../zest/api/mixin/privateMixin/Cargo.java      |   36 -
 .../zest/api/mixin/privateMixin/CargoMixin.java |   46 -
 .../zest/api/mixin/privateMixin/CargoState.java |   30 -
 .../zest/api/object/ObjectBuilderTest.java      |   69 -
 .../zest/api/property/PropertyErrorTest.java    |   61 -
 .../zest/api/service/DocumentationSupport.java  |  135 --
 .../apache/zest/api/unitofwork/RemovalTest.java |  130 --
 .../api/unitofwork/UnitOfWorkTemplateTest.java  |   73 -
 .../org/apache/zest/api/util/ClassesTest.java   |  214 --
 .../zest/api/value/DocumentationSupport.java    |  298 ---
 .../api/value/ValueBuilderTemplateTest.java     |   84 -
 .../zest/api/value/ValueCompositeTest.java      |  308 ---
 .../test/java/org/qi4j/api/OperatorsTest.java   |  115 ++
 .../api/activation/ActivationEventsTest.java    |  290 +++
 .../activation/PassivationExceptionTest.java    |  212 ++
 .../org/qi4j/api/annotation/MixinsTest.java     |   43 +
 .../org/qi4j/api/annotation/ModifiedByTest.java |   43 +
 .../qi4j/api/annotation/scope/ModifiesTest.java |   44 +
 .../java/org/qi4j/api/common/AppliesToTest.java |   42 +
 .../org/qi4j/api/common/QualifiedNameTest.java  |   83 +
 .../qi4j/api/composite/PropertyMapperTest.java  |  240 +++
 .../qi4j/api/concern/DocumentationSupport.java  |  100 +
 .../api/configuration/ConfigurationTest.java    |  109 ++
 .../DeclareConfigurationDefaultsTest.java       |   83 +
 .../org/qi4j/api/configuration/MailService.java |   66 +
 .../configuration/MailServiceConfiguration.java |   29 +
 .../dataset/iterable/IterableDataSetTest.java   |   61 +
 .../qi4j/api/docsupport/ApplicationDocs.java    |  274 +++
 .../qi4j/api/docsupport/CompositionDocs.java    |   56 +
 .../java/org/qi4j/api/docsupport/package.html   |   21 +
 .../api/injection/scope/StateFieldTest.java     |  143 ++
 .../org/qi4j/api/injection/scope/ThisTest.java  |   47 +
 .../qi4j/api/metrics/DocumentationSupport.java  |  115 ++
 .../java/org/qi4j/api/mixin/BankAccount.java    |   30 +
 .../src/test/java/org/qi4j/api/mixin/Car.java   |   26 +
 .../test/java/org/qi4j/api/mixin/Something.java |   27 +
 .../java/org/qi4j/api/mixin/SomethingMixin.java |   32 +
 .../java/org/qi4j/api/mixin/StartMixin.java     |   22 +
 .../test/java/org/qi4j/api/mixin/Startable.java |   28 +
 .../test/java/org/qi4j/api/mixin/Vehicle.java   |   31 +
 .../java/org/qi4j/api/mixin/VehicleMixin.java   |   22 +
 .../decoratorMixin/DecoratorMixinTest.java      |   91 +
 .../qi4j/api/mixin/decoratorMixin/FooModel.java |   36 +
 .../api/mixin/decoratorMixin/FooModelImpl.java  |   41 +
 .../FooModelInvocationHandler.java              |   47 +
 .../qi4j/api/mixin/decoratorMixin/View1.java    |   43 +
 .../qi4j/api/mixin/decoratorMixin/View2.java    |   40 +
 .../java/org/qi4j/api/mixin/partial/Car.java    |   30 +
 .../api/mixin/partial/CrashResultMixin.java     |   23 +
 .../org/qi4j/api/mixin/partial/Crashable.java   |   23 +
 .../qi4j/api/mixin/partial/SpeedLocation.java   |   28 +
 .../org/qi4j/api/mixin/partial/SpeedMixin.java  |   33 +
 .../org/qi4j/api/mixin/partial/Vehicle.java     |   26 +
 .../org/qi4j/api/mixin/privateMixin/Cargo.java  |   36 +
 .../qi4j/api/mixin/privateMixin/CargoMixin.java |   46 +
 .../qi4j/api/mixin/privateMixin/CargoState.java |   30 +
 .../org/qi4j/api/object/ObjectBuilderTest.java  |   69 +
 .../qi4j/api/property/PropertyErrorTest.java    |   61 +
 .../qi4j/api/service/DocumentationSupport.java  |  135 ++
 .../org/qi4j/api/unitofwork/RemovalTest.java    |  130 ++
 .../api/unitofwork/UnitOfWorkTemplateTest.java  |   73 +
 .../java/org/qi4j/api/util/ClassesTest.java     |  214 ++
 .../qi4j/api/value/DocumentationSupport.java    |  298 +++
 .../api/value/ValueBuilderTemplateTest.java     |   84 +
 .../org/qi4j/api/value/ValueCompositeTest.java  |  308 +++
 .../zest/api/configuration/MyService.properties |   16 -
 .../qi4j/api/configuration/MyService.properties |   16 +
 .../zest/bootstrap/ApplicationAssembler.java    |   33 -
 .../bootstrap/ApplicationAssemblerAdapter.java  |   43 -
 .../zest/bootstrap/ApplicationAssembly.java     |  110 --
 .../bootstrap/ApplicationAssemblyFactory.java   |   61 -
 .../zest/bootstrap/ApplicationModelFactory.java |   27 -
 .../apache/zest/bootstrap/ApplicationName.java  |   36 -
 .../org/apache/zest/bootstrap/Assembler.java    |   44 -
 .../zest/bootstrap/AssemblerCollection.java     |   70 -
 .../org/apache/zest/bootstrap/Assemblers.java   |  446 -----
 .../zest/bootstrap/AssemblyException.java       |   41 -
 .../zest/bootstrap/AssemblySpecifications.java  |   49 -
 .../apache/zest/bootstrap/AssemblyVisitor.java  |   54 -
 .../zest/bootstrap/AssemblyVisitorAdapter.java  |   77 -
 .../zest/bootstrap/AssociationDeclarations.java |   26 -
 .../apache/zest/bootstrap/BindingException.java |   32 -
 .../zest/bootstrap/BootstrapException.java      |   36 -
 .../org/apache/zest/bootstrap/ClassScanner.java |  216 ---
 .../zest/bootstrap/ConfigurationAssembly.java   |   28 -
 .../bootstrap/ConfigurationDeclaration.java     |   87 -
 .../org/apache/zest/bootstrap/Energy4Java.java  |   96 -
 .../apache/zest/bootstrap/EntityAssembly.java   |   29 -
 .../zest/bootstrap/EntityDeclaration.java       |   87 -
 .../zest/bootstrap/ImportedServiceAssembly.java |   29 -
 .../bootstrap/ImportedServiceDeclaration.java   |   63 -
 .../zest/bootstrap/InjectionException.java      |   37 -
 .../bootstrap/InvalidInjectionException.java    |   36 -
 .../apache/zest/bootstrap/LayerAssembly.java    |  123 --
 .../org/apache/zest/bootstrap/LayerName.java    |   36 -
 .../bootstrap/ManyAssociationDeclarations.java  |   26 -
 .../zest/bootstrap/MetaInfoDeclaration.java     |  221 ---
 .../apache/zest/bootstrap/MixinDeclaration.java |   27 -
 .../apache/zest/bootstrap/ModuleAssembly.java   |  240 ---
 .../org/apache/zest/bootstrap/ModuleName.java   |   36 -
 .../bootstrap/NamedAssociationDeclarations.java |   31 -
 .../apache/zest/bootstrap/ObjectAssembly.java   |   29 -
 .../zest/bootstrap/ObjectDeclaration.java       |   33 -
 .../org/apache/zest/bootstrap/Qi4jRuntime.java  |   32 -
 .../apache/zest/bootstrap/RuntimeFactory.java   |   62 -
 .../apache/zest/bootstrap/ServiceAssembly.java  |   29 -
 .../zest/bootstrap/ServiceDeclaration.java      |   58 -
 .../zest/bootstrap/SingletonAssembler.java      |   99 -
 .../zest/bootstrap/StateDeclarations.java       |   30 -
 .../zest/bootstrap/TransientAssembly.java       |   29 -
 .../zest/bootstrap/TransientDeclaration.java    |   40 -
 .../apache/zest/bootstrap/ValueAssembly.java    |   29 -
 .../apache/zest/bootstrap/ValueDeclaration.java |   39 -
 .../bootstrap/builder/ApplicationBuilder.java   |  250 ---
 .../bootstrap/builder/LayerDeclaration.java     |  109 --
 .../bootstrap/builder/ModuleDeclaration.java    |  169 --
 .../apache/zest/bootstrap/builder/package.html  |   25 -
 .../zest/bootstrap/layered/LayerAssembler.java  |   28 -
 .../layered/LayeredApplicationAssembler.java    |  212 --
 .../layered/LayeredLayerAssembler.java          |   86 -
 .../zest/bootstrap/layered/ModuleAssembler.java |   29 -
 .../apache/zest/bootstrap/layered/package.html  |   21 -
 .../java/org/apache/zest/bootstrap/package.html |   21 -
 .../qi4j/bootstrap/ApplicationAssembler.java    |   33 +
 .../bootstrap/ApplicationAssemblerAdapter.java  |   43 +
 .../org/qi4j/bootstrap/ApplicationAssembly.java |  110 ++
 .../bootstrap/ApplicationAssemblyFactory.java   |   61 +
 .../qi4j/bootstrap/ApplicationModelFactory.java |   27 +
 .../org/qi4j/bootstrap/ApplicationName.java     |   36 +
 .../main/java/org/qi4j/bootstrap/Assembler.java |   44 +
 .../org/qi4j/bootstrap/AssemblerCollection.java |   70 +
 .../java/org/qi4j/bootstrap/Assemblers.java     |  446 +++++
 .../org/qi4j/bootstrap/AssemblyException.java   |   41 +
 .../qi4j/bootstrap/AssemblySpecifications.java  |   49 +
 .../org/qi4j/bootstrap/AssemblyVisitor.java     |   54 +
 .../qi4j/bootstrap/AssemblyVisitorAdapter.java  |   77 +
 .../qi4j/bootstrap/AssociationDeclarations.java |   26 +
 .../org/qi4j/bootstrap/BindingException.java    |   32 +
 .../org/qi4j/bootstrap/BootstrapException.java  |   36 +
 .../java/org/qi4j/bootstrap/ClassScanner.java   |  216 +++
 .../qi4j/bootstrap/ConfigurationAssembly.java   |   28 +
 .../bootstrap/ConfigurationDeclaration.java     |   87 +
 .../java/org/qi4j/bootstrap/Energy4Java.java    |   96 +
 .../java/org/qi4j/bootstrap/EntityAssembly.java |   29 +
 .../org/qi4j/bootstrap/EntityDeclaration.java   |   87 +
 .../qi4j/bootstrap/ImportedServiceAssembly.java |   29 +
 .../bootstrap/ImportedServiceDeclaration.java   |   63 +
 .../org/qi4j/bootstrap/InjectionException.java  |   37 +
 .../bootstrap/InvalidInjectionException.java    |   36 +
 .../java/org/qi4j/bootstrap/LayerAssembly.java  |  123 ++
 .../main/java/org/qi4j/bootstrap/LayerName.java |   36 +
 .../bootstrap/ManyAssociationDeclarations.java  |   26 +
 .../org/qi4j/bootstrap/MetaInfoDeclaration.java |  221 +++
 .../org/qi4j/bootstrap/MixinDeclaration.java    |   27 +
 .../java/org/qi4j/bootstrap/ModuleAssembly.java |  240 +++
 .../java/org/qi4j/bootstrap/ModuleName.java     |   36 +
 .../bootstrap/NamedAssociationDeclarations.java |   31 +
 .../java/org/qi4j/bootstrap/ObjectAssembly.java |   29 +
 .../org/qi4j/bootstrap/ObjectDeclaration.java   |   33 +
 .../java/org/qi4j/bootstrap/Qi4jRuntime.java    |   32 +
 .../java/org/qi4j/bootstrap/RuntimeFactory.java |   62 +
 .../org/qi4j/bootstrap/ServiceAssembly.java     |   29 +
 .../org/qi4j/bootstrap/ServiceDeclaration.java  |   58 +
 .../org/qi4j/bootstrap/SingletonAssembler.java  |   99 +
 .../org/qi4j/bootstrap/StateDeclarations.java   |   30 +
 .../org/qi4j/bootstrap/TransientAssembly.java   |   29 +
 .../qi4j/bootstrap/TransientDeclaration.java    |   40 +
 .../java/org/qi4j/bootstrap/ValueAssembly.java  |   29 +
 .../org/qi4j/bootstrap/ValueDeclaration.java    |   39 +
 .../bootstrap/builder/ApplicationBuilder.java   |  250 +++
 .../bootstrap/builder/LayerDeclaration.java     |  109 ++
 .../bootstrap/builder/ModuleDeclaration.java    |  169 ++
 .../org/qi4j/bootstrap/builder/package.html     |   25 +
 .../qi4j/bootstrap/layered/LayerAssembler.java  |   29 +
 .../layered/LayeredApplicationAssembler.java    |  212 ++
 .../layered/LayeredLayerAssembler.java          |   86 +
 .../qi4j/bootstrap/layered/ModuleAssembler.java |   29 +
 .../org/qi4j/bootstrap/layered/package.html     |   21 +
 .../main/java/org/qi4j/bootstrap/package.html   |   21 +
 .../apache/zest/bootstrap/ClassScannerTest.java |   64 -
 .../zest/bootstrap/DocumentationSupport.java    |  441 -----
 .../org/apache/zest/bootstrap/TestValue.java    |   28 -
 .../LayeredApplicationAssemblerTest.java        |   41 -
 .../bootstrap/assembly/TestApplication.java     |   61 -
 .../assembly/config/ConfigurationLayer.java     |   33 -
 .../connectivity/ConnectivityLayer.java         |   35 -
 .../bootstrap/assembly/domain/DomainLayer.java  |   35 -
 .../assembly/domain/InvoicingModule.java        |   35 -
 .../bootstrap/assembly/domain/OrderModule.java  |   56 -
 .../assembly/infrastructure/IndexingModule.java |   43 -
 .../infrastructure/InfrastructureLayer.java     |   47 -
 .../infrastructure/SerializationModule.java     |   36 -
 .../assembly/infrastructure/StorageModule.java  |   43 -
 .../assembly/service/ServiceLayer.java          |   35 -
 .../builder/ApplicationBuilderTest.java         |  133 --
 .../zest/bootstrap/somepackage/Test2Value.java  |   28 -
 .../org/qi4j/bootstrap/ClassScannerTest.java    |   64 +
 .../qi4j/bootstrap/DocumentationSupport.java    |  441 +++++
 .../test/java/org/qi4j/bootstrap/TestValue.java |   28 +
 .../LayeredApplicationAssemblerTest.java        |   41 +
 .../bootstrap/assembly/TestApplication.java     |   61 +
 .../assembly/config/ConfigurationLayer.java     |   33 +
 .../connectivity/ConnectivityLayer.java         |   35 +
 .../bootstrap/assembly/domain/DomainLayer.java  |   35 +
 .../assembly/domain/InvoicingModule.java        |   35 +
 .../bootstrap/assembly/domain/OrderModule.java  |   56 +
 .../assembly/infrastructure/IndexingModule.java |   44 +
 .../infrastructure/InfrastructureLayer.java     |   47 +
 .../infrastructure/SerializationModule.java     |   36 +
 .../assembly/infrastructure/StorageModule.java  |   44 +
 .../assembly/service/ServiceLayer.java          |   35 +
 .../builder/ApplicationBuilderTest.java         |  133 ++
 .../qi4j/bootstrap/somepackage/Test2Value.java  |   28 +
 .../org/apache/zest/functional/ForEach.java     |   95 -
 .../org/apache/zest/functional/Function.java    |   35 -
 .../org/apache/zest/functional/Function2.java   |   33 -
 .../org/apache/zest/functional/Functions.java   |  276 ---
 .../zest/functional/HierarchicalVisitor.java    |   53 -
 .../functional/HierarchicalVisitorAdapter.java  |   47 -
 .../org/apache/zest/functional/Iterables.java   |  939 ---------
 .../apache/zest/functional/Specification.java   |   37 -
 .../apache/zest/functional/Specifications.java  |  206 --
 .../org/apache/zest/functional/Visitable.java   |   28 -
 .../zest/functional/VisitableHierarchy.java     |   28 -
 .../org/apache/zest/functional/Visitor.java     |   38 -
 .../org/apache/zest/functional/package.html     |   21 -
 .../main/java/org/qi4j/functional/ForEach.java  |   95 +
 .../main/java/org/qi4j/functional/Function.java |   35 +
 .../java/org/qi4j/functional/Function2.java     |   33 +
 .../java/org/qi4j/functional/Functions.java     |  276 +++
 .../qi4j/functional/HierarchicalVisitor.java    |   53 +
 .../functional/HierarchicalVisitorAdapter.java  |   47 +
 .../java/org/qi4j/functional/Iterables.java     |  939 +++++++++
 .../java/org/qi4j/functional/Specification.java |   37 +
 .../org/qi4j/functional/Specifications.java     |  206 ++
 .../java/org/qi4j/functional/Visitable.java     |   28 +
 .../org/qi4j/functional/VisitableHierarchy.java |   28 +
 .../main/java/org/qi4j/functional/Visitor.java  |   38 +
 .../main/java/org/qi4j/functional/package.html  |   21 +
 .../apache/zest/functional/FunctionsTest.java   |  143 --
 .../IntegerRangeSpecificationTest.java          |   59 -
 .../apache/zest/functional/IterablesTest.java   |  292 ---
 .../zest/functional/SpecificationsTest.java     |   85 -
 .../functional/docsupport/FunctionalDocs.java   |   55 -
 .../java/org/qi4j/functional/FunctionsTest.java |  143 ++
 .../IntegerRangeSpecificationTest.java          |   59 +
 .../java/org/qi4j/functional/IterablesTest.java |  292 +++
 .../org/qi4j/functional/SpecificationsTest.java |   85 +
 .../functional/docsupport/FunctionalDocs.java   |   55 +
 .../src/main/java/org/apache/zest/io/Files.java |   35 -
 .../src/main/java/org/apache/zest/io/Input.java |   33 -
 .../main/java/org/apache/zest/io/Inputs.java    |  490 -----
 .../main/java/org/apache/zest/io/Output.java    |   40 -
 .../main/java/org/apache/zest/io/Outputs.java   |  528 -----
 .../main/java/org/apache/zest/io/Receiver.java  |   36 -
 .../main/java/org/apache/zest/io/Sender.java    |   39 -
 .../java/org/apache/zest/io/Transforms.java     |  435 -----
 .../main/java/org/apache/zest/io/package.html   |   21 -
 core/io/src/main/java/org/qi4j/io/Files.java    |   35 +
 core/io/src/main/java/org/qi4j/io/Input.java    |   33 +
 core/io/src/main/java/org/qi4j/io/Inputs.java   |  490 +++++
 core/io/src/main/java/org/qi4j/io/Output.java   |   40 +
 core/io/src/main/java/org/qi4j/io/Outputs.java  |  528 +++++
 core/io/src/main/java/org/qi4j/io/Receiver.java |   36 +
 core/io/src/main/java/org/qi4j/io/Sender.java   |   39 +
 .../src/main/java/org/qi4j/io/Transforms.java   |  435 +++++
 core/io/src/main/java/org/qi4j/io/package.html  |   21 +
 .../org/apache/zest/io/InputOutputTest.java     |  381 ----
 .../org/apache/zest/io/docsupport/IoDocs.java   |   53 -
 .../test/java/org/qi4j/io/InputOutputTest.java  |  381 ++++
 .../java/org/qi4j/io/docsupport/IoDocs.java     |   53 +
 .../apache/zest/runtime/Qi4jRuntimeImpl.java    |  358 ----
 .../runtime/activation/ActivationDelegate.java  |  394 ----
 .../ActivationEventListenerSupport.java         |   64 -
 .../zest/runtime/activation/ActivatorModel.java |  108 --
 .../runtime/activation/ActivatorsInstance.java  |  106 -
 .../runtime/activation/ActivatorsModel.java     |   97 -
 .../AbstractAssociationInstance.java            |   93 -
 .../runtime/association/AssociationInfo.java    |   36 -
 .../association/AssociationInstance.java        |  132 --
 .../runtime/association/AssociationModel.java   |  251 ---
 .../runtime/association/AssociationsModel.java  |  117 --
 .../association/ManyAssociationInstance.java    |  225 ---
 .../association/ManyAssociationModel.java       |  265 ---
 .../association/ManyAssociationsModel.java      |  123 --
 .../association/NamedAssociationInstance.java   |  237 ---
 .../association/NamedAssociationModel.java      |  266 ---
 .../association/NamedAssociationsModel.java     |  128 --
 .../runtime/bootstrap/AndAppliesToFilter.java   |   41 -
 .../bootstrap/AnnotationAppliesToFilter.java    |   41 -
 .../ApplicationAssemblyFactoryImpl.java         |   73 -
 .../bootstrap/ApplicationAssemblyImpl.java      |  152 --
 .../bootstrap/ApplicationModelFactoryImpl.java  |  192 --
 .../zest/runtime/bootstrap/AssemblyHelper.java  |  198 --
 .../bootstrap/CompositeAssemblyImpl.java        |  837 --------
 .../bootstrap/ConfigurationAssemblyImpl.java    |   42 -
 .../bootstrap/ConfigurationDeclarationImpl.java |  124 --
 .../runtime/bootstrap/EntityAssemblyImpl.java   |  271 ---
 .../bootstrap/EntityDeclarationImpl.java        |   94 -
 .../ImplementsMethodAppliesToFilter.java        |   40 -
 .../bootstrap/ImportedServiceAssemblyImpl.java  |  112 --
 .../ImportedServiceDeclarationImpl.java         |  123 --
 .../runtime/bootstrap/LayerAssemblyImpl.java    |  625 ------
 .../runtime/bootstrap/ModuleAssemblyImpl.java   |  635 ------
 .../runtime/bootstrap/ObjectAssemblyImpl.java   |   66 -
 .../bootstrap/ObjectDeclarationImpl.java        |   53 -
 .../runtime/bootstrap/OrAppliesToFilter.java    |   41 -
 .../runtime/bootstrap/ServiceAssemblyImpl.java  |  108 --
 .../bootstrap/ServiceDeclarationImpl.java       |  152 --
 .../bootstrap/TransientAssemblyImpl.java        |   61 -
 .../bootstrap/TransientDeclarationImpl.java     |   94 -
 .../bootstrap/TypeCheckAppliesToFilter.java     |   41 -
 .../bootstrap/TypedFragmentAppliesToFilter.java |   31 -
 .../runtime/bootstrap/ValueAssemblyImpl.java    |  248 ---
 .../runtime/bootstrap/ValueDeclarationImpl.java |   94 -
 .../composite/AbstractConstraintModel.java      |   49 -
 .../composite/AbstractModifierModel.java        |  177 --
 .../runtime/composite/AtomicInstancePool.java   |   53 -
 .../zest/runtime/composite/CompactLevel.java    |   36 -
 .../composite/CompositeConstraintModel.java     |   68 -
 .../composite/CompositeMethodInstance.java      |   77 -
 .../runtime/composite/CompositeMethodModel.java |  321 ---
 .../composite/CompositeMethodsModel.java        |  132 --
 .../zest/runtime/composite/CompositeModel.java  |  267 ---
 .../zest/runtime/composite/ConcernModel.java    |   29 -
 .../runtime/composite/ConcernsInstance.java     |   64 -
 .../zest/runtime/composite/ConcernsModel.java   |   83 -
 .../composite/ConstraintDeclaration.java        |   69 -
 .../runtime/composite/ConstraintInstance.java   |   43 -
 .../zest/runtime/composite/ConstraintModel.java |   49 -
 .../runtime/composite/ConstraintsCheck.java     |   26 -
 .../runtime/composite/ConstraintsInstance.java  |   80 -
 .../runtime/composite/ConstraintsModel.java     |   76 -
 .../runtime/composite/ConstructorModel.java     |  105 -
 .../runtime/composite/ConstructorsModel.java    |  301 ---
 .../runtime/composite/FragmentClassLoader.java  |  852 --------
 .../composite/FragmentInvocationHandler.java    |  123 --
 .../composite/FunctionStateResolver.java        |  119 --
 .../GenericFragmentInvocationHandler.java       |   43 -
 .../runtime/composite/GenericSpecification.java |   37 -
 .../zest/runtime/composite/InstancePool.java    |   29 -
 .../zest/runtime/composite/MixinModel.java      |  181 --
 .../zest/runtime/composite/MixinsInstance.java  |   29 -
 .../zest/runtime/composite/MixinsModel.java     |  242 ---
 .../zest/runtime/composite/ProxyGenerator.java  |   34 -
 .../ProxyReferenceInvocationHandler.java        |   81 -
 .../SideEffectInvocationHandlerResult.java      |   58 -
 .../zest/runtime/composite/SideEffectModel.java |   30 -
 .../runtime/composite/SideEffectsInstance.java  |   95 -
 .../runtime/composite/SideEffectsModel.java     |   81 -
 .../zest/runtime/composite/StateModel.java      |   76 -
 .../zest/runtime/composite/StateResolver.java   |   36 -
 ...SynchronizedCompositeMethodInstancePool.java |   44 -
 .../composite/TransientBuilderInstance.java     |   98 -
 .../runtime/composite/TransientClassLoader.java |  804 --------
 .../runtime/composite/TransientInstance.java    |  224 ---
 .../zest/runtime/composite/TransientModel.java  |   70 -
 .../composite/TransientStateInstance.java       |   60 -
 .../zest/runtime/composite/TransientsModel.java |   55 -
 .../TypedModifierInvocationHandler.java         |   45 -
 ...synchronizedCompositeMethodInstancePool.java |   44 -
 .../zest/runtime/composite/UsageGraph.java      |  132 --
 .../zest/runtime/composite/UsesInstance.java    |  107 -
 .../composite/ValueConstraintsInstance.java     |  125 --
 .../composite/ValueConstraintsModel.java        |   66 -
 .../zest/runtime/entity/EntitiesModel.java      |   55 -
 .../zest/runtime/entity/EntityInstance.java     |  329 ----
 .../zest/runtime/entity/EntityMixinsModel.java  |   94 -
 .../apache/zest/runtime/entity/EntityModel.java |  174 --
 .../runtime/entity/EntityPropertyInstance.java  |   53 -
 .../runtime/entity/EntityStateInstance.java     |  263 ---
 .../zest/runtime/entity/EntityStateModel.java   |  157 --
 .../zest/runtime/injection/Dependencies.java    |   38 -
 .../zest/runtime/injection/DependencyModel.java |  412 ----
 .../runtime/injection/InjectedFieldModel.java   |  147 --
 .../runtime/injection/InjectedFieldsModel.java  |  124 --
 .../runtime/injection/InjectedMethodModel.java  |   86 -
 .../runtime/injection/InjectedMethodsModel.java |  124 --
 .../injection/InjectedParametersModel.java      |  103 -
 .../runtime/injection/InjectionContext.java     |  121 --
 .../runtime/injection/InjectionProvider.java    |   26 -
 .../injection/InjectionProviderFactory.java     |   37 -
 .../injection/ParameterizedTypeInstance.java    |   65 -
 .../CachingInjectionProviderDecorator.java      |   57 -
 ...achingInjectionProviderFactoryDecorator.java |   50 -
 .../provider/InjectionProviderException.java    |   32 -
 .../InjectionProviderFactoryStrategy.java       |  102 -
 .../InvocationInjectionProviderFactory.java     |  117 --
 .../ModifiesInjectionProviderFactory.java       |   70 -
 .../ServiceInjectionProviderFactory.java        |  225 ---
 .../provider/StateInjectionProviderFactory.java |  273 ---
 .../StructureInjectionProviderFactory.java      |  118 --
 .../provider/ThisInjectionProviderFactory.java  |  138 --
 .../provider/UsesInjectionProviderFactory.java  |  131 --
 .../apache/zest/runtime/internal/Activator.java |   57 -
 .../org/apache/zest/runtime/model/Binder.java   |   26 -
 .../apache/zest/runtime/model/Resolution.java   |   86 -
 .../apache/zest/runtime/object/ObjectModel.java |  143 --
 .../zest/runtime/object/ObjectsModel.java       |   55 -
 .../java/org/apache/zest/runtime/package.html   |   21 -
 .../zest/runtime/property/PropertiesModel.java  |  104 -
 .../zest/runtime/property/PropertyInfo.java     |   36 -
 .../zest/runtime/property/PropertyInstance.java |  321 ---
 .../zest/runtime/property/PropertyModel.java    |  309 ---
 .../zest/runtime/query/IterableQuerySource.java |  239 ---
 .../runtime/query/QueryBuilderFactoryImpl.java  |   68 -
 .../zest/runtime/query/QueryBuilderImpl.java    |   95 -
 .../apache/zest/runtime/query/QueryImpl.java    |  213 --
 .../service/ImportedServiceInstance.java        |   66 -
 .../runtime/service/ImportedServiceModel.java   |  189 --
 .../ImportedServiceReferenceInstance.java       |  220 ---
 .../service/ImportedServicesInstance.java       |  110 --
 .../runtime/service/ImportedServicesModel.java  |   65 -
 .../zest/runtime/service/ServiceInstance.java   |   85 -
 .../zest/runtime/service/ServiceModel.java      |  216 ---
 .../service/ServiceReferenceInstance.java       |  314 ---
 .../zest/runtime/service/ServicesInstance.java  |  108 --
 .../zest/runtime/service/ServicesModel.java     |   65 -
 .../runtime/structure/ApplicationInstance.java  |  162 --
 .../runtime/structure/ApplicationModel.java     |  173 --
 .../zest/runtime/structure/LayerInstance.java   |  212 --
 .../zest/runtime/structure/LayerModel.java      |  121 --
 .../zest/runtime/structure/ModuleInstance.java  |  873 ---------
 .../zest/runtime/structure/ModuleModel.java     |  130 --
 .../runtime/structure/ModuleUnitOfWork.java     |  773 --------
 .../zest/runtime/structure/TypeLookup.java      |  629 ------
 .../runtime/structure/UsedLayersInstance.java   |  100 -
 .../zest/runtime/structure/UsedLayersModel.java |   63 -
 .../structure/VisibilitySpecification.java      |   47 -
 .../zest/runtime/types/ValueTypeFactory.java    |  230 ---
 .../runtime/unitofwork/BuilderEntityState.java  |  172 --
 .../unitofwork/BuilderManyAssociationState.java |   78 -
 .../BuilderNamedAssociationState.java           |   89 -
 .../unitofwork/EntityBuilderInstance.java       |  151 --
 .../runtime/unitofwork/EntityStateStore.java    |   33 -
 .../runtime/unitofwork/UnitOfWorkInstance.java  |  545 ------
 .../value/ManyAssociationValueState.java        |  105 -
 .../value/NamedAssociationValueState.java       |   84 -
 .../zest/runtime/value/ReferenceProperty.java   |   53 -
 .../runtime/value/ValueBuilderInstance.java     |   79 -
 .../value/ValueBuilderWithPrototype.java        |  228 ---
 .../runtime/value/ValueBuilderWithState.java    |   91 -
 .../zest/runtime/value/ValueInstance.java       |  182 --
 .../apache/zest/runtime/value/ValueModel.java   |  112 --
 .../zest/runtime/value/ValueStateInstance.java  |  233 ---
 .../zest/runtime/value/ValueStateModel.java     |  132 --
 .../apache/zest/runtime/value/ValuesModel.java  |   55 -
 .../java/org/qi4j/runtime/Qi4jRuntimeImpl.java  |  358 ++++
 .../runtime/activation/ActivationDelegate.java  |  394 ++++
 .../ActivationEventListenerSupport.java         |   64 +
 .../qi4j/runtime/activation/ActivatorModel.java |  108 ++
 .../runtime/activation/ActivatorsInstance.java  |  106 +
 .../runtime/activation/ActivatorsModel.java     |   97 +
 .../AbstractAssociationInstance.java            |   93 +
 .../runtime/association/AssociationInfo.java    |   36 +
 .../association/AssociationInstance.java        |  132 ++
 .../runtime/association/AssociationModel.java   |  251 +++
 .../runtime/association/AssociationsModel.java  |  117 ++
 .../association/ManyAssociationInstance.java    |  225 +++
 .../association/ManyAssociationModel.java       |  265 +++
 .../association/ManyAssociationsModel.java      |  123 ++
 .../association/NamedAssociationInstance.java   |  240 +++
 .../association/NamedAssociationModel.java      |  266 +++
 .../association/NamedAssociationsModel.java     |  128 ++
 .../runtime/bootstrap/AndAppliesToFilter.java   |   41 +
 .../bootstrap/AnnotationAppliesToFilter.java    |   41 +
 .../ApplicationAssemblyFactoryImpl.java         |   73 +
 .../bootstrap/ApplicationAssemblyImpl.java      |  152 ++
 .../bootstrap/ApplicationModelFactoryImpl.java  |  192 ++
 .../qi4j/runtime/bootstrap/AssemblyHelper.java  |  198 ++
 .../bootstrap/CompositeAssemblyImpl.java        |  837 ++++++++
 .../bootstrap/ConfigurationAssemblyImpl.java    |   85 +
 .../bootstrap/ConfigurationDeclarationImpl.java |  125 ++
 .../runtime/bootstrap/EntityAssemblyImpl.java   |  271 +++
 .../bootstrap/EntityDeclarationImpl.java        |   94 +
 .../ImplementsMethodAppliesToFilter.java        |   40 +
 .../bootstrap/ImportedServiceAssemblyImpl.java  |  112 ++
 .../ImportedServiceDeclarationImpl.java         |  123 ++
 .../runtime/bootstrap/LayerAssemblyImpl.java    |  625 ++++++
 .../runtime/bootstrap/ModuleAssemblyImpl.java   |  635 ++++++
 .../runtime/bootstrap/ObjectAssemblyImpl.java   |   66 +
 .../bootstrap/ObjectDeclarationImpl.java        |   53 +
 .../runtime/bootstrap/OrAppliesToFilter.java    |   41 +
 .../runtime/bootstrap/ServiceAssemblyImpl.java  |  108 ++
 .../bootstrap/ServiceDeclarationImpl.java       |  152 ++
 .../bootstrap/TransientAssemblyImpl.java        |   61 +
 .../bootstrap/TransientDeclarationImpl.java     |   94 +
 .../bootstrap/TypeCheckAppliesToFilter.java     |   41 +
 .../bootstrap/TypedFragmentAppliesToFilter.java |   31 +
 .../runtime/bootstrap/ValueAssemblyImpl.java    |  248 +++
 .../runtime/bootstrap/ValueDeclarationImpl.java |   94 +
 .../composite/AbstractConstraintModel.java      |   49 +
 .../composite/AbstractModifierModel.java        |  177 ++
 .../runtime/composite/AtomicInstancePool.java   |   53 +
 .../qi4j/runtime/composite/CompactLevel.java    |   36 +
 .../composite/CompositeConstraintModel.java     |   68 +
 .../composite/CompositeMethodInstance.java      |   77 +
 .../runtime/composite/CompositeMethodModel.java |  321 +++
 .../composite/CompositeMethodsModel.java        |  132 ++
 .../qi4j/runtime/composite/CompositeModel.java  |  269 +++
 .../qi4j/runtime/composite/ConcernModel.java    |   29 +
 .../runtime/composite/ConcernsInstance.java     |   64 +
 .../qi4j/runtime/composite/ConcernsModel.java   |   83 +
 .../composite/ConstraintDeclaration.java        |   69 +
 .../runtime/composite/ConstraintInstance.java   |   43 +
 .../qi4j/runtime/composite/ConstraintModel.java |   49 +
 .../runtime/composite/ConstraintsCheck.java     |   26 +
 .../runtime/composite/ConstraintsInstance.java  |   80 +
 .../runtime/composite/ConstraintsModel.java     |   76 +
 .../runtime/composite/ConstructorModel.java     |  105 +
 .../runtime/composite/ConstructorsModel.java    |  301 +++
 .../runtime/composite/FragmentClassLoader.java  |  852 ++++++++
 .../composite/FragmentInvocationHandler.java    |  123 ++
 .../composite/FunctionStateResolver.java        |  120 ++
 .../GenericFragmentInvocationHandler.java       |   43 +
 .../runtime/composite/GenericSpecification.java |   37 +
 .../qi4j/runtime/composite/InstancePool.java    |   29 +
 .../org/qi4j/runtime/composite/MixinModel.java  |  181 ++
 .../qi4j/runtime/composite/MixinsInstance.java  |   29 +
 .../org/qi4j/runtime/composite/MixinsModel.java |  242 +++
 .../qi4j/runtime/composite/ProxyGenerator.java  |   34 +
 .../ProxyReferenceInvocationHandler.java        |   81 +
 .../SideEffectInvocationHandlerResult.java      |   58 +
 .../qi4j/runtime/composite/SideEffectModel.java |   30 +
 .../runtime/composite/SideEffectsInstance.java  |   95 +
 .../runtime/composite/SideEffectsModel.java     |   81 +
 .../org/qi4j/runtime/composite/StateModel.java  |   76 +
 .../qi4j/runtime/composite/StateResolver.java   |   36 +
 ...SynchronizedCompositeMethodInstancePool.java |   44 +
 .../composite/TransientBuilderInstance.java     |   98 +
 .../runtime/composite/TransientClassLoader.java |  804 ++++++++
 .../runtime/composite/TransientInstance.java    |  224 +++
 .../qi4j/runtime/composite/TransientModel.java  |   70 +
 .../composite/TransientStateInstance.java       |   60 +
 .../qi4j/runtime/composite/TransientsModel.java |   55 +
 .../TypedModifierInvocationHandler.java         |   45 +
 ...synchronizedCompositeMethodInstancePool.java |   44 +
 .../org/qi4j/runtime/composite/UsageGraph.java  |  132 ++
 .../qi4j/runtime/composite/UsesInstance.java    |  107 +
 .../composite/ValueConstraintsInstance.java     |  125 ++
 .../composite/ValueConstraintsModel.java        |   66 +
 .../org/qi4j/runtime/entity/EntitiesModel.java  |   55 +
 .../org/qi4j/runtime/entity/EntityInstance.java |  329 ++++
 .../qi4j/runtime/entity/EntityMixinsModel.java  |   94 +
 .../org/qi4j/runtime/entity/EntityModel.java    |  174 ++
 .../runtime/entity/EntityPropertyInstance.java  |   53 +
 .../runtime/entity/EntityStateInstance.java     |  263 +++
 .../qi4j/runtime/entity/EntityStateModel.java   |  157 ++
 .../qi4j/runtime/injection/Dependencies.java    |   38 +
 .../qi4j/runtime/injection/DependencyModel.java |  412 ++++
 .../runtime/injection/InjectedFieldModel.java   |  147 ++
 .../runtime/injection/InjectedFieldsModel.java  |  124 ++
 .../runtime/injection/InjectedMethodModel.java  |   86 +
 .../runtime/injection/InjectedMethodsModel.java |  124 ++
 .../injection/InjectedParametersModel.java      |  103 +
 .../runtime/injection/InjectionContext.java     |  121 ++
 .../runtime/injection/InjectionProvider.java    |   26 +
 .../injection/InjectionProviderFactory.java     |   37 +
 .../injection/ParameterizedTypeInstance.java    |   65 +
 .../CachingInjectionProviderDecorator.java      |   57 +
 ...achingInjectionProviderFactoryDecorator.java |   50 +
 .../provider/InjectionProviderException.java    |   32 +
 .../InjectionProviderFactoryStrategy.java       |  102 +
 .../InvocationInjectionProviderFactory.java     |  117 ++
 .../ModifiesInjectionProviderFactory.java       |   70 +
 .../ServiceInjectionProviderFactory.java        |  225 +++
 .../provider/StateInjectionProviderFactory.java |  273 +++
 .../StructureInjectionProviderFactory.java      |  118 ++
 .../provider/ThisInjectionProviderFactory.java  |  138 ++
 .../provider/UsesInjectionProviderFactory.java  |  132 ++
 .../org/qi4j/runtime/internal/Activator.java    |   57 +
 .../java/org/qi4j/runtime/model/Binder.java     |   26 +
 .../java/org/qi4j/runtime/model/Resolution.java |   86 +
 .../org/qi4j/runtime/object/ObjectModel.java    |  143 ++
 .../org/qi4j/runtime/object/ObjectsModel.java   |   55 +
 .../src/main/java/org/qi4j/runtime/package.html |   21 +
 .../qi4j/runtime/property/PropertiesModel.java  |  104 +
 .../org/qi4j/runtime/property/PropertyInfo.java |   36 +
 .../qi4j/runtime/property/PropertyInstance.java |  321 +++
 .../qi4j/runtime/property/PropertyModel.java    |  309 +++
 .../qi4j/runtime/query/IterableQuerySource.java |  239 +++
 .../runtime/query/QueryBuilderFactoryImpl.java  |   68 +
 .../qi4j/runtime/query/QueryBuilderImpl.java    |   95 +
 .../java/org/qi4j/runtime/query/QueryImpl.java  |  213 ++
 .../service/ImportedServiceInstance.java        |   66 +
 .../runtime/service/ImportedServiceModel.java   |  189 ++
 .../ImportedServiceReferenceInstance.java       |  220 +++
 .../service/ImportedServicesInstance.java       |  110 ++
 .../runtime/service/ImportedServicesModel.java  |   65 +
 .../qi4j/runtime/service/ServiceInstance.java   |   85 +
 .../org/qi4j/runtime/service/ServiceModel.java  |  216 +++
 .../service/ServiceReferenceInstance.java       |  314 +++
 .../qi4j/runtime/service/ServicesInstance.java  |  108 ++
 .../org/qi4j/runtime/service/ServicesModel.java |   65 +
 .../runtime/structure/ApplicationInstance.java  |  162 ++
 .../runtime/structure/ApplicationModel.java     |  173 ++
 .../qi4j/runtime/structure/LayerInstance.java   |  212 ++
 .../org/qi4j/runtime/structure/LayerModel.java  |  121 ++
 .../qi4j/runtime/structure/ModuleInstance.java  |  876 +++++++++
 .../org/qi4j/runtime/structure/ModuleModel.java |  130 ++
 .../runtime/structure/ModuleUnitOfWork.java     |  773 ++++++++
 .../org/qi4j/runtime/structure/TypeLookup.java  |  629 ++++++
 .../runtime/structure/UsedLayersInstance.java   |  104 +
 .../qi4j/runtime/structure/UsedLayersModel.java |   63 +
 .../structure/VisibilitySpecification.java      |   47 +
 .../qi4j/runtime/types/ValueTypeFactory.java    |  230 +++
 .../runtime/unitofwork/BuilderEntityState.java  |  172 ++
 .../unitofwork/BuilderManyAssociationState.java |   78 +
 .../BuilderNamedAssociationState.java           |   89 +
 .../unitofwork/EntityBuilderInstance.java       |  151 ++
 .../runtime/unitofwork/EntityStateStore.java    |   33 +
 .../runtime/unitofwork/UnitOfWorkInstance.java  |  545 ++++++
 .../value/ManyAssociationValueState.java        |  105 +
 .../value/NamedAssociationValueState.java       |   84 +
 .../qi4j/runtime/value/ReferenceProperty.java   |   53 +
 .../runtime/value/ValueBuilderInstance.java     |   79 +
 .../value/ValueBuilderWithPrototype.java        |  228 +++
 .../runtime/value/ValueBuilderWithState.java    |   91 +
 .../org/qi4j/runtime/value/ValueInstance.java   |  182 ++
 .../java/org/qi4j/runtime/value/ValueModel.java |  112 ++
 .../qi4j/runtime/value/ValueStateInstance.java  |  233 +++
 .../org/qi4j/runtime/value/ValueStateModel.java |  132 ++
 .../org/qi4j/runtime/value/ValuesModel.java     |   55 +
 .../apache/zest/api/common/OptionalTest.java    |  196 --
 .../org/apache/zest/api/common/PluginTest.java  |  371 ----
 .../zest/api/common/PropertyErrorTest.java      |   62 -
 .../zest/api/common/PropertyTypeTest.java       |  159 --
 .../org/apache/zest/api/common/RemovalTest.java |  124 --
 .../zest/api/common/ValueCompositeTest.java     |  238 ---
 .../bootstrap/ApplicationAssemblerTest.java     |  106 -
 .../org/apache/zest/runtime/Qi4jAPITest.java    |   81 -
 .../org/apache/zest/runtime/Qi4jSPITest.java    |  127 --
 .../activation/ActivatorOrderTestSupport.java   |  156 --
 .../activation/ApplicationActivationTest.java   |   85 -
 .../ImportedServiceActivationTest.java          |  203 --
 .../IntraMixinActivationOrderTest.java          |  211 --
 .../runtime/activation/LayerActivationTest.java |   85 -
 .../activation/ModuleActivationTest.java        |   85 -
 .../activation/ServiceActivationTest.java       |  139 --
 .../activation/ServiceActivatorOrderTest.java   |  362 ----
 .../activation/StructureActivatorOrderTest.java |  258 ---
 .../runtime/appliesto/AppliesToFilterTest.java  |  111 --
 .../AppliesToOrConditionQI241Test.java          |  250 ---
 .../zest/runtime/appliesto/AppliesToTest.java   |  135 --
 .../appliesto/FragmentAppliesToTest.java        |  166 --
 .../association/AssociationEqualityTest.java    |  455 -----
 .../DereferenceForBootstrappedConcernsTest.java |  135 --
 .../runtime/composite/AbstractMixinTest.java    |  121 --
 .../composite/CompositeFactoryImplTest.java     |  153 --
 .../composite/CompositeModelResolverTest.java   |  147 --
 .../runtime/composite/FunctionalListTest.java   |   98 -
 .../zest/runtime/composite/MapOverrideTest.java |  206 --
 .../zest/runtime/composite/QI247Test1.java      |  142 --
 .../zest/runtime/composite/QI247Test2.java      |  158 --
 .../zest/runtime/composite/QI256Test.java       |  338 ----
 .../runtime/composite/TransientAsClassTest.java |   58 -
 .../zest/runtime/composite/UsageGraphTest.java  |  370 ----
 .../runtime/concerns/GenericConcernTest.java    |   77 -
 .../runtime/concerns/ModuleConcernTest.java     |   97 -
 .../concerns/PropertyInheritanceTest.java       |  112 --
 .../runtime/constraints/ConstraintsTest.java    |  207 --
 .../constraints/ConstraintsTest.properties      |   21 -
 .../zest/runtime/defaults/UseDefaultsTest.java  |   76 -
 .../zest/runtime/entity/AggregatedTest.java     |  181 --
 .../entity/EntityBuilderWithStateTest.java      |  148 --
 .../entity/EntityCompositeEqualityTest.java     |   91 -
 .../zest/runtime/entity/EntityCreationTest.java |   96 -
 .../zest/runtime/entity/EntityTypeTest.java     |   71 -
 .../runtime/entity/EntityVisibilityTest.java    | 1013 ----------
 .../zest/runtime/entity/LifecycleTest.java      |  120 --
 .../apache/zest/runtime/entity/QI273Test.java   |   97 -
 .../entity/associations/AssociationTest.java    |  216 ---
 .../associations/ImmutableAssociationTest.java  |  151 --
 .../injection/ActivatorInjectionTest.java       |  170 --
 .../ConstructorInjectionOfThisTest.java         |  120 --
 .../IllegalUnitOfWorkInjectionTest.java         |   94 -
 .../injection/InvocationInjectionTest.java      |  141 --
 .../runtime/injection/ServiceInjectionTest.java |  360 ----
 .../runtime/injection/StateInjectionTest.java   |  105 -
 .../injection/StateParameterInjectionTest.java  |   96 -
 .../injection/StructureInjectionTest.java       |  196 --
 .../runtime/injection/ThisInjectionTest.java    |  137 --
 .../injection/UnitOfWorkInjectionTest.java      |  118 --
 .../runtime/injection/UsesGenericClassTest.java |   69 -
 .../runtime/injection/UsesGenericListTest.java  |   76 -
 .../zest/runtime/injection/UsesGraphTest.java   |   84 -
 .../runtime/injection/UsesInjectionTest.java    |   87 -
 .../EagerServiceInstantiationTest.java          |   85 -
 .../ServiceInstantiationTests.java              |   76 -
 .../TransientInstantiationTests.java            |   67 -
 .../instantiation/ValueInstantiationTests.java  |  110 --
 .../zest/runtime/mixin/AssemblyMixinTest.java   |  107 -
 .../zest/runtime/mixin/AssemblyRoleTest.java    |  122 --
 .../zest/runtime/mixin/InitializableTest.java   |   97 -
 .../InvokeServiceFromModuleAssemblyTest.java    |   60 -
 .../apache/zest/runtime/mixin/JDKMixinTest.java |  191 --
 .../mixin/MethodInterceptionMixinTest.java      |   99 -
 .../zest/runtime/mixin/MixinPrecedenceTest.java |  128 --
 .../mixin/MixinsOnThisInjectionTest.java        |   79 -
 .../zest/runtime/mixin/PrivateMixinTest.java    |   89 -
 .../apache/zest/runtime/mixin/Qi228Test.java    |   75 -
 .../objects/ObjectBuilderFactoryTest.java       |  174 --
 .../zest/runtime/objects/ObjectConcernTest.java |   69 -
 .../runtime/objects/ObjectVisibilityTest.java   |  881 ---------
 .../apache/zest/runtime/objects/OuterClass.java |   48 -
 .../runtime/property/ImmutablePropertyTest.java |  132 --
 .../runtime/property/PropertyEqualityTest.java  |  430 ----
 .../property/PropertyStringArrayTest.java       |   63 -
 .../zest/runtime/property/PropertyTest.java     |  189 --
 .../property/ValueNestedBuilderTest.java        |  131 --
 .../runtime/query/IterableQuerySourceTest.java  |  553 ------
 .../org/apache/zest/runtime/query/Network.java  |  237 ---
 .../zest/runtime/query/NonQueryableTest.java    |   93 -
 .../query/QueryBuilderFactoryImplTest.java      |  162 --
 .../apache/zest/runtime/query/model/Alive.java  |   22 -
 .../apache/zest/runtime/query/model/City.java   |   31 -
 .../zest/runtime/query/model/Describable.java   |   55 -
 .../apache/zest/runtime/query/model/Domain.java |   28 -
 .../apache/zest/runtime/query/model/Female.java |   32 -
 .../apache/zest/runtime/query/model/Male.java   |   36 -
 .../zest/runtime/query/model/Nameable.java      |   27 -
 .../apache/zest/runtime/query/model/Person.java |   58 -
 .../apache/zest/runtime/query/model/Pet.java    |   47 -
 .../query/model/entities/CityEntity.java        |   26 -
 .../query/model/entities/DomainEntity.java      |   26 -
 .../query/model/entities/FemaleEntity.java      |   26 -
 .../query/model/entities/MaleEntity.java        |   26 -
 .../query/model/entities/PersonEntity.java      |   26 -
 .../runtime/query/model/entities/PetEntity.java |   28 -
 .../query/model/values/ContactValue.java        |   29 -
 .../query/model/values/ContactsValue.java       |   30 -
 .../runtime/service/ActivatableServiceTest.java |   95 -
 .../runtime/service/AvailableServiceTest.java   |  181 --
 .../runtime/service/ComplexActivatableTest.java |  102 -
 .../zest/runtime/service/ConfigurationTest.java |  150 --
 .../service/LazyActivatedServiceTest.java       |  114 --
 .../zest/runtime/service/PassivationTest.java   |  209 --
 .../zest/runtime/service/ServiceFinderTest.java |  125 --
 .../runtime/service/ServiceIdSelectorTest.java  |  110 --
 .../runtime/service/ServiceVisibilityTest.java  |  880 ---------
 .../sideeffects/GenericSideEffectTest.java      |  107 -
 .../sideeffects/ModuleSideEffectTest.java       |   83 -
 .../sideeffects/SampleTransientTest.java        |   84 -
 .../sideeffects/SpecificSideEffectTest.java     |   96 -
 .../runtime/structure/ApplicationModeTest.java  |  109 --
 .../structure/CompositeDescriptorTest.java      |   71 -
 .../runtime/structure/MixinVisibilityTest.java  |  438 -----
 .../zest/runtime/structure/ModuleTest.java      |  162 --
 .../PrivateCompositeVisibilityTest.java         |  110 --
 .../zest/runtime/structure/StructureTest.java   |  129 --
 .../structure/TypeToCompositeLookupTest.java    |  386 ----
 .../runtime/threaded/ContextCompositeTest.java  |  142 --
 .../transients/TransientBuilderFactoryTest.java |  216 ---
 .../transients/TransientVisibilityTest.java     |  893 ---------
 .../unitofwork/AutoCloseableUoWTest.java        |   83 -
 .../unitofwork/PrivateEntityUnitOfWorkTest.java |  270 ---
 .../zest/runtime/unitofwork/RemovalTest.java    |  156 --
 .../unitofwork/UnitOfWorkFactoryTest.java       |  144 --
 .../zest/runtime/util/AnnotationsTest.java      |   50 -
 .../runtime/value/NestedValueBuilderTest.java   |  182 --
 .../zest/runtime/value/ValueComposite2Test.java |  137 --
 .../runtime/value/ValueCompositeBasicsTest.java |   99 -
 .../zest/runtime/value/ValueEqualityTest.java   |  238 ---
 .../ValueInjectionDeserializationTest.java      |  130 --
 .../value/ValueSerializationRegressionTest.java |   77 -
 .../zest/runtime/value/ValueVisibilityTest.java |  894 ---------
 .../runtime/value/ValueWithAssociationTest.java |  202 --
 .../visibility/VisibilityInUnitOfWorkTest.java  |  159 --
 .../service/importer/InstanceImporterTest.java  |   67 -
 .../service/importer/NewObjectImporterTest.java |   60 -
 .../importer/ServiceInstanceImporterTest.java   |   87 -
 .../importer/ServiceSelectorImporterTest.java   |  160 --
 .../test/java/org/apache/zest/test/ASMTest.java |  581 ------
 .../java/org/apache/zest/test/Exception1.java   |   23 -
 .../java/org/apache/zest/test/Exception2.java   |   23 -
 .../test/java/org/apache/zest/test/Other.java   |   48 -
 .../test/java/org/apache/zest/test/Some.java    |   26 -
 .../java/org/apache/zest/test/SomeMixin.java    |   55 -
 .../org/apache/zest/test/SomeMixin_Stubx.java   |  243 ---
 .../test/java/org/apache/zest/test/World.java   |   23 -
 .../test/composite/CleanStackTraceTest.java     |  138 --
 .../memory/MemoryEntityStoreTest.java           |   58 -
 .../java/org/qi4j/api/common/OptionalTest.java  |  196 ++
 .../java/org/qi4j/api/common/PluginTest.java    |  371 ++++
 .../org/qi4j/api/common/PropertyErrorTest.java  |   62 +
 .../org/qi4j/api/common/PropertyTypeTest.java   |  159 ++
 .../java/org/qi4j/api/common/RemovalTest.java   |  124 ++
 .../org/qi4j/api/common/ValueCompositeTest.java |  238 +++
 .../bootstrap/ApplicationAssemblerTest.java     |  106 +
 .../constraints/PropertyConstraintTest.java     |   24 +-
 .../qi4j/regression/qi230/Qi230IssueTest.java   |   26 +-
 ...faceCollisionWithRelatedReturnTypesTest.java |   22 +-
 ...ceCollisionWithUnrelatedReturnTypesTest.java |   10 +-
 .../org/qi4j/regression/qi377/IssueTest.java    |   10 +-
 .../qi377/SetAssociationInSideEffectTest.java   |   28 +-
 ...alueCollisionWithRelatedReturnTypesTest.java |   18 +-
 .../org/qi4j/regression/qi382/Qi382Test.java    |   35 +-
 .../org/qi4j/regression/qi383/Qi383Test.java    |   20 +-
 .../org/qi4j/regression/qi53/IssueTest.java     |   22 +-
 .../org/qi4j/regression/qi55/IssueTest.java     |    8 +-
 .../org/qi4j/regression/qi59/IssueTest.java     |   16 +-
 .../org/qi4j/regression/qi65/IssueTest.java     |   10 +-
 .../org/qi4j/regression/qi74/IssueTest.java     |   14 +-
 .../org/qi4j/regression/qi78/IssueTest.java     |   20 +-
 .../org/qi4j/regression/qi94/IssueTest.java     |   18 +-
 .../test/java/org/qi4j/runtime/Qi4jAPITest.java |   81 +
 .../test/java/org/qi4j/runtime/Qi4jSPITest.java |  127 ++
 .../activation/ActivatorOrderTestSupport.java   |  156 ++
 .../activation/ApplicationActivationTest.java   |   85 +
 .../ImportedServiceActivationTest.java          |  203 ++
 .../IntraMixinActivationOrderTest.java          |  211 ++
 .../runtime/activation/LayerActivationTest.java |   85 +
 .../activation/ModuleActivationTest.java        |   85 +
 .../activation/ServiceActivationTest.java       |  139 ++
 .../activation/ServiceActivatorOrderTest.java   |  362 ++++
 .../activation/StructureActivatorOrderTest.java |  258 +++
 .../runtime/appliesto/AppliesToFilterTest.java  |  111 ++
 .../AppliesToOrConditionQI241Test.java          |  250 +++
 .../qi4j/runtime/appliesto/AppliesToTest.java   |  135 ++
 .../appliesto/FragmentAppliesToTest.java        |  166 ++
 .../association/AssociationEqualityTest.java    |  455 +++++
 .../DereferenceForBootstrappedConcernsTest.java |  135 ++
 .../runtime/composite/AbstractMixinTest.java    |  121 ++
 .../composite/CompositeFactoryImplTest.java     |  153 ++
 .../composite/CompositeModelResolverTest.java   |  147 ++
 .../runtime/composite/FunctionalListTest.java   |   98 +
 .../qi4j/runtime/composite/MapOverrideTest.java |  206 ++
 .../org/qi4j/runtime/composite/QI247Test1.java  |  142 ++
 .../org/qi4j/runtime/composite/QI247Test2.java  |  158 ++
 .../org/qi4j/runtime/composite/QI256Test.java   |  338 ++++
 .../runtime/composite/TransientAsClassTest.java |   58 +
 .../qi4j/runtime/composite/UsageGraphTest.java  |  370 ++++
 .../runtime/concerns/GenericConcernTest.java    |   77 +
 .../runtime/concerns/ModuleConcernTest.java     |   97 +
 .../concerns/PropertyInheritanceTest.java       |  112 ++
 .../runtime/constraints/ConstraintsTest.java    |  207 ++
 .../constraints/ConstraintsTest.properties      |   21 +
 .../qi4j/runtime/defaults/UseDefaultsTest.java  |   76 +
 .../org/qi4j/runtime/entity/AggregatedTest.java |  181 ++
 .../entity/EntityBuilderWithStateTest.java      |  148 ++
 .../entity/EntityCompositeEqualityTest.java     |   91 +
 .../qi4j/runtime/entity/EntityCreationTest.java |   96 +
 .../org/qi4j/runtime/entity/EntityTypeTest.java |   71 +
 .../runtime/entity/EntityVisibilityTest.java    | 1013 ++++++++++
 .../org/qi4j/runtime/entity/LifecycleTest.java  |  120 ++
 .../java/org/qi4j/runtime/entity/QI273Test.java |   97 +
 .../entity/associations/AssociationTest.java    |  216 +++
 .../associations/ImmutableAssociationTest.java  |  151 ++
 .../injection/ActivatorInjectionTest.java       |  170 ++
 .../ConstructorInjectionOfThisTest.java         |  120 ++
 .../IllegalUnitOfWorkInjectionTest.java         |   94 +
 .../injection/InvocationInjectionTest.java      |  141 ++
 .../runtime/injection/ServiceInjectionTest.java |  360 ++++
 .../runtime/injection/StateInjectionTest.java   |  105 +
 .../injection/StateParameterInjectionTest.java  |   96 +
 .../injection/StructureInjectionTest.java       |  196 ++
 .../runtime/injection/ThisInjectionTest.java    |  137 ++
 .../injection/UnitOfWorkInjectionTest.java      |  118 ++
 .../runtime/injection/UsesGenericClassTest.java |   69 +
 .../runtime/injection/UsesGenericListTest.java  |   76 +
 .../qi4j/runtime/injection/UsesGraphTest.java   |   84 +
 .../runtime/injection/UsesInjectionTest.java    |   87 +
 .../EagerServiceInstantiationTest.java          |   85 +
 .../ServiceInstantiationTests.java              |   76 +
 .../TransientInstantiationTests.java            |   67 +
 .../instantiation/ValueInstantiationTests.java  |  110 ++
 .../qi4j/runtime/mixin/AssemblyMixinTest.java   |  107 +
 .../qi4j/runtime/mixin/AssemblyRoleTest.java    |  122 ++
 .../qi4j/runtime/mixin/InitializableTest.java   |   97 +
 .../InvokeServiceFromModuleAssemblyTest.java    |   60 +
 .../org/qi4j/runtime/mixin/JDKMixinTest.java    |  191 ++
 .../mixin/MethodInterceptionMixinTest.java      |   99 +
 .../qi4j/runtime/mixin/MixinPrecedenceTest.java |  128 ++
 .../mixin/MixinsOnThisInjectionTest.java        |   79 +
 .../qi4j/runtime/mixin/PrivateMixinTest.java    |   89 +
 .../java/org/qi4j/runtime/mixin/Qi228Test.java  |   75 +
 .../objects/ObjectBuilderFactoryTest.java       |  174 ++
 .../qi4j/runtime/objects/ObjectConcernTest.java |   69 +
 .../runtime/objects/ObjectVisibilityTest.java   |  881 +++++++++
 .../org/qi4j/runtime/objects/OuterClass.java    |   48 +
 .../runtime/property/ImmutablePropertyTest.java |  132 ++
 .../runtime/property/PropertyEqualityTest.java  |  430 ++++
 .../property/PropertyStringArrayTest.java       |   63 +
 .../org/qi4j/runtime/property/PropertyTest.java |  189 ++
 .../property/ValueNestedBuilderTest.java        |  131 ++
 .../runtime/query/IterableQuerySourceTest.java  |  553 ++++++
 .../java/org/qi4j/runtime/query/Network.java    |  237 +++
 .../qi4j/runtime/query/NonQueryableTest.java    |   93 +
 .../query/QueryBuilderFactoryImplTest.java      |  162 ++
 .../org/qi4j/runtime/query/model/Alive.java     |   22 +
 .../java/org/qi4j/runtime/query/model/City.java |   31 +
 .../qi4j/runtime/query/model/Describable.java   |   55 +
 .../org/qi4j/runtime/query/model/Domain.java    |   28 +
 .../org/qi4j/runtime/query/model/Female.java    |   32 +
 .../java/org/qi4j/runtime/query/model/Male.java |   36 +
 .../org/qi4j/runtime/query/model/Nameable.java  |   27 +
 .../org/qi4j/runtime/query/model/Person.java    |   58 +
 .../java/org/qi4j/runtime/query/model/Pet.java  |   47 +
 .../query/model/entities/CityEntity.java        |   26 +
 .../query/model/entities/DomainEntity.java      |   26 +
 .../query/model/entities/FemaleEntity.java      |   26 +
 .../query/model/entities/MaleEntity.java        |   26 +
 .../query/model/entities/PersonEntity.java      |   26 +
 .../runtime/query/model/entities/PetEntity.java |   28 +
 .../query/model/values/ContactValue.java        |   29 +
 .../query/model/values/ContactsValue.java       |   30 +
 .../runtime/service/ActivatableServiceTest.java |   95 +
 .../runtime/service/AvailableServiceTest.java   |  181 ++
 .../runtime/service/ComplexActivatableTest.java |  102 +
 .../qi4j/runtime/service/ConfigurationTest.java |  150 ++
 .../service/LazyActivatedServiceTest.java       |  114 ++
 .../qi4j/runtime/service/PassivationTest.java   |  209 ++
 .../qi4j/runtime/service/ServiceFinderTest.java |  125 ++
 .../runtime/service/ServiceIdSelectorTest.java  |  110 ++
 .../runtime/service/ServiceVisibilityTest.java  |  880 +++++++++
 .../sideeffects/GenericSideEffectTest.java      |  107 +
 .../sideeffects/ModuleSideEffectTest.java       |   83 +
 .../sideeffects/SampleTransientTest.java        |   84 +
 .../sideeffects/SpecificSideEffectTest.java     |   96 +
 .../runtime/structure/ApplicationModeTest.java  |  109 ++
 .../structure/CompositeDescriptorTest.java      |   71 +
 .../runtime/structure/MixinVisibilityTest.java  |  438 +++++
 .../org/qi4j/runtime/structure/ModuleTest.java  |  162 ++
 .../PrivateCompositeVisibilityTest.java         |  110 ++
 .../qi4j/runtime/structure/StructureTest.java   |  129 ++
 .../structure/TypeToCompositeLookupTest.java    |  386 ++++
 .../runtime/threaded/ContextCompositeTest.java  |  142 ++
 .../transients/TransientBuilderFactoryTest.java |  216 +++
 .../transients/TransientVisibilityTest.java     |  893 +++++++++
 .../unitofwork/AutoCloseableUoWTest.java        |   83 +
 .../unitofwork/PrivateEntityUnitOfWorkTest.java |  270 +++
 .../qi4j/runtime/unitofwork/RemovalTest.java    |  156 ++
 .../unitofwork/UnitOfWorkFactoryTest.java       |  144 ++
 .../org/qi4j/runtime/util/AnnotationsTest.java  |   50 +
 .../runtime/value/NestedValueBuilderTest.java   |  182 ++
 .../qi4j/runtime/value/ValueComposite2Test.java |  138 ++
 .../runtime/value/ValueCompositeBasicsTest.java |   99 +
 .../qi4j/runtime/value/ValueEqualityTest.java   |  238 +++
 .../ValueInjectionDeserializationTest.java      |  130 ++
 .../value/ValueSerializationRegressionTest.java |   77 +
 .../qi4j/runtime/value/ValueVisibilityTest.java |  894 +++++++++
 .../runtime/value/ValueWithAssociationTest.java |  202 ++
 .../visibility/VisibilityInUnitOfWorkTest.java  |  159 ++
 .../service/importer/InstanceImporterTest.java  |   67 +
 .../service/importer/NewObjectImporterTest.java |   60 +
 .../importer/ServiceInstanceImporterTest.java   |   87 +
 .../importer/ServiceSelectorImporterTest.java   |  160 ++
 .../src/test/java/org/qi4j/test/ASMTest.java    |  581 ++++++
 .../src/test/java/org/qi4j/test/Exception1.java |   23 +
 .../src/test/java/org/qi4j/test/Exception2.java |   23 +
 .../src/test/java/org/qi4j/test/Other.java      |   48 +
 .../src/test/java/org/qi4j/test/Some.java       |   26 +
 .../src/test/java/org/qi4j/test/SomeMixin.java  |   55 +
 .../java/org/qi4j/test/SomeMixin_Stubx.java     |  243 +++
 .../src/test/java/org/qi4j/test/World.java      |   23 +
 .../test/composite/CleanStackTraceTest.java     |  138 ++
 .../memory/MemoryEntityStoreTest.java           |   58 +
 .../zest/runtime/instantiation/My.properties    |   16 -
 .../service/HelloWorldService.properties        |   17 -
 .../qi4j/runtime/instantiation/My.properties    |   16 +
 .../service/HelloWorldService.properties        |   17 +
 .../memory/MemoryEntityStoreService.java        |   39 -
 .../memory/MemoryMapEntityStoreMixin.java       |  241 ---
 .../apache/zest/entitystore/memory/package.html |   21 -
 .../main/java/org/apache/zest/spi/Qi4jSPI.java  |   69 -
 .../java/org/apache/zest/spi/cache/Cache.java   |   37 -
 .../org/apache/zest/spi/cache/CachePool.java    |   61 -
 .../org/apache/zest/spi/cache/NullCache.java    |   48 -
 .../java/org/apache/zest/spi/cache/package.html |   21 -
 .../org/apache/zest/spi/entity/EntityState.java |   85 -
 .../apache/zest/spi/entity/EntityStatus.java    |   31 -
 .../zest/spi/entity/ManyAssociationState.java   |   35 -
 .../zest/spi/entity/NamedAssociationState.java  |   43 -
 .../zest/spi/entity/QualifiedIdentity.java      |  137 --
 .../org/apache/zest/spi/entity/package.html     |   21 -
 .../zest/spi/entitystore/BackupRestore.java     |   40 -
 ...currentEntityStateModificationException.java |   41 -
 .../ConcurrentModificationCheckConcern.java     |  191 --
 .../DefaultEntityStoreUnitOfWork.java           |  107 -
 .../EntityAlreadyExistsException.java           |   40 -
 .../entitystore/EntityNotFoundException.java    |   39 -
 .../spi/entitystore/EntityStateVersions.java    |  108 --
 .../zest/spi/entitystore/EntityStore.java       |   32 -
 .../spi/entitystore/EntityStoreException.java   |   43 -
 .../zest/spi/entitystore/EntityStoreSPI.java    |   36 -
 .../spi/entitystore/EntityStoreUnitOfWork.java  |   68 -
 .../ModuleEntityStoreUnitOfWork.java            |   85 -
 .../ReadOnlyEntityStoreException.java           |   30 -
 .../spi/entitystore/StateChangeListener.java    |   26 -
 .../StateChangeNotificationConcern.java         |   56 -
 .../zest/spi/entitystore/StateCommitter.java    |   29 -
 .../entitystore/helpers/DefaultEntityState.java |  257 ---
 .../helpers/DefaultManyAssociationState.java    |  106 -
 .../helpers/DefaultNamedAssociationState.java   |  124 --
 .../entitystore/helpers/JSONEntityState.java    |  336 ----
 .../zest/spi/entitystore/helpers/JSONKeys.java  |   62 -
 .../helpers/JSONManyAssociationState.java       |  184 --
 .../helpers/JSONMapEntityStoreActivation.java   |   61 -
 .../helpers/JSONMapEntityStoreMixin.java        |  535 -----
 .../helpers/JSONNamedAssociationState.java      |  175 --
 .../spi/entitystore/helpers/MapEntityStore.java |   77 -
 .../helpers/MapEntityStoreActivation.java       |   46 -
 .../helpers/MapEntityStoreMixin.java            |  564 ------
 .../zest/spi/entitystore/helpers/Migration.java |   27 -
 .../spi/entitystore/helpers/StateStore.java     |   27 -
 .../zest/spi/entitystore/helpers/package.html   |   21 -
 .../apache/zest/spi/entitystore/package.html    |   21 -
 .../apache/zest/spi/metrics/DefaultMetric.java  |   93 -
 .../spi/metrics/MetricsProviderAdapter.java     |  102 -
 .../zest/spi/metrics/NullMetricsFactory.java    |  131 --
 .../org/apache/zest/spi/metrics/package.html    |   21 -
 .../org/apache/zest/spi/module/ModelModule.java |  121 --
 .../org/apache/zest/spi/module/ModuleSpi.java   |   46 -
 .../org/apache/zest/spi/module/package.html     |   21 -
 .../main/java/org/apache/zest/spi/package.html  |   21 -
 .../org/apache/zest/spi/query/EntityFinder.java |   80 -
 .../zest/spi/query/EntityFinderException.java   |   42 -
 .../apache/zest/spi/query/IndexExporter.java    |   54 -
 .../apache/zest/spi/query/QueryBuilderSPI.java  |   29 -
 .../org/apache/zest/spi/query/QuerySource.java  |   55 -
 .../java/org/apache/zest/spi/query/package.html |   21 -
 .../spi/uuid/UuidIdentityGeneratorMixin.java    |   41 -
 .../spi/uuid/UuidIdentityGeneratorService.java  |   28 -
 .../java/org/apache/zest/spi/uuid/package.html  |   21 -
 .../spi/value/ValueDeserializerAdapter.java     | 1100 -----------
 .../zest/spi/value/ValueSerializerAdapter.java  |  625 ------
 .../java/org/apache/zest/spi/value/package.html |   21 -
 .../orgjson/OrgJsonValueDeserializer.java       |  481 -----
 .../orgjson/OrgJsonValueSerialization.java      |  167 --
 .../OrgJsonValueSerializationService.java       |   28 -
 .../orgjson/OrgJsonValueSerializer.java         |  112 --
 .../valueserialization/orgjson/package.html     |   21 -
 .../memory/MemoryEntityStoreService.java        |   39 +
 .../memory/MemoryMapEntityStoreMixin.java       |  241 +++
 .../org/qi4j/entitystore/memory/package.html    |   21 +
 .../spi/src/main/java/org/qi4j/spi/Qi4jSPI.java |   69 +
 .../src/main/java/org/qi4j/spi/cache/Cache.java |   37 +
 .../main/java/org/qi4j/spi/cache/CachePool.java |   61 +
 .../main/java/org/qi4j/spi/cache/NullCache.java |   48 +
 .../main/java/org/qi4j/spi/cache/package.html   |   21 +
 .../java/org/qi4j/spi/entity/EntityState.java   |   85 +
 .../java/org/qi4j/spi/entity/EntityStatus.java  |   31 +
 .../qi4j/spi/entity/ManyAssociationState.java   |   35 +
 .../qi4j/spi/entity/NamedAssociationState.java  |   43 +
 .../org/qi4j/spi/entity/QualifiedIdentity.java  |  137 ++
 .../main/java/org/qi4j/spi/entity/package.html  |   21 +
 .../org/qi4j/spi/entitystore/BackupRestore.java |   40 +
 ...currentEntityStateModificationException.java |   41 +
 .../ConcurrentModificationCheckConcern.java     |  191 ++
 .../DefaultEntityStoreUnitOfWork.java           |  107 +
 .../EntityAlreadyExistsException.java           |   40 +
 .../entitystore/EntityNotFoundException.java    |   39 +
 .../spi/entitystore/EntityStateVersions.java    |  108 ++
 .../org/qi4j/spi/entitystore/EntityStore.java   |   33 +
 .../spi/entitystore/EntityStoreException.java   |   43 +
 .../qi4j/spi/entitystore/EntityStoreSPI.java    |   36 +
 .../spi/entitystore/EntityStoreUnitOfWork.java  |   69 +
 .../ModuleEntityStoreUnitOfWork.java            |   85 +
 .../ReadOnlyEntityStoreException.java           |   30 +
 .../spi/entitystore/StateChangeListener.java    |   26 +
 .../StateChangeNotificationConcern.java         |   57 +
 .../qi4j/spi/entitystore/StateCommitter.java    |   29 +
 .../entitystore/helpers/DefaultEntityState.java |  257 +++
 .../helpers/DefaultManyAssociationState.java    |  106 +
 .../helpers/DefaultNamedAssociationState.java   |  124 ++
 .../entitystore/helpers/JSONEntityState.java    |  336 ++++
 .../qi4j/spi/entitystore/helpers/JSONKeys.java  |   62 +
 .../helpers/JSONManyAssociationState.java       |  184 ++
 .../helpers/JSONMapEntityStoreActivation.java   |   61 +
 .../helpers/JSONMapEntityStoreMixin.java        |  535 +++++
 .../helpers/JSONNamedAssociationState.java      |  175 ++
 .../spi/entitystore/helpers/MapEntityStore.java |   77 +
 .../helpers/MapEntityStoreActivation.java       |   46 +
 .../helpers/MapEntityStoreMixin.java            |  564 ++++++
 .../qi4j/spi/entitystore/helpers/Migration.java |   27 +
 .../spi/entitystore/helpers/StateStore.java     |   27 +
 .../qi4j/spi/entitystore/helpers/package.html   |   21 +
 .../java/org/qi4j/spi/entitystore/package.html  |   21 +
 .../org/qi4j/spi/metrics/DefaultMetric.java     |   93 +
 .../spi/metrics/MetricsProviderAdapter.java     |  102 +
 .../qi4j/spi/metrics/NullMetricsFactory.java    |  131 ++
 .../main/java/org/qi4j/spi/metrics/package.html |   21 +
 .../java/org/qi4j/spi/module/ModelModule.java   |  124 ++
 .../java/org/qi4j/spi/module/ModuleSpi.java     |   46 +
 .../main/java/org/qi4j/spi/module/package.html  |   21 +
 .../spi/src/main/java/org/qi4j/spi/package.html |   21 +
 .../java/org/qi4j/spi/query/EntityFinder.java   |   80 +
 .../qi4j/spi/query/EntityFinderException.java   |   42 +
 .../java/org/qi4j/spi/query/IndexExporter.java  |   54 +
 .../org/qi4j/spi/query/QueryBuilderSPI.java     |   29 +
 .../java/org/qi4j/spi/query/QuerySource.java    |   55 +
 .../main/java/org/qi4j/spi/query/package.html   |   21 +
 .../spi/uuid/UuidIdentityGeneratorMixin.java    |   41 +
 .../spi/uuid/UuidIdentityGeneratorService.java  |   28 +
 .../main/java/org/qi4j/spi/uuid/package.html    |   21 +
 .../spi/value/ValueDeserializerAdapter.java     | 1100 +++++++++++
 .../qi4j/spi/value/ValueSerializerAdapter.java  |  626 ++++++
 .../main/java/org/qi4j/spi/value/package.html   |   21 +
 .../orgjson/OrgJsonValueDeserializer.java       |  481 +++++
 .../orgjson/OrgJsonValueSerialization.java      |  167 ++
 .../OrgJsonValueSerializationService.java       |   28 +
 .../orgjson/OrgJsonValueSerializer.java         |  112 ++
 .../valueserialization/orgjson/package.html     |   21 +
 .../helpers/JSONManyAssociationStateTest.java   |  137 --
 .../zest/spi/metrics/DefaultMetricsTest.java    |  113 --
 .../zest/spi/property/DefaultValuesTest.java    |   70 -
 .../helpers/JSONManyAssociationStateTest.java   |  137 ++
 .../qi4j/spi/metrics/DefaultMetricsTest.java    |  113 ++
 .../qi4j/spi/property/DefaultValuesTest.java    |   70 +
 core/spi/src/test/resources/logback-test.xml    |    2 +-
 .../apache/zest/test/AbstractQi4jBaseTest.java  |  128 --
 .../zest/test/AbstractQi4jScenarioTest.java     |  143 --
 .../org/apache/zest/test/AbstractQi4jTest.java  |   85 -
 .../apache/zest/test/EntityTestAssembler.java   |   43 -
 .../zest/test/cache/AbstractCachePoolTest.java  |  125 --
 .../cache/AbstractEntityStoreWithCacheTest.java |  165 --
 .../apache/zest/test/cache/MemoryCacheImpl.java |  142 --
 .../zest/test/cache/MemoryCachePoolMixin.java   |   82 -
 .../zest/test/cache/MemoryCachePoolService.java |   37 -
 .../org/apache/zest/test/cache/package.html     |   21 -
 ...bstractConfigurationDeserializationTest.java |  120 --
 .../test/entity/AbstractEntityStoreTest.java    |  597 ------
 .../org/apache/zest/test/entity/package.html    |   21 -
 .../test/indexing/AbstractAnyQueryTest.java     |   89 -
 .../test/indexing/AbstractComplexQueryTest.java |  327 ----
 .../test/indexing/AbstractEntityFinderTest.java |  475 -----
 .../test/indexing/AbstractNamedQueryTest.java   |  356 ----
 .../zest/test/indexing/AbstractQueryTest.java   |  833 --------
 .../zest/test/indexing/NameableAssert.java      |  145 --
 .../org/apache/zest/test/indexing/TestData.java |  252 ---
 .../zest/test/indexing/model/Account.java       |   28 -
 .../zest/test/indexing/model/Address.java       |   31 -
 .../apache/zest/test/indexing/model/Alive.java  |   25 -
 .../apache/zest/test/indexing/model/Cat.java    |   26 -
 .../apache/zest/test/indexing/model/City.java   |   31 -
 .../apache/zest/test/indexing/model/Dog.java    |   26 -
 .../apache/zest/test/indexing/model/Domain.java |   29 -
 .../apache/zest/test/indexing/model/Female.java |   31 -
 .../apache/zest/test/indexing/model/File.java   |   32 -
 .../apache/zest/test/indexing/model/Host.java   |   30 -
 .../apache/zest/test/indexing/model/Male.java   |   31 -
 .../zest/test/indexing/model/Nameable.java      |   28 -
 .../apache/zest/test/indexing/model/Person.java |   98 -
 .../apache/zest/test/indexing/model/Pet.java    |   26 -
 .../apache/zest/test/indexing/model/Port.java   |   32 -
 .../zest/test/indexing/model/Protocol.java      |   30 -
 .../zest/test/indexing/model/QueryParam.java    |   32 -
 .../apache/zest/test/indexing/model/URL.java    |   46 -
 .../indexing/model/entities/AccountEntity.java  |   29 -
 .../test/indexing/model/entities/CatEntity.java |   31 -
 .../indexing/model/entities/CityEntity.java     |   29 -
 .../test/indexing/model/entities/DogEntity.java |   29 -
 .../indexing/model/entities/DomainEntity.java   |   29 -
 .../indexing/model/entities/FemaleEntity.java   |   29 -
 .../indexing/model/entities/MaleEntity.java     |   29 -
 .../indexing/model/entities/PersonEntity.java   |   29 -
 .../test/indexing/model/entities/PetEntity.java |   29 -
 .../test/indexing/model/entities/package.html   |   21 -
 .../zest/test/indexing/model/package.html       |   21 -
 .../org/apache/zest/test/indexing/package.html  |   21 -
 .../apache/zest/test/mock/MockComposite.java    |   31 -
 .../zest/test/mock/MockPlayerConcern.java       |   39 -
 .../apache/zest/test/mock/MockPlayerMixin.java  |   65 -
 .../org/apache/zest/test/mock/MockRecorder.java |   23 -
 .../apache/zest/test/mock/MockResolverType.java |   23 -
 .../MethodClassMatcherMockResolver.java         |   52 -
 .../test/mock/internal/MockRecorderMixin.java   |   53 -
 .../zest/test/mock/internal/MockRepository.java |   25 -
 .../zest/test/mock/internal/MockResolver.java   |   38 -
 .../test/mock/internal/MockResolverProxy.java   |   93 -
 .../mock/internal/MockResolverTypeImpl.java     |   37 -
 .../mock/internal/UnresolvableMockResolver.java |   39 -
 .../apache/zest/test/mock/internal/package.html |   21 -
 .../java/org/apache/zest/test/mock/package.html |   21 -
 .../main/java/org/apache/zest/test/package.html |   21 -
 .../java/org/apache/zest/test/util/Assume.java  |  118 --
 .../org/apache/zest/test/util/DelTreeAfter.java |  103 -
 .../apache/zest/test/util/FreePortFinder.java   |   55 -
 .../org/apache/zest/test/util/JSONAssert.java   |  116 --
 .../org/apache/zest/test/util/RepeatRule.java   |   60 -
 .../java/org/apache/zest/test/util/package.html |   21 -
 .../AbstractCollectionSerializationTest.java    |  438 -----
 .../test/value/AbstractJsonDateFormatTest.java  |   88 -
 .../AbstractPlainValueSerializationTest.java    |  231 ---
 ...AbstractValueCompositeSerializationTest.java |  439 -----
 .../org/apache/zest/test/value/package.html     |   21 -
 .../org/qi4j/test/AbstractQi4jBaseTest.java     |  128 ++
 .../org/qi4j/test/AbstractQi4jScenarioTest.java |  143 ++
 .../java/org/qi4j/test/AbstractQi4jTest.java    |   85 +
 .../java/org/qi4j/test/EntityTestAssembler.java |   43 +
 .../qi4j/test/cache/AbstractCachePoolTest.java  |  125 ++
 .../cache/AbstractEntityStoreWithCacheTest.java |  165 ++
 .../org/qi4j/test/cache/MemoryCacheImpl.java    |  142 ++
 .../qi4j/test/cache/MemoryCachePoolMixin.java   |   82 +
 .../qi4j/test/cache/MemoryCachePoolService.java |   37 +
 .../main/java/org/qi4j/test/cache/package.html  |   21 +
 ...bstractConfigurationDeserializationTest.java |  120 ++
 .../test/entity/AbstractEntityStoreTest.java    |  597 ++++++
 .../main/java/org/qi4j/test/entity/package.html |   21 +
 .../test/indexing/AbstractAnyQueryTest.java     |   89 +
 .../test/indexing/AbstractComplexQueryTest.java |  327 ++++
 .../test/indexing/AbstractEntityFinderTest.java |  475 +++++
 .../test/indexing/AbstractNamedQueryTest.java   |  356 ++++
 .../qi4j/test/indexing/AbstractQueryTest.java   |  833 ++++++++
 .../org/qi4j/test/indexing/NameableAssert.java  |  145 ++
 .../java/org/qi4j/test/indexing/TestData.java   |  253 +++
 .../org/qi4j/test/indexing/model/Account.java   |   28 +
 .../org/qi4j/test/indexing/model/Address.java   |   31 +
 .../org/qi4j/test/indexing/model/Alive.java     |   25 +
 .../java/org/qi4j/test/indexing/model/Cat.java  |   26 +
 .../java/org/qi4j/test/indexing/model/City.java |   31 +
 .../java/org/qi4j/test/indexing/model/Dog.java  |   26 +
 .../org/qi4j/test/indexing/model/Domain.java    |   29 +
 .../org/qi4j/test/indexing/model/Female.java    |   31 +
 .../java/org/qi4j/test/indexing/model/File.java |   32 +
 .../java/org/qi4j/test/indexing/model/Host.java |   30 +
 .../java/org/qi4j/test/indexing/model/Male.java |   31 +
 .../org/qi4j/test/indexing/model/Nameable.java  |   28 +
 .../org/qi4j/test/indexing/model/Person.java    |   99 +
 .../java/org/qi4j/test/indexing/model/Pet.java  |   26 +
 .../java/org/qi4j/test/indexing/model/Port.java |   32 +
 .../org/qi4j/test/indexing/model/Protocol.java  |   30 +
 .../qi4j/test/indexing/model/QueryParam.java    |   32 +
 .../java/org/qi4j/test/indexing/model/URL.java  |   46 +
 .../indexing/model/entities/AccountEntity.java  |   29 +
 .../test/indexing/model/entities/CatEntity.java |   31 +
 .../indexing/model/entities/CityEntity.java     |   29 +
 .../test/indexing/model/entities/DogEntity.java |   29 +
 .../indexing/model/entities/DomainEntity.java   |   29 +
 .../indexing/model/entities/FemaleEntity.java   |   29 +
 .../indexing/model/entities/MaleEntity.java     |   29 +
 .../indexing/model/entities/PersonEntity.java   |   29 +
 .../test/indexing/model/entities/PetEntity.java |   29 +
 .../test/indexing/model/entities/package.html   |   21 +
 .../org/qi4j/test/indexing/model/package.html   |   21 +
 .../java/org/qi4j/test/indexing/package.html    |   21 +
 .../java/org/qi4j/test/mock/MockComposite.java  |   31 +
 .../org/qi4j/test/mock/MockPlayerConcern.java   |   39 +
 .../org/qi4j/test/mock/MockPlayerMixin.java     |   65 +
 .../java/org/qi4j/test/mock/MockRecorder.java   |   23 +
 .../org/qi4j/test/mock/MockResolverType.java    |   23 +
 .../MethodClassMatcherMockResolver.java         |   52 +
 .../test/mock/internal/MockRecorderMixin.java   |   53 +
 .../qi4j/test/mock/internal/MockRepository.java |   25 +
 .../qi4j/test/mock/internal/MockResolver.java   |   38 +
 .../test/mock/internal/MockResolverProxy.java   |   93 +
 .../mock/internal/MockResolverTypeImpl.java     |   37 +
 .../mock/internal/UnresolvableMockResolver.java |   39 +
 .../org/qi4j/test/mock/internal/package.html    |   21 +
 .../main/java/org/qi4j/test/mock/package.html   |   21 +
 .../src/main/java/org/qi4j/test/package.html    |   21 +
 .../main/java/org/qi4j/test/util/Assume.java    |  118 ++
 .../java/org/qi4j/test/util/DelTreeAfter.java   |  103 +
 .../java/org/qi4j/test/util/FreePortFinder.java |   55 +
 .../java/org/qi4j/test/util/JSONAssert.java     |  116 ++
 .../java/org/qi4j/test/util/RepeatRule.java     |   60 +
 .../main/java/org/qi4j/test/util/package.html   |   21 +
 .../AbstractCollectionSerializationTest.java    |  438 +++++
 .../test/value/AbstractJsonDateFormatTest.java  |   88 +
 .../AbstractPlainValueSerializationTest.java    |  231 +++
 ...AbstractValueCompositeSerializationTest.java |  439 +++++
 .../main/java/org/qi4j/test/value/package.html  |   21 +
 .../apache/zest/test/cache/MemoryCacheTest.java |   31 -
 .../org/qi4j/test/cache/MemoryCacheTest.java    |   32 +
 .../cache/ehcache/EhCacheConfiguration.java     |  103 -
 .../apache/zest/cache/ehcache/EhCacheImpl.java  |   89 -
 .../zest/cache/ehcache/EhCachePoolMixin.java    |  216 ---
 .../zest/cache/ehcache/EhCachePoolService.java  |   28 -
 .../ehcache/assembly/EhCacheAssembler.java      |   44 -
 .../zest/cache/ehcache/assembly/package.html    |   21 -
 .../org/apache/zest/cache/ehcache/package.html  |   21 -
 .../cache/ehcache/EhCacheConfiguration.java     |  103 +
 .../org/qi4j/cache/ehcache/EhCacheImpl.java     |   89 +
 .../qi4j/cache/ehcache/EhCachePoolMixin.java    |  216 +++
 .../qi4j/cache/ehcache/EhCachePoolService.java  |   28 +
 .../ehcache/assembly/EhCacheAssembler.java      |   44 +
 .../qi4j/cache/ehcache/assembly/package.html    |   21 +
 .../java/org/qi4j/cache/ehcache/package.html    |   21 +
 .../apache/zest/cache/ehcache/EhCacheTest.java  |   45 -
 .../org/qi4j/cache/ehcache/EhCacheTest.java     |   45 +
 .../zest/cache/memcache/MemcacheAssembler.java  |   45 -
 .../cache/memcache/MemcacheConfiguration.java   |   80 -
 .../zest/cache/memcache/MemcacheImpl.java       |  110 --
 .../zest/cache/memcache/MemcachePoolMixin.java  |  129 --
 .../cache/memcache/MemcachePoolService.java     |   31 -
 .../org/apache/zest/cache/memcache/package.html |   39 -
 .../qi4j/cache/memcache/MemcacheAssembler.java  |   45 +
 .../cache/memcache/MemcacheConfiguration.java   |   80 +
 .../org/qi4j/cache/memcache/MemcacheImpl.java   |  110 ++
 .../qi4j/cache/memcache/MemcachePoolMixin.java  |  129 ++
 .../cache/memcache/MemcachePoolService.java     |   31 +
 .../java/org/qi4j/cache/memcache/package.html   |   39 +
 .../cache/memcache/MemcacheCachePoolTest.java   |   62 -
 .../cache/memcache/MemcacheCachePoolTest.java   |   62 +
 .../file/FileEntityStoreActivation.java         |   47 -
 .../file/FileEntityStoreConfiguration.java      |   91 -
 .../entitystore/file/FileEntityStoreMixin.java  |  498 -----
 .../file/FileEntityStoreService.java            |   50 -
 .../file/assembly/FileEntityStoreAssembler.java |   46 -
 .../zest/entitystore/file/assembly/package.html |   21 -
 .../apache/zest/entitystore/file/package.html   |   21 -
 .../file/FileEntityStoreActivation.java         |   47 +
 .../file/FileEntityStoreConfiguration.java      |   91 +
 .../entitystore/file/FileEntityStoreMixin.java  |  498 +++++
 .../file/FileEntityStoreService.java            |   50 +
 .../file/assembly/FileEntityStoreAssembler.java |   46 +
 .../qi4j/entitystore/file/assembly/package.html |   21 +
 .../java/org/qi4j/entitystore/file/package.html |   21 +
 .../entitystore/file/FileEntityStoreTest.java   |   47 -
 .../file/FileEntityStoreWithCacheTest.java      |   42 -
 .../entitystore/file/FileEntityStoreTest.java   |   47 +
 .../file/FileEntityStoreWithCacheTest.java      |   42 +
 .../hazelcast/HazelcastAccessors.java           |   31 -
 .../hazelcast/HazelcastConfiguration.java       |   40 -
 .../hazelcast/HazelcastEntityStoreMixin.java    |  192 --
 .../hazelcast/HazelcastEntityStoreService.java  |   50 -
 .../assembly/HazelcastEntityStoreAssembler.java |   49 -
 .../entitystore/hazelcast/assembly/package.html |   21 -
 .../zest/entitystore/hazelcast/package.html     |   21 -
 .../hazelcast/HazelcastAccessors.java           |   31 +
 .../hazelcast/HazelcastConfiguration.java       |   40 +
 .../hazelcast/HazelcastEntityStoreMixin.java    |  192 ++
 .../hazelcast/HazelcastEntityStoreService.java  |   50 +
 .../assembly/HazelcastEntityStoreAssembler.java |   49 +
 .../entitystore/hazelcast/assembly/package.html |   21 +
 .../org/qi4j/entitystore/hazelcast/package.html |   21 +
 .../hazelcast/HazelcastEntityStoreTest.java     |   67 -
 .../HazelcastEntityStoreWithCacheTest.java      |   40 -
 .../hazelcast/HazelcastEntityStoreTest.java     |   67 +
 .../HazelcastEntityStoreWithCacheTest.java      |   40 +
 .../HazelcastEntityStoreService.properties      |   16 -
 .../zest/entitystore/hazelcast/hazelcast.xml    |   37 -
 .../HazelcastEntityStoreService.properties      |   16 +
 .../qi4j/entitystore/hazelcast/hazelcast.xml    |   37 +
 .../jclouds/JCloudsMapEntityStoreAssembler.java |   42 -
 .../JCloudsMapEntityStoreConfiguration.java     |   45 -
 .../jclouds/JCloudsMapEntityStoreMixin.java     |  316 ---
 .../jclouds/JCloudsMapEntityStoreService.java   |   44 -
 .../zest/entitystore/jclouds/package.html       |   21 -
 .../jclouds/JCloudsMapEntityStoreAssembler.java |   42 +
 .../JCloudsMapEntityStoreConfiguration.java     |   45 +
 .../jclouds/JCloudsMapEntityStoreMixin.java     |  316 +++
 .../jclouds/JCloudsMapEntityStoreService.java   |   44 +
 .../org/qi4j/entitystore/jclouds/package.html   |   21 +
 .../jclouds/JCloudsFilesystemTest.java          |   53 -
 .../jclouds/JCloudsTransientTest.java           |   40 -
 .../jclouds/JCloudsWithCacheTest.java           |   39 -
 .../jclouds/JCloudsFilesystemTest.java          |   53 +
 .../jclouds/JCloudsTransientTest.java           |   40 +
 .../jclouds/JCloudsWithCacheTest.java           |   39 +
 .../entitystore/jdbm/JdbmConfiguration.java     |   51 -
 .../jdbm/JdbmEntityStoreActivation.java         |   56 -
 .../entitystore/jdbm/JdbmEntityStoreMixin.java  |  468 -----
 .../jdbm/JdbmEntityStoreService.java            |   48 -
 .../jdbm/assembly/JdbmEntityStoreAssembler.java |   46 -
 .../zest/entitystore/jdbm/assembly/package.html |   21 -
 .../apache/zest/entitystore/jdbm/package.html   |   21 -
 .../entitystore/jdbm/JdbmConfiguration.java     |   51 +
 .../jdbm/JdbmEntityStoreActivation.java         |   56 +
 .../entitystore/jdbm/JdbmEntityStoreMixin.java  |  468 +++++
 .../jdbm/JdbmEntityStoreService.java            |   48 +
 .../jdbm/assembly/JdbmEntityStoreAssembler.java |   46 +
 .../qi4j/entitystore/jdbm/assembly/package.html |   21 +
 .../java/org/qi4j/entitystore/jdbm/package.html |   21 +
 .../entitystore/jdbm/DocumentationSupport.java  |   35 -
 .../entitystore/jdbm/JdbmEntityStoreTest.java   |   56 -
 .../jdbm/JdbmEntityStoreWithCacheTest.java      |   54 -
 .../entitystore/jdbm/DocumentationSupport.java  |   35 +
 .../entitystore/jdbm/JdbmEntityStoreTest.java   |   56 +
 .../jdbm/JdbmEntityStoreWithCacheTest.java      |   54 +
 .../leveldb/LevelDBEntityStoreAssembler.java    |   47 -
 .../LevelDBEntityStoreConfiguration.java        |   64 -
 .../leveldb/LevelDBEntityStoreMixin.java        |  300 ---
 .../leveldb/LevelDBEntityStoreService.java      |   56 -
 .../zest/entitystore/leveldb/package.html       |   36 -
 .../leveldb/LevelDBEntityStoreAssembler.java    |   47 +
 .../LevelDBEntityStoreConfiguration.java        |   64 +
 .../leveldb/LevelDBEntityStoreMixin.java        |  300 +++
 .../leveldb/LevelDBEntityStoreService.java      |   56 +
 .../org/qi4j/entitystore/leveldb/package.html   |   36 +
 .../leveldb/JavaLevelDBEntityStoreTest.java     |   56 -
 .../leveldb/JniLevelDBEntityStoreTest.java      |   51 -
 .../LevelDBEntityStoreWithCacheTest.java        |   46 -
 .../leveldb/JavaLevelDBEntityStoreTest.java     |   56 +
 .../leveldb/JniLevelDBEntityStoreTest.java      |   51 +
 .../LevelDBEntityStoreWithCacheTest.java        |   46 +
 .../memory/MemoryEntityStoreAssembler.java      |   43 -
 .../apache/zest/entitystore/memory/package.html |   21 -
 .../memory/MemoryEntityStoreAssembler.java      |   43 +
 .../org/qi4j/entitystore/memory/package.html    |   21 +
 .../memory/MemoryEntityStoreTest.java           |   41 -
 .../memory/MemoryEntityStoreWithCacheTest.java  |   35 -
 .../memory/MemoryEntityStoreTest.java           |   41 +
 .../memory/MemoryEntityStoreWithCacheTest.java  |   35 +
 .../entitystore/mongodb/MongoAccessors.java     |   32 -
 .../mongodb/MongoEntityStoreConfiguration.java  |   75 -
 .../mongodb/MongoMapEntityStoreAssembler.java   |   44 -
 .../mongodb/MongoMapEntityStoreMixin.java       |  328 ----
 .../mongodb/MongoMapEntityStoreService.java     |   49 -
 .../zest/entitystore/mongodb/package.html       |   21 -
 .../entitystore/mongodb/MongoAccessors.java     |   32 +
 .../mongodb/MongoEntityStoreConfiguration.java  |   75 +
 .../mongodb/MongoMapEntityStoreAssembler.java   |   44 +
 .../mongodb/MongoMapEntityStoreMixin.java       |  328 ++++
 .../mongodb/MongoMapEntityStoreService.java     |   49 +
 .../org/qi4j/entitystore/mongodb/package.html   |   21 +
 .../mongodb/MongoMapEntityStoreTest.java        |   89 -
 .../MongoMapEntityStoreWithCacheTest.java       |   83 -
 .../mongodb/MongoMapEntityStoreTest.java        |   89 +
 .../MongoMapEntityStoreWithCacheTest.java       |   83 +
 .../entitystore/prefs/ListPreferencesNodes.java |   66 -
 .../prefs/PreferencesEntityStoreInfo.java       |   42 -
 .../prefs/PreferencesEntityStoreMixin.java      |  715 -------
 .../prefs/PreferencesEntityStoreService.java    |   54 -
 .../PreferenceEntityStoreAssembler.java         |   51 -
 .../entitystore/prefs/assembly/package.html     |   21 -
 .../apache/zest/entitystore/prefs/package.html  |   21 -
 .../entitystore/prefs/ListPreferencesNodes.java |   66 +
 .../prefs/PreferencesEntityStoreInfo.java       |   42 +
 .../prefs/PreferencesEntityStoreMixin.java      |  715 +++++++
 .../prefs/PreferencesEntityStoreService.java    |   54 +
 .../PreferenceEntityStoreAssembler.java         |   51 +
 .../entitystore/prefs/assembly/package.html     |   21 +
 .../org/qi4j/entitystore/prefs/package.html     |   21 +
 .../zest/entitystore/DocumentationSupport.java  |   37 -
 .../entitystore/PreferencesEntityStoreTest.java |   42 -
 .../qi4j/entitystore/DocumentationSupport.java  |   37 +
 .../entitystore/PreferencesEntityStoreTest.java |   42 +
 .../zest/entitystore/redis/RedisAccessors.java  |   27 -
 .../redis/RedisEntityStoreConfiguration.java    |   71 -
 .../redis/RedisMapEntityStoreAssembler.java     |   47 -
 .../redis/RedisMapEntityStoreMixin.java         |  213 --
 .../redis/RedisMapEntityStoreService.java       |   49 -
 .../apache/zest/entitystore/redis/package.html  |   21 -
 .../qi4j/entitystore/redis/RedisAccessors.java  |   27 +
 .../redis/RedisEntityStoreConfiguration.java    |   71 +
 .../redis/RedisMapEntityStoreAssembler.java     |   47 +
 .../redis/RedisMapEntityStoreMixin.java         |  213 ++
 .../redis/RedisMapEntityStoreService.java       |   49 +
 .../org/qi4j/entitystore/redis/package.html     |   21 +
 .../redis/RedisMapEntityStoreTest.java          |   82 -
 .../redis/RedisMapEntityStoreWithCacheTest.java |   78 -
 .../redis/RedisMapEntityStoreTest.java          |   82 +
 .../redis/RedisMapEntityStoreWithCacheTest.java |   78 +
 .../riak/AbstractRiakMapEntityStore.java        |  233 ---
 .../zest/entitystore/riak/RiakAccessors.java    |   29 -
 .../riak/RiakHttpEntityStoreConfiguration.java  |   67 -
 .../riak/RiakHttpMapEntityStoreAssembler.java   |   51 -
 .../riak/RiakHttpMapEntityStoreMixin.java       |   68 -
 .../riak/RiakMapEntityStoreService.java         |   53 -
 .../RiakProtobufEntityStoreConfiguration.java   |  102 -
 .../RiakProtobufMapEntityStoreAssembler.java    |   51 -
 .../riak/RiakProtobufMapEntityStoreMixin.java   |   88 -
 .../apache/zest/entitystore/riak/package.html   |   21 -
 .../riak/AbstractRiakMapEntityStore.java        |  233 +++
 .../qi4j/entitystore/riak/RiakAccessors.java    |   29 +
 .../riak/RiakHttpEntityStoreConfiguration.java  |   67 +
 .../riak/RiakHttpMapEntityStoreAssembler.java   |   51 +
 .../riak/RiakHttpMapEntityStoreMixin.java       |   68 +
 .../riak/RiakMapEntityStoreService.java         |   53 +
 .../RiakProtobufEntityStoreConfiguration.java   |  102 +
 .../RiakProtobufMapEntityStoreAssembler.java    |   51 +
 .../riak/RiakProtobufMapEntityStoreMixin.java   |   88 +
 .../java/org/qi4j/entitystore/riak/package.html |   21 +
 .../riak/RiakHttpMapEntityStoreTest.java        |   80 -
 .../riak/RiakMapEntityStoreWithCacheTest.java   |   76 -
 .../riak/RiakProtobufMapEntityStoreTest.java    |   80 -
 .../riak/RiakHttpMapEntityStoreTest.java        |   80 +
 .../riak/RiakMapEntityStoreWithCacheTest.java   |   76 +
 .../riak/RiakProtobufMapEntityStoreTest.java    |   80 +
 .../entitystore/sql/SQLEntityStoreMixin.java    |  629 ------
 .../entitystore/sql/SQLEntityStoreService.java  |   33 -
 .../AbstractSQLEntityStoreAssembler.java        |   91 -
 .../assembly/DerbySQLEntityStoreAssembler.java  |   43 -
 .../sql/assembly/H2SQLEntityStoreAssembler.java |   42 -
 .../sql/assembly/MySQLEntityStoreAssembler.java |   43 -
 .../PostgreSQLEntityStoreAssembler.java         |   50 -
 .../assembly/SQLiteEntityStoreAssembler.java    |   42 -
 .../zest/entitystore/sql/assembly/package.html  |   21 -
 .../sql/internal/DatabaseSQLService.java        |  118 --
 .../internal/DatabaseSQLServiceCoreMixin.java   |  154 --
 .../sql/internal/DatabaseSQLServiceSpi.java     |   76 -
 .../sql/internal/DatabaseSQLServiceState.java   |   30 -
 .../DatabaseSQLServiceStatementsMixin.java      |  112 --
 .../sql/internal/DatabaseSQLStringsBuilder.java |  374 ----
 .../DerbySQLDatabaseSQLServiceMixin.java        |   67 -
 .../internal/H2SQLDatabaseSQLServiceMixin.java  |   57 -
 .../internal/MySQLDatabaseSQLServiceMixin.java  |   67 -
 .../PostgreSQLDatabaseSQLServiceMixin.java      |   63 -
 .../internal/PostgreSQLStringBuilderMixin.java  |   39 -
 .../sql/internal/SQLEntityState.java            |  183 --
 .../internal/SQLiteDatabaseSQLServiceMixin.java |   59 -
 .../zest/entitystore/sql/internal/SQLs.java     |   34 -
 .../zest/entitystore/sql/internal/package.html  |   21 -
 .../apache/zest/entitystore/sql/package.html    |   21 -
 .../entitystore/sql/SQLEntityStoreMixin.java    |  629 ++++++
 .../entitystore/sql/SQLEntityStoreService.java  |   33 +
 .../AbstractSQLEntityStoreAssembler.java        |   91 +
 .../assembly/DerbySQLEntityStoreAssembler.java  |   43 +
 .../sql/assembly/H2SQLEntityStoreAssembler.java |   42 +
 .../sql/assembly/MySQLEntityStoreAssembler.java |   43 +
 .../PostgreSQLEntityStoreAssembler.java         |   50 +
 .../assembly/SQLiteEntityStoreAssembler.java    |   42 +
 .../qi4j/entitystore/sql/assembly/package.html  |   21 +
 .../sql/internal/DatabaseSQLService.java        |  118 ++
 .../internal/DatabaseSQLServiceCoreMixin.java   |  154 ++
 .../sql/internal/DatabaseSQLServiceSpi.java     |   76 +
 .../sql/internal/DatabaseSQLServiceState.java   |   30 +
 .../DatabaseSQLServiceStatementsMixin.java      |  112 ++
 .../sql/internal/DatabaseSQLStringsBuilder.java |  374 ++++
 .../DerbySQLDatabaseSQLServiceMixin.java        |   67 +
 .../internal/H2SQLDatabaseSQLServiceMixin.java  |   57 +
 .../internal/MySQLDatabaseSQLServiceMixin.java  |   67 +
 .../PostgreSQLDatabaseSQLServiceMixin.java      |   63 +
 .../internal/PostgreSQLStringBuilderMixin.java  |   39 +
 .../sql/internal/SQLEntityState.java            |  183 ++
 .../internal/SQLiteDatabaseSQLServiceMixin.java |   59 +
 .../org/qi4j/entitystore/sql/internal/SQLs.java |   34 +
 .../qi4j/entitystore/sql/internal/package.html  |   21 +
 .../java/org/qi4j/entitystore/sql/package.html  |   21 +
 .../sql/DerbySQLEntityStoreTest.java            |  105 -
 .../entitystore/sql/H2SQLEntityStoreTest.java   |   80 -
 .../entitystore/sql/MySQLEntityStoreTest.java   |  116 --
 .../sql/PostgreSQLEntityStoreTest.java          |  142 --
 .../entitystore/sql/SQLiteEntityStoreTest.java  |   89 -
 .../sql/DerbySQLEntityStoreTest.java            |  105 +
 .../entitystore/sql/H2SQLEntityStoreTest.java   |   80 +
 .../entitystore/sql/MySQLEntityStoreTest.java   |  116 ++
 .../sql/PostgreSQLEntityStoreTest.java          |  142 ++
 .../entitystore/sql/SQLiteEntityStoreTest.java  |   89 +
 .../src/test/resources/logback.xml              |    4 +-
 .../ElasticSearchClusterConfiguration.java      |   62 -
 .../ElasticSearchConfiguration.java             |   50 -
 .../elasticsearch/ElasticSearchFinder.java      |  545 ------
 .../ElasticSearchFinderSupport.java             |   65 -
 .../ElasticSearchIndexException.java            |   34 -
 .../ElasticSearchIndexExporter.java             |   52 -
 .../elasticsearch/ElasticSearchIndexer.java     |  348 ----
 .../elasticsearch/ElasticSearchSupport.java     |   35 -
 .../assembly/ESClusterIndexQueryAssembler.java  |   49 -
 .../ESFilesystemIndexQueryAssembler.java        |   49 -
 .../assembly/ESMemoryIndexQueryAssembler.java   |   49 -
 .../index/elasticsearch/assembly/package.html   |   21 -
 .../cluster/ESClusterIndexQueryService.java     |   30 -
 .../elasticsearch/cluster/ESClusterSupport.java |   71 -
 .../index/elasticsearch/cluster/package.html    |   21 -
 .../ESFilesystemIndexQueryService.java          |   30 -
 .../filesystem/ESFilesystemSupport.java         |   88 -
 .../index/elasticsearch/filesystem/package.html |   21 -
 .../AbstractElasticSearchAssembler.java         |   29 -
 .../internal/AbstractElasticSearchSupport.java  |  131 --
 .../index/elasticsearch/internal/package.html   |   21 -
 .../memory/ESMemoryIndexQueryService.java       |   30 -
 .../elasticsearch/memory/ESMemorySupport.java   |   89 -
 .../index/elasticsearch/memory/package.html     |   21 -
 .../zest/index/elasticsearch/package.html       |   21 -
 .../ElasticSearchClusterConfiguration.java      |   62 +
 .../ElasticSearchConfiguration.java             |   50 +
 .../elasticsearch/ElasticSearchFinder.java      |  545 ++++++
 .../ElasticSearchFinderSupport.java             |   65 +
 .../ElasticSearchIndexException.java            |   34 +
 .../ElasticSearchIndexExporter.java             |   52 +
 .../elasticsearch/ElasticSearchIndexer.java     |  348 ++++
 .../elasticsearch/ElasticSearchSupport.java     |   35 +
 .../assembly/ESClusterIndexQueryAssembler.java  |   49 +
 .../ESFilesystemIndexQueryAssembler.java        |   49 +
 .../assembly/ESMemoryIndexQueryAssembler.java   |   49 +
 .../index/elasticsearch/assembly/package.html   |   21 +
 .../cluster/ESClusterIndexQueryService.java     |   30 +
 .../elasticsearch/cluster/ESClusterSupport.java |   71 +
 .../index/elasticsearch/cluster/package.html    |   21 +
 .../ESFilesystemIndexQueryService.java          |   30 +
 .../filesystem/ESFilesystemSupport.java         |   88 +
 .../index/elasticsearch/filesystem/package.html |   21 +
 .../AbstractElasticSearchAssembler.java         |   29 +
 .../internal/AbstractElasticSearchSupport.java  |  131 ++
 .../index/elasticsearch/internal/package.html   |   21 +
 .../memory/ESMemoryIndexQueryService.java       |   30 +
 .../elasticsearch/memory/ESMemorySupport.java   |   89 +
 .../index/elasticsearch/memory/package.html     |   21 +
 .../org/qi4j/index/elasticsearch/package.html   |   21 +
 .../elasticsearch/DocumentationSupport.java     |   53 -
 .../ElasticSearchComplexQueryTest.java          |   82 -
 .../elasticsearch/ElasticSearchFinderTest.java  |   80 -
 .../elasticsearch/ElasticSearchQueryTest.java   |  107 -
 .../index/elasticsearch/ElasticSearchTest.java  |  247 ---
 .../index/elasticsearch/ImmenseTermTest.java    |  143 --
 .../elasticsearch/DocumentationSupport.java     |   53 +
 .../ElasticSearchComplexQueryTest.java          |   82 +
 .../elasticsearch/ElasticSearchFinderTest.java  |   80 +
 .../elasticsearch/ElasticSearchQueryTest.java   |  107 +
 .../index/elasticsearch/ElasticSearchTest.java  |  247 +++
 .../index/elasticsearch/ImmenseTermTest.java    |  143 ++
 .../src/test/resources/logback-test.xml         |    2 +-
 .../index/rdf/RdfIndexingEngineService.java     |   29 -
 .../index/rdf/UnsupportedLanguageException.java |   37 -
 .../rdf/assembly/RdfMemoryStoreAssembler.java   |   63 -
 .../assembly/RdfNativeSesameStoreAssembler.java |   62 -
 .../assembly/RdfRdbmsSesameStoreAssembler.java  |   63 -
 .../apache/zest/index/rdf/assembly/package.html |   21 -
 .../zest/index/rdf/indexing/RdfExporter.java    |  100 -
 .../index/rdf/indexing/RdfIndexingService.java  |  232 ---
 .../apache/zest/index/rdf/indexing/package.html |   21 -
 .../java/org/apache/zest/index/rdf/package.html |   21 -
 ...llectingQualifiedIdentityResultCallback.java |   40 -
 .../query/QualifiedIdentityResultCallback.java  |   31 -
 .../zest/index/rdf/query/RdfQueryParser.java    |   35 -
 .../index/rdf/query/RdfQueryParserFactory.java  |   57 -
 .../zest/index/rdf/query/RdfQueryService.java   |  121 --
 .../zest/index/rdf/query/SesameExpressions.java |   37 -
 .../SingleQualifiedIdentityResultCallback.java  |   38 -
 .../index/rdf/query/TupleQueryExecutor.java     |  148 --
 .../index/rdf/query/internal/Namespaces.java    |   84 -
 .../rdf/query/internal/RdfQueryParserImpl.java  |  581 ------
 .../zest/index/rdf/query/internal/Triples.java  |  285 ---
 .../zest/index/rdf/query/internal/package.html  |   21 -
 .../apache/zest/index/rdf/query/package.html    |   21 -
 .../index/rdf/RdfIndexingEngineService.java     |   29 +
 .../index/rdf/UnsupportedLanguageException.java |   37 +
 .../rdf/assembly/RdfMemoryStoreAssembler.java   |   63 +
 .../assembly/RdfNativeSesameStoreAssembler.java |   63 +
 .../assembly/RdfRdbmsSesameStoreAssembler.java  |   63 +
 .../org/qi4j/index/rdf/assembly/package.html    |   21 +
 .../qi4j/index/rdf/indexing/RdfExporter.java    |  100 +
 .../index/rdf/indexing/RdfIndexingService.java  |  232 +++
 .../org/qi4j/index/rdf/indexing/package.html    |   21 +
 .../main/java/org/qi4j/index/rdf/package.html   |   21 +
 ...llectingQualifiedIdentityResultCallback.java |   40 +
 .../query/QualifiedIdentityResultCallback.java  |   31 +
 .../qi4j/index/rdf/query/RdfQueryParser.java    |   35 +
 .../index/rdf/query/RdfQueryParserFactory.java  |   57 +
 .../qi4j/index/rdf/query/RdfQueryService.java   |  121 ++
 .../qi4j/index/rdf/query/SesameExpressions.java |   37 +
 .../SingleQualifiedIdentityResultCallback.java  |   38 +
 .../index/rdf/query/TupleQueryExecutor.java     |  148 ++
 .../index/rdf/query/internal/Namespaces.java    |   84 +
 .../rdf/query/internal/RdfQueryParserImpl.java  |  581 ++++++
 .../qi4j/index/rdf/query/internal/Triples.java  |  285 +++
 .../qi4j/index/rdf/query/internal/package.html  |   21 +
 .../java/org/qi4j/index/rdf/query/package.html  |   21 +
 .../apache/zest/index/rdf/ContainsAllTest.java  |  387 ----
 .../org/apache/zest/index/rdf/ContainsTest.java |  210 --
 .../zest/index/rdf/DocumentationSupport.java    |   71 -
 .../zest/index/rdf/RDFPerformanceTest.java      |  253 ---
 .../zest/index/rdf/RdfComplexQueryTest.java     |   46 -
 .../zest/index/rdf/RdfEntityFinderTest.java     |   43 -
 .../zest/index/rdf/RdfNamedQueryTest.java       |  251 ---
 .../org/apache/zest/index/rdf/RdfQueryTest.java |   99 -
 .../zest/index/rdf/qi173/Qi173IssueTest.java    |  130 --
 .../zest/index/rdf/qi64/AbstractIssueTest.java  |   66 -
 .../org/apache/zest/index/rdf/qi64/Account.java |   22 -
 .../zest/index/rdf/qi64/AccountComposite.java   |   25 -
 .../org/apache/zest/index/rdf/qi64/HasName.java |   25 -
 .../AccountService.java                         |   61 -
 .../AccountServiceComposite.java                |   27 -
 .../withPropagationMandatory/IssueTest.java     |   90 -
 .../withPropagationRequired/AccountService.java |   60 -
 .../AccountServiceComposite.java                |   27 -
 .../qi64/withPropagationRequired/IssueTest.java |   90 -
 .../AccountService.java                         |   60 -
 .../AccountServiceComposite.java                |   29 -
 .../withPropagationRequiresNew/IssueTest.java   |   89 -
 .../org/apache/zest/index/rdf/qi66/Account.java |   22 -
 .../zest/index/rdf/qi66/AccountComposite.java   |   24 -
 .../org/apache/zest/index/rdf/qi66/HasName.java |   25 -
 .../zest/index/rdf/qi66/Qi66IssueTest.java      |   99 -
 .../zest/index/rdf/qi95/Qi95IssueTest.java      |  392 ----
 .../org/qi4j/index/rdf/ContainsAllTest.java     |  387 ++++
 .../java/org/qi4j/index/rdf/ContainsTest.java   |  210 ++
 .../qi4j/index/rdf/DocumentationSupport.java    |   71 +
 .../org/qi4j/index/rdf/RDFPerformanceTest.java  |  253 +++
 .../org/qi4j/index/rdf/RdfComplexQueryTest.java |   46 +
 .../org/qi4j/index/rdf/RdfEntityFinderTest.java |   43 +
 .../org/qi4j/index/rdf/RdfNamedQueryTest.java   |  251 +++
 .../java/org/qi4j/index/rdf/RdfQueryTest.java   |   99 +
 .../qi4j/index/rdf/qi173/Qi173IssueTest.java    |  130 ++
 .../qi4j/index/rdf/qi64/AbstractIssueTest.java  |   66 +
 .../java/org/qi4j/index/rdf/qi64/Account.java   |   22 +
 .../qi4j/index/rdf/qi64/AccountComposite.java   |   25 +
 .../java/org/qi4j/index/rdf/qi64/HasName.java   |   25 +
 .../AccountService.java                         |   61 +
 .../AccountServiceComposite.java                |   27 +
 .../withPropagationMandatory/IssueTest.java     |   90 +
 .../withPropagationRequired/AccountService.java |   60 +
 .../AccountServiceComposite.java                |   27 +
 .../qi64/withPropagationRequired/IssueTest.java |   90 +
 .../AccountService.java                         |   60 +
 .../AccountServiceComposite.java                |   29 +
 .../withPropagationRequiresNew/IssueTest.java   |   89 +
 .../java/org/qi4j/index/rdf/qi66/Account.java   |   22 +
 .../qi4j/index/rdf/qi66/AccountComposite.java   |   24 +
 .../java/org/qi4j/index/rdf/qi66/HasName.java   |   25 +
 .../org/qi4j/index/rdf/qi66/Qi66IssueTest.java  |   99 +
 .../org/qi4j/index/rdf/qi95/Qi95IssueTest.java  |  392 ++++
 .../zest/index/solr/EmbeddedSolrService.java    |  128 --
 .../apache/zest/index/solr/SolrAssembler.java   |   43 -
 .../apache/zest/index/solr/SolrExpressions.java |   32 -
 .../zest/index/solr/SolrQueryService.java       |   59 -
 .../org/apache/zest/index/solr/SolrSearch.java  |   26 -
 .../solr/internal/SingleTokenTokenizer.java     |   44 -
 .../internal/SingleTokenTokenizerFactory.java   |   32 -
 .../solr/internal/SolrEntityIndexerMixin.java   |  232 ---
 .../solr/internal/SolrEntityQueryMixin.java     |  130 --
 .../zest/index/solr/internal/package.html       |   21 -
 .../org/apache/zest/index/solr/package.html     |   21 -
 .../qi4j/index/solr/EmbeddedSolrService.java    |  128 ++
 .../java/org/qi4j/index/solr/SolrAssembler.java |   43 +
 .../org/qi4j/index/solr/SolrExpressions.java    |   32 +
 .../org/qi4j/index/solr/SolrQueryService.java   |   59 +
 .../java/org/qi4j/index/solr/SolrSearch.java    |   26 +
 .../solr/internal/SingleTokenTokenizer.java     |   44 +
 .../internal/SingleTokenTokenizerFactory.java   |   32 +
 .../solr/internal/SolrEntityIndexerMixin.java   |  232 +++
 .../solr/internal/SolrEntityQueryMixin.java     |  130 ++
 .../org/qi4j/index/solr/internal/package.html   |   21 +
 .../main/java/org/qi4j/index/solr/package.html  |   21 +
 .../zest/index/solr/SolrEntityFinderTest.java   |   51 -
 .../zest/index/solr/SolrNamedQueryTest.java     |   67 -
 .../zest/index/solr/SolrQueryServiceTest.java   |  124 --
 .../apache/zest/index/solr/SolrQueryTest.java   |   51 -
 .../qi4j/index/solr/SolrEntityFinderTest.java   |   51 +
 .../org/qi4j/index/solr/SolrNamedQueryTest.java |   67 +
 .../qi4j/index/solr/SolrQueryServiceTest.java   |  124 ++
 .../java/org/qi4j/index/solr/SolrQueryTest.java |   51 +
 .../indexing-solr/src/test/resources/schema.xml |    4 +-
 .../index/sql/SQLIndexingEngineService.java     |   43 -
 .../AbstractSQLIndexQueryAssembler.java         |   96 -
 .../assembly/PostgreSQLIndexQueryAssembler.java |   44 -
 .../apache/zest/index/sql/assembly/package.html |   21 -
 .../index/sql/internal/SQLEntityFinder.java     |  259 ---
 .../sql/internal/SQLStateChangeListener.java    |   60 -
 .../apache/zest/index/sql/internal/package.html |   21 -
 .../java/org/apache/zest/index/sql/package.html |   21 -
 .../index/sql/support/api/SQLAppStartup.java    |   56 -
 .../zest/index/sql/support/api/SQLIndexing.java |   37 -
 .../zest/index/sql/support/api/SQLQuerying.java |   73 -
 .../zest/index/sql/support/api/SQLTypeInfo.java |   56 -
 .../zest/index/sql/support/api/package.html     |   21 -
 .../zest/index/sql/support/common/DBNames.java  |   93 -
 .../support/common/GenericDatabaseExplorer.java |  454 -----
 .../index/sql/support/common/QNameInfo.java     |  335 ----
 .../sql/support/common/RebuildingStrategy.java  |   76 -
 .../sql/support/common/ReindexingStrategy.java  |   76 -
 .../zest/index/sql/support/common/package.html  |   21 -
 .../zest/index/sql/support/derby/package.html   |   21 -
 .../postgresql/PostgreSQLAppStartup.java        |  108 --
 .../postgresql/PostgreSQLIndexExporter.java     |  342 ----
 .../support/postgresql/PostgreSQLIndexing.java  |   87 -
 .../support/postgresql/PostgreSQLQuerying.java  |   61 -
 .../support/postgresql/PostgreSQLService.java   |   52 -
 .../postgresql/PostgreSQLTypeHelper.java        |  129 --
 .../index/sql/support/postgresql/package.html   |   21 -
 .../support/skeletons/AbstractSQLIndexing.java  | 1058 ----------
 .../support/skeletons/AbstractSQLQuerying.java  | 1831 ------------------
 .../support/skeletons/AbstractSQLStartup.java   | 1769 -----------------
 .../skeletons/SQLCompatEntityStateWrapper.java  |  369 ----
 .../index/sql/support/skeletons/SQLDBState.java |   88 -
 .../sql/support/skeletons/SQLSkeletonUtil.java  |   95 -
 .../index/sql/support/skeletons/package.html    |   21 -
 .../zest/index/sql/support/sqlite/package.html  |   21 -
 .../index/sql/SQLIndexingEngineService.java     |   43 +
 .../AbstractSQLIndexQueryAssembler.java         |   96 +
 .../assembly/PostgreSQLIndexQueryAssembler.java |   44 +
 .../org/qi4j/index/sql/assembly/package.html    |   21 +
 .../index/sql/internal/SQLEntityFinder.java     |  259 +++
 .../sql/internal/SQLStateChangeListener.java    |   60 +
 .../org/qi4j/index/sql/internal/package.html    |   21 +
 .../main/java/org/qi4j/index/sql/package.html   |   21 +
 .../index/sql/support/api/SQLAppStartup.java    |   56 +
 .../qi4j/index/sql/support/api/SQLIndexing.java |   37 +
 .../qi4j/index/sql/support/api/SQLQuerying.java |   73 +
 .../qi4j/index/sql/support/api/SQLTypeInfo.java |   56 +
 .../org/qi4j/index/sql/support/api/package.html |   21 +
 .../qi4j/index/sql/support/common/DBNames.java  |   93 +
 .../support/common/GenericDatabaseExplorer.java |  454 +++++
 .../index/sql/support/common/QNameInfo.java     |  335 ++++
 .../sql/support/common/RebuildingStrategy.java  |   76 +
 .../sql/support/common/ReindexingStrategy.java  |   76 +
 .../qi4j/index/sql/support/common/package.html  |   21 +
 .../qi4j/index/sql/support/derby/package.html   |   21 +
 .../postgresql/PostgreSQLAppStartup.java        |  108 ++
 .../postgresql/PostgreSQLIndexExporter.java     |  342 ++++
 .../support/postgresql/PostgreSQLIndexing.java  |   87 +
 .../support/postgresql/PostgreSQLQuerying.java  |   61 +
 .../support/postgresql/PostgreSQLService.java   |   52 +
 .../postgresql/PostgreSQLTypeHelper.java        |  129 ++
 .../index/sql/support/postgresql/package.html   |   21 +
 .../support/skeletons/AbstractSQLIndexing.java  | 1058 ++++++++++
 .../support/skeletons/AbstractSQLQuerying.java  | 1831 ++++++++++++++++++
 .../support/skeletons/AbstractSQLStartup.java   | 1769 +++++++++++++++++
 .../skeletons/SQLCompatEntityStateWrapper.java  |  369 ++++
 .../index/sql/support/skeletons/SQLDBState.java |   88 +
 .../sql/support/skeletons/SQLSkeletonUtil.java  |   95 +
 .../index/sql/support/skeletons/package.html    |   21 +
 .../qi4j/index/sql/support/sqlite/package.html  |   21 +
 .../postgresql/PostgreSQLComplexQueryTest.java  |   62 -
 .../postgresql/PostgreSQLDBIntegrityTest.java   |  145 --
 .../postgresql/PostgreSQLEntityFinderTest.java  |   62 -
 .../sql/postgresql/PostgreSQLQueryTest.java     |  264 ---
 .../index/sql/postgresql/SQLTestHelper.java     |  120 --
 .../postgresql/PostgreSQLComplexQueryTest.java  |   62 +
 .../postgresql/PostgreSQLDBIntegrityTest.java   |  145 ++
 .../postgresql/PostgreSQLEntityFinderTest.java  |   62 +
 .../sql/postgresql/PostgreSQLQueryTest.java     |  264 +++
 .../index/sql/postgresql/SQLTestHelper.java     |  120 ++
 .../indexing-sql/src/test/resources/logback.xml |    2 +-
 .../zest/metrics/yammer/YammerCounter.java      |   56 -
 .../apache/zest/metrics/yammer/YammerGauge.java |   37 -
 .../zest/metrics/yammer/YammerHealthCheck.java  |   63 -
 .../zest/metrics/yammer/YammerHistogram.java    |   37 -
 .../apache/zest/metrics/yammer/YammerMeter.java |   43 -
 .../metrics/yammer/YammerMetricsAssembler.java  |   94 -
 .../zest/metrics/yammer/YammerMetricsMixin.java |  178 --
 .../metrics/yammer/YammerMetricsProvider.java   |   46 -
 .../apache/zest/metrics/yammer/YammerTimer.java |   46 -
 .../org/apache/zest/metrics/yammer/package.html |   21 -
 .../org/qi4j/metrics/yammer/YammerCounter.java  |   56 +
 .../org/qi4j/metrics/yammer/YammerGauge.java    |   37 +
 .../qi4j/metrics/yammer/YammerHealthCheck.java  |   63 +
 .../qi4j/metrics/yammer/YammerHistogram.java    |   37 +
 .../org/qi4j/metrics/yammer/YammerMeter.java    |   43 +
 .../metrics/yammer/YammerMetricsAssembler.java  |   94 +
 .../qi4j/metrics/yammer/YammerMetricsMixin.java |  178 ++
 .../metrics/yammer/YammerMetricsProvider.java   |   46 +
 .../org/qi4j/metrics/yammer/YammerTimer.java    |   46 +
 .../java/org/qi4j/metrics/yammer/package.html   |   21 +
 .../metrics/yammer/NoMetricsInstalledTest.java  |   96 -
 .../apache/zest/metrics/yammer/YammerTest.java  |   97 -
 .../metrics/yammer/NoMetricsInstalledTest.java  |   96 +
 .../org/qi4j/metrics/yammer/YammerTest.java     |   97 +
 .../zest/migration/MigrationConfiguration.java  |   29 -
 .../zest/migration/MigrationEventLogger.java    |  106 -
 .../apache/zest/migration/MigrationEvents.java  |   48 -
 .../apache/zest/migration/MigrationService.java |  492 -----
 .../org/apache/zest/migration/Migrator.java     |   64 -
 .../assembly/AbstractMigrationRule.java         |   40 -
 .../assembly/EntityMigrationBuilder.java        |  300 ---
 .../assembly/EntityMigrationOperation.java      |   32 -
 .../migration/assembly/EntityMigrationRule.java |   91 -
 .../migration/assembly/MigrationBuilder.java    |   48 -
 .../migration/assembly/MigrationOperation.java  |   34 -
 .../zest/migration/assembly/MigrationRule.java  |   52 -
 .../zest/migration/assembly/MigrationRules.java |  118 --
 .../assembly/PackageMigrationBuilder.java       |   65 -
 .../assembly/VersionMigrationBuilder.java       |   65 -
 .../apache/zest/migration/assembly/package.html |   21 -
 .../migration/operation/AddAssociation.java     |   57 -
 .../migration/operation/AddManyAssociation.java |   58 -
 .../operation/AddNamedAssociation.java          |   61 -
 .../zest/migration/operation/AddProperty.java   |   57 -
 .../migration/operation/RemoveAssociation.java  |   58 -
 .../operation/RemoveManyAssociation.java        |   58 -
 .../operation/RemoveNamedAssociation.java       |   61 -
 .../migration/operation/RemoveProperty.java     |   58 -
 .../migration/operation/RenameAssociation.java  |   57 -
 .../zest/migration/operation/RenameEntity.java  |   77 -
 .../operation/RenameManyAssociation.java        |   57 -
 .../operation/RenameNamedAssociation.java       |   60 -
 .../migration/operation/RenameProperty.java     |   57 -
 .../zest/migration/operation/package.html       |   21 -
 .../java/org/apache/zest/migration/package.html |   21 -
 .../qi4j/migration/MigrationConfiguration.java  |   29 +
 .../qi4j/migration/MigrationEventLogger.java    |  106 +
 .../org/qi4j/migration/MigrationEvents.java     |   48 +
 .../org/qi4j/migration/MigrationService.java    |  492 +++++
 .../main/java/org/qi4j/migration/Migrator.java  |   64 +
 .../assembly/AbstractMigrationRule.java         |   40 +
 .../assembly/EntityMigrationBuilder.java        |  300 +++
 .../assembly/EntityMigrationOperation.java      |   32 +
 .../migration/assembly/EntityMigrationRule.java |   91 +
 .../migration/assembly/MigrationBuilder.java    |   48 +
 .../migration/assembly/MigrationOperation.java  |   34 +
 .../qi4j/migration/assembly/MigrationRule.java  |   52 +
 .../qi4j/migration/assembly/MigrationRules.java |  118 ++
 .../assembly/PackageMigrationBuilder.java       |   65 +
 .../assembly/VersionMigrationBuilder.java       |   65 +
 .../org/qi4j/migration/assembly/package.html    |   21 +
 .../migration/operation/AddAssociation.java     |   57 +
 .../migration/operation/AddManyAssociation.java |   58 +
 .../operation/AddNamedAssociation.java          |   61 +
 .../qi4j/migration/operation/AddProperty.java   |   57 +
 .../migration/operation/RemoveAssociation.java  |   58 +
 .../operation/RemoveManyAssociation.java        |   58 +
 .../operation/RemoveNamedAssociation.java       |   61 +
 .../migration/operation/RemoveProperty.java     |   58 +
 .../migration/operation/RenameAssociation.java  |   57 +
 .../qi4j/migration/operation/RenameEntity.java  |   77 +
 .../operation/RenameManyAssociation.java        |   57 +
 .../operation/RenameNamedAssociation.java       |   60 +
 .../migration/operation/RenameProperty.java     |   57 +
 .../org/qi4j/migration/operation/package.html   |   21 +
 .../main/java/org/qi4j/migration/package.html   |   21 +
 .../apache/zest/migration/MigrationTest.java    |  307 ---
 .../apache/zest/migration/TestEntity1_0.java    |   37 -
 .../apache/zest/migration/TestEntity1_1.java    |   37 -
 .../apache/zest/migration/TestEntity2_0.java    |   39 -
 .../zest/migration/moved/TestEntity2_0.java     |   39 -
 .../java/org/qi4j/migration/MigrationTest.java  |  307 +++
 .../java/org/qi4j/migration/TestEntity1_0.java  |   37 +
 .../java/org/qi4j/migration/TestEntity1_1.java  |   37 +
 .../java/org/qi4j/migration/TestEntity2_0.java  |   39 +
 .../org/qi4j/migration/moved/TestEntity2_0.java |   39 +
 .../zest/index/reindexer/ReindexAllService.java |   29 -
 .../apache/zest/index/reindexer/Reindexer.java  |   27 -
 .../index/reindexer/ReindexerConfiguration.java |   38 -
 .../zest/index/reindexer/ReindexerService.java  |   29 -
 .../reindexer/internal/ReindexAllMixin.java     |   46 -
 .../reindexer/internal/ReindexerMixin.java      |  137 --
 .../zest/index/reindexer/internal/package.html  |   21 -
 .../apache/zest/index/reindexer/package.html    |   21 -
 .../qi4j/index/reindexer/ReindexAllService.java |   29 +
 .../org/qi4j/index/reindexer/Reindexer.java     |   27 +
 .../index/reindexer/ReindexerConfiguration.java |   38 +
 .../qi4j/index/reindexer/ReindexerService.java  |   29 +
 .../reindexer/internal/ReindexAllMixin.java     |   46 +
 .../reindexer/internal/ReindexerMixin.java      |  137 ++
 .../qi4j/index/reindexer/internal/package.html  |   21 +
 .../java/org/qi4j/index/reindexer/package.html  |   21 +
 .../zest/index/reindexer/ReindexerTest.java     |  160 --
 .../org/qi4j/index/reindexer/ReindexerTest.java |  160 ++
 .../jdbm/JdbmEntityStoreService.properties      |   16 -
 .../rdf/repository/rdf-indexing.properties      |   16 -
 .../jdbm/JdbmEntityStoreService.properties      |   16 +
 .../rdf/repository/rdf-indexing.properties      |   16 +
 .../jackson/JacksonValueDeserializer.java       |  374 ----
 .../JacksonValueSerializationAssembler.java     |   58 -
 .../JacksonValueSerializationService.java       |   28 -
 .../jackson/JacksonValueSerializer.java         |   88 -
 .../valueserialization/jackson/package.html     |   21 -
 .../jackson/JacksonValueDeserializer.java       |  374 ++++
 .../JacksonValueSerializationAssembler.java     |   58 +
 .../JacksonValueSerializationService.java       |   28 +
 .../jackson/JacksonValueSerializer.java         |   88 +
 .../valueserialization/jackson/package.html     |   21 +
 .../JacksonCollectionSerializationTest.java     |   33 -
 ...JacksonConfigurationDeserializationTest.java |   36 -
 .../jackson/JacksonJsonDateFormatTest.java      |   33 -
 .../JacksonPlainValueSerializationTest.java     |   34 -
 .../JacksonValueCompositeSerializationTest.java |   33 -
 .../JacksonCollectionSerializationTest.java     |   33 +
 ...JacksonConfigurationDeserializationTest.java |   36 +
 .../jackson/JacksonJsonDateFormatTest.java      |   33 +
 .../JacksonPlainValueSerializationTest.java     |   34 +
 .../JacksonValueCompositeSerializationTest.java |   33 +
 .../OrgJsonValueSerializationAssembler.java     |   58 -
 .../valueserialization/orgjson/package.html     |   21 -
 .../OrgJsonValueSerializationAssembler.java     |   58 +
 .../valueserialization/orgjson/package.html     |   21 +
 .../OrgJsonCollectionSerializationTest.java     |   33 -
 ...OrgJsonConfigurationDeserializationTest.java |   36 -
 .../orgjson/OrgJsonDateFormatTest.java          |   33 -
 .../OrgJsonPlainValueSerializationTest.java     |   34 -
 .../OrgJsonValueCompositeSerializationTest.java |   33 -
 .../OrgJsonCollectionSerializationTest.java     |   33 +
 ...OrgJsonConfigurationDeserializationTest.java |   36 +
 .../orgjson/OrgJsonDateFormatTest.java          |   33 +
 .../OrgJsonPlainValueSerializationTest.java     |   34 +
 .../OrgJsonValueCompositeSerializationTest.java |   33 +
 .../stax/StaxValueDeserializer.java             |  509 -----
 .../stax/StaxValueSerializationAssembler.java   |   58 -
 .../stax/StaxValueSerializationService.java     |   28 -
 .../stax/StaxValueSerializer.java               |  130 --
 .../zest/valueserialization/stax/package.html   |   21 -
 .../stax/StaxValueDeserializer.java             |  509 +++++
 .../stax/StaxValueSerializationAssembler.java   |   58 +
 .../stax/StaxValueSerializationService.java     |   28 +
 .../stax/StaxValueSerializer.java               |  130 ++
 .../qi4j/valueserialization/stax/package.html   |   21 +
 .../stax/StaxCollectionSerializationTest.java   |   42 -
 .../StaxConfigurationDeserializationTest.java   |   65 -
 .../stax/StaxPlainValueSerializationTest.java   |   43 -
 .../StaxValueCompositeSerializationTest.java    |   42 -
 .../stax/StaxCollectionSerializationTest.java   |   42 +
 .../StaxConfigurationDeserializationTest.java   |   65 +
 .../stax/StaxPlainValueSerializationTest.java   |   43 +
 .../StaxValueCompositeSerializationTest.java    |   42 +
 .../src/test/resources/configtest.xml           |    2 +-
 .../zest/library/alarm/AlarmCategory.java       |   30 -
 .../apache/zest/library/alarm/AlarmClass.java   |   42 -
 .../apache/zest/library/alarm/AlarmEvent.java   |  119 --
 .../apache/zest/library/alarm/AlarmHistory.java |  267 ---
 .../zest/library/alarm/AlarmListener.java       |   42 -
 .../apache/zest/library/alarm/AlarmModel.java   |  131 --
 .../library/alarm/AlarmModelDescriptor.java     |   41 -
 .../zest/library/alarm/AlarmNameFormat.java     |   71 -
 .../apache/zest/library/alarm/AlarmPoint.java   |  479 -----
 .../zest/library/alarm/AlarmPointEntity.java    |   26 -
 .../zest/library/alarm/AlarmPointFactory.java   |   68 -
 .../apache/zest/library/alarm/AlarmProxy.java   |  205 --
 .../apache/zest/library/alarm/AlarmStatus.java  |  108 --
 .../apache/zest/library/alarm/AlarmSystem.java  |  294 ---
 .../library/alarm/AlarmSystemAssembler.java     |   47 -
 .../zest/library/alarm/AlarmSystemService.java  |   24 -
 .../alarm/ExtendedAlarmModelService.java        |  429 ----
 .../zest/library/alarm/SimpleAlarmCategory.java |   33 -
 .../library/alarm/SimpleAlarmModelService.java  |  251 ---
 .../alarm/StandardAlarmModelService.java        |  297 ---
 .../org/apache/zest/library/alarm/package.html  |  115 --
 .../org/qi4j/library/alarm/AlarmCategory.java   |   30 +
 .../java/org/qi4j/library/alarm/AlarmClass.java |   42 +
 .../java/org/qi4j/library/alarm/AlarmEvent.java |  119 ++
 .../org/qi4j/library/alarm/AlarmHistory.java    |  267 +++
 .../org/qi4j/library/alarm/AlarmListener.java   |   42 +
 .../java/org/qi4j/library/alarm/AlarmModel.java |  131 ++
 .../library/alarm/AlarmModelDescriptor.java     |   41 +
 .../org/qi4j/library/alarm/AlarmNameFormat.java |   71 +
 .../java/org/qi4j/library/alarm/AlarmPoint.java |  479 +++++
 .../qi4j/library/alarm/AlarmPointEntity.java    |   26 +
 .../qi4j/library/alarm/AlarmPointFactory.java   |   68 +
 .../java/org/qi4j/library/alarm/AlarmProxy.java |  205 ++
 .../org/qi4j/library/alarm/AlarmStatus.java     |  108 ++
 .../org/qi4j/library/alarm/AlarmSystem.java     |  294 +++
 .../library/alarm/AlarmSystemAssembler.java     |   47 +
 .../qi4j/library/alarm/AlarmSystemService.java  |   24 +
 .../alarm/ExtendedAlarmModelService.java        |  429 ++++
 .../qi4j/library/alarm/SimpleAlarmCategory.java |   33 +
 .../library/alarm/SimpleAlarmModelService.java  |  251 +++
 .../alarm/StandardAlarmModelService.java        |  297 +++
 .../java/org/qi4j/library/alarm/package.html    |  115 ++
 .../library/alarm/AlarmResources.properties     |   80 -
 .../library/alarm/AlarmResources_sv.properties  |   80 -
 .../library/alarm/AlarmResources.properties     |   80 +
 .../library/alarm/AlarmResources_sv.properties  |   80 +
 .../library/alarm/AlarmHistoryImplTest.java     |  299 ---
 .../zest/library/alarm/AlarmPointImplTest.java  |  238 ---
 .../zest/library/alarm/AlarmProxyTest.java      |   79 -
 .../zest/library/alarm/AlarmServiceTest.java    |  227 ---
 .../library/alarm/ExtendedAlarmModelTest.java   |  976 ----------
 .../library/alarm/SimpleAlarmModelTest.java     |  361 ----
 .../library/alarm/StandardAlarmModelTest.java   |  487 -----
 .../library/alarm/AlarmHistoryImplTest.java     |  299 +++
 .../qi4j/library/alarm/AlarmPointImplTest.java  |  238 +++
 .../org/qi4j/library/alarm/AlarmProxyTest.java  |   79 +
 .../qi4j/library/alarm/AlarmServiceTest.java    |  227 +++
 .../library/alarm/ExtendedAlarmModelTest.java   |  976 ++++++++++
 .../library/alarm/SimpleAlarmModelTest.java     |  361 ++++
 .../library/alarm/StandardAlarmModelTest.java   |  487 +++++
 .../alarm/user/AlarmDescriptions.properties     |   19 -
 .../user/AlarmDescriptions_en_GB.properties     |   19 -
 .../alarm/user/AlarmDescriptions_sv.properties  |   19 -
 .../alarm/user/AlarmDescriptions.properties     |   19 +
 .../user/AlarmDescriptions_en_GB.properties     |   19 +
 .../alarm/user/AlarmDescriptions_sv.properties  |   19 +
 .../org/qi4j/library/appbrowser/Browser.java    |    6 +-
 .../library/appbrowser/BrowserException.java    |    2 +-
 .../org/qi4j/library/appbrowser/Formatter.java  |    2 +-
 .../library/appbrowser/FormatterFactory.java    |    2 +-
 .../appbrowser/json/AbstractJsonFormatter.java  |    4 +-
 .../json/ApplicationModelFormatter.java         |    6 +-
 .../library/appbrowser/json/ArrayFormatter.java |    4 +-
 .../json/CompositeMethodModelFormatter.java     |    6 +-
 .../json/ConstructorModelFormatter.java         |    4 +-
 .../appbrowser/json/EntityModelFormatter.java   |    4 +-
 .../json/InjectedFieldModelFormatter.java       |    8 +-
 .../appbrowser/json/JsonFormatterFactory.java   |    6 +-
 .../appbrowser/json/LayerModelFormatter.java    |    6 +-
 .../appbrowser/json/MixinModelFormatter.java    |    4 +-
 .../appbrowser/json/ModuleModelFormatter.java   |    6 +-
 .../library/appbrowser/json/NullFormatter.java  |    4 +-
 .../appbrowser/json/ObjectModelFormatter.java   |    4 +-
 .../appbrowser/json/ServiceModelFormatter.java  |    4 +-
 .../appbrowser/json/ValueModelFormatter.java    |    6 +-
 .../qi4j/library/appbrowser/AppBrowserTest.java |   34 +-
 .../library/circuitbreaker/CircuitBreaker.java  |  239 ---
 .../library/circuitbreaker/CircuitBreakers.java |  113 --
 .../circuitbreaker/jmx/CircuitBreakerJMX.java   |  126 --
 .../jmx/CircuitBreakerJMXMBean.java             |   34 -
 .../jmx/CircuitBreakerManagement.java           |  173 --
 .../library/circuitbreaker/jmx/package.html     |   21 -
 .../zest/library/circuitbreaker/package.html    |   21 -
 .../service/AbstractBreakOnThrowable.java       |   31 -
 ...stractEnabledCircuitBreakerAvailability.java |   55 -
 .../service/BreakCircuitConcern.java            |   59 -
 .../service/BreaksCircuitOnThrowable.java       |   32 -
 .../service/ServiceCircuitBreaker.java          |   30 -
 .../service/ServiceCircuitBreakerMixin.java     |   50 -
 .../library/circuitbreaker/service/package.html |   21 -
 .../library/circuitbreaker/CircuitBreaker.java  |  239 +++
 .../library/circuitbreaker/CircuitBreakers.java |  113 ++
 .../circuitbreaker/jmx/CircuitBreakerJMX.java   |  126 ++
 .../jmx/CircuitBreakerJMXMBean.java             |   34 +
 .../jmx/CircuitBreakerManagement.java           |  173 ++
 .../library/circuitbreaker/jmx/package.html     |   21 +
 .../qi4j/library/circuitbreaker/package.html    |   21 +
 .../service/AbstractBreakOnThrowable.java       |   31 +
 ...stractEnabledCircuitBreakerAvailability.java |   55 +
 .../service/BreakCircuitConcern.java            |   59 +
 .../service/BreaksCircuitOnThrowable.java       |   32 +
 .../service/ServiceCircuitBreaker.java          |   30 +
 .../service/ServiceCircuitBreakerMixin.java     |   50 +
 .../library/circuitbreaker/service/package.html |   21 +
 .../BreaksCircuitOnThrowableTest.java           |  121 --
 .../circuitbreaker/CircuitBreakerTest.java      |  222 ---
 .../jmx/CircuitBreakerManagementSample.java     |  117 --
 .../BreaksCircuitOnThrowableTest.java           |  121 ++
 .../circuitbreaker/CircuitBreakerTest.java      |  222 +++
 .../jmx/CircuitBreakerManagementSample.java     |  117 ++
 .../library/constraints/ContainsConstraint.java |   39 -
 .../constraints/GreaterThanConstraint.java      |   39 -
 .../constraints/InstanceOfConstraint.java       |   45 -
 .../library/constraints/LessThanConstraint.java |   39 -
 .../library/constraints/MatchesConstraint.java  |   46 -
 .../constraints/MaxLengthConstraint.java        |   44 -
 .../constraints/MinLengthConstraint.java        |   45 -
 .../NotEmptyCollectionConstraint.java           |   40 -
 .../constraints/NotEmptyStringConstraint.java   |   39 -
 .../library/constraints/OneOfConstraint.java    |   47 -
 .../library/constraints/RangeConstraint.java    |   39 -
 .../zest/library/constraints/URIConstraint.java |   41 -
 .../zest/library/constraints/URLConstraint.java |   41 -
 .../constraints/annotation/Contains.java        |   36 -
 .../library/constraints/annotation/Email.java   |   34 -
 .../constraints/annotation/GreaterThan.java     |   36 -
 .../constraints/annotation/InstanceOf.java      |   32 -
 .../constraints/annotation/LessThan.java        |   36 -
 .../library/constraints/annotation/Matches.java |   36 -
 .../constraints/annotation/MaxLength.java       |   36 -
 .../constraints/annotation/MinLength.java       |   36 -
 .../constraints/annotation/NotEmpty.java        |   39 -
 .../library/constraints/annotation/OneOf.java   |   36 -
 .../library/constraints/annotation/Range.java   |   38 -
 .../library/constraints/annotation/URI.java     |   32 -
 .../library/constraints/annotation/URL.java     |   32 -
 .../library/constraints/annotation/package.html |   21 -
 .../zest/library/constraints/package.html       |   21 -
 .../library/constraints/ContainsConstraint.java |   39 +
 .../constraints/GreaterThanConstraint.java      |   39 +
 .../constraints/InstanceOfConstraint.java       |   45 +
 .../library/constraints/LessThanConstraint.java |   39 +
 .../library/constraints/MatchesConstraint.java  |   46 +
 .../constraints/MaxLengthConstraint.java        |   44 +
 .../constraints/MinLengthConstraint.java        |   45 +
 .../NotEmptyCollectionConstraint.java           |   40 +
 .../constraints/NotEmptyStringConstraint.java   |   39 +
 .../library/constraints/OneOfConstraint.java    |   47 +
 .../library/constraints/RangeConstraint.java    |   39 +
 .../qi4j/library/constraints/URIConstraint.java |   41 +
 .../qi4j/library/constraints/URLConstraint.java |   41 +
 .../constraints/annotation/Contains.java        |   36 +
 .../library/constraints/annotation/Email.java   |   34 +
 .../constraints/annotation/GreaterThan.java     |   36 +
 .../constraints/annotation/InstanceOf.java      |   32 +
 .../constraints/annotation/LessThan.java        |   36 +
 .../library/constraints/annotation/Matches.java |   36 +
 .../constraints/annotation/MaxLength.java       |   36 +
 .../constraints/annotation/MinLength.java       |   36 +
 .../constraints/annotation/NotEmpty.java        |   39 +
 .../library/constraints/annotation/OneOf.java   |   36 +
 .../library/constraints/annotation/Range.java   |   38 +
 .../library/constraints/annotation/URI.java     |   32 +
 .../library/constraints/annotation/URL.java     |   32 +
 .../library/constraints/annotation/package.html |   21 +
 .../org/qi4j/library/constraints/package.html   |   21 +
 .../library/constraints/ConstraintTest.java     |  277 ---
 .../library/constraints/TestCaseComposite.java  |   71 -
 .../library/constraints/qi70/IssueTest.java     |   44 -
 .../zest/library/constraints/qi70/Sample.java   |   28 -
 .../constraints/qi70/SampleComposite.java       |   29 -
 .../library/constraints/qi70/SampleMixin.java   |   24 -
 .../library/constraints/ConstraintTest.java     |  277 +++
 .../library/constraints/TestCaseComposite.java  |   71 +
 .../library/constraints/qi70/IssueTest.java     |   44 +
 .../qi4j/library/constraints/qi70/Sample.java   |   28 +
 .../constraints/qi70/SampleComposite.java       |   29 +
 .../library/constraints/qi70/SampleMixin.java   |   24 +
 .../conversion/values/EntityToValue.java        |  462 -----
 .../values/EntityToValueAssembler.java          |   43 -
 .../conversion/values/EntityToValueService.java |   53 -
 .../values/PropertyNotPresentException.java     |   43 -
 .../zest/library/conversion/values/Shared.java  |   67 -
 .../library/conversion/values/Unqualified.java  |   33 -
 .../conversion/values/ValueToEntity.java        |  133 --
 .../values/ValueToEntityAssembler.java          |   41 -
 .../conversion/values/ValueToEntityMixin.java   |  838 --------
 .../conversion/values/ValueToEntityService.java |   29 -
 .../zest/library/conversion/values/package.html |   21 -
 .../conversion/values/EntityToValue.java        |  462 +++++
 .../values/EntityToValueAssembler.java          |   43 +
 .../conversion/values/EntityToValueService.java |   53 +
 .../values/PropertyNotPresentException.java     |   43 +
 .../qi4j/library/conversion/values/Shared.java  |   67 +
 .../library/conversion/values/Unqualified.java  |   33 +
 .../conversion/values/ValueToEntity.java        |  133 ++
 .../values/ValueToEntityAssembler.java          |   41 +
 .../conversion/values/ValueToEntityMixin.java   |  838 ++++++++
 .../conversion/values/ValueToEntityService.java |   29 +
 .../qi4j/library/conversion/values/package.html |   21 +
 .../conversion/values/EntityToValueTest.java    |  231 ---
 .../values/NestedValuesConversionTest.java      |  126 --
 .../library/conversion/values/TestModel.java    |  200 --
 .../conversion/values/ValueToEntityTest.java    |  351 ----
 .../conversion/values/EntityToValueTest.java    |  231 +++
 .../values/NestedValuesConversionTest.java      |  126 ++
 .../library/conversion/values/TestModel.java    |  200 ++
 .../conversion/values/ValueToEntityTest.java    |  351 ++++
 .../source/jdbm/JdbmEventStoreService.java      |  257 ---
 .../domain/source/jdbm/package.html             |   21 -
 .../source/jdbm/JdbmEventStoreService.java      |  257 +++
 .../domain/source/jdbm/package.html             |   21 +
 .../source/jdbm/JdbmEventStoreServiceTest.java  |  120 --
 .../source/jdbm/JdbmEventStoreServiceTest.java  |  120 ++
 .../rest/server/DomainEventSourceResource.java  |  253 ---
 .../domain/rest/server/package.html             |   21 -
 .../rest/server/DomainEventSourceResource.java  |  253 +++
 .../domain/rest/server/package.html             |   21 +
 .../server/DomainEventSourceResourceSample.java |  185 --
 .../server/DomainEventSourceResourceSample.java |  186 ++
 .../application/api/ApplicationEvent.java       |   56 -
 .../api/TransactionApplicationEvents.java       |   42 -
 .../eventsourcing/application/api/package.html  |   21 -
 .../ApplicationEventCreationConcern.java        |   47 -
 .../factory/ApplicationEventCreator.java        |   30 -
 .../factory/ApplicationEventFactory.java        |   27 -
 .../factory/ApplicationEventFactoryService.java |  110 --
 .../factory/ApplicationEventMethodFilter.java   |   35 -
 .../factory/TransactionNotificationConcern.java |   95 -
 .../factory/UnitOfWorkApplicationEvents.java    |   39 -
 .../application/factory/package.html            |   21 -
 .../replay/ApplicationEventPlayer.java          |   37 -
 .../replay/ApplicationEventPlayerService.java   |  153 --
 .../replay/ApplicationEventReplayException.java |   40 -
 .../application/replay/package.html             |   21 -
 .../AbstractApplicationEventStoreMixin.java     |  192 --
 .../source/ApplicationEventSource.java          |   55 -
 .../source/ApplicationEventStore.java           |   29 -
 .../source/ApplicationEventStoreActivation.java |   50 -
 .../source/ApplicationEventStream.java          |   32 -
 .../helper/ApplicationEventParameters.java      |   67 -
 .../source/helper/ApplicationEvents.java        |  194 --
 .../helper/ApplicationTransactionTracker.java   |  151 --
 .../application/source/helper/package.html      |   21 -
 .../MemoryApplicationEventStoreService.java     |  141 --
 .../application/source/memory/package.html      |   21 -
 .../application/source/package.html             |   21 -
 .../bootstrap/EventsourcingAssembler.java       |   81 -
 .../eventsourcing/bootstrap/package.html        |   21 -
 .../eventsourcing/domain/api/DomainEvent.java   |   35 -
 .../domain/api/DomainEventValue.java            |   47 -
 .../eventsourcing/domain/api/DomainEvents.java  |   40 -
 .../domain/api/UnitOfWorkDomainEventsValue.java |   53 -
 .../eventsourcing/domain/api/package.html       |   21 -
 .../domain/factory/CurrentUserSubject.java      |   38 -
 .../domain/factory/CurrentUserUoWPrincipal.java |   42 -
 .../factory/DomainEventCreationConcern.java     |   65 -
 .../domain/factory/DomainEventFactory.java      |   29 -
 .../factory/DomainEventFactoryService.java      |   86 -
 .../domain/factory/UnitOfWorkEvents.java        |   40 -
 .../factory/UnitOfWorkNotificationConcern.java  |  149 --
 .../eventsourcing/domain/factory/package.html   |   21 -
 .../domain/replay/DomainEventPlayer.java        |   42 -
 .../domain/replay/DomainEventPlayerService.java |  204 --
 .../domain/replay/EventReplayException.java     |   41 -
 .../eventsourcing/domain/replay/package.html    |   21 -
 .../domain/source/AbstractEventStoreMixin.java  |  181 --
 .../domain/source/EventManagement.java          |   31 -
 .../domain/source/EventSource.java              |   42 -
 .../eventsourcing/domain/source/EventStore.java |   29 -
 .../domain/source/EventStoreActivation.java     |   50 -
 .../domain/source/EventStream.java              |   30 -
 .../domain/source/UnitOfWorkEventsListener.java |   27 -
 .../domain/source/UnitOfWorkEventsVisitor.java  |   28 -
 .../source/helper/DomainEventTracker.java       |  114 --
 .../helper/DomainEventTrackerConfiguration.java |   40 -
 .../domain/source/helper/EventParameters.java   |   68 -
 .../domain/source/helper/EventRouter.java       |  101 -
 .../domain/source/helper/Events.java            |  202 --
 .../domain/source/helper/UnitOfWorkRouter.java  |   82 -
 .../domain/source/helper/package.html           |   21 -
 .../source/memory/MemoryEventStoreService.java  |  124 --
 .../domain/source/memory/package.html           |   21 -
 .../eventsourcing/domain/source/package.html    |   21 -
 .../eventsourcing/domain/spi/CurrentUser.java   |   24 -
 .../eventsourcing/domain/spi/package.html       |   21 -
 .../application/api/ApplicationEvent.java       |   56 +
 .../api/TransactionApplicationEvents.java       |   42 +
 .../eventsourcing/application/api/package.html  |   21 +
 .../ApplicationEventCreationConcern.java        |   47 +
 .../factory/ApplicationEventCreator.java        |   30 +
 .../factory/ApplicationEventFactory.java        |   27 +
 .../factory/ApplicationEventFactoryService.java |  110 ++
 .../factory/ApplicationEventMethodFilter.java   |   35 +
 .../factory/TransactionNotificationConcern.java |   95 +
 .../factory/UnitOfWorkApplicationEvents.java    |   39 +
 .../application/factory/package.html            |   21 +
 .../replay/ApplicationEventPlayer.java          |   37 +
 .../replay/ApplicationEventPlayerService.java   |  153 ++
 .../replay/ApplicationEventReplayException.java |   40 +
 .../application/replay/package.html             |   21 +
 .../AbstractApplicationEventStoreMixin.java     |  192 ++
 .../source/ApplicationEventSource.java          |   55 +
 .../source/ApplicationEventStore.java           |   29 +
 .../source/ApplicationEventStoreActivation.java |   50 +
 .../source/ApplicationEventStream.java          |   32 +
 .../helper/ApplicationEventParameters.java      |   67 +
 .../source/helper/ApplicationEvents.java        |  194 ++
 .../helper/ApplicationTransactionTracker.java   |  151 ++
 .../application/source/helper/package.html      |   21 +
 .../MemoryApplicationEventStoreService.java     |  142 ++
 .../application/source/memory/package.html      |   21 +
 .../application/source/package.html             |   21 +
 .../bootstrap/EventsourcingAssembler.java       |   81 +
 .../eventsourcing/bootstrap/package.html        |   21 +
 .../eventsourcing/domain/api/DomainEvent.java   |   35 +
 .../domain/api/DomainEventValue.java            |   47 +
 .../eventsourcing/domain/api/DomainEvents.java  |   40 +
 .../domain/api/UnitOfWorkDomainEventsValue.java |   53 +
 .../eventsourcing/domain/api/package.html       |   21 +
 .../domain/factory/CurrentUserSubject.java      |   38 +
 .../domain/factory/CurrentUserUoWPrincipal.java |   42 +
 .../factory/DomainEventCreationConcern.java     |   65 +
 .../domain/factory/DomainEventFactory.java      |   29 +
 .../factory/DomainEventFactoryService.java      |   86 +
 .../domain/factory/UnitOfWorkEvents.java        |   40 +
 .../factory/UnitOfWorkNotificationConcern.java  |  149 ++
 .../eventsourcing/domain/factory/package.html   |   21 +
 .../domain/replay/DomainEventPlayer.java        |   42 +
 .../domain/replay/DomainEventPlayerService.java |  204 ++
 .../domain/replay/EventReplayException.java     |   41 +
 .../eventsourcing/domain/replay/package.html    |   21 +
 .../domain/source/AbstractEventStoreMixin.java  |  181 ++
 .../domain/source/EventManagement.java          |   31 +
 .../domain/source/EventSource.java              |   42 +
 .../eventsourcing/domain/source/EventStore.java |   29 +
 .../domain/source/EventStoreActivation.java     |   50 +
 .../domain/source/EventStream.java              |   30 +
 .../domain/source/UnitOfWorkEventsListener.java |   27 +
 .../domain/source/UnitOfWorkEventsVisitor.java  |   28 +
 .../source/helper/DomainEventTracker.java       |  114 ++
 .../helper/DomainEventTrackerConfiguration.java |   40 +
 .../domain/source/helper/EventParameters.java   |   68 +
 .../domain/source/helper/EventRouter.java       |  101 +
 .../domain/source/helper/Events.java            |  202 ++
 .../domain/source/helper/UnitOfWorkRouter.java  |   82 +
 .../domain/source/helper/package.html           |   21 +
 .../source/memory/MemoryEventStoreService.java  |  124 ++
 .../domain/source/memory/package.html           |   21 +
 .../eventsourcing/domain/source/package.html    |   21 +
 .../eventsourcing/domain/spi/CurrentUser.java   |   24 +
 .../eventsourcing/domain/spi/package.html       |   21 +
 .../application/ApplicationEventTest.java       |  225 ---
 .../eventsourcing/domain/DomainEventTest.java   |  121 --
 .../source/helper/DomainEventTrackerTest.java   |  182 --
 .../domain/source/helper/EventRouterTest.java   |  110 --
 .../domain/source/helper/EventsTest.java        |  101 -
 .../source/helper/UnitOfWorkRouterTest.java     |  153 --
 .../application/ApplicationEventTest.java       |  227 +++
 .../eventsourcing/domain/DomainEventTest.java   |  125 ++
 .../source/helper/DomainEventTrackerTest.java   |  182 ++
 .../domain/source/helper/EventRouterTest.java   |  110 ++
 .../domain/source/helper/EventsTest.java        |  101 +
 .../source/helper/UnitOfWorkRouterTest.java     |  153 ++
 .../library/fileconfig/FileConfiguration.java   |   68 -
 .../fileconfig/FileConfigurationAssembler.java  |   53 -
 .../fileconfig/FileConfigurationDataWiper.java  |   84 -
 .../fileconfig/FileConfigurationOverride.java   |   82 -
 .../fileconfig/FileConfigurationService.java    |  292 ---
 .../apache/zest/library/fileconfig/package.html |   21 -
 .../library/fileconfig/FileConfiguration.java   |   68 +
 .../fileconfig/FileConfigurationAssembler.java  |   53 +
 .../fileconfig/FileConfigurationDataWiper.java  |   84 +
 .../fileconfig/FileConfigurationOverride.java   |   82 +
 .../fileconfig/FileConfigurationService.java    |  292 +++
 .../org/qi4j/library/fileconfig/package.html    |   21 +
 .../fileconfig/FileConfiguration_mac.properties |   20 -
 .../FileConfiguration_unix.properties           |   20 -
 .../FileConfiguration_windows.properties        |   20 -
 .../fileconfig/FileConfiguration_mac.properties |   20 +
 .../FileConfiguration_unix.properties           |   20 +
 .../FileConfiguration_windows.properties        |   20 +
 .../fileconfig/FileConfigurationTest.java       |   82 -
 .../fileconfig/FileConfiguration_mac.properties |   23 -
 .../fileconfig/FileConfigurationTest.java       |   82 +
 .../fileconfig/FileConfiguration_mac.properties |   23 +
 .../zest/library/http/AbstractJettyMixin.java   |  186 --
 .../zest/library/http/ConstraintInfo.java       |   70 -
 .../zest/library/http/ConstraintService.java    |   59 -
 .../zest/library/http/ContextListenerInfo.java  |   37 -
 .../apache/zest/library/http/Dispatchers.java   |   49 -
 .../apache/zest/library/http/FilterInfo.java    |   56 -
 .../apache/zest/library/http/HttpService.java   |   23 -
 .../org/apache/zest/library/http/Interface.java |   32 -
 .../apache/zest/library/http/InterfaceImpl.java |   49 -
 .../zest/library/http/JettyActivation.java      |   48 -
 .../zest/library/http/JettyConfiguration.java   |  165 --
 .../library/http/JettyConfigurationHelper.java  |  362 ----
 .../apache/zest/library/http/JettyMixin.java    |   59 -
 .../apache/zest/library/http/JettyService.java  |   26 -
 .../library/http/JettyServiceAssembler.java     |   94 -
 .../library/http/SecureJettyConfiguration.java  |  210 --
 .../zest/library/http/SecureJettyMixin.java     |  110 --
 .../zest/library/http/SecureJettyService.java   |   22 -
 .../http/SecureJettyServiceAssembler.java       |   32 -
 .../apache/zest/library/http/ServletInfo.java   |   53 -
 .../org/apache/zest/library/http/Servlets.java  |  341 ----
 .../zest/library/http/UnitOfWorkFilter.java     |   67 -
 .../library/http/UnitOfWorkFilterService.java   |   29 -
 .../zest/library/http/WelcomeServlet.java       |   42 -
 .../library/http/WelcomeServletService.java     |   27 -
 .../org/apache/zest/library/http/package.html   |   21 -
 .../qi4j/library/http/AbstractJettyMixin.java   |  186 ++
 .../org/qi4j/library/http/ConstraintInfo.java   |   70 +
 .../qi4j/library/http/ConstraintService.java    |   59 +
 .../qi4j/library/http/ContextListenerInfo.java  |   37 +
 .../java/org/qi4j/library/http/Dispatchers.java |   49 +
 .../java/org/qi4j/library/http/FilterInfo.java  |   56 +
 .../java/org/qi4j/library/http/HttpService.java |   23 +
 .../java/org/qi4j/library/http/Interface.java   |   32 +
 .../org/qi4j/library/http/InterfaceImpl.java    |   49 +
 .../org/qi4j/library/http/JettyActivation.java  |   48 +
 .../qi4j/library/http/JettyConfiguration.java   |  165 ++
 .../library/http/JettyConfigurationHelper.java  |  362 ++++
 .../java/org/qi4j/library/http/JettyMixin.java  |   59 +
 .../org/qi4j/library/http/JettyService.java     |   26 +
 .../library/http/JettyServiceAssembler.java     |   94 +
 .../library/http/SecureJettyConfiguration.java  |  210 ++
 .../org/qi4j/library/http/SecureJettyMixin.java |  110 ++
 .../qi4j/library/http/SecureJettyService.java   |   22 +
 .../http/SecureJettyServiceAssembler.java       |   32 +
 .../java/org/qi4j/library/http/ServletInfo.java |   53 +
 .../java/org/qi4j/library/http/Servlets.java    |  341 ++++
 .../org/qi4j/library/http/UnitOfWorkFilter.java |   67 +
 .../library/http/UnitOfWorkFilterService.java   |   29 +
 .../org/qi4j/library/http/WelcomeServlet.java   |   42 +
 .../library/http/WelcomeServletService.java     |   27 +
 .../java/org/qi4j/library/http/package.html     |   21 +
 .../zest/library/http/AbstractJettyTest.java    |   64 -
 .../library/http/AbstractSecureJettyTest.java   |  128 --
 .../library/http/FooServletContextListener.java |   37 -
 .../http/FooServletContextListenerService.java  |   30 -
 .../zest/library/http/HelloWorldServlet.java    |   44 -
 .../library/http/HelloWorldServletService.java  |   29 -
 .../library/http/JettyJMXStatisticsTest.java    |   62 -
 .../zest/library/http/JettyServiceTest.java     |   86 -
 .../zest/library/http/JettyTestSuite.java       |   29 -
 .../http/MutualSecureJettyServiceTest.java      |   74 -
 .../library/http/SecureJettyServiceTest.java    |  102 -
 .../http/VirtualHostJettyServiceTest.java       |   82 -
 .../zest/library/http/dns/LocalManagedDns.java  |  119 --
 .../http/dns/LocalManagedDnsDescriptor.java     |   42 -
 .../qi4j/library/http/AbstractJettyTest.java    |   64 +
 .../library/http/AbstractSecureJettyTest.java   |  128 ++
 .../library/http/FooServletContextListener.java |   37 +
 .../http/FooServletContextListenerService.java  |   30 +
 .../qi4j/library/http/HelloWorldServlet.java    |   44 +
 .../library/http/HelloWorldServletService.java  |   29 +
 .../library/http/JettyJMXStatisticsTest.java    |   62 +
 .../org/qi4j/library/http/JettyServiceTest.java |   86 +
 .../org/qi4j/library/http/JettyTestSuite.java   |   29 +
 .../http/MutualSecureJettyServiceTest.java      |   74 +
 .../library/http/SecureJettyServiceTest.java    |  102 +
 .../http/VirtualHostJettyServiceTest.java       |   82 +
 .../qi4j/library/http/dns/LocalManagedDns.java  |  120 ++
 .../http/dns/LocalManagedDnsDescriptor.java     |   42 +
 ...un.net.spi.nameservice.NameServiceDescriptor |    2 +-
 libraries/http/src/test/resources/logback.xml   |    2 +-
 .../http/qi4j-lib-http-unittests-ca.jceks       |  Bin 1075 -> 0 bytes
 .../qi4j-lib-http-unittests-client-cert.jceks   |  Bin 3395 -> 0 bytes
 .../qi4j-lib-http-unittests-server-cert.jceks   |  Bin 3380 -> 0 bytes
 .../http/qi4j-lib-http-unittests-ca.jceks       |  Bin 0 -> 1075 bytes
 .../qi4j-lib-http-unittests-client-cert.jceks   |  Bin 0 -> 3395 bytes
 .../qi4j-lib-http-unittests-server-cert.jceks   |  Bin 0 -> 3380 bytes
 .../zest/library/invocationcache/Cached.java    |   36 -
 .../invocationcache/InvocationCache.java        |   37 -
 .../ReturnCachedValueConcern.java               |   61 -
 .../ReturnCachedValueOnExceptionConcern.java    |   70 -
 .../SimpleInvocationCacheMixin.java             |   69 -
 .../zest/library/invocationcache/package.html   |   21 -
 .../qi4j/library/invocationcache/Cached.java    |   36 +
 .../invocationcache/InvocationCache.java        |   37 +
 .../ReturnCachedValueConcern.java               |   62 +
 .../ReturnCachedValueOnExceptionConcern.java    |   70 +
 .../SimpleInvocationCacheMixin.java             |   69 +
 .../qi4j/library/invocationcache/package.html   |   21 +
 .../invocationcache/DocumentationSupport.java   |   51 -
 .../invocationcache/DocumentationSupport.java   |   51 +
 .../library/jmx/ApplicationManagerService.java  |  377 ----
 .../jmx/ConfigurationManagerService.java        |  428 ----
 .../apache/zest/library/jmx/JMXAssembler.java   |   37 -
 .../library/jmx/JMXConnectorConfiguration.java  |   38 -
 .../zest/library/jmx/JMXConnectorService.java   |  190 --
 .../zest/library/jmx/MBeanServerImporter.java   |   40 -
 .../apache/zest/library/jmx/MBeanTracker.java   |  212 --
 .../zest/library/jmx/ModelMBeanBuilder.java     |  129 --
 .../org/apache/zest/library/jmx/Qi4jMBeans.java |   42 -
 .../org/apache/zest/library/jmx/package.html    |   21 -
 .../library/jmx/ApplicationManagerService.java  |  377 ++++
 .../jmx/ConfigurationManagerService.java        |  428 ++++
 .../java/org/qi4j/library/jmx/JMXAssembler.java |   37 +
 .../library/jmx/JMXConnectorConfiguration.java  |   38 +
 .../qi4j/library/jmx/JMXConnectorService.java   |  190 ++
 .../qi4j/library/jmx/MBeanServerImporter.java   |   40 +
 .../java/org/qi4j/library/jmx/MBeanTracker.java |  212 ++
 .../org/qi4j/library/jmx/ModelMBeanBuilder.java |  129 ++
 .../java/org/qi4j/library/jmx/Qi4jMBeans.java   |   42 +
 .../main/java/org/qi4j/library/jmx/package.html |   21 +
 .../org/apache/zest/library/jmx/JMXTest.java    |  207 --
 .../test/java/org/qi4j/library/jmx/JMXTest.java |  207 ++
 .../apache/zest/library/groovy/GroovyMixin.java |  215 --
 .../org/apache/zest/library/groovy/package.html |   21 -
 .../java/org/qi4j/lang/groovy/GroovyMixin.java  |  215 ++
 .../main/java/org/qi4j/lang/groovy/package.html |   21 +
 .../zest/library/groovy/GroovyComposite.java    |   23 -
 .../zest/library/groovy/GroovyMixinTest.java    |   46 -
 .../zest/library/groovy/HelloSpeaker.java       |   19 -
 .../library/groovy/HelloSpeakerMixin.groovy     |   26 -
 .../zest/library/groovy/HelloSpeakerTest.java   |   79 -
 .../org/apache/zest/library/groovy/Mixin1.java  |   24 -
 .../org/qi4j/lang/groovy/GroovyComposite.java   |   23 +
 .../org/qi4j/lang/groovy/GroovyMixinTest.java   |   46 +
 .../org/qi4j/lang/groovy/HelloSpeaker.java      |   19 +
 .../qi4j/lang/groovy/HelloSpeakerMixin.groovy   |   26 +
 .../org/qi4j/lang/groovy/HelloSpeakerTest.java  |   79 +
 .../groovy/org/qi4j/lang/groovy/Mixin1.java     |   24 +
 .../zest/library/groovy/HelloSpeaker.groovy     |   26 -
 .../library/groovy/HelloSpeaker.sayHello.groovy |   21 -
 .../apache/zest/library/groovy/Mixin1.groovy    |   23 -
 .../org/qi4j/lang/groovy/HelloSpeaker.groovy    |   25 +
 .../lang/groovy/HelloSpeaker.sayHello.groovy    |   20 +
 .../org/qi4j/lang/groovy/Mixin1.groovy          |   22 +
 .../library/javascript/JavaScriptMixin.java     |  324 ----
 .../apache/zest/library/javascript/package.html |   21 -
 .../qi4j/lang/javascript/JavaScriptMixin.java   |  324 ++++
 .../java/org/qi4j/lang/javascript/package.html  |   21 +
 .../zest/library/javascript/DomainType.java     |   24 -
 .../zest/library/javascript/HelloSpeaker.java   |   23 -
 .../library/javascript/JavaScriptMixinTest.java |   35 -
 .../org/qi4j/lang/javascript/DomainType.java    |   24 +
 .../org/qi4j/lang/javascript/HelloSpeaker.java  |   24 +
 .../lang/javascript/JavaScriptMixinTest.java    |   35 +
 .../zest/library/javascript/DomainType.js       |   25 -
 .../org/qi4j/lang/javascript/DomainType.js      |   25 +
 .../zest/library/scala/ScalaTraitMixin.java     |  214 --
 .../org/apache/zest/library/scala/package.html  |   21 -
 .../org/qi4j/lang/scala/ScalaTraitMixin.java    |  214 ++
 .../main/java/org/qi4j/lang/scala/package.html  |   21 +
 .../scala/scala/ExclamationGenericConcern.scala |   36 -
 .../library/scala/scala/HelloThereConcern.scala |   22 -
 .../scala/scala/HelloWorldComposite.scala       |   21 -
 .../scala/scala/HelloWorldComposite2.scala      |   15 -
 .../scala/scala/HelloWorldCompositeTest.java    |  123 --
 .../library/scala/scala/HelloWorldMixin.scala   |   20 -
 .../library/scala/scala/HelloWorldMixin2.scala  |   21 -
 .../library/scala/scala/HelloWorldMixin3.scala  |   22 -
 .../zest/library/scala/scala/TestEntity.scala   |   62 -
 .../zest/library/scala/scala/TestService.scala  |   25 -
 .../scala/ExclamationGenericConcern.scala       |   36 +
 .../qi4j/sample/scala/HelloThereConcern.scala   |   22 +
 .../qi4j/sample/scala/HelloWorldComposite.scala |   21 +
 .../sample/scala/HelloWorldComposite2.scala     |   15 +
 .../sample/scala/HelloWorldCompositeTest.java   |  123 ++
 .../org/qi4j/sample/scala/HelloWorldMixin.scala |   20 +
 .../qi4j/sample/scala/HelloWorldMixin2.scala    |   21 +
 .../qi4j/sample/scala/HelloWorldMixin3.scala    |   22 +
 .../org/qi4j/sample/scala/TestEntity.scala      |   62 +
 .../org/qi4j/sample/scala/TestService.scala     |   25 +
 .../apache/zest/library/locking/LockMixin.java  |   41 -
 .../locking/LockingAbstractComposite.java       |   31 -
 .../apache/zest/library/locking/ReadLock.java   |   25 -
 .../zest/library/locking/ReadLockConcern.java   |   90 -
 .../apache/zest/library/locking/WriteLock.java  |   25 -
 .../zest/library/locking/WriteLockConcern.java  |   81 -
 .../apache/zest/library/locking/package.html    |   21 -
 .../org/qi4j/library/locking/LockMixin.java     |   41 +
 .../locking/LockingAbstractComposite.java       |   31 +
 .../java/org/qi4j/library/locking/ReadLock.java |   25 +
 .../qi4j/library/locking/ReadLockConcern.java   |   90 +
 .../org/qi4j/library/locking/WriteLock.java     |   25 +
 .../qi4j/library/locking/WriteLockConcern.java  |   81 +
 .../java/org/qi4j/library/locking/package.html  |   21 +
 .../library/locking/DocumentationSupport.java   |   42 -
 .../zest/library/locking/LockingTest.java       |  126 --
 .../library/locking/DocumentationSupport.java   |   42 +
 .../org/qi4j/library/locking/LockingTest.java   |  126 ++
 .../zest/library/logging/debug/Debug.java       |   46 -
 .../library/logging/debug/DebugConcern.java     |   98 -
 .../zest/library/logging/debug/package.html     |   21 -
 .../records/CompositeDebugRecordEntity.java     |   27 -
 .../logging/debug/records/DebugRecord.java      |   35 -
 .../debug/records/EntityDebugRecordEntity.java  |   26 -
 .../debug/records/ServiceDebugRecordEntity.java |   26 -
 .../library/logging/debug/records/package.html  |   21 -
 .../debug/service/DebugOnConsoleSideEffect.java |  111 --
 .../service/DebugServiceConfiguration.java      |   27 -
 .../logging/debug/service/DebuggingService.java |   35 -
 .../service/DebuggingServiceComposite.java      |   29 -
 .../debug/service/DebuggingServiceMixin.java    |  180 --
 .../library/logging/debug/service/package.html  |   21 -
 .../zest/library/logging/log/CategoryLog.java   |   53 -
 .../library/logging/log/CategoryLogConcern.java |  160 --
 .../library/logging/log/CategoryLogMixin.java   |   85 -
 .../zest/library/logging/log/LogType.java       |   23 -
 .../zest/library/logging/log/SimpleLog.java     |   51 -
 .../library/logging/log/SimpleLogConcern.java   |  165 --
 .../zest/library/logging/log/StandardLog.java   |   34 -
 .../library/logging/log/StandardLogConcern.java |   76 -
 .../log/assemblies/LoggingAssembler.java        |   36 -
 .../library/logging/log/assemblies/package.html |   21 -
 .../zest/library/logging/log/package.html       |   21 -
 .../logging/log/records/CompositeLogRecord.java |   27 -
 .../logging/log/records/EntityLogRecord.java    |   27 -
 .../library/logging/log/records/LogRecord.java  |   40 -
 .../logging/log/records/ServiceLogRecord.java   |   25 -
 .../library/logging/log/records/package.html    |   21 -
 .../log/service/LogOnConsoleSideEffect.java     |   83 -
 .../logging/log/service/LoggingService.java     |   27 -
 .../log/service/LoggingServiceComposite.java    |   28 -
 .../log/service/LoggingServiceMixin.java        |  171 --
 .../library/logging/log/service/package.html    |   21 -
 .../logging/trace/AbstractTraceConcern.java     |   84 -
 .../logging/trace/ExcludeCompositeFilter.java   |   32 -
 .../zest/library/logging/trace/Trace.java       |   63 -
 .../library/logging/trace/TraceAllConcern.java  |   54 -
 .../library/logging/trace/TraceConcern.java     |   58 -
 .../logging/trace/TraceOnConsoleSideEffect.java |   95 -
 .../trace/assemblies/TracingAssembler.java      |   38 -
 .../logging/trace/assemblies/package.html       |   21 -
 .../zest/library/logging/trace/package.html     |   21 -
 .../records/CompositeTraceRecordEntity.java     |   28 -
 .../trace/records/EntityTraceRecordEntity.java  |   28 -
 .../trace/records/ServiceTraceRecordEntity.java |   26 -
 .../logging/trace/records/TraceRecord.java      |   40 -
 .../library/logging/trace/records/package.html  |   21 -
 .../service/StandardTraceServiceComposite.java  |   30 -
 .../logging/trace/service/TraceService.java     |   33 -
 .../service/TraceServiceConfiguration.java      |   28 -
 .../trace/service/TraceServiceMixin.java        |  164 --
 .../library/logging/trace/service/package.html  |   21 -
 .../logging/view/ConsoleViewerComposite.java    |   26 -
 .../logging/view/ConsoleViewerMixin.java        |   27 -
 .../logging/view/LogServiceListener.java        |   22 -
 .../zest/library/logging/view/SwingViewer.java  |   27 -
 .../zest/library/logging/view/package.html      |   21 -
 .../main/java/org/qi4j/logging/debug/Debug.java |   46 +
 .../org/qi4j/logging/debug/DebugConcern.java    |   98 +
 .../java/org/qi4j/logging/debug/package.html    |   21 +
 .../records/CompositeDebugRecordEntity.java     |   27 +
 .../qi4j/logging/debug/records/DebugRecord.java |   35 +
 .../debug/records/EntityDebugRecordEntity.java  |   26 +
 .../debug/records/ServiceDebugRecordEntity.java |   26 +
 .../org/qi4j/logging/debug/records/package.html |   21 +
 .../debug/service/DebugOnConsoleSideEffect.java |  111 ++
 .../service/DebugServiceConfiguration.java      |   27 +
 .../logging/debug/service/DebuggingService.java |   35 +
 .../service/DebuggingServiceComposite.java      |   29 +
 .../debug/service/DebuggingServiceMixin.java    |  180 ++
 .../org/qi4j/logging/debug/service/package.html |   21 +
 .../java/org/qi4j/logging/log/CategoryLog.java  |   53 +
 .../qi4j/logging/log/CategoryLogConcern.java    |  160 ++
 .../org/qi4j/logging/log/CategoryLogMixin.java  |   85 +
 .../main/java/org/qi4j/logging/log/LogType.java |   23 +
 .../java/org/qi4j/logging/log/SimpleLog.java    |   51 +
 .../org/qi4j/logging/log/SimpleLogConcern.java  |  165 ++
 .../java/org/qi4j/logging/log/StandardLog.java  |   34 +
 .../qi4j/logging/log/StandardLogConcern.java    |   76 +
 .../log/assemblies/LoggingAssembler.java        |   36 +
 .../qi4j/logging/log/assemblies/package.html    |   21 +
 .../main/java/org/qi4j/logging/log/package.html |   21 +
 .../logging/log/records/CompositeLogRecord.java |   27 +
 .../logging/log/records/EntityLogRecord.java    |   27 +
 .../org/qi4j/logging/log/records/LogRecord.java |   40 +
 .../logging/log/records/ServiceLogRecord.java   |   25 +
 .../org/qi4j/logging/log/records/package.html   |   21 +
 .../log/service/LogOnConsoleSideEffect.java     |   83 +
 .../logging/log/service/LoggingService.java     |   27 +
 .../log/service/LoggingServiceComposite.java    |   28 +
 .../log/service/LoggingServiceMixin.java        |  171 ++
 .../org/qi4j/logging/log/service/package.html   |   21 +
 .../logging/trace/AbstractTraceConcern.java     |   84 +
 .../logging/trace/ExcludeCompositeFilter.java   |   32 +
 .../main/java/org/qi4j/logging/trace/Trace.java |   63 +
 .../org/qi4j/logging/trace/TraceAllConcern.java |   54 +
 .../org/qi4j/logging/trace/TraceConcern.java    |   58 +
 .../logging/trace/TraceOnConsoleSideEffect.java |   95 +
 .../trace/assemblies/TracingAssembler.java      |   38 +
 .../qi4j/logging/trace/assemblies/package.html  |   21 +
 .../java/org/qi4j/logging/trace/package.html    |   21 +
 .../records/CompositeTraceRecordEntity.java     |   28 +
 .../trace/records/EntityTraceRecordEntity.java  |   28 +
 .../trace/records/ServiceTraceRecordEntity.java |   26 +
 .../qi4j/logging/trace/records/TraceRecord.java |   40 +
 .../org/qi4j/logging/trace/records/package.html |   21 +
 .../service/StandardTraceServiceComposite.java  |   30 +
 .../logging/trace/service/TraceService.java     |   33 +
 .../service/TraceServiceConfiguration.java      |   28 +
 .../trace/service/TraceServiceMixin.java        |  164 ++
 .../org/qi4j/logging/trace/service/package.html |   21 +
 .../logging/view/ConsoleViewerComposite.java    |   26 +
 .../qi4j/logging/view/ConsoleViewerMixin.java   |   27 +
 .../qi4j/logging/view/LogServiceListener.java   |   22 +
 .../java/org/qi4j/logging/view/SwingViewer.java |   27 +
 .../java/org/qi4j/logging/view/package.html     |   21 +
 .../zest/library/logging/DebuggingTest.java     |  143 --
 .../zest/library/logging/TracingTest.java       |  256 ---
 .../library/logging/docsupport/LoggingDocs.java |   71 -
 .../java/org/qi4j/logging/DebuggingTest.java    |  144 ++
 .../test/java/org/qi4j/logging/TracingTest.java |  256 +++
 .../qi4j/logging/docsupport/LoggingDocs.java    |   71 +
 .../DebuggingServiceComposite.properties        |   16 -
 .../DebuggingServiceComposite.properties        |   16 +
 .../zest/library/metrics/TimingCapture.java     |   32 -
 .../metrics/TimingCaptureAllConcern.java        |   75 -
 .../library/metrics/TimingCaptureConcern.java   |   43 -
 .../apache/zest/library/metrics/package.html    |   21 -
 .../org/qi4j/library/metrics/TimingCapture.java |   32 +
 .../metrics/TimingCaptureAllConcern.java        |   75 +
 .../library/metrics/TimingCaptureConcern.java   |   43 +
 .../java/org/qi4j/library/metrics/package.html  |   21 +
 .../library/metrics/DocumentationSupport.java   |   79 -
 .../zest/library/metrics/MetricsTest.java       |  195 --
 .../library/metrics/DocumentationSupport.java   |   79 +
 .../org/qi4j/library/metrics/MetricsTest.java   |  195 ++
 .../zest/library/osgi/FallbackStrategy.java     |   39 -
 .../zest/library/osgi/OSGiEnabledService.java   |  125 --
 .../zest/library/osgi/OSGiImportInfo.java       |   46 -
 .../zest/library/osgi/OSGiServiceExporter.java  |  122 --
 .../zest/library/osgi/OSGiServiceImporter.java  |  121 --
 .../org/apache/zest/library/osgi/package.html   |   21 -
 .../org/qi4j/library/osgi/FallbackStrategy.java |   39 +
 .../qi4j/library/osgi/OSGiEnabledService.java   |  125 ++
 .../org/qi4j/library/osgi/OSGiImportInfo.java   |   46 +
 .../qi4j/library/osgi/OSGiServiceExporter.java  |  122 ++
 .../qi4j/library/osgi/OSGiServiceImporter.java  |  121 ++
 .../java/org/qi4j/library/osgi/package.html     |   21 +
 .../zest/library/osgi/DocumentationSupport.java |   92 -
 .../zest/library/osgi/OSGiServiceTest.java      |   78 -
 .../qi4j/library/osgi/DocumentationSupport.java |   92 +
 .../org/qi4j/library/osgi/OSGiServiceTest.java  |   78 +
 .../java/org/apache/zest/library/rdf/DcRdf.java |   24 -
 .../org/apache/zest/library/rdf/Qi4jEntity.java |   33 -
 .../apache/zest/library/rdf/Qi4jEntityType.java |   33 -
 .../org/apache/zest/library/rdf/Qi4jRdf.java    |   81 -
 .../org/apache/zest/library/rdf/RdfFormat.java  |   19 -
 .../java/org/apache/zest/library/rdf/Rdfs.java  |   60 -
 .../rdf/entity/EntityStateSerializer.java       |  249 ---
 .../rdf/entity/EntityTypeSerializer.java        |  160 --
 .../apache/zest/library/rdf/entity/package.html |   21 -
 .../rdf/model/ApplicationSerializer.java        |   43 -
 .../library/rdf/model/ApplicationVisitor.java   |  112 --
 .../zest/library/rdf/model/Model2XML.java       |  217 ---
 .../apache/zest/library/rdf/model/package.html  |   21 -
 .../org/apache/zest/library/rdf/package.html    |   21 -
 .../repository/HttpRepositoryConfiguration.java |   45 -
 .../rdf/repository/HttpRepositoryService.java   |   92 -
 .../rdf/repository/MemoryRepositoryService.java |  132 --
 .../rdf/repository/NativeConfiguration.java     |   36 -
 .../rdf/repository/NativeRepositoryService.java |  221 ---
 .../RdbmsRepositoryConfiguration.java           |   31 -
 .../rdf/repository/RdbmsRepositoryService.java  |  135 --
 .../rdf/repository/ResetableRepository.java     |   27 -
 .../zest/library/rdf/repository/package.html    |   21 -
 .../rdf/serializer/AbstractSerializer.java      |   78 -
 .../library/rdf/serializer/N3Serializer.java    |   28 -
 .../rdf/serializer/RdfXmlSerializer.java        |   28 -
 .../zest/library/rdf/serializer/Serializer.java |   28 -
 .../rdf/serializer/SerializerContext.java       |  123 --
 .../rdf/serializer/TurtleSerializer.java        |   28 -
 .../zest/library/rdf/serializer/package.html    |   21 -
 .../main/java/org/qi4j/library/rdf/DcRdf.java   |   24 +
 .../java/org/qi4j/library/rdf/Qi4jEntity.java   |   33 +
 .../org/qi4j/library/rdf/Qi4jEntityType.java    |   33 +
 .../main/java/org/qi4j/library/rdf/Qi4jRdf.java |   81 +
 .../java/org/qi4j/library/rdf/RdfFormat.java    |   19 +
 .../main/java/org/qi4j/library/rdf/Rdfs.java    |   60 +
 .../rdf/entity/EntityStateSerializer.java       |  249 +++
 .../rdf/entity/EntityTypeSerializer.java        |  160 ++
 .../org/qi4j/library/rdf/entity/package.html    |   21 +
 .../rdf/model/ApplicationSerializer.java        |   43 +
 .../library/rdf/model/ApplicationVisitor.java   |  112 ++
 .../org/qi4j/library/rdf/model/Model2XML.java   |  217 +++
 .../org/qi4j/library/rdf/model/package.html     |   21 +
 .../main/java/org/qi4j/library/rdf/package.html |   21 +
 .../repository/HttpRepositoryConfiguration.java |   45 +
 .../rdf/repository/HttpRepositoryService.java   |   92 +
 .../rdf/repository/MemoryRepositoryService.java |  132 ++
 .../rdf/repository/NativeConfiguration.java     |   36 +
 .../rdf/repository/NativeRepositoryService.java |  221 +++
 .../RdbmsRepositoryConfiguration.java           |   31 +
 .../rdf/repository/RdbmsRepositoryService.java  |  135 ++
 .../rdf/repository/ResetableRepository.java     |   27 +
 .../qi4j/library/rdf/repository/package.html    |   21 +
 .../rdf/serializer/AbstractSerializer.java      |   78 +
 .../library/rdf/serializer/N3Serializer.java    |   28 +
 .../rdf/serializer/RdfXmlSerializer.java        |   28 +
 .../qi4j/library/rdf/serializer/Serializer.java |   28 +
 .../rdf/serializer/SerializerContext.java       |  123 ++
 .../rdf/serializer/TurtleSerializer.java        |   28 +
 .../qi4j/library/rdf/serializer/package.html    |   21 +
 .../zest/library/rdf/ApplicationXmlTest.java    |  156 --
 .../apache/zest/library/rdf/Model2XMLTest.java  |   82 -
 .../rdf/entity/EntitySerializerTest.java        |  138 --
 .../rdf/entity/EntityTypeSerializerTest.java    |  123 --
 .../zest/library/rdf/entity/Test2Value.java     |   27 -
 .../zest/library/rdf/entity/TestEntity.java     |   41 -
 .../zest/library/rdf/entity/TestValue.java      |   31 -
 .../org/apache/zest/library/rdf/entity/test.xml |   53 -
 .../apache/zest/library/rdf/entity/test2.xml    |   42 -
 .../rdf/repository/MemoryRepositoryTest.java    |   55 -
 .../rdf/repository/NativeRepositoryTest.java    |   59 -
 .../qi4j/library/rdf/ApplicationXmlTest.java    |  156 ++
 .../org/qi4j/library/rdf/Model2XMLTest.java     |   82 +
 .../rdf/entity/EntitySerializerTest.java        |  138 ++
 .../rdf/entity/EntityTypeSerializerTest.java    |  123 ++
 .../org/qi4j/library/rdf/entity/Test2Value.java |   27 +
 .../org/qi4j/library/rdf/entity/TestEntity.java |   41 +
 .../org/qi4j/library/rdf/entity/TestValue.java  |   31 +
 .../java/org/qi4j/library/rdf/entity/test.xml   |   53 +
 .../java/org/qi4j/library/rdf/entity/test2.xml  |   42 +
 .../rdf/repository/MemoryRepositoryTest.java    |   55 +
 .../rdf/repository/NativeRepositoryTest.java    |   59 +
 .../NativeRepositoryService.properties          |   16 -
 .../NativeRepositoryService.properties          |   16 +
 .../library/rest/client/ClientAssembler.java    |   52 -
 .../zest/library/rest/client/ClientCache.java   |  149 --
 .../rest/client/RequestWriterDelegator.java     |  100 -
 .../rest/client/ResponseReaderDelegator.java    |   87 -
 .../rest/client/api/ContextResourceClient.java  |  488 -----
 .../api/ContextResourceClientFactory.java       |  186 --
 .../library/rest/client/api/ErrorHandler.java   |   86 -
 .../library/rest/client/api/HandlerCommand.java |  221 ---
 .../zest/library/rest/client/api/package.html   |   21 -
 .../zest/library/rest/client/package.html       |   21 -
 .../client/requestwriter/FormRequestWriter.java |   49 -
 .../ValueCompositeRequestWriter.java            |  111 --
 .../rest/client/requestwriter/package.html      |   21 -
 .../responsereader/DefaultResponseReader.java   |   62 -
 .../responsereader/JSONResponseReader.java      |   84 -
 .../responsereader/TableResponseReader.java     |  110 --
 .../rest/client/responsereader/package.html     |   21 -
 .../rest/client/spi/NullResponseHandler.java    |   36 -
 .../library/rest/client/spi/RequestWriter.java  |   38 -
 .../rest/client/spi/ResponseHandler.java        |   31 -
 .../library/rest/client/spi/ResponseReader.java |   29 -
 .../library/rest/client/spi/ResultHandler.java  |   29 -
 .../zest/library/rest/client/spi/package.html   |   21 -
 .../library/rest/client/ClientAssembler.java    |   52 +
 .../qi4j/library/rest/client/ClientCache.java   |  149 ++
 .../rest/client/RequestWriterDelegator.java     |  100 +
 .../rest/client/ResponseReaderDelegator.java    |   87 +
 .../rest/client/api/ContextResourceClient.java  |  488 +++++
 .../api/ContextResourceClientFactory.java       |  186 ++
 .../library/rest/client/api/ErrorHandler.java   |   86 +
 .../library/rest/client/api/HandlerCommand.java |  221 +++
 .../qi4j/library/rest/client/api/package.html   |   21 +
 .../org/qi4j/library/rest/client/package.html   |   21 +
 .../client/requestwriter/FormRequestWriter.java |   49 +
 .../ValueCompositeRequestWriter.java            |  111 ++
 .../rest/client/requestwriter/package.html      |   21 +
 .../responsereader/DefaultResponseReader.java   |   62 +
 .../responsereader/JSONResponseReader.java      |   84 +
 .../responsereader/TableResponseReader.java     |  110 ++
 .../rest/client/responsereader/package.html     |   21 +
 .../rest/client/spi/NullResponseHandler.java    |   36 +
 .../library/rest/client/spi/RequestWriter.java  |   38 +
 .../rest/client/spi/ResponseHandler.java        |   31 +
 .../library/rest/client/spi/ResponseReader.java |   29 +
 .../library/rest/client/spi/ResultHandler.java  |   29 +
 .../qi4j/library/rest/client/spi/package.html   |   21 +
 .../library/rest/client/rest-client.properties  |   22 -
 .../library/rest/client/rest-client.properties  |   22 +
 .../ContextResourceClientFactoryTest.java       |  754 --------
 .../rest/client/ContinuousIntegrationTest.java  |  452 -----
 .../zest/library/rest/client/RssReaderTest.java |  177 --
 .../rest/client/docsupport/RestPrimerDocs.java  |  125 --
 .../ContextResourceClientFactoryTest.java       |  754 ++++++++
 .../rest/client/ContinuousIntegrationTest.java  |  452 +++++
 .../qi4j/library/rest/client/RssReaderTest.java |  177 ++
 .../rest/client/docsupport/RestPrimerDocs.java  |  125 ++
 .../apache/zest/library/rest/common/Form.java   |   33 -
 .../zest/library/rest/common/Resource.java      |   77 -
 .../library/rest/common/ValueAssembler.java     |   45 -
 .../zest/library/rest/common/link/Link.java     |   68 -
 .../zest/library/rest/common/link/Links.java    |   33 -
 .../library/rest/common/link/LinksBuilder.java  |  131 --
 .../library/rest/common/link/LinksUtil.java     |   99 -
 .../zest/library/rest/common/link/package.html  |   21 -
 .../zest/library/rest/common/package.html       |   21 -
 .../zest/library/rest/common/table/Cell.java    |   35 -
 .../zest/library/rest/common/table/Column.java  |   32 -
 .../zest/library/rest/common/table/Problem.java |   32 -
 .../library/rest/common/table/QueryBuilder.java |   63 -
 .../zest/library/rest/common/table/Row.java     |   33 -
 .../zest/library/rest/common/table/Table.java   |   68 -
 .../library/rest/common/table/TableBuilder.java |  302 ---
 .../rest/common/table/TableBuilderFactory.java  |   98 -
 .../library/rest/common/table/TableQuery.java   |  238 ---
 .../rest/common/table/TableResponse.java        |   50 -
 .../zest/library/rest/common/table/package.html |   21 -
 .../java/org/qi4j/library/rest/common/Form.java |   33 +
 .../org/qi4j/library/rest/common/Resource.java  |   77 +
 .../library/rest/common/ValueAssembler.java     |   45 +
 .../org/qi4j/library/rest/common/link/Link.java |   68 +
 .../qi4j/library/rest/common/link/Links.java    |   33 +
 .../library/rest/common/link/LinksBuilder.java  |  131 ++
 .../library/rest/common/link/LinksUtil.java     |   99 +
 .../qi4j/library/rest/common/link/package.html  |   21 +
 .../org/qi4j/library/rest/common/package.html   |   21 +
 .../qi4j/library/rest/common/table/Cell.java    |   35 +
 .../qi4j/library/rest/common/table/Column.java  |   32 +
 .../qi4j/library/rest/common/table/Problem.java |   32 +
 .../library/rest/common/table/QueryBuilder.java |   63 +
 .../org/qi4j/library/rest/common/table/Row.java |   33 +
 .../qi4j/library/rest/common/table/Table.java   |   68 +
 .../library/rest/common/table/TableBuilder.java |  302 +++
 .../rest/common/table/TableBuilderFactory.java  |   98 +
 .../library/rest/common/table/TableQuery.java   |  238 +++
 .../rest/common/table/TableResponse.java        |   50 +
 .../qi4j/library/rest/common/table/package.html |   21 +
 .../rest/server/api/ContextResource.java        |  917 ---------
 .../library/rest/server/api/ContextRestlet.java |  308 ---
 .../api/InteractionConstraintsConcern.java      |   81 -
 .../rest/server/api/ObjectSelection.java        |   89 -
 .../library/rest/server/api/ResourceCreate.java |   26 -
 .../library/rest/server/api/ResourceDelete.java |   29 -
 .../library/rest/server/api/ResourceIndex.java  |   26 -
 .../library/rest/server/api/ResourceUpdate.java |   26 -
 .../rest/server/api/ResourceValidity.java       |  100 -
 .../library/rest/server/api/SubResource.java    |   34 -
 .../library/rest/server/api/SubResources.java   |   38 -
 .../api/constraint/InteractionConstraint.java   |   29 -
 .../InteractionConstraintDeclaration.java       |   30 -
 .../api/constraint/InteractionValidation.java   |   56 -
 .../rest/server/api/constraint/Requires.java    |   64 -
 .../server/api/constraint/RequiresValid.java    |   45 -
 .../server/api/constraint/ServiceAvailable.java |   50 -
 .../rest/server/api/constraint/package.html     |   21 -
 .../zest/library/rest/server/api/dci/Role.java  |   59 -
 .../library/rest/server/api/dci/package.html    |   21 -
 .../zest/library/rest/server/api/package.html   |   21 -
 .../server/assembler/RestServerAssembler.java   |  111 --
 .../library/rest/server/assembler/package.html  |   21 -
 .../restlet/ConstraintViolationMessages.java    |   84 -
 .../restlet/ExtensionMediaTypeFilter.java       |   85 -
 .../server/restlet/InteractionConstraints.java  |   33 -
 .../restlet/InteractionConstraintsService.java  |  359 ----
 .../rest/server/restlet/NullCommandResult.java  |   33 -
 .../server/restlet/RequestReaderDelegator.java  |  107 -
 .../server/restlet/ResponseWriterDelegator.java |   96 -
 .../freemarker/ValueCompositeObjectWrapper.java |   45 -
 .../freemarker/ValueCompositeTemplateModel.java |  125 --
 .../rest/server/restlet/freemarker/package.html |   21 -
 .../library/rest/server/restlet/package.html    |   21 -
 .../requestreader/DefaultRequestReader.java     |  499 -----
 .../server/restlet/requestreader/package.html   |   21 -
 .../responsewriter/AbstractResponseWriter.java  |   63 -
 .../responsewriter/DefaultResponseWriter.java   |   55 -
 .../responsewriter/FormResponseWriter.java      |  118 --
 .../responsewriter/JSONResponseWriter.java      |   61 -
 .../responsewriter/LinksResponseWriter.java     |  151 --
 .../responsewriter/ResourceResponseWriter.java  |  105 -
 .../ResourceTemplateResponseWriter.java         |  116 --
 .../responsewriter/TableResponseWriter.java     |  203 --
 .../ValueCompositeResponseWriter.java           |  117 --
 .../ValueDescriptorResponseWriter.java          |  119 --
 .../server/restlet/responsewriter/package.html  |   21 -
 .../library/rest/server/spi/CommandResult.java  |   27 -
 .../library/rest/server/spi/RequestReader.java  |   32 -
 .../library/rest/server/spi/ResponseWriter.java |   31 -
 .../rest/server/spi/ResultConverter.java        |   28 -
 .../zest/library/rest/server/spi/package.html   |   21 -
 .../rest/server/api/ContextResource.java        |  917 +++++++++
 .../library/rest/server/api/ContextRestlet.java |  308 +++
 .../api/InteractionConstraintsConcern.java      |   81 +
 .../rest/server/api/ObjectSelection.java        |   89 +
 .../library/rest/server/api/ResourceCreate.java |   26 +
 .../library/rest/server/api/ResourceDelete.java |   29 +
 .../library/rest/server/api/ResourceIndex.java  |   26 +
 .../library/rest/server/api/ResourceUpdate.java |   26 +
 .../rest/server/api/ResourceValidity.java       |  100 +
 .../library/rest/server/api/SubResource.java    |   34 +
 .../library/rest/server/api/SubResources.java   |   38 +
 .../api/constraint/InteractionConstraint.java   |   29 +
 .../InteractionConstraintDeclaration.java       |   30 +
 .../api/constraint/InteractionValidation.java   |   56 +
 .../rest/server/api/constraint/Requires.java    |   64 +
 .../server/api/constraint/RequiresValid.java    |   45 +
 .../server/api/constraint/ServiceAvailable.java |   50 +
 .../rest/server/api/constraint/package.html     |   21 +
 .../qi4j/library/rest/server/api/dci/Role.java  |   59 +
 .../library/rest/server/api/dci/package.html    |   21 +
 .../qi4j/library/rest/server/api/package.html   |   21 +
 .../server/assembler/RestServerAssembler.java   |  111 ++
 .../library/rest/server/assembler/package.html  |   21 +
 .../restlet/ConstraintViolationMessages.java    |   84 +
 .../restlet/ExtensionMediaTypeFilter.java       |   85 +
 .../server/restlet/InteractionConstraints.java  |   33 +
 .../restlet/InteractionConstraintsService.java  |  359 ++++
 .../rest/server/restlet/NullCommandResult.java  |   33 +
 .../server/restlet/RequestReaderDelegator.java  |  107 +
 .../server/restlet/ResponseWriterDelegator.java |   96 +
 .../freemarker/ValueCompositeObjectWrapper.java |   45 +
 .../freemarker/ValueCompositeTemplateModel.java |  125 ++
 .../rest/server/restlet/freemarker/package.html |   21 +
 .../library/rest/server/restlet/package.html    |   21 +
 .../requestreader/DefaultRequestReader.java     |  499 +++++
 .../server/restlet/requestreader/package.html   |   21 +
 .../responsewriter/AbstractResponseWriter.java  |   63 +
 .../responsewriter/DefaultResponseWriter.java   |   55 +
 .../responsewriter/FormResponseWriter.java      |  118 ++
 .../responsewriter/JSONResponseWriter.java      |   61 +
 .../responsewriter/LinksResponseWriter.java     |  151 ++
 .../responsewriter/ResourceResponseWriter.java  |  105 +
 .../ResourceTemplateResponseWriter.java         |  116 ++
 .../responsewriter/TableResponseWriter.java     |  203 ++
 .../ValueCompositeResponseWriter.java           |  117 ++
 .../ValueDescriptorResponseWriter.java          |  119 ++
 .../server/restlet/responsewriter/package.html  |   21 +
 .../library/rest/server/spi/CommandResult.java  |   27 +
 .../library/rest/server/spi/RequestReader.java  |   32 +
 .../library/rest/server/spi/ResponseWriter.java |   31 +
 .../rest/server/spi/ResultConverter.java        |   28 +
 .../qi4j/library/rest/server/spi/package.html   |   21 +
 .../library/rest/server/rest-server.properties  |   26 -
 .../rest/server/restlet/responsewriter/form.htm |   41 -
 .../server/restlet/responsewriter/links.atom    |   15 -
 .../server/restlet/responsewriter/links.htm     |   19 -
 .../server/restlet/responsewriter/resource.htm  |   57 -
 .../restlet/responsewriter/selectresource.htm   |   15 -
 .../server/restlet/responsewriter/table.htm     |   33 -
 .../server/restlet/responsewriter/value.htm     |   20 -
 .../library/rest/server/rest-server.properties  |   26 +
 .../rest/server/restlet/responsewriter/form.htm |   41 +
 .../server/restlet/responsewriter/links.atom    |   15 +
 .../server/restlet/responsewriter/links.htm     |   19 +
 .../server/restlet/responsewriter/resource.htm  |   57 +
 .../restlet/responsewriter/selectresource.htm   |   15 +
 .../server/restlet/responsewriter/table.htm     |   33 +
 .../server/restlet/responsewriter/value.htm     |   20 +
 .../rest/server/DocumentationSupport.java       |   37 -
 .../rest/server/DocumentationSupport.java       |   37 +
 .../library/rest/admin/EntitiesResource.java    |  239 ---
 .../zest/library/rest/admin/EntityResource.java |  534 -----
 .../rest/admin/ExceptionRepresentation.java     |   46 -
 .../rest/admin/ExtensionMediaTypeFilter.java    |   81 -
 .../zest/library/rest/admin/IndexResource.java  |  124 --
 .../zest/library/rest/admin/Qi4jFinder.java     |   38 -
 .../library/rest/admin/Qi4jServerServlet.java   |   38 -
 .../rest/admin/Qi4jServerServletService.java    |   28 -
 .../library/rest/admin/RestApplication.java     |  103 -
 .../zest/library/rest/admin/RestAssembler.java  |   34 -
 .../zest/library/rest/admin/RestServer.java     |   22 -
 .../library/rest/admin/RestServerComposite.java |   56 -
 .../library/rest/admin/RestServerMixin.java     |   50 -
 .../zest/library/rest/admin/SPARQLResource.java |  377 ----
 .../apache/zest/library/rest/admin/package.html |   21 -
 .../library/rest/admin/EntitiesResource.java    |  239 +++
 .../qi4j/library/rest/admin/EntityResource.java |  534 +++++
 .../rest/admin/ExceptionRepresentation.java     |   46 +
 .../rest/admin/ExtensionMediaTypeFilter.java    |   81 +
 .../qi4j/library/rest/admin/IndexResource.java  |  124 ++
 .../org/qi4j/library/rest/admin/Qi4jFinder.java |   38 +
 .../library/rest/admin/Qi4jServerServlet.java   |   38 +
 .../rest/admin/Qi4jServerServletService.java    |   28 +
 .../library/rest/admin/RestApplication.java     |  103 +
 .../qi4j/library/rest/admin/RestAssembler.java  |   34 +
 .../org/qi4j/library/rest/admin/RestServer.java |   22 +
 .../library/rest/admin/RestServerComposite.java |   56 +
 .../library/rest/admin/RestServerMixin.java     |   50 +
 .../qi4j/library/rest/admin/SPARQLResource.java |  377 ++++
 .../org/qi4j/library/rest/admin/package.html    |   21 +
 .../zest/library/rest/admin/sparqlform.html     |   79 -
 .../zest/library/rest/admin/sparqlhtml.xsl      |  188 --
 .../org/qi4j/library/rest/admin/sparqlform.html |   79 +
 .../org/qi4j/library/rest/admin/sparqlhtml.xsl  |  188 ++
 .../library/rest/admin/DomainAssembler.java     |   48 -
 .../library/rest/admin/DummyDataService.java    |  108 --
 .../apache/zest/library/rest/admin/Main.java    |   46 -
 .../zest/library/rest/admin/MainAssembler.java  |   70 -
 .../MemoryEntityStoreServiceAssembler.java      |   34 -
 .../apache/zest/library/rest/admin/Named.java   |   27 -
 .../zest/library/rest/admin/RDFAssembler.java   |   38 -
 .../zest/library/rest/admin/RestTest.java       |  324 ----
 .../rest/admin/RestletServletAssembler.java     |   36 -
 .../zest/library/rest/admin/TestEntity.java     |   49 -
 .../zest/library/rest/admin/TestEntity2.java    |   25 -
 .../zest/library/rest/admin/TestRole.java       |   27 -
 .../zest/library/rest/admin/TestValue.java      |   41 -
 .../zest/library/rest/admin/TestValue2.java     |   29 -
 .../library/rest/admin/DomainAssembler.java     |   48 +
 .../library/rest/admin/DummyDataService.java    |  108 ++
 .../java/org/qi4j/library/rest/admin/Main.java  |   46 +
 .../qi4j/library/rest/admin/MainAssembler.java  |   70 +
 .../MemoryEntityStoreServiceAssembler.java      |   34 +
 .../java/org/qi4j/library/rest/admin/Named.java |   27 +
 .../qi4j/library/rest/admin/RDFAssembler.java   |   38 +
 .../org/qi4j/library/rest/admin/RestTest.java   |  324 ++++
 .../rest/admin/RestletServletAssembler.java     |   37 +
 .../org/qi4j/library/rest/admin/TestEntity.java |   49 +
 .../qi4j/library/rest/admin/TestEntity2.java    |   25 +
 .../org/qi4j/library/rest/admin/TestRole.java   |   27 +
 .../org/qi4j/library/rest/admin/TestValue.java  |   41 +
 .../org/qi4j/library/rest/admin/TestValue2.java |   29 +
 .../zest/library/scheduler/Scheduler.java       |  118 --
 .../scheduler/SchedulerConfiguration.java       |   51 -
 .../zest/library/scheduler/SchedulerMixin.java  |  371 ----
 .../library/scheduler/SchedulerService.java     |   78 -
 .../org/apache/zest/library/scheduler/Task.java |   62 -
 .../scheduler/bootstrap/SchedulerAssembler.java |  105 -
 .../library/scheduler/bootstrap/package.html    |   21 -
 .../apache/zest/library/scheduler/package.html  |   21 -
 .../library/scheduler/schedule/Schedule.java    |   84 -
 .../scheduler/schedule/ScheduleFactory.java     |  128 --
 .../scheduler/schedule/ScheduleTime.java        |   81 -
 .../library/scheduler/schedule/Schedules.java   |   24 -
 .../scheduler/schedule/cron/CronExpression.java |   36 -
 .../schedule/cron/CronExpressionConstraint.java |   34 -
 .../scheduler/schedule/cron/CronSchedule.java   |   94 -
 .../scheduler/schedule/cron/package.html        |   21 -
 .../scheduler/schedule/once/OnceSchedule.java   |   73 -
 .../scheduler/schedule/once/package.html        |   21 -
 .../library/scheduler/schedule/package.html     |   21 -
 .../library/scheduler/timeline/Timeline.java    |   73 -
 .../timeline/TimelineForScheduleConcern.java    |   90 -
 .../scheduler/timeline/TimelineRecord.java      |   79 -
 .../scheduler/timeline/TimelineRecordStep.java  |   27 -
 .../timeline/TimelineScheduleMixin.java         |  136 --
 .../timeline/TimelineScheduleState.java         |   26 -
 .../timeline/TimelineSchedulerServiceMixin.java |  111 --
 .../library/scheduler/timeline/package.html     |   21 -
 .../org/qi4j/library/scheduler/Scheduler.java   |  118 ++
 .../scheduler/SchedulerConfiguration.java       |   51 +
 .../qi4j/library/scheduler/SchedulerMixin.java  |  371 ++++
 .../library/scheduler/SchedulerService.java     |   78 +
 .../java/org/qi4j/library/scheduler/Task.java   |   62 +
 .../scheduler/bootstrap/SchedulerAssembler.java |  105 +
 .../library/scheduler/bootstrap/package.html    |   21 +
 .../org/qi4j/library/scheduler/package.html     |   21 +
 .../library/scheduler/schedule/Schedule.java    |   84 +
 .../scheduler/schedule/ScheduleFactory.java     |  128 ++
 .../scheduler/schedule/ScheduleTime.java        |   81 +
 .../library/scheduler/schedule/Schedules.java   |   24 +
 .../scheduler/schedule/cron/CronExpression.java |   36 +
 .../schedule/cron/CronExpressionConstraint.java |   34 +
 .../scheduler/schedule/cron/CronSchedule.java   |   94 +
 .../scheduler/schedule/cron/package.html        |   21 +
 .../scheduler/schedule/once/OnceSchedule.java   |   73 +
 .../scheduler/schedule/once/package.html        |   21 +
 .../library/scheduler/schedule/package.html     |   21 +
 .../library/scheduler/timeline/Timeline.java    |   73 +
 .../timeline/TimelineForScheduleConcern.java    |   90 +
 .../scheduler/timeline/TimelineRecord.java      |   79 +
 .../scheduler/timeline/TimelineRecordStep.java  |   27 +
 .../timeline/TimelineScheduleMixin.java         |  136 ++
 .../timeline/TimelineScheduleState.java         |   26 +
 .../timeline/TimelineSchedulerServiceMixin.java |  111 ++
 .../library/scheduler/timeline/package.html     |   21 +
 .../scheduler/AbstractSchedulerTest.java        |   54 -
 .../zest/library/scheduler/Constants.java       |   26 -
 .../apache/zest/library/scheduler/FooTask.java  |   64 -
 .../zest/library/scheduler/SchedulerTest.java   |  173 --
 .../scheduler/docsupport/SchedulerDocs.java     |   78 -
 .../scheduler/AbstractSchedulerTest.java        |   54 +
 .../org/qi4j/library/scheduler/Constants.java   |   26 +
 .../org/qi4j/library/scheduler/FooTask.java     |   64 +
 .../qi4j/library/scheduler/SchedulerTest.java   |  173 ++
 .../scheduler/docsupport/SchedulerDocs.java     |   78 +
 .../src/test/resources/logback-test.xml         |    2 +-
 .../zest/library/scripting/ScriptException.java |   26 -
 .../library/scripting/ScriptReloadable.java     |   23 -
 .../zest/library/scripting/ScriptUtil.java      |   24 -
 .../zest/library/scripting/ScriptUtilImpl.java  |   27 -
 .../apache/zest/library/scripting/package.html  |   21 -
 .../qi4j/library/scripting/ScriptException.java |   26 +
 .../library/scripting/ScriptReloadable.java     |   23 +
 .../org/qi4j/library/scripting/ScriptUtil.java  |   24 +
 .../qi4j/library/scripting/ScriptUtilImpl.java  |   27 +
 .../org/qi4j/library/scripting/package.html     |   21 +
 .../library/scripting/ScriptUtilImplTest.java   |   40 -
 .../library/scripting/ScriptUtilImplTest.java   |   40 +
 .../apache/zest/library/servlet/Qi4jFilter.java |   45 -
 .../zest/library/servlet/Qi4jServlet.java       |   51 -
 .../library/servlet/Qi4jServletSupport.java     |   38 -
 .../lifecycle/AbstractQi4jServletBootstrap.java |  137 --
 .../zest/library/servlet/lifecycle/package.html |   21 -
 .../apache/zest/library/servlet/package.html    |   47 -
 .../org/qi4j/library/servlet/Qi4jFilter.java    |   45 +
 .../org/qi4j/library/servlet/Qi4jServlet.java   |   51 +
 .../library/servlet/Qi4jServletSupport.java     |   38 +
 .../lifecycle/AbstractQi4jServletBootstrap.java |  137 ++
 .../qi4j/library/servlet/lifecycle/package.html |   21 +
 .../java/org/qi4j/library/servlet/package.html  |   47 +
 .../zest/library/servlet/ServletTest.java       |  106 -
 .../org/qi4j/library/servlet/ServletTest.java   |  106 +
 .../org/apache/zest/library/shiro/Shiro.java    |   23 -
 .../shiro/assembly/PasswordDomainAssembler.java |   45 -
 .../assembly/PermissionsDomainAssembler.java    |   36 -
 .../assembly/StandaloneShiroAssembler.java      |   43 -
 .../zest/library/shiro/assembly/package.html    |   21 -
 .../shiro/concerns/RequiresAuthentication.java  |   29 -
 .../library/shiro/concerns/RequiresGuest.java   |   29 -
 .../shiro/concerns/RequiresPermissions.java     |   36 -
 .../library/shiro/concerns/RequiresRoles.java   |   36 -
 .../library/shiro/concerns/RequiresUser.java    |   29 -
 .../library/shiro/concerns/SecurityConcern.java |  178 --
 .../zest/library/shiro/concerns/package.html    |   21 -
 .../domain/common/IdentifiableSubject.java      |   23 -
 .../library/shiro/domain/common/package.html    |   21 -
 .../passwords/PasswordRealmConfiguration.java   |   38 -
 .../domain/passwords/PasswordRealmMixin.java    |  170 --
 .../domain/passwords/PasswordRealmService.java  |   28 -
 .../domain/passwords/PasswordSecurable.java     |   28 -
 .../library/shiro/domain/passwords/package.html |   21 -
 .../library/shiro/domain/permissions/Role.java  |   64 -
 .../shiro/domain/permissions/RoleAssignee.java  |   69 -
 .../domain/permissions/RoleAssignment.java      |   27 -
 .../shiro/domain/permissions/RoleFactory.java   |   65 -
 .../shiro/domain/permissions/package.html       |   21 -
 .../shiro/ini/IniSecurityManagerService.java    |  105 -
 .../shiro/ini/ShiroIniConfiguration.java        |   34 -
 .../apache/zest/library/shiro/ini/package.html  |   21 -
 .../org/apache/zest/library/shiro/package.html  |   31 -
 .../main/java/org/qi4j/library/shiro/Shiro.java |   23 +
 .../shiro/assembly/PasswordDomainAssembler.java |   45 +
 .../assembly/PermissionsDomainAssembler.java    |   36 +
 .../assembly/StandaloneShiroAssembler.java      |   43 +
 .../qi4j/library/shiro/assembly/package.html    |   21 +
 .../shiro/concerns/RequiresAuthentication.java  |   29 +
 .../library/shiro/concerns/RequiresGuest.java   |   29 +
 .../shiro/concerns/RequiresPermissions.java     |   36 +
 .../library/shiro/concerns/RequiresRoles.java   |   36 +
 .../library/shiro/concerns/RequiresUser.java    |   29 +
 .../library/shiro/concerns/SecurityConcern.java |  178 ++
 .../qi4j/library/shiro/concerns/package.html    |   21 +
 .../domain/common/IdentifiableSubject.java      |   23 +
 .../library/shiro/domain/common/package.html    |   21 +
 .../passwords/PasswordRealmConfiguration.java   |   38 +
 .../domain/passwords/PasswordRealmMixin.java    |  170 ++
 .../domain/passwords/PasswordRealmService.java  |   28 +
 .../domain/passwords/PasswordSecurable.java     |   28 +
 .../library/shiro/domain/passwords/package.html |   21 +
 .../library/shiro/domain/permissions/Role.java  |   64 +
 .../shiro/domain/permissions/RoleAssignee.java  |   69 +
 .../domain/permissions/RoleAssignment.java      |   27 +
 .../shiro/domain/permissions/RoleFactory.java   |   65 +
 .../shiro/domain/permissions/package.html       |   21 +
 .../shiro/ini/IniSecurityManagerService.java    |  105 +
 .../shiro/ini/ShiroIniConfiguration.java        |   34 +
 .../org/qi4j/library/shiro/ini/package.html     |   21 +
 .../java/org/qi4j/library/shiro/package.html    |   31 +
 .../zest/library/shiro/PasswordDomainTest.java  |  142 --
 .../library/shiro/PermissionsDomainTest.java    |  168 --
 .../zest/library/shiro/RealmServiceTest.java    |  113 --
 .../zest/library/shiro/StandaloneShiroTest.java |  165 --
 .../qi4j/library/shiro/PasswordDomainTest.java  |  142 ++
 .../library/shiro/PermissionsDomainTest.java    |  168 ++
 .../qi4j/library/shiro/RealmServiceTest.java    |  113 ++
 .../qi4j/library/shiro/StandaloneShiroTest.java |  165 ++
 .../src/test/resources/logback-test.xml         |    2 +-
 .../shiro/web/EnvironmentLoaderService.java     |   88 -
 .../library/shiro/web/ShiroFilterService.java   |   25 -
 .../shiro/web/assembly/HttpShiroAssembler.java  |   55 -
 .../library/shiro/web/assembly/package.html     |   21 -
 .../apache/zest/library/shiro/web/package.html  |   31 -
 .../shiro/web/EnvironmentLoaderService.java     |   88 +
 .../library/shiro/web/ShiroFilterService.java   |   25 +
 .../shiro/web/assembly/HttpShiroAssembler.java  |   55 +
 .../library/shiro/web/assembly/package.html     |   21 +
 .../org/qi4j/library/shiro/web/package.html     |   31 +
 .../library/shiro/web/WebHttpShiroTest.java     |   71 -
 .../library/shiro/web/WebRealmServiceTest.java  |  229 ---
 .../library/shiro/web/WebServletShiroTest.java  |   57 -
 .../library/shiro/web/WebHttpShiroTest.java     |   71 +
 .../library/shiro/web/WebRealmServiceTest.java  |  229 +++
 .../library/shiro/web/WebServletShiroTest.java  |   57 +
 .../src/test/resources/logback-test.xml         |    2 +-
 .../library/spring/bootstrap/Constants.java     |   26 -
 .../bootstrap/Qi4jApplicationBootstrap.java     |   85 -
 .../internal/Qi4jNamespaceHandler.java          |   31 -
 .../application/Qi4jApplicationFactoryBean.java |  116 --
 .../Qi4jBootstrapBeanDefinitionParser.java      |   99 -
 .../bootstrap/internal/application/package.html |   21 -
 .../spring/bootstrap/internal/package.html      |   21 -
 .../Qi4jServiceBeanDefinitionParser.java        |   52 -
 .../internal/service/ServiceFactoryBean.java    |   65 -
 .../internal/service/ServiceLocator.java        |  129 --
 .../bootstrap/internal/service/package.html     |   21 -
 .../zest/library/spring/bootstrap/package.html  |   21 -
 .../library/spring/importer/SpringImporter.java |   57 -
 .../importer/SpringImporterAssembler.java       |   73 -
 .../zest/library/spring/importer/package.html   |   21 -
 .../org/apache/zest/library/spring/package.html |   21 -
 .../library/spring/bootstrap/Constants.java     |   26 +
 .../bootstrap/Qi4jApplicationBootstrap.java     |   85 +
 .../internal/Qi4jNamespaceHandler.java          |   31 +
 .../application/Qi4jApplicationFactoryBean.java |  116 ++
 .../Qi4jBootstrapBeanDefinitionParser.java      |   99 +
 .../bootstrap/internal/application/package.html |   21 +
 .../spring/bootstrap/internal/package.html      |   21 +
 .../Qi4jServiceBeanDefinitionParser.java        |   52 +
 .../internal/service/ServiceFactoryBean.java    |   65 +
 .../internal/service/ServiceLocator.java        |  129 ++
 .../bootstrap/internal/service/package.html     |   21 +
 .../qi4j/library/spring/bootstrap/package.html  |   21 +
 .../library/spring/importer/SpringImporter.java |   57 +
 .../importer/SpringImporterAssembler.java       |   73 +
 .../qi4j/library/spring/importer/package.html   |   21 +
 .../java/org/qi4j/library/spring/package.html   |   21 +
 .../src/main/resources/META-INF/spring.handlers |    2 +-
 .../apache/zest/library/spring/spring-0.5.xsd   |   61 -
 .../org/qi4j/library/spring/spring-0.5.xsd      |   61 +
 .../zest/library/spring/MyZestBootstrapper.java |   49 -
 .../spring/bootstrap/CommentService.java        |   22 -
 .../bootstrap/CommentServiceComposite.java      |   50 -
 .../spring/bootstrap/CommentServiceHolder.java  |   32 -
 .../spring/bootstrap/Qi4jExportServiceTest.java |   56 -
 .../spring/bootstrap/Qi4jTestBootstrap.java     |   55 -
 .../spring/bootstrap/TextProcessingService.java |   24 -
 .../spring/bootstrap/ToUppercaseService.java    |   30 -
 .../library/spring/importer/CommentService.java |   22 -
 .../spring/importer/CommentServiceBean.java     |   33 -
 .../spring/importer/CommentServiceBean2.java    |   33 -
 .../spring/importer/Qi4jImportServiceTest.java  |  111 --
 .../qi4j/library/spring/MyZestBootstrapper.java |   49 +
 .../spring/bootstrap/CommentService.java        |   22 +
 .../bootstrap/CommentServiceComposite.java      |   50 +
 .../spring/bootstrap/CommentServiceHolder.java  |   32 +
 .../spring/bootstrap/Qi4jExportServiceTest.java |   56 +
 .../spring/bootstrap/Qi4jTestBootstrap.java     |   55 +
 .../spring/bootstrap/TextProcessingService.java |   24 +
 .../spring/bootstrap/ToUppercaseService.java    |   30 +
 .../library/spring/importer/CommentService.java |   22 +
 .../spring/importer/CommentServiceBean.java     |   33 +
 .../spring/importer/CommentServiceBean2.java    |   33 +
 .../spring/importer/Qi4jImportServiceTest.java  |  111 ++
 .../bootstrap/Qi4jExportServiceTest-context.xml |   33 -
 .../importer/Qi4jImportServiceTest-context.xml  |   25 -
 .../bootstrap/Qi4jExportServiceTest-context.xml |   33 +
 .../importer/Qi4jImportServiceTest-context.xml  |   25 +
 .../BoneCPDataSourceServiceAssembler.java       |   33 -
 .../bonecp/BoneCPDataSourceServiceImporter.java |   93 -
 .../apache/zest/library/sql/bonecp/package.html |   21 -
 .../BoneCPDataSourceServiceAssembler.java       |   33 +
 .../bonecp/BoneCPDataSourceServiceImporter.java |   93 +
 .../org/qi4j/library/sql/bonecp/package.html    |   21 +
 .../dbcp/DBCPDataSourceServiceAssembler.java    |   33 -
 .../sql/dbcp/DBCPDataSourceServiceImporter.java |   79 -
 .../apache/zest/library/sql/dbcp/package.html   |   21 -
 .../dbcp/DBCPDataSourceServiceAssembler.java    |   33 +
 .../sql/dbcp/DBCPDataSourceServiceImporter.java |   79 +
 .../java/org/qi4j/library/sql/dbcp/package.html |   21 +
 .../sql/liquibase/LiquibaseAssembler.java       |   45 -
 .../sql/liquibase/LiquibaseConfiguration.java   |   32 -
 .../library/sql/liquibase/LiquibaseService.java |  121 --
 .../zest/library/sql/liquibase/package.html     |   21 -
 .../sql/liquibase/LiquibaseAssembler.java       |   45 +
 .../sql/liquibase/LiquibaseConfiguration.java   |   32 +
 .../library/sql/liquibase/LiquibaseService.java |  121 ++
 .../org/qi4j/library/sql/liquibase/package.html |   21 +
 .../sql/liquibase/LiquibaseServiceTest.java     |  172 --
 .../sql/liquibase/LiquibaseServiceTest.java     |  172 ++
 ...bstractPooledDataSourceServiceAssembler.java |   47 -
 .../sql/assembly/DataSourceAssembler.java       |   81 -
 .../sql/assembly/DataSourceJMXAssembler.java    |   34 -
 .../assembly/ExternalDataSourceAssembler.java   |   74 -
 .../zest/library/sql/assembly/package.html      |   21 -
 .../zest/library/sql/common/Databases.java      |  243 ---
 .../library/sql/common/SQLConfiguration.java    |   35 -
 .../apache/zest/library/sql/common/SQLUtil.java |   68 -
 .../apache/zest/library/sql/common/package.html |   21 -
 .../AbstractDataSourceServiceImporterMixin.java |  192 --
 .../sql/datasource/DataSourceConfiguration.java |   25 -
 .../DataSourceConfigurationState.java           |   39 -
 .../DataSourceConfigurationValue.java           |   24 -
 .../DataSourceServiceImporterActivation.java    |   38 -
 .../library/sql/datasource/DataSources.java     |   90 -
 .../zest/library/sql/datasource/package.html    |   21 -
 .../DataSourceConfigurationManagerService.java  |  305 ---
 .../apache/zest/library/sql/jmx/package.html    |   21 -
 ...bstractPooledDataSourceServiceAssembler.java |   47 +
 .../sql/assembly/DataSourceAssembler.java       |   81 +
 .../sql/assembly/DataSourceJMXAssembler.java    |   34 +
 .../assembly/ExternalDataSourceAssembler.java   |   74 +
 .../org/qi4j/library/sql/assembly/package.html  |   21 +
 .../org/qi4j/library/sql/common/Databases.java  |  243 +++
 .../library/sql/common/SQLConfiguration.java    |   35 +
 .../org/qi4j/library/sql/common/SQLUtil.java    |   68 +
 .../org/qi4j/library/sql/common/package.html    |   21 +
 .../AbstractDataSourceServiceImporterMixin.java |  192 ++
 .../sql/datasource/DataSourceConfiguration.java |   25 +
 .../DataSourceConfigurationState.java           |   39 +
 .../DataSourceConfigurationValue.java           |   24 +
 .../DataSourceServiceImporterActivation.java    |   38 +
 .../library/sql/datasource/DataSources.java     |   90 +
 .../qi4j/library/sql/datasource/package.html    |   21 +
 .../DataSourceConfigurationManagerService.java  |  305 +++
 .../java/org/qi4j/library/sql/jmx/package.html  |   21 +
 .../zest/library/sql/DocumentationSupport.java  |  116 --
 .../sql/datasource/ExternalDataSourceTest.java  |   61 -
 ...taSourceConfigurationManagerServiceTest.java |  205 --
 .../qi4j/library/sql/DocumentationSupport.java  |  116 ++
 .../sql/datasource/ExternalDataSourceTest.java  |   61 +
 ...taSourceConfigurationManagerServiceTest.java |  205 ++
 .../uid/sequence/PersistedSequencingMixin.java  |   79 -
 .../sequence/PersistingSequencingService.java   |   26 -
 .../zest/library/uid/sequence/Sequence.java     |   31 -
 .../library/uid/sequence/SequenceEntity.java    |   24 -
 .../zest/library/uid/sequence/Sequencing.java   |   33 -
 .../uid/sequence/SequencingException.java       |   35 -
 .../uid/sequence/TransientSequencingMixin.java  |   43 -
 .../sequence/TransientSequencingService.java    |   26 -
 .../assembly/PersistingSequencingAssembler.java |   37 -
 .../assembly/TransientSequencingAssembler.java  |   34 -
 .../library/uid/sequence/assembly/package.html  |   21 -
 .../zest/library/uid/sequence/package.html      |   21 -
 .../library/uid/uuid/UuidGenerationMixin.java   |   67 -
 .../zest/library/uid/uuid/UuidService.java      |   23 -
 .../library/uid/uuid/UuidServiceComposite.java  |   26 -
 .../uid/uuid/assembly/UuidServiceAssembler.java |   34 -
 .../zest/library/uid/uuid/assembly/package.html |   21 -
 .../apache/zest/library/uid/uuid/package.html   |   21 -
 .../uid/sequence/PersistedSequencingMixin.java  |   79 +
 .../sequence/PersistingSequencingService.java   |   26 +
 .../org/qi4j/library/uid/sequence/Sequence.java |   31 +
 .../library/uid/sequence/SequenceEntity.java    |   24 +
 .../qi4j/library/uid/sequence/Sequencing.java   |   33 +
 .../uid/sequence/SequencingException.java       |   35 +
 .../uid/sequence/TransientSequencingMixin.java  |   43 +
 .../sequence/TransientSequencingService.java    |   26 +
 .../assembly/PersistingSequencingAssembler.java |   37 +
 .../assembly/TransientSequencingAssembler.java  |   34 +
 .../library/uid/sequence/assembly/package.html  |   21 +
 .../org/qi4j/library/uid/sequence/package.html  |   21 +
 .../library/uid/uuid/UuidGenerationMixin.java   |   67 +
 .../org/qi4j/library/uid/uuid/UuidService.java  |   23 +
 .../library/uid/uuid/UuidServiceComposite.java  |   26 +
 .../uid/uuid/assembly/UuidServiceAssembler.java |   34 +
 .../qi4j/library/uid/uuid/assembly/package.html |   21 +
 .../java/org/qi4j/library/uid/uuid/package.html |   21 +
 .../zest/library/uid/DocumentationSupport.java  |  102 -
 .../uid/sequence/PersistingSequencingTest.java  |  100 -
 .../uid/sequence/TransientSequencingTest.java   |   98 -
 .../zest/library/uid/uuid/UuidServiceTest.java  |   99 -
 .../qi4j/library/uid/DocumentationSupport.java  |  102 +
 .../uid/sequence/PersistingSequencingTest.java  |  100 +
 .../uid/sequence/TransientSequencingTest.java   |   98 +
 .../qi4j/library/uid/uuid/UuidServiceTest.java  |   99 +
 .../uowfile/bootstrap/UoWFileAssembler.java     |   46 -
 .../zest/library/uowfile/bootstrap/package.html |   21 -
 .../ConcurrentUoWFileModificationException.java |   45 -
 ...urrentUoWFileStateModificationException.java |   40 -
 .../zest/library/uowfile/internal/UoWFile.java  |  167 --
 .../uowfile/internal/UoWFileException.java      |   34 -
 .../uowfile/internal/UoWFileFactory.java        |  185 --
 .../zest/library/uowfile/internal/package.html  |   21 -
 .../library/uowfile/plural/HasUoWFiles.java     |   88 -
 .../uowfile/plural/HasUoWFilesLifecycle.java    |   68 -
 .../library/uowfile/plural/UoWFilesLocator.java |   27 -
 .../zest/library/uowfile/plural/package.html    |   21 -
 .../library/uowfile/singular/HasUoWFile.java    |   64 -
 .../uowfile/singular/HasUoWFileLifecycle.java   |   56 -
 .../uowfile/singular/UoWFileLocator.java        |   25 -
 .../zest/library/uowfile/singular/package.html  |   21 -
 .../uowfile/bootstrap/UoWFileAssembler.java     |   46 +
 .../qi4j/library/uowfile/bootstrap/package.html |   21 +
 .../ConcurrentUoWFileModificationException.java |   45 +
 ...urrentUoWFileStateModificationException.java |   40 +
 .../qi4j/library/uowfile/internal/UoWFile.java  |  167 ++
 .../uowfile/internal/UoWFileException.java      |   34 +
 .../uowfile/internal/UoWFileFactory.java        |  185 ++
 .../qi4j/library/uowfile/internal/package.html  |   21 +
 .../library/uowfile/plural/HasUoWFiles.java     |   88 +
 .../uowfile/plural/HasUoWFilesLifecycle.java    |   68 +
 .../library/uowfile/plural/UoWFilesLocator.java |   27 +
 .../qi4j/library/uowfile/plural/package.html    |   21 +
 .../library/uowfile/singular/HasUoWFile.java    |   64 +
 .../uowfile/singular/HasUoWFileLifecycle.java   |   56 +
 .../uowfile/singular/UoWFileLocator.java        |   25 +
 .../qi4j/library/uowfile/singular/package.html  |   21 +
 .../library/uowfile/AbstractUoWFileTest.java    |   90 -
 .../zest/library/uowfile/HasUoWFileTest.java    |  392 ----
 .../zest/library/uowfile/HasUoWFilesTest.java   |  407 ----
 .../library/uowfile/AbstractUoWFileTest.java    |   90 +
 .../qi4j/library/uowfile/HasUoWFileTest.java    |  392 ++++
 .../qi4j/library/uowfile/HasUoWFilesTest.java   |  407 ++++
 .../apache/zest/library/uowfile/creation.txt    |    1 -
 .../zest/library/uowfile/modification.txt       |    1 -
 .../org/qi4j/library/uowfile/creation.txt       |    1 +
 .../org/qi4j/library/uowfile/modification.txt   |    1 +
 .../zest/manual/recipes/assemble/Docs.java      |   54 -
 .../zest/manual/recipes/assemble/Main.java      |  173 --
 .../manual/recipes/concern/AnyMixinType.java    |   38 -
 .../recipes/concern/InventoryConcern.java       |   33 -
 .../zest/manual/recipes/concern/LineItem.java   |   24 -
 .../manual/recipes/concern/MyAnnotation.java    |   23 -
 .../recipes/concern/MyAppliesToFilter.java      |   40 -
 .../recipes/concern/MyGenericConcern.java       |   42 -
 .../zest/manual/recipes/concern/Order.java      |   33 -
 .../recipes/contextualFragments/TraceAll.java   |   41 -
 .../manual/recipes/createConstraint/Dialer.java |   27 -
 .../createConstraint/DialerComposite.java       |   29 -
 .../createConstraint/HasPhoneNumber.java        |   29 -
 .../ParameterViolationConcern.java              |   58 -
 .../recipes/createConstraint/PhoneNumber.java   |   35 -
 .../createConstraint/PhoneNumberConstraint.java |   33 -
 .../PhoneNumberParameterViolationConcern.java   |   59 -
 .../manual/recipes/createEntity/Accident.java   |   32 -
 .../recipes/createEntity/AccidentValue.java     |   27 -
 .../zest/manual/recipes/createEntity/Car.java   |   38 -
 .../manual/recipes/createEntity/CarEntity.java  |   27 -
 .../recipes/createEntity/CarEntityFactory.java  |   27 -
 .../createEntity/CarEntityFactoryMixin.java     |   56 -
 .../createEntity/CarEntityFactoryService.java   |   29 -
 .../zest/manual/recipes/createEntity/Main.java  |   44 -
 .../recipes/createEntity/Manufacturer.java      |   34 -
 .../createEntity/ManufacturerEntity.java        |   27 -
 .../createEntity/ManufacturerRepository.java    |   28 -
 .../ManufacturerRepositoryMixin.java            |   61 -
 .../ManufacturerRepositoryService.java          |   29 -
 .../recipes/createEntity/MyAssembler.java       |   45 -
 .../org/apache/zest/manual/recipes/io/Docs.java |   38 -
 .../zest/manual/recipes/properties/Book.java    |   33 -
 .../manual/recipes/properties/BookFactory.java  |   45 -
 .../manual/recipes/properties/SwingInfo.java    |   32 -
 .../manual/recipes/properties/SwingPanel.java   |   48 -
 .../manual/recipes/properties/pojo/Book.java    |   27 -
 .../recipes/properties/pojo/MutableBook.java    |   28 -
 .../recipes/sideeffects/AnyMixinType.java       |   38 -
 .../manual/recipes/sideeffects/Confirmable.java |   23 -
 .../manual/recipes/sideeffects/HasCustomer.java |   23 -
 .../recipes/sideeffects/HasLineItems.java       |   23 -
 .../recipes/sideeffects/HasSequenceNumber.java  |   23 -
 .../sideeffects/MailNotifySideEffect.java       |   26 -
 .../recipes/sideeffects/MyAnnotation.java       |   23 -
 .../recipes/sideeffects/MyAppliesToFilter.java  |   40 -
 .../sideeffects/MyGenericSideEffect.java        |   51 -
 .../zest/manual/recipes/sideeffects/Order.java  |   23 -
 .../manual/recipes/sideeffects/OrderEntity.java |   31 -
 .../manual/travel/ExpediaService.properties     |   25 -
 .../org/apache/zest/manual/travel/Main.java     |   62 -
 .../zest/manual/travel/OrbitzService.properties |   25 -
 .../apache/zest/manual/travel/TravelPlan.java   |   26 -
 .../manual/travel/TravelPlanConfiguration.java  |   36 -
 .../zest/manual/travel/TravelPlanMixin.java     |   51 -
 .../zest/manual/travel/TravelPlanService.java   |   31 -
 .../manual/travel/TravelPlanService.properties  |   26 -
 .../org/qi4j/manual/recipes/assemble/Docs.java  |   54 +
 .../org/qi4j/manual/recipes/assemble/Main.java  |  173 ++
 .../manual/recipes/concern/AnyMixinType.java    |   38 +
 .../recipes/concern/InventoryConcern.java       |   33 +
 .../qi4j/manual/recipes/concern/LineItem.java   |   24 +
 .../manual/recipes/concern/MyAnnotation.java    |   23 +
 .../recipes/concern/MyAppliesToFilter.java      |   40 +
 .../recipes/concern/MyGenericConcern.java       |   42 +
 .../org/qi4j/manual/recipes/concern/Order.java  |   33 +
 .../recipes/contextualFragments/TraceAll.java   |   41 +
 .../manual/recipes/createConstraint/Dialer.java |   27 +
 .../createConstraint/DialerComposite.java       |   29 +
 .../createConstraint/HasPhoneNumber.java        |   29 +
 .../ParameterViolationConcern.java              |   58 +
 .../recipes/createConstraint/PhoneNumber.java   |   35 +
 .../createConstraint/PhoneNumberConstraint.java |   33 +
 .../PhoneNumberParameterViolationConcern.java   |   59 +
 .../manual/recipes/createEntity/Accident.java   |   32 +
 .../recipes/createEntity/AccidentValue.java     |   27 +
 .../qi4j/manual/recipes/createEntity/Car.java   |   38 +
 .../manual/recipes/createEntity/CarEntity.java  |   27 +
 .../recipes/createEntity/CarEntityFactory.java  |   27 +
 .../createEntity/CarEntityFactoryMixin.java     |   56 +
 .../createEntity/CarEntityFactoryService.java   |   29 +
 .../qi4j/manual/recipes/createEntity/Main.java  |   44 +
 .../recipes/createEntity/Manufacturer.java      |   34 +
 .../createEntity/ManufacturerEntity.java        |   27 +
 .../createEntity/ManufacturerRepository.java    |   28 +
 .../ManufacturerRepositoryMixin.java            |   63 +
 .../ManufacturerRepositoryService.java          |   29 +
 .../recipes/createEntity/MyAssembler.java       |   45 +
 .../java/org/qi4j/manual/recipes/io/Docs.java   |   38 +
 .../qi4j/manual/recipes/properties/Book.java    |   33 +
 .../manual/recipes/properties/BookFactory.java  |   45 +
 .../manual/recipes/properties/SwingInfo.java    |   32 +
 .../manual/recipes/properties/SwingPanel.java   |   48 +
 .../manual/recipes/properties/pojo/Book.java    |   27 +
 .../recipes/properties/pojo/MutableBook.java    |   28 +
 .../recipes/sideeffects/AnyMixinType.java       |   38 +
 .../manual/recipes/sideeffects/Confirmable.java |   23 +
 .../manual/recipes/sideeffects/HasCustomer.java |   23 +
 .../recipes/sideeffects/HasLineItems.java       |   23 +
 .../recipes/sideeffects/HasSequenceNumber.java  |   23 +
 .../sideeffects/MailNotifySideEffect.java       |   26 +
 .../recipes/sideeffects/MyAnnotation.java       |   23 +
 .../recipes/sideeffects/MyAppliesToFilter.java  |   40 +
 .../sideeffects/MyGenericSideEffect.java        |   51 +
 .../qi4j/manual/recipes/sideeffects/Order.java  |   23 +
 .../manual/recipes/sideeffects/OrderEntity.java |   31 +
 .../manual/travel/ExpediaService.properties     |   25 +
 .../main/java/org/qi4j/manual/travel/Main.java  |   62 +
 .../qi4j/manual/travel/OrbitzService.properties |   25 +
 .../java/org/qi4j/manual/travel/TravelPlan.java |   26 +
 .../manual/travel/TravelPlanConfiguration.java  |   36 +
 .../org/qi4j/manual/travel/TravelPlanMixin.java |   51 +
 .../qi4j/manual/travel/TravelPlanService.java   |   31 +
 .../manual/travel/TravelPlanService.properties  |   26 +
 .../pathfinder_a/api/GraphTraversalService.java |   41 -
 .../dcicargo/pathfinder_a/api/TransitEdge.java  |   83 -
 .../dcicargo/pathfinder_a/api/TransitPath.java  |   49 -
 .../dcicargo/pathfinder_a/api/package.html      |   23 -
 .../pathfinder_a/internal/GraphDAO.java         |   58 -
 .../internal/GraphTraversalServiceImpl.java     |  108 --
 .../dcicargo/pathfinder_a/internal/package.html |   23 -
 .../sample/dcicargo/pathfinder_a/package.html   |   31 -
 .../bootstrap/DCISampleApplication_a.java       |   81 -
 .../VisualizeApplicationStructure.java          |   57 -
 .../sample_a/bootstrap/assembly/Assembler.java  |  293 ---
 .../sample_a/bootstrap/sampledata/BaseData.java |  121 --
 .../bootstrap/sampledata/BaseDataService.java   |  180 --
 .../bootstrap/sampledata/SampleDataService.java |  321 ---
 .../communication/query/BookingQueries.java     |   73 -
 .../communication/query/CommonQueries.java      |   75 -
 .../communication/query/HandlingQueries.java    |   75 -
 .../communication/query/TrackingQueries.java    |   76 -
 .../communication/query/dto/CargoDTO.java       |   51 -
 .../query/dto/HandlingEventDTO.java             |   49 -
 .../communication/query/dto/LocationDTO.java    |   31 -
 .../communication/query/dto/VoyageDTO.java      |   31 -
 .../sample_a/communication/web/BasePage.java    |   75 -
 .../web/booking/BookNewCargoPage.java           |  152 --
 .../web/booking/BookingBasePage.java            |   37 -
 .../web/booking/CargoDetailsPage.java           |  175 --
 .../web/booking/CargoListPage.java              |   94 -
 .../web/booking/ChangeDestinationPage.java      |  106 -
 .../web/booking/RouteCargoPage.java             |   67 -
 .../communication/web/booking/RoutePanel.java   |  114 --
 .../web/handling/RegisterHandlingEventPage.java |  145 --
 .../web/tracking/HandlingHistoryPanel.java      |   84 -
 .../web/tracking/NextHandlingEventPanel.java    |   99 -
 .../web/tracking/TrackCargoPage.java            |  198 --
 .../sample_a/context/rolemap/CargoRoleMap.java  |   30 -
 .../sample_a/context/rolemap/CargosRoleMap.java |   30 -
 .../context/rolemap/HandlingEventRoleMap.java   |   32 -
 .../context/rolemap/HandlingEventsRoleMap.java  |   30 -
 .../context/rolemap/ItineraryRoleMap.java       |   34 -
 .../rolemap/RouteSpecificationRoleMap.java      |   34 -
 .../context/shipping/booking/BookNewCargo.java  |  256 ---
 .../shipping/booking/BuildDeliverySnapshot.java |  558 ------
 .../shipping/booking/RouteException.java        |   27 -
 .../context/shipping/handling/InspectCargo.java |  106 -
 .../handling/RegisterHandlingEvent.java         |  268 ---
 .../context/support/ApplicationEvents.java      |  152 --
 .../context/support/FoundNoRoutesException.java |   58 -
 .../RegisterHandlingEventAttemptDTO.java        |   49 -
 .../context/support/RoutingService.java         |  154 --
 .../sample_a/data/entity/CargoEntity.java       |   31 -
 .../sample_a/data/entity/CargosEntity.java      |   30 -
 .../data/entity/HandlingEventEntity.java        |   31 -
 .../data/entity/HandlingEventsEntity.java       |   32 -
 .../sample_a/data/entity/LocationEntity.java    |   34 -
 .../sample_a/data/entity/VoyageEntity.java      |   34 -
 .../sample_a/data/shipping/cargo/Cargo.java     |   51 -
 .../sample_a/data/shipping/cargo/Cargos.java    |   76 -
 .../data/shipping/cargo/RouteSpecification.java |   73 -
 .../data/shipping/cargo/TrackingId.java         |   33 -
 .../data/shipping/delivery/Delivery.java        |  127 --
 .../delivery/ExpectedHandlingEvent.java         |   46 -
 .../data/shipping/delivery/RoutingStatus.java   |   29 -
 .../data/shipping/delivery/TransportStatus.java |   30 -
 .../data/shipping/handling/HandlingEvent.java   |   71 -
 .../shipping/handling/HandlingEventType.java    |   58 -
 .../data/shipping/handling/HandlingEvents.java  |   85 -
 .../data/shipping/itinerary/Itinerary.java      |   91 -
 .../sample_a/data/shipping/itinerary/Leg.java   |   46 -
 .../data/shipping/location/Location.java        |   58 -
 .../data/shipping/location/UnLocode.java        |   39 -
 .../data/shipping/voyage/CarrierMovement.java   |   41 -
 .../sample_a/data/shipping/voyage/Schedule.java |   33 -
 .../sample_a/data/shipping/voyage/Voyage.java   |   35 -
 .../data/shipping/voyage/VoyageNumber.java      |   32 -
 .../infrastructure/WicketQi4jApplication.java   |  254 ---
 .../sample_a/infrastructure/conversion/DTO.java |   29 -
 .../conversion/EntityToDTOService.java          |  324 ----
 .../sample_a/infrastructure/dci/Context.java    |  127 --
 .../sample_a/infrastructure/dci/RoleMixin.java  |   53 -
 .../infrastructure/model/EntityModel.java       |   78 -
 .../infrastructure/model/JSONModel.java         |   69 -
 .../sample_a/infrastructure/model/Queries.java  |   40 -
 .../infrastructure/model/QueryModel.java        |   68 -
 .../infrastructure/model/ReadOnlyModel.java     |   69 -
 .../wicket/color/CorrectColor.java              |   31 -
 .../infrastructure/wicket/color/ErrorColor.java |   34 -
 .../wicket/form/AbstractForm.java               |   66 -
 .../wicket/form/DateTextFieldWithPicker.java    |  227 ---
 .../wicket/form/SelectorInForm.java             |   70 -
 .../infrastructure/wicket/link/LinkPanel.java   |   45 -
 .../infrastructure/wicket/page/BaseWebPage.java |   56 -
 .../wicket/prevnext/PrevNext.java               |  120 --
 .../infrastructure/wicket/tabs/TabsPanel.java   |   91 -
 .../pathfinder_a/api/GraphTraversalService.java |   41 +
 .../dcicargo/pathfinder_a/api/TransitEdge.java  |   83 +
 .../dcicargo/pathfinder_a/api/TransitPath.java  |   49 +
 .../dcicargo/pathfinder_a/api/package.html      |   23 +
 .../pathfinder_a/internal/GraphDAO.java         |   58 +
 .../internal/GraphTraversalServiceImpl.java     |  108 ++
 .../dcicargo/pathfinder_a/internal/package.html |   23 +
 .../sample/dcicargo/pathfinder_a/package.html   |   31 +
 .../bootstrap/DCISampleApplication_a.java       |   81 +
 .../VisualizeApplicationStructure.java          |   57 +
 .../sample_a/bootstrap/assembly/Assembler.java  |  293 +++
 .../sample_a/bootstrap/sampledata/BaseData.java |  122 ++
 .../bootstrap/sampledata/BaseDataService.java   |  182 ++
 .../bootstrap/sampledata/SampleDataService.java |  321 +++
 .../communication/query/BookingQueries.java     |   73 +
 .../communication/query/CommonQueries.java      |   75 +
 .../communication/query/HandlingQueries.java    |   75 +
 .../communication/query/TrackingQueries.java    |   76 +
 .../communication/query/dto/CargoDTO.java       |   51 +
 .../query/dto/HandlingEventDTO.java             |   49 +
 .../communication/query/dto/LocationDTO.java    |   31 +
 .../communication/query/dto/VoyageDTO.java      |   31 +
 .../sample_a/communication/web/BasePage.java    |   75 +
 .../web/booking/BookNewCargoPage.java           |  152 ++
 .../web/booking/BookingBasePage.java            |   37 +
 .../web/booking/CargoDetailsPage.java           |  175 ++
 .../web/booking/CargoListPage.java              |   94 +
 .../web/booking/ChangeDestinationPage.java      |  106 +
 .../web/booking/RouteCargoPage.java             |   67 +
 .../communication/web/booking/RoutePanel.java   |  114 ++
 .../web/handling/RegisterHandlingEventPage.java |  145 ++
 .../web/tracking/HandlingHistoryPanel.java      |   84 +
 .../web/tracking/NextHandlingEventPanel.java    |   99 +
 .../web/tracking/TrackCargoPage.java            |  198 ++
 .../sample_a/context/rolemap/CargoRoleMap.java  |   30 +
 .../sample_a/context/rolemap/CargosRoleMap.java |   30 +
 .../context/rolemap/HandlingEventRoleMap.java   |   32 +
 .../context/rolemap/HandlingEventsRoleMap.java  |   30 +
 .../context/rolemap/ItineraryRoleMap.java       |   34 +
 .../rolemap/RouteSpecificationRoleMap.java      |   34 +
 .../context/shipping/booking/BookNewCargo.java  |  256 +++
 .../shipping/booking/BuildDeliverySnapshot.java |  558 ++++++
 .../shipping/booking/RouteException.java        |   27 +
 .../context/shipping/handling/InspectCargo.java |  106 +
 .../handling/RegisterHandlingEvent.java         |  268 +++
 .../context/support/ApplicationEvents.java      |  152 ++
 .../context/support/FoundNoRoutesException.java |   58 +
 .../RegisterHandlingEventAttemptDTO.java        |   49 +
 .../context/support/RoutingService.java         |  154 ++
 .../sample_a/data/entity/CargoEntity.java       |   31 +
 .../sample_a/data/entity/CargosEntity.java      |   30 +
 .../data/entity/HandlingEventEntity.java        |   31 +
 .../data/entity/HandlingEventsEntity.java       |   32 +
 .../sample_a/data/entity/LocationEntity.java    |   34 +
 .../sample_a/data/entity/VoyageEntity.java      |   34 +
 .../sample_a/data/shipping/cargo/Cargo.java     |   51 +
 .../sample_a/data/shipping/cargo/Cargos.java    |   76 +
 .../data/shipping/cargo/RouteSpecification.java |   73 +
 .../data/shipping/cargo/TrackingId.java         |   33 +
 .../data/shipping/delivery/Delivery.java        |  127 ++
 .../delivery/ExpectedHandlingEvent.java         |   46 +
 .../data/shipping/delivery/RoutingStatus.java   |   29 +
 .../data/shipping/delivery/TransportStatus.java |   30 +
 .../data/shipping/handling/HandlingEvent.java   |   71 +
 .../shipping/handling/HandlingEventType.java    |   58 +
 .../data/shipping/handling/HandlingEvents.java  |   85 +
 .../data/shipping/itinerary/Itinerary.java      |   91 +
 .../sample_a/data/shipping/itinerary/Leg.java   |   46 +
 .../data/shipping/location/Location.java        |   58 +
 .../data/shipping/location/UnLocode.java        |   39 +
 .../data/shipping/voyage/CarrierMovement.java   |   41 +
 .../sample_a/data/shipping/voyage/Schedule.java |   33 +
 .../sample_a/data/shipping/voyage/Voyage.java   |   35 +
 .../data/shipping/voyage/VoyageNumber.java      |   32 +
 .../infrastructure/WicketQi4jApplication.java   |  254 +++
 .../sample_a/infrastructure/conversion/DTO.java |   29 +
 .../conversion/EntityToDTOService.java          |  324 ++++
 .../sample_a/infrastructure/dci/Context.java    |  127 ++
 .../sample_a/infrastructure/dci/RoleMixin.java  |   53 +
 .../infrastructure/model/EntityModel.java       |   78 +
 .../infrastructure/model/JSONModel.java         |   69 +
 .../sample_a/infrastructure/model/Queries.java  |   40 +
 .../infrastructure/model/QueryModel.java        |   68 +
 .../infrastructure/model/ReadOnlyModel.java     |   69 +
 .../wicket/color/CorrectColor.java              |   31 +
 .../infrastructure/wicket/color/ErrorColor.java |   34 +
 .../wicket/form/AbstractForm.java               |   66 +
 .../wicket/form/DateTextFieldWithPicker.java    |  227 +++
 .../wicket/form/SelectorInForm.java             |   70 +
 .../infrastructure/wicket/link/LinkPanel.java   |   45 +
 .../infrastructure/wicket/page/BaseWebPage.java |   56 +
 .../wicket/prevnext/PrevNext.java               |  120 ++
 .../infrastructure/wicket/tabs/TabsPanel.java   |   91 +
 .../sample_a/communication/web/BasePage.html    |  108 --
 .../web/booking/BookNewCargoPage.html           |   71 -
 .../web/booking/BookingBasePage.html            |   23 -
 .../web/booking/CargoDetailsPage.html           |   89 -
 .../web/booking/CargoListPage.html              |   49 -
 .../web/booking/ChangeDestinationPage.html      |   60 -
 .../web/booking/RouteCargoPage.html             |   35 -
 .../communication/web/booking/RoutePanel.html   |   44 -
 .../web/handling/RegisterHandlingEventPage.html |   70 -
 .../RegisterHandlingEventPage.properties        |   21 -
 .../web/tracking/HandlingHistoryPanel.html      |   30 -
 .../tracking/HandlingHistoryPanel.properties    |   21 -
 .../web/tracking/NextHandlingEventPanel.html    |   21 -
 .../tracking/NextHandlingEventPanel.properties  |   23 -
 .../web/tracking/TrackCargoPage.html            |   50 -
 .../web/tracking/TrackCargoPage.properties      |   24 -
 .../context/shipping/booking/BookNewCargo.txt   |   75 -
 .../shipping/booking/BuildDeliverySnapshot.txt  |  157 --
 .../context/shipping/handling/InspectCargo.txt  |   24 -
 .../shipping/handling/RegisterHandlingEvent.txt |   79 -
 .../infrastructure/wicket/link/LinkPanel.html   |   21 -
 .../wicket/prevnext/PrevNext.html               |   27 -
 .../infrastructure/wicket/tabs/TabsPanel.html   |   31 -
 .../sample_a/communication/web/BasePage.html    |  108 ++
 .../web/booking/BookNewCargoPage.html           |   71 +
 .../web/booking/BookingBasePage.html            |   23 +
 .../web/booking/CargoDetailsPage.html           |   89 +
 .../web/booking/CargoListPage.html              |   49 +
 .../web/booking/ChangeDestinationPage.html      |   60 +
 .../web/booking/RouteCargoPage.html             |   35 +
 .../communication/web/booking/RoutePanel.html   |   44 +
 .../web/handling/RegisterHandlingEventPage.html |   70 +
 .../RegisterHandlingEventPage.properties        |   21 +
 .../web/tracking/HandlingHistoryPanel.html      |   30 +
 .../tracking/HandlingHistoryPanel.properties    |   21 +
 .../web/tracking/NextHandlingEventPanel.html    |   21 +
 .../tracking/NextHandlingEventPanel.properties  |   23 +
 .../web/tracking/TrackCargoPage.html            |   50 +
 .../web/tracking/TrackCargoPage.properties      |   24 +
 .../context/shipping/booking/BookNewCargo.txt   |   75 +
 .../shipping/booking/BuildDeliverySnapshot.txt  |  157 ++
 .../context/shipping/handling/InspectCargo.txt  |   24 +
 .../shipping/handling/RegisterHandlingEvent.txt |   79 +
 .../infrastructure/wicket/link/LinkPanel.html   |   21 +
 .../wicket/prevnext/PrevNext.html               |   27 +
 .../infrastructure/wicket/tabs/TabsPanel.html   |   31 +
 .../dcisample_a/src/main/webapp/WEB-INF/web.xml |    2 +-
 .../dcicargo/sample_a/bootstrap/Start8081.java  |   68 -
 .../bootstrap/test/TestApplication.java         |  112 --
 .../sample_a/bootstrap/test/TestAssembler.java  |  226 ---
 .../shipping/booking/BookNewCargoTest.java      |  220 ---
 .../booking/BuildDeliverySnapshotTest.java      |  639 ------
 .../shipping/handling/InspectCargoTest.java     |  136 --
 .../handling/RegisterHandlingEventTest.java     |  249 ---
 .../dcicargo/sample_a/bootstrap/Start8081.java  |   68 +
 .../bootstrap/test/TestApplication.java         |  113 ++
 .../sample_a/bootstrap/test/TestAssembler.java  |  226 +++
 .../shipping/booking/BookNewCargoTest.java      |  220 +++
 .../booking/BuildDeliverySnapshotTest.java      |  639 ++++++
 .../shipping/handling/InspectCargoTest.java     |  136 ++
 .../handling/RegisterHandlingEventTest.java     |  249 +++
 .../pathfinder_b/api/GraphTraversalService.java |   46 -
 .../dcicargo/pathfinder_b/api/TransitEdge.java  |   83 -
 .../dcicargo/pathfinder_b/api/TransitPath.java  |   72 -
 .../dcicargo/pathfinder_b/api/package.html      |   23 -
 .../pathfinder_b/internal/GraphDAO.java         |  104 -
 .../internal/GraphTraversalServiceImpl.java     |  136 --
 .../dcicargo/pathfinder_b/internal/package.html |   23 -
 .../sample/dcicargo/pathfinder_b/package.html   |   31 -
 .../bootstrap/DCISampleApplication_b.java       |   84 -
 .../VisualizeApplicationStructure.java          |   57 -
 .../sample_b/bootstrap/assembly/Assembler.java  |  298 ---
 .../sample_b/bootstrap/sampledata/BaseData.java |  192 --
 .../bootstrap/sampledata/BaseDataService.java   |  186 --
 .../bootstrap/sampledata/SampleDataService.java |  416 ----
 .../communication/query/BookingQueries.java     |   85 -
 .../communication/query/CommonQueries.java      |   75 -
 .../communication/query/HandlingQueries.java    |   75 -
 .../communication/query/TrackingQueries.java    |   76 -
 .../communication/query/dto/CargoDTO.java       |   54 -
 .../query/dto/HandlingEventDTO.java             |   50 -
 .../communication/query/dto/LocationDTO.java    |   31 -
 .../communication/query/dto/VoyageDTO.java      |   31 -
 .../sample_b/communication/web/BasePage.java    |   76 -
 .../web/booking/BookNewCargoPage.java           |  151 --
 .../web/booking/BookingBasePage.java            |   37 -
 .../web/booking/CargoDetailsPage.java           |  209 --
 .../web/booking/CargoListPage.java              |  111 --
 .../web/booking/ChangeDestinationPage.java      |  111 --
 .../web/booking/ReRouteCargoPage.java           |   72 -
 .../web/booking/RouteCargoPage.java             |   65 -
 .../communication/web/booking/RoutePanel.java   |  118 --
 .../IncidentLoggingApplicationMockupPage.java   |  268 ---
 .../web/tracking/HandlingHistoryPanel.java      |   86 -
 .../web/tracking/NextHandlingEventPanel.java    |   99 -
 .../web/tracking/TrackCargoPage.java            |  200 --
 .../interaction/booking/BookNewCargo.java       |  134 --
 .../exception/ChangeDestinationException.java   |   61 -
 .../booking/exception/RoutingException.java     |   29 -
 .../exception/UnsatisfyingRouteException.java   |   45 -
 .../booking/routing/AssignCargoToRoute.java     |  196 --
 .../booking/routing/RegisterNewDestination.java |  124 --
 .../DeriveUpdatedRouteSpecification.java        |  152 --
 .../handling/ProcessHandlingEvent.java          |  143 --
 .../handling/ProcessHandlingEventException.java |   26 -
 .../inspection/InspectCargoDeliveryStatus.java  |  159 --
 .../inspection/event/InspectArrivedCargo.java   |  162 --
 .../inspection/event/InspectCargoInCustoms.java |  158 --
 .../inspection/event/InspectClaimedCargo.java   |  156 --
 .../inspection/event/InspectLoadedCargo.java    |  266 ---
 .../inspection/event/InspectReceivedCargo.java  |  179 --
 .../inspection/event/InspectUnhandledCargo.java |  143 --
 .../inspection/event/InspectUnloadedCargo.java  |  214 --
 .../exception/CargoArrivedException.java        |   38 -
 .../exception/CargoHijackedException.java       |   42 -
 .../exception/CargoMisdirectedException.java    |   57 -
 .../exception/CargoMisroutedException.java      |   50 -
 .../exception/CargoNotRoutedException.java      |   36 -
 .../exception/InspectionException.java          |   29 -
 .../exception/InspectionFailedException.java    |   35 -
 .../exception/UnexpectedCarrierException.java   |   36 -
 .../parsing/ParseHandlingEventData.java         |  118 --
 .../parsing/dto/ParsedHandlingEventData.java    |   76 -
 .../InvalidHandlingEventDataException.java      |   26 -
 .../registration/RegisterHandlingEvent.java     |  223 ---
 .../exception/AlreadyClaimedException.java      |   37 -
 .../CannotRegisterHandlingEventException.java   |   65 -
 .../exception/ChronologicalException.java       |   41 -
 .../exception/DuplicateEventException.java      |   52 -
 .../exception/MissingVoyageNumberException.java |   43 -
 .../exception/NonRoutedCargoException.java      |   43 -
 .../exception/UnknownCargoException.java        |   37 -
 .../exception/UnknownEventTypeException.java    |   40 -
 .../exception/UnknownLocationException.java     |   37 -
 .../exception/UnknownVoyageException.java       |   37 -
 .../sample_b/context/rolemap/CargoRoleMap.java  |   57 -
 .../sample_b/context/rolemap/CargosRoleMap.java |   33 -
 .../context/rolemap/HandlingEventsRoleMap.java  |   33 -
 .../context/service/routing/RoutingService.java |  148 --
 .../exception/FoundNoRoutesException.java       |   58 -
 .../data/aggregateroot/CargoAggregateRoot.java  |   36 -
 .../HandlingEventAggregateRoot.java             |   36 -
 .../sample_b/data/entity/CargoEntity.java       |   31 -
 .../data/entity/HandlingEventEntity.java        |   31 -
 .../sample_b/data/entity/LocationEntity.java    |   34 -
 .../sample_b/data/entity/VoyageEntity.java      |   34 -
 .../sample_b/data/factory/CargoFactory.java     |  102 -
 .../data/factory/HandlingEventFactory.java      |   94 -
 .../RouteSpecificationFactoryService.java       |   85 -
 .../exception/CannotCreateCargoException.java   |   35 -
 .../CannotCreateHandlingEventException.java     |   35 -
 ...CannotCreateRouteSpecificationException.java |   37 -
 .../sample_b/data/structure/cargo/Cargo.java    |   54 -
 .../structure/cargo/RouteSpecification.java     |   99 -
 .../data/structure/delivery/Delivery.java       |  137 --
 .../structure/delivery/NextHandlingEvent.java   |   54 -
 .../data/structure/delivery/RoutingStatus.java  |   31 -
 .../structure/delivery/TransportStatus.java     |   32 -
 .../data/structure/handling/HandlingEvent.java  |   98 -
 .../structure/handling/HandlingEventType.java   |   60 -
 .../data/structure/itinerary/Itinerary.java     |  115 --
 .../sample_b/data/structure/itinerary/Leg.java  |   46 -
 .../data/structure/location/Location.java       |   60 -
 .../data/structure/location/UnLocode.java       |   41 -
 .../data/structure/tracking/TrackingId.java     |   40 -
 .../data/structure/voyage/CarrierMovement.java  |   43 -
 .../data/structure/voyage/Schedule.java         |   35 -
 .../sample_b/data/structure/voyage/Voyage.java  |   88 -
 .../data/structure/voyage/VoyageNumber.java     |   34 -
 .../infrastructure/WicketQi4jApplication.java   |  236 ---
 .../sample_b/infrastructure/conversion/DTO.java |   35 -
 .../conversion/EntityToDTOService.java          |  325 ----
 .../sample_b/infrastructure/dci/Context.java    |  143 --
 .../sample_b/infrastructure/dci/RoleMixin.java  |   64 -
 .../infrastructure/model/EntityModel.java       |   84 -
 .../infrastructure/model/JSONModel.java         |   71 -
 .../sample_b/infrastructure/model/Queries.java  |   42 -
 .../infrastructure/model/QueryModel.java        |   70 -
 .../infrastructure/model/ReadOnlyModel.java     |   71 -
 .../wicket/color/CorrectColor.java              |   33 -
 .../infrastructure/wicket/color/ErrorColor.java |   33 -
 .../wicket/form/AbstractForm.java               |   67 -
 .../wicket/form/DateTextFieldWithPicker.java    |  227 ---
 .../wicket/form/SelectorInForm.java             |   77 -
 .../infrastructure/wicket/link/LinkPanel.java   |   47 -
 .../infrastructure/wicket/page/BaseWebPage.java |   56 -
 .../wicket/prevnext/PrevNext.java               |  122 --
 .../infrastructure/wicket/tabs/TabsPanel.java   |  103 -
 .../pathfinder_b/api/GraphTraversalService.java |   46 +
 .../dcicargo/pathfinder_b/api/TransitEdge.java  |   83 +
 .../dcicargo/pathfinder_b/api/TransitPath.java  |   72 +
 .../dcicargo/pathfinder_b/api/package.html      |   23 +
 .../pathfinder_b/internal/GraphDAO.java         |  104 +
 .../internal/GraphTraversalServiceImpl.java     |  136 ++
 .../dcicargo/pathfinder_b/internal/package.html |   23 +
 .../sample/dcicargo/pathfinder_b/package.html   |   31 +
 .../bootstrap/DCISampleApplication_b.java       |   84 +
 .../VisualizeApplicationStructure.java          |   57 +
 .../sample_b/bootstrap/assembly/Assembler.java  |  298 +++
 .../sample_b/bootstrap/sampledata/BaseData.java |  192 ++
 .../bootstrap/sampledata/BaseDataService.java   |  186 ++
 .../bootstrap/sampledata/SampleDataService.java |  416 ++++
 .../communication/query/BookingQueries.java     |   85 +
 .../communication/query/CommonQueries.java      |   75 +
 .../communication/query/HandlingQueries.java    |   75 +
 .../communication/query/TrackingQueries.java    |   76 +
 .../communication/query/dto/CargoDTO.java       |   54 +
 .../query/dto/HandlingEventDTO.java             |   50 +
 .../communication/query/dto/LocationDTO.java    |   31 +
 .../communication/query/dto/VoyageDTO.java      |   31 +
 .../sample_b/communication/web/BasePage.java    |   76 +
 .../web/booking/BookNewCargoPage.java           |  151 ++
 .../web/booking/BookingBasePage.java            |   37 +
 .../web/booking/CargoDetailsPage.java           |  209 ++
 .../web/booking/CargoListPage.java              |  111 ++
 .../web/booking/ChangeDestinationPage.java      |  111 ++
 .../web/booking/ReRouteCargoPage.java           |   72 +
 .../web/booking/RouteCargoPage.java             |   65 +
 .../communication/web/booking/RoutePanel.java   |  118 ++
 .../IncidentLoggingApplicationMockupPage.java   |  268 +++
 .../web/tracking/HandlingHistoryPanel.java      |   86 +
 .../web/tracking/NextHandlingEventPanel.java    |   99 +
 .../web/tracking/TrackCargoPage.java            |  200 ++
 .../interaction/booking/BookNewCargo.java       |  134 ++
 .../exception/ChangeDestinationException.java   |   61 +
 .../booking/exception/RoutingException.java     |   29 +
 .../exception/UnsatisfyingRouteException.java   |   45 +
 .../booking/routing/AssignCargoToRoute.java     |  196 ++
 .../booking/routing/RegisterNewDestination.java |  124 ++
 .../DeriveUpdatedRouteSpecification.java        |  152 ++
 .../handling/ProcessHandlingEvent.java          |  143 ++
 .../handling/ProcessHandlingEventException.java |   26 +
 .../inspection/InspectCargoDeliveryStatus.java  |  159 ++
 .../inspection/event/InspectArrivedCargo.java   |  162 ++
 .../inspection/event/InspectCargoInCustoms.java |  158 ++
 .../inspection/event/InspectClaimedCargo.java   |  156 ++
 .../inspection/event/InspectLoadedCargo.java    |  266 +++
 .../inspection/event/InspectReceivedCargo.java  |  179 ++
 .../inspection/event/InspectUnhandledCargo.java |  143 ++
 .../inspection/event/InspectUnloadedCargo.java  |  214 ++
 .../exception/CargoArrivedException.java        |   38 +
 .../exception/CargoHijackedException.java       |   42 +
 .../exception/CargoMisdirectedException.java    |   57 +
 .../exception/CargoMisroutedException.java      |   50 +
 .../exception/CargoNotRoutedException.java      |   36 +
 .../exception/InspectionException.java          |   29 +
 .../exception/InspectionFailedException.java    |   35 +
 .../exception/UnexpectedCarrierException.java   |   36 +
 .../parsing/ParseHandlingEventData.java         |  118 ++
 .../parsing/dto/ParsedHandlingEventData.java    |   76 +
 .../InvalidHandlingEventDataException.java      |   26 +
 .../registration/RegisterHandlingEvent.java     |  223 +++
 .../exception/AlreadyClaimedException.java      |   37 +
 .../CannotRegisterHandlingEventException.java   |   65 +
 .../exception/ChronologicalException.java       |   41 +
 .../exception/DuplicateEventException.java      |   52 +
 .../exception/MissingVoyageNumberException.java |   43 +
 .../exception/NonRoutedCargoException.java      |   43 +
 .../exception/UnknownCargoException.java        |   37 +
 .../exception/UnknownEventTypeException.java    |   40 +
 .../exception/UnknownLocationException.java     |   37 +
 .../exception/UnknownVoyageException.java       |   37 +
 .../sample_b/context/rolemap/CargoRoleMap.java  |   57 +
 .../sample_b/context/rolemap/CargosRoleMap.java |   33 +
 .../context/rolemap/HandlingEventsRoleMap.java  |   33 +
 .../context/service/routing/RoutingService.java |  148 ++
 .../exception/FoundNoRoutesException.java       |   58 +
 .../data/aggregateroot/CargoAggregateRoot.java  |   36 +
 .../HandlingEventAggregateRoot.java             |   36 +
 .../sample_b/data/entity/CargoEntity.java       |   31 +
 .../data/entity/HandlingEventEntity.java        |   31 +
 .../sample_b/data/entity/LocationEntity.java    |   34 +
 .../sample_b/data/entity/VoyageEntity.java      |   34 +
 .../sample_b/data/factory/CargoFactory.java     |  102 +
 .../data/factory/HandlingEventFactory.java      |   94 +
 .../RouteSpecificationFactoryService.java       |   85 +
 .../exception/CannotCreateCargoException.java   |   35 +
 .../CannotCreateHandlingEventException.java     |   35 +
 ...CannotCreateRouteSpecificationException.java |   37 +
 .../sample_b/data/structure/cargo/Cargo.java    |   54 +
 .../structure/cargo/RouteSpecification.java     |   99 +
 .../data/structure/delivery/Delivery.java       |  137 ++
 .../structure/delivery/NextHandlingEvent.java   |   54 +
 .../data/structure/delivery/RoutingStatus.java  |   31 +
 .../structure/delivery/TransportStatus.java     |   32 +
 .../data/structure/handling/HandlingEvent.java  |   98 +
 .../structure/handling/HandlingEventType.java   |   60 +
 .../data/structure/itinerary/Itinerary.java     |  115 ++
 .../sample_b/data/structure/itinerary/Leg.java  |   46 +
 .../data/structure/location/Location.java       |   60 +
 .../data/structure/location/UnLocode.java       |   41 +
 .../data/structure/tracking/TrackingId.java     |   40 +
 .../data/structure/voyage/CarrierMovement.java  |   43 +
 .../data/structure/voyage/Schedule.java         |   35 +
 .../sample_b/data/structure/voyage/Voyage.java  |   88 +
 .../data/structure/voyage/VoyageNumber.java     |   34 +
 .../infrastructure/WicketQi4jApplication.java   |  236 +++
 .../sample_b/infrastructure/conversion/DTO.java |   35 +
 .../conversion/EntityToDTOService.java          |  325 ++++
 .../sample_b/infrastructure/dci/Context.java    |  145 ++
 .../sample_b/infrastructure/dci/RoleMixin.java  |   64 +
 .../infrastructure/model/EntityModel.java       |   84 +
 .../infrastructure/model/JSONModel.java         |   71 +
 .../sample_b/infrastructure/model/Queries.java  |   42 +
 .../infrastructure/model/QueryModel.java        |   70 +
 .../infrastructure/model/ReadOnlyModel.java     |   71 +
 .../wicket/color/CorrectColor.java              |   33 +
 .../infrastructure/wicket/color/ErrorColor.java |   33 +
 .../wicket/form/AbstractForm.java               |   67 +
 .../wicket/form/DateTextFieldWithPicker.java    |  227 +++
 .../wicket/form/SelectorInForm.java             |   77 +
 .../infrastructure/wicket/link/LinkPanel.java   |   47 +
 .../infrastructure/wicket/page/BaseWebPage.java |   56 +
 .../wicket/prevnext/PrevNext.java               |  122 ++
 .../infrastructure/wicket/tabs/TabsPanel.java   |  103 +
 .../sample_b/communication/web/BasePage.html    |  108 --
 .../web/booking/BookNewCargoPage.html           |   71 -
 .../web/booking/BookingBasePage.html            |   23 -
 .../web/booking/CargoDetailsPage.html           |  110 --
 .../web/booking/CargoListPage.html              |   49 -
 .../web/booking/ChangeDestinationPage.html      |   60 -
 .../web/booking/ReRouteCargoPage.html           |   35 -
 .../web/booking/RouteCargoPage.html             |   35 -
 .../communication/web/booking/RoutePanel.html   |   44 -
 .../IncidentLoggingApplicationMockupPage.html   |   91 -
 ...identLoggingApplicationMockupPage.properties |   21 -
 .../web/tracking/HandlingHistoryPanel.html      |   30 -
 .../tracking/HandlingHistoryPanel.properties    |   21 -
 .../web/tracking/NextHandlingEventPanel.html    |   21 -
 .../tracking/NextHandlingEventPanel.properties  |   23 -
 .../web/tracking/TrackCargoPage.html            |   50 -
 .../web/tracking/TrackCargoPage.properties      |   24 -
 .../sample_b/context/usecase/_ShipCargo.txt     |   50 -
 .../context/usecase/booking/BookNewCargo.txt    |   51 -
 .../booking/ChangeDestinationOfCargo.txt        |   39 -
 .../context/usecase/booking/ReRouteCargo.txt    |   33 -
 .../context/usecase/booking/RouteCargo.txt      |   27 -
 .../booking/routing/AssignCargoToRoute.txt      |   42 -
 .../booking/routing/RegisterNewDestination.txt  |   30 -
 .../DeriveUpdatedRouteSpecification.txt         |   32 -
 .../usecase/handling/_ProcessHandlingEvent.txt  |   67 -
 .../inspection/InspectCargoDeliveryStatus.txt   |   57 -
 .../inspection/event/InspectArrivedCargo.txt    |   38 -
 .../inspection/event/InspectCargoInCustoms.txt  |   38 -
 .../inspection/event/InspectClaimedCargo.txt    |   38 -
 .../inspection/event/InspectLoadedCargo.txt     |   60 -
 .../inspection/event/InspectReceivedCargo.txt   |   35 -
 .../inspection/event/InspectUnhandledCargo.txt  |   32 -
 .../inspection/event/InspectUnloadedCargo.txt   |   45 -
 .../handling/parsing/ParseHandlingEventData.txt |   62 -
 .../registration/RegisterHandlingEvent.txt      |   76 -
 .../infrastructure/wicket/link/LinkPanel.html   |   21 -
 .../wicket/prevnext/PrevNext.html               |   27 -
 .../infrastructure/wicket/tabs/TabsPanel.html   |   31 -
 .../sample_b/communication/web/BasePage.html    |  108 ++
 .../web/booking/BookNewCargoPage.html           |   71 +
 .../web/booking/BookingBasePage.html            |   23 +
 .../web/booking/CargoDetailsPage.html           |  110 ++
 .../web/booking/CargoListPage.html              |   49 +
 .../web/booking/ChangeDestinationPage.html      |   60 +
 .../web/booking/ReRouteCargoPage.html           |   35 +
 .../web/booking/RouteCargoPage.html             |   35 +
 .../communication/web/booking/RoutePanel.html   |   44 +
 .../IncidentLoggingApplicationMockupPage.html   |   91 +
 ...identLoggingApplicationMockupPage.properties |   21 +
 .../web/tracking/HandlingHistoryPanel.html      |   30 +
 .../tracking/HandlingHistoryPanel.properties    |   21 +
 .../web/tracking/NextHandlingEventPanel.html    |   21 +
 .../tracking/NextHandlingEventPanel.properties  |   23 +
 .../web/tracking/TrackCargoPage.html            |   50 +
 .../web/tracking/TrackCargoPage.properties      |   24 +
 .../sample_b/context/usecase/_ShipCargo.txt     |   50 +
 .../context/usecase/booking/BookNewCargo.txt    |   51 +
 .../booking/ChangeDestinationOfCargo.txt        |   39 +
 .../context/usecase/booking/ReRouteCargo.txt    |   33 +
 .../context/usecase/booking/RouteCargo.txt      |   27 +
 .../booking/routing/AssignCargoToRoute.txt      |   42 +
 .../booking/routing/RegisterNewDestination.txt  |   30 +
 .../DeriveUpdatedRouteSpecification.txt         |   32 +
 .../usecase/handling/_ProcessHandlingEvent.txt  |   67 +
 .../inspection/InspectCargoDeliveryStatus.txt   |   57 +
 .../inspection/event/InspectArrivedCargo.txt    |   38 +
 .../inspection/event/InspectCargoInCustoms.txt  |   38 +
 .../inspection/event/InspectClaimedCargo.txt    |   38 +
 .../inspection/event/InspectLoadedCargo.txt     |   60 +
 .../inspection/event/InspectReceivedCargo.txt   |   35 +
 .../inspection/event/InspectUnhandledCargo.txt  |   32 +
 .../inspection/event/InspectUnloadedCargo.txt   |   45 +
 .../handling/parsing/ParseHandlingEventData.txt |   62 +
 .../registration/RegisterHandlingEvent.txt      |   76 +
 .../infrastructure/wicket/link/LinkPanel.html   |   21 +
 .../wicket/prevnext/PrevNext.html               |   27 +
 .../infrastructure/wicket/tabs/TabsPanel.html   |   31 +
 .../dcisample_b/src/main/webapp/WEB-INF/web.xml |    2 +-
 .../dcicargo/sample_b/bootstrap/Start8082.java  |   68 -
 .../bootstrap/test/TestApplication.java         |  450 -----
 .../sample_b/bootstrap/test/TestAssembler.java  |  231 ---
 .../context/test/booking/BookNewCargoTest.java  |  218 ---
 .../booking/routing/AssignCargoToRouteTest.java |  196 --
 .../routing/RegisterNewDestinationTest.java     |  314 ---
 .../DeriveUpdatedRouteSpecTest.java             |  158 --
 .../event/InspectArrivedCargoTest.java          |  138 --
 .../event/InspectCargoInCustomsTest.java        |  136 --
 .../event/InspectClaimedCargoTest.java          |  131 --
 .../event/InspectLoadedCargoTest.java           |  513 -----
 .../event/InspectReceivedCargoTest.java         |  284 ---
 .../event/InspectUnhandledCargoTest.java        |  128 --
 .../event/InspectUnloadedCargoTest.java         |  343 ----
 .../parsing/ParseHandlingEventDataTest.java     |  140 --
 .../registration/RegisterHandlingEventTest.java |  232 ---
 .../testing/ExpectedException.java              |  101 -
 .../dcicargo/sample_b/bootstrap/Start8082.java  |   68 +
 .../bootstrap/test/TestApplication.java         |  453 +++++
 .../sample_b/bootstrap/test/TestAssembler.java  |  231 +++
 .../context/test/booking/BookNewCargoTest.java  |  218 +++
 .../booking/routing/AssignCargoToRouteTest.java |  196 ++
 .../routing/RegisterNewDestinationTest.java     |  314 +++
 .../DeriveUpdatedRouteSpecTest.java             |  158 ++
 .../event/InspectArrivedCargoTest.java          |  138 ++
 .../event/InspectCargoInCustomsTest.java        |  136 ++
 .../event/InspectClaimedCargoTest.java          |  131 ++
 .../event/InspectLoadedCargoTest.java           |  513 +++++
 .../event/InspectReceivedCargoTest.java         |  284 +++
 .../event/InspectUnhandledCargoTest.java        |  128 ++
 .../event/InspectUnloadedCargoTest.java         |  343 ++++
 .../parsing/ParseHandlingEventDataTest.java     |  140 ++
 .../registration/RegisterHandlingEventTest.java |  232 +++
 .../testing/ExpectedException.java              |  101 +
 .../moneytransfer/context/PayBillsContext.java  |  146 --
 .../moneytransfer/context/PayBillsContext2.java |  138 --
 .../zest/dci/moneytransfer/context/Role.java    |   75 -
 .../context/TransferMoneyContext.java           |  113 --
 .../context/TransferMoneyContext2.java          |   89 -
 .../moneytransfer/domain/data/BalanceData.java  |   61 -
 .../domain/entity/CheckingAccountEntity.java    |   28 -
 .../domain/entity/CreditorEntity.java           |   28 -
 .../domain/entity/SavingsAccountEntity.java     |   28 -
 .../rolemap/CheckingAccountRolemap.java         |   32 -
 .../moneytransfer/rolemap/CreditorRolemap.java  |   28 -
 .../rolemap/SavingsAccountRolemap.java          |   28 -
 .../moneytransfer/context/PayBillsContext.java  |  146 ++
 .../moneytransfer/context/PayBillsContext2.java |  138 ++
 .../qi4j/dci/moneytransfer/context/Role.java    |   75 +
 .../context/TransferMoneyContext.java           |  113 ++
 .../context/TransferMoneyContext2.java          |   89 +
 .../moneytransfer/domain/data/BalanceData.java  |   61 +
 .../domain/entity/CheckingAccountEntity.java    |   28 +
 .../domain/entity/CreditorEntity.java           |   28 +
 .../domain/entity/SavingsAccountEntity.java     |   28 +
 .../rolemap/CheckingAccountRolemap.java         |   32 +
 .../moneytransfer/rolemap/CreditorRolemap.java  |   28 +
 .../rolemap/SavingsAccountRolemap.java          |   28 +
 .../moneytransfer/test/TransferMoneyTest.java   |  208 --
 .../moneytransfer/test/TransferMoneyTest2.java  |  210 --
 .../moneytransfer/test/TransferMoneyTest.java   |  208 ++
 .../moneytransfer/test/TransferMoneyTest2.java  |  210 ++
 .../samples/cargo/app1/model/cargo/Cargo.java   |  230 +++
 .../sample/forum/assembler/ForumAssembler.java  |  175 --
 .../zest/sample/forum/context/Context.java      |   43 -
 .../zest/sample/forum/context/Events.java       |   29 -
 .../sample/forum/context/EventsService.java     |  119 --
 .../forum/context/account/UpdateProfile.java    |   66 -
 .../administration/BoardAdministration.java     |   69 -
 .../administration/ForumAdministration.java     |   89 -
 .../administration/ForumsAdministration.java    |   86 -
 .../administration/ModeratorAdministration.java |   75 -
 .../ModeratorsAdministration.java               |   83 -
 .../administration/UsersAdministration.java     |   55 -
 .../zest/sample/forum/context/login/Login.java  |   47 -
 .../context/moderation/ModerationContext.java   |   27 -
 .../forum/context/signup/Registration.java      |   37 -
 .../sample/forum/context/signup/Signup.java     |   53 -
 .../sample/forum/context/view/ViewBoard.java    |  127 --
 .../sample/forum/context/view/ViewForum.java    |   61 -
 .../sample/forum/context/view/ViewPost.java     |   91 -
 .../sample/forum/context/view/ViewTopic.java    |   49 -
 .../zest/sample/forum/data/Administrators.java  |   30 -
 .../zest/sample/forum/data/Moderators.java      |   30 -
 .../zest/sample/forum/data/entity/Board.java    |   49 -
 .../zest/sample/forum/data/entity/Forum.java    |   42 -
 .../zest/sample/forum/data/entity/Forums.java   |   54 -
 .../zest/sample/forum/data/entity/Post.java     |   53 -
 .../zest/sample/forum/data/entity/Topic.java    |   51 -
 .../zest/sample/forum/data/entity/User.java     |   81 -
 .../zest/sample/forum/data/entity/Users.java    |   68 -
 .../forum/domainevent/DomainCommandResult.java  |   35 -
 .../sample/forum/domainevent/DomainEvent.java   |  112 --
 .../forum/domainevent/DomainEventValue.java     |   51 -
 .../forum/domainevent/ParameterValue.java       |   33 -
 .../zest/sample/forum/rest/ForumRestlet.java    |   38 -
 .../forum/rest/resource/RootResource.java       |   87 -
 .../administration/AdministrationResource.java  |   45 -
 .../resource/administration/ForumsResource.java |   29 -
 .../resource/administration/UsersResource.java  |   40 -
 .../rest/resource/forum/BoardResource.java      |   41 -
 .../rest/resource/forum/ForumResource.java      |   41 -
 .../rest/resource/forum/ForumsResource.java     |   40 -
 .../rest/resource/login/LoginResource.java      |   41 -
 .../rest/resource/signup/SignupResource.java    |   45 -
 .../sample/forum/service/BootstrapData.java     |  101 -
 .../samples/forum/assembler/ForumAssembler.java |  175 ++
 .../org/qi4j/samples/forum/context/Context.java |   43 +
 .../org/qi4j/samples/forum/context/Events.java  |   29 +
 .../samples/forum/context/EventsService.java    |  119 ++
 .../forum/context/account/UpdateProfile.java    |   66 +
 .../administration/BoardAdministration.java     |   69 +
 .../administration/ForumAdministration.java     |   89 +
 .../administration/ForumsAdministration.java    |   86 +
 .../administration/ModeratorAdministration.java |   75 +
 .../ModeratorsAdministration.java               |   83 +
 .../administration/UsersAdministration.java     |   55 +
 .../qi4j/samples/forum/context/login/Login.java |   47 +
 .../context/moderation/ModerationContext.java   |   27 +
 .../forum/context/signup/Registration.java      |   37 +
 .../samples/forum/context/signup/Signup.java    |   53 +
 .../samples/forum/context/view/ViewBoard.java   |  127 ++
 .../samples/forum/context/view/ViewForum.java   |   61 +
 .../samples/forum/context/view/ViewPost.java    |   91 +
 .../samples/forum/context/view/ViewTopic.java   |   49 +
 .../qi4j/samples/forum/data/Administrators.java |   30 +
 .../org/qi4j/samples/forum/data/Moderators.java |   30 +
 .../qi4j/samples/forum/data/entity/Board.java   |   49 +
 .../qi4j/samples/forum/data/entity/Forum.java   |   42 +
 .../qi4j/samples/forum/data/entity/Forums.java  |   54 +
 .../qi4j/samples/forum/data/entity/Post.java    |   53 +
 .../qi4j/samples/forum/data/entity/Topic.java   |   51 +
 .../qi4j/samples/forum/data/entity/User.java    |   81 +
 .../qi4j/samples/forum/data/entity/Users.java   |   68 +
 .../forum/domainevent/DomainCommandResult.java  |   35 +
 .../samples/forum/domainevent/DomainEvent.java  |  112 ++
 .../forum/domainevent/DomainEventValue.java     |   51 +
 .../forum/domainevent/ParameterValue.java       |   33 +
 .../qi4j/samples/forum/rest/ForumRestlet.java   |   38 +
 .../forum/rest/resource/RootResource.java       |   87 +
 .../administration/AdministrationResource.java  |   45 +
 .../resource/administration/ForumsResource.java |   29 +
 .../resource/administration/UsersResource.java  |   40 +
 .../rest/resource/forum/BoardResource.java      |   41 +
 .../rest/resource/forum/ForumResource.java      |   41 +
 .../rest/resource/forum/ForumsResource.java     |   40 +
 .../rest/resource/login/LoginResource.java      |   41 +
 .../rest/resource/signup/SignupResource.java    |   45 +
 .../samples/forum/service/BootstrapData.java    |  101 +
 .../org/apache/zest/sample/forum/web/Main.java  |   60 -
 .../java/org/qi4j/samples/forum/web/Main.java   |   60 +
 .../zest/sample/rental/domain/Address.java      |   36 -
 .../zest/sample/rental/domain/Booking.java      |   45 -
 .../apache/zest/sample/rental/domain/Car.java   |   63 -
 .../zest/sample/rental/domain/CarCategory.java  |   28 -
 .../zest/sample/rental/domain/Customer.java     |   51 -
 .../zest/sample/rental/domain/Period.java       |   31 -
 .../zest/sample/rental/domain/RentalShop.java   |  250 ---
 .../sample/rental/domain/dev/InitialData.java   |  212 --
 .../zest/sample/rental/web/BookingPage.java     |   86 -
 .../zest/sample/rental/web/DataInitializer.java |   25 -
 .../apache/zest/sample/rental/web/MainPage.java |  108 --
 .../org/apache/zest/sample/rental/web/Page.java |  181 --
 .../zest/sample/rental/web/PageMetaInfo.java    |   47 -
 .../sample/rental/web/PageUowManagement.java    |   46 -
 .../zest/sample/rental/web/QuikitContext.java   |   69 -
 .../zest/sample/rental/web/QuikitResolver.java  |  126 --
 .../zest/sample/rental/web/QuikitServlet.java   |  338 ----
 .../zest/sample/rental/web/RenderException.java |   40 -
 .../zest/sample/rental/web/UrlService.java      |   53 -
 .../sample/rental/web/assembly/PagesModule.java |   43 -
 .../assembly/RentalApplicationAssembler.java    |   55 -
 .../rental/web/assembly/RentalModule.java       |   51 -
 .../rental/web/assembly/StorageModule.java      |   53 -
 .../org/qi4j/sample/rental/domain/Address.java  |   36 +
 .../org/qi4j/sample/rental/domain/Booking.java  |   45 +
 .../java/org/qi4j/sample/rental/domain/Car.java |   63 +
 .../qi4j/sample/rental/domain/CarCategory.java  |   28 +
 .../org/qi4j/sample/rental/domain/Customer.java |   51 +
 .../org/qi4j/sample/rental/domain/Period.java   |   31 +
 .../qi4j/sample/rental/domain/RentalShop.java   |  250 +++
 .../sample/rental/domain/dev/InitialData.java   |  212 ++
 .../org/qi4j/sample/rental/web/BookingPage.java |   86 +
 .../qi4j/sample/rental/web/DataInitializer.java |   25 +
 .../org/qi4j/sample/rental/web/MainPage.java    |  108 ++
 .../java/org/qi4j/sample/rental/web/Page.java   |  181 ++
 .../qi4j/sample/rental/web/PageMetaInfo.java    |   47 +
 .../sample/rental/web/PageUowManagement.java    |   46 +
 .../qi4j/sample/rental/web/QuikitContext.java   |   69 +
 .../qi4j/sample/rental/web/QuikitResolver.java  |  126 ++
 .../qi4j/sample/rental/web/QuikitServlet.java   |  338 ++++
 .../qi4j/sample/rental/web/RenderException.java |   40 +
 .../org/qi4j/sample/rental/web/UrlService.java  |   53 +
 .../sample/rental/web/assembly/PagesModule.java |   43 +
 .../assembly/RentalApplicationAssembler.java    |   55 +
 .../rental/web/assembly/RentalModule.java       |   51 +
 .../rental/web/assembly/StorageModule.java      |   53 +
 .../org/apache/zest/sample/rental/index.html    |   16 -
 .../zest/sample/rental/web/BookingPage.html     |   48 -
 .../apache/zest/sample/rental/web/MainPage.html |   29 -
 .../resources/org/qi4j/sample/rental/index.html |   16 +
 .../org/qi4j/sample/rental/web/BookingPage.html |   48 +
 .../org/qi4j/sample/rental/web/MainPage.html    |   29 +
 samples/rental/src/main/webapp/WEB-INF/web.xml  |    4 +-
 .../zest/sample/sqlsupport/AppAssembler.java    |  115 --
 .../org/apache/zest/sample/sqlsupport/Main.java |  163 --
 .../zest/sample/sqlsupport/PretextEntity.java   |   24 -
 .../qi4j/sample/sqlsupport/AppAssembler.java    |  115 ++
 .../java/org/qi4j/sample/sqlsupport/Main.java   |  163 ++
 .../qi4j/sample/sqlsupport/PretextEntity.java   |   24 +
 .../zest/sample/swing/binding/Binding.java      |   25 -
 .../swing/binding/IllegalBindingException.java  |   30 -
 .../zest/sample/swing/binding/StateModel.java   |   74 -
 .../zest/sample/swing/binding/SwingAdapter.java |   71 -
 .../zest/sample/swing/binding/SwingBinding.java |   25 -
 .../swing/binding/SwingBindingAssembler.java    |   43 -
 .../StringToTextFieldAdapterService.java        |  140 --
 .../sample/swing/binding/example/Address.java   |   26 -
 .../swing/binding/example/AddressTransient.java |   25 -
 .../binding/example/BoundPersonComposite.java   |   22 -
 .../zest/sample/swing/binding/example/City.java |   23 -
 .../sample/swing/binding/example/CityValue.java |   25 -
 .../sample/swing/binding/example/Country.java   |   22 -
 .../swing/binding/example/CountryValue.java     |   25 -
 .../zest/sample/swing/binding/example/Form.java |   96 -
 .../swing/binding/example/HasAddress.java       |   25 -
 .../sample/swing/binding/example/HasCity.java   |   25 -
 .../swing/binding/example/HasCountry.java       |   25 -
 .../sample/swing/binding/example/HasName.java   |   25 -
 .../zest/sample/swing/binding/example/Main.java |  142 --
 .../sample/swing/binding/example/Person.java    |   26 -
 .../swing/binding/example/PersonComposite.java  |   25 -
 .../swing/binding/internal/AbstractBinding.java |  115 --
 .../internal/AssociationFocusLostListener.java  |   58 -
 .../binding/internal/BoundAssociation.java      |   92 -
 .../binding/internal/BoundManyAssociation.java  |  108 --
 .../binding/internal/BoundNamedAssociation.java |  114 --
 .../swing/binding/internal/BoundProperty.java   |   78 -
 .../internal/PropertyFocusLostListener.java     |   59 -
 .../internal/StateInvocationHandler.java        |  127 --
 .../org/qi4j/lib/swing/binding/Binding.java     |   25 +
 .../swing/binding/IllegalBindingException.java  |   30 +
 .../org/qi4j/lib/swing/binding/StateModel.java  |   74 +
 .../qi4j/lib/swing/binding/SwingAdapter.java    |   71 +
 .../qi4j/lib/swing/binding/SwingBinding.java    |   25 +
 .../swing/binding/SwingBindingAssembler.java    |   43 +
 .../StringToTextFieldAdapterService.java        |  140 ++
 .../qi4j/lib/swing/binding/example/Address.java |   26 +
 .../swing/binding/example/AddressTransient.java |   25 +
 .../binding/example/BoundPersonComposite.java   |   22 +
 .../qi4j/lib/swing/binding/example/City.java    |   23 +
 .../lib/swing/binding/example/CityValue.java    |   25 +
 .../qi4j/lib/swing/binding/example/Country.java |   22 +
 .../lib/swing/binding/example/CountryValue.java |   25 +
 .../qi4j/lib/swing/binding/example/Form.java    |   96 +
 .../lib/swing/binding/example/HasAddress.java   |   25 +
 .../qi4j/lib/swing/binding/example/HasCity.java |   25 +
 .../lib/swing/binding/example/HasCountry.java   |   25 +
 .../qi4j/lib/swing/binding/example/HasName.java |   25 +
 .../qi4j/lib/swing/binding/example/Main.java    |  142 ++
 .../qi4j/lib/swing/binding/example/Person.java  |   26 +
 .../swing/binding/example/PersonComposite.java  |   25 +
 .../swing/binding/internal/AbstractBinding.java |  115 ++
 .../internal/AssociationFocusLostListener.java  |   58 +
 .../binding/internal/BoundAssociation.java      |   92 +
 .../binding/internal/BoundManyAssociation.java  |  108 ++
 .../binding/internal/BoundNamedAssociation.java |  114 ++
 .../swing/binding/internal/BoundProperty.java   |   78 +
 .../internal/PropertyFocusLostListener.java     |   59 +
 .../internal/StateInvocationHandler.java        |  127 ++
 .../AbstractEntityStorePerformanceTest.java     |  442 -----
 .../performance/entitystore/ComplexProduct.java |   36 -
 .../test/performance/entitystore/Money.java     |   65 -
 .../test/performance/entitystore/Report.java    |  100 -
 .../performance/entitystore/ReportTypes.java    |   42 -
 .../performance/entitystore/SimpleProduct.java  |   29 -
 .../test/performance/entitystore/package.html   |   21 -
 .../AbstractEntityStorePerformanceTest.java     |  442 +++++
 .../performance/entitystore/ComplexProduct.java |   36 +
 .../test/performance/entitystore/Money.java     |   65 +
 .../test/performance/entitystore/Report.java    |  100 +
 .../performance/entitystore/ReportTypes.java    |   42 +
 .../performance/entitystore/SimpleProduct.java  |   29 +
 .../test/performance/entitystore/package.html   |   21 +
 .../jdbm/JdbmEntityStorePerformanceTest.java    |   72 -
 .../MemoryEntityStorePerformanceTest.java       |   60 -
 .../sql/DerbySQLEntityStorePerformanceTest.java |  126 --
 .../PostgreSQLEntityStorePerformanceTest.java   |  151 --
 .../indexing/rdf/QueryPerformanceTest.java      |  393 ----
 .../CompositeCreationPerformanceTest.java       |  222 ---
 .../composite/InvocationPerformanceTest.java    |  204 --
 .../PropertyMixinInvocationPerformanceTest.java |  133 --
 .../object/ObjectCreationPerformanceTest.java   |   70 -
 .../ServiceInvocationPerformanceTest.java       |  112 --
 .../jdbm/JdbmEntityStorePerformanceTest.java    |   72 +
 .../MemoryEntityStorePerformanceTest.java       |   60 +
 .../sql/DerbySQLEntityStorePerformanceTest.java |  126 ++
 .../PostgreSQLEntityStorePerformanceTest.java   |  151 ++
 .../indexing/rdf/QueryPerformanceTest.java      |  393 ++++
 .../CompositeCreationPerformanceTest.java       |  222 +++
 .../composite/InvocationPerformanceTest.java    |  204 ++
 .../PropertyMixinInvocationPerformanceTest.java |  133 ++
 .../object/ObjectCreationPerformanceTest.java   |   70 +
 .../ServiceInvocationPerformanceTest.java       |  112 ++
 .../jdbm/JdbmEntityStoreService.properties      |   20 -
 .../rdf/repository/rdf-indexing.properties      |   17 -
 .../jdbm/JdbmEntityStoreService.properties      |   20 +
 .../rdf/repository/rdf-indexing.properties      |   17 +
 .../zest/test/regression/Regressions.java       |   29 -
 .../niclas2/ConcernsOnPropertyTest.java         |  114 --
 .../org/qi4j/test/regression/Regressions.java   |   29 +
 .../niclas2/ConcernsOnPropertyTest.java         |  115 ++
 .../java/org/apache/zest/envisage/Envisage.java |  147 --
 .../org/apache/zest/envisage/EnvisageFrame.form |   27 -
 .../org/apache/zest/envisage/EnvisageFrame.java |  245 ---
 .../java/org/apache/zest/envisage/Main.java     |   44 -
 .../apache/zest/envisage/detail/APIPane.form    |   41 -
 .../apache/zest/envisage/detail/APIPane.java    |  294 ---
 .../zest/envisage/detail/DependencyPane.form    |  212 --
 .../zest/envisage/detail/DependencyPane.java    |  474 -----
 .../zest/envisage/detail/DetailModelPane.java   |  229 ---
 .../apache/zest/envisage/detail/DetailPane.java |   40 -
 .../zest/envisage/detail/GeneralPane.form       |   39 -
 .../zest/envisage/detail/GeneralPane.java       |  249 ---
 .../zest/envisage/detail/ImportedByPane.form    |   88 -
 .../zest/envisage/detail/ImportedByPane.java    |  183 --
 .../apache/zest/envisage/detail/MethodPane.form |   61 -
 .../apache/zest/envisage/detail/MethodPane.java |  357 ----
 .../apache/zest/envisage/detail/SPIPane.form    |   39 -
 .../apache/zest/envisage/detail/SPIPane.java    |  293 ---
 .../detail/ServiceConfigurationPane.form        |  127 --
 .../detail/ServiceConfigurationPane.java        |  350 ----
 .../zest/envisage/detail/ServiceUsagePane.form  |   39 -
 .../zest/envisage/detail/ServiceUsagePane.java  |  335 ----
 .../apache/zest/envisage/detail/StatePane.form  |   61 -
 .../apache/zest/envisage/detail/StatePane.java  |  379 ----
 .../apache/zest/envisage/detail/package.html    |   21 -
 .../apache/zest/envisage/event/LinkEvent.java   |   41 -
 .../zest/envisage/event/LinkListener.java       |   26 -
 .../org/apache/zest/envisage/event/package.html |   21 -
 .../zest/envisage/graph/GraphBuilder.java       |  270 ---
 .../zest/envisage/graph/GraphDisplay.java       |   82 -
 .../apache/zest/envisage/graph/GraphPane.java   |  164 --
 .../envisage/graph/StackedGraphDisplay.java     |  580 ------
 .../zest/envisage/graph/StackedLayout.java      |  221 ---
 .../zest/envisage/graph/TreeGraphDisplay.java   |  388 ----
 .../org/apache/zest/envisage/graph/package.html |   21 -
 .../java/org/apache/zest/envisage/package.html  |   21 -
 .../apache/zest/envisage/print/PDFWriter.java   |  825 --------
 .../zest/envisage/print/PrintingException.java  |   27 -
 .../org/apache/zest/envisage/print/package.html |   21 -
 .../envisage/tree/StructureModelBuilder.java    |  152 --
 .../envisage/tree/TreeModelCellRenderer.java    |  153 --
 .../zest/envisage/tree/TreeModelPane.java       |  301 ---
 .../zest/envisage/tree/TypeModelBuilder.java    |  152 --
 .../org/apache/zest/envisage/tree/package.html  |   21 -
 .../zest/envisage/util/ColorUtilities.java      |   58 -
 .../org/apache/zest/envisage/util/TableRow.java |   68 -
 .../zest/envisage/util/TableRowUtilities.java   |   61 -
 .../org/apache/zest/envisage/util/package.html  |   21 -
 .../main/java/org/qi4j/envisage/Envisage.java   |  147 ++
 .../java/org/qi4j/envisage/EnvisageFrame.form   |   27 +
 .../java/org/qi4j/envisage/EnvisageFrame.java   |  245 +++
 .../src/main/java/org/qi4j/envisage/Main.java   |   44 +
 .../java/org/qi4j/envisage/detail/APIPane.form  |   41 +
 .../java/org/qi4j/envisage/detail/APIPane.java  |  294 +++
 .../qi4j/envisage/detail/DependencyPane.form    |  212 ++
 .../qi4j/envisage/detail/DependencyPane.java    |  474 +++++
 .../qi4j/envisage/detail/DetailModelPane.java   |  229 +++
 .../org/qi4j/envisage/detail/DetailPane.java    |   40 +
 .../org/qi4j/envisage/detail/GeneralPane.form   |   39 +
 .../org/qi4j/envisage/detail/GeneralPane.java   |  249 +++
 .../qi4j/envisage/detail/ImportedByPane.form    |   88 +
 .../qi4j/envisage/detail/ImportedByPane.java    |  183 ++
 .../org/qi4j/envisage/detail/MethodPane.form    |   61 +
 .../org/qi4j/envisage/detail/MethodPane.java    |  357 ++++
 .../java/org/qi4j/envisage/detail/SPIPane.form  |   39 +
 .../java/org/qi4j/envisage/detail/SPIPane.java  |  293 +++
 .../detail/ServiceConfigurationPane.form        |  127 ++
 .../detail/ServiceConfigurationPane.java        |  350 ++++
 .../qi4j/envisage/detail/ServiceUsagePane.form  |   39 +
 .../qi4j/envisage/detail/ServiceUsagePane.java  |  335 ++++
 .../org/qi4j/envisage/detail/StatePane.form     |   61 +
 .../org/qi4j/envisage/detail/StatePane.java     |  379 ++++
 .../java/org/qi4j/envisage/detail/package.html  |   21 +
 .../java/org/qi4j/envisage/event/LinkEvent.java |   41 +
 .../org/qi4j/envisage/event/LinkListener.java   |   26 +
 .../java/org/qi4j/envisage/event/package.html   |   21 +
 .../org/qi4j/envisage/graph/GraphBuilder.java   |  270 +++
 .../org/qi4j/envisage/graph/GraphDisplay.java   |   82 +
 .../java/org/qi4j/envisage/graph/GraphPane.java |  164 ++
 .../envisage/graph/StackedGraphDisplay.java     |  580 ++++++
 .../org/qi4j/envisage/graph/StackedLayout.java  |  221 +++
 .../qi4j/envisage/graph/TreeGraphDisplay.java   |  388 ++++
 .../java/org/qi4j/envisage/graph/package.html   |   21 +
 .../main/java/org/qi4j/envisage/package.html    |   21 +
 .../java/org/qi4j/envisage/print/PDFWriter.java |  825 ++++++++
 .../qi4j/envisage/print/PrintingException.java  |   27 +
 .../java/org/qi4j/envisage/print/package.html   |   21 +
 .../envisage/tree/StructureModelBuilder.java    |  152 ++
 .../envisage/tree/TreeModelCellRenderer.java    |  153 ++
 .../org/qi4j/envisage/tree/TreeModelPane.java   |  301 +++
 .../qi4j/envisage/tree/TypeModelBuilder.java    |  152 ++
 .../java/org/qi4j/envisage/tree/package.html    |   21 +
 .../org/qi4j/envisage/util/ColorUtilities.java  |   58 +
 .../java/org/qi4j/envisage/util/TableRow.java   |   68 +
 .../qi4j/envisage/util/TableRowUtilities.java   |   61 +
 .../java/org/qi4j/envisage/util/package.html    |   21 +
 .../zest/envisage/EnvisageFrame.properties      |   16 -
 .../zest/envisage/detail/APIPane.properties     |   18 -
 .../envisage/detail/DependencyPane.properties   |   23 -
 .../envisage/detail/DetailModelPane.properties  |   24 -
 .../zest/envisage/detail/GeneralPane.properties |   17 -
 .../envisage/detail/ImportedByPane.properties   |   17 -
 .../zest/envisage/detail/MethodPane.properties  |   17 -
 .../zest/envisage/detail/SPIPane.properties     |   18 -
 .../detail/ServiceConfigurationPane.properties  |   19 -
 .../envisage/detail/ServiceUsagePane.properties |   20 -
 .../zest/envisage/detail/StatePane.properties   |   17 -
 .../org/apache/zest/envisage/detail/private.png |  Bin 506 -> 0 bytes
 .../org/apache/zest/envisage/detail/public.png  |  Bin 514 -> 0 bytes
 .../tree/TreeModelCellRenderer.properties       |   24 -
 .../zest/envisage/tree/TreeModelPane.properties |   16 -
 .../apache/zest/envisage/tree/application.png   |  Bin 625 -> 0 bytes
 .../org/apache/zest/envisage/tree/entity.png    |  Bin 627 -> 0 bytes
 .../zest/envisage/tree/importedService.png      |  Bin 766 -> 0 bytes
 .../org/apache/zest/envisage/tree/layer.png     |  Bin 697 -> 0 bytes
 .../org/apache/zest/envisage/tree/module.png    |  Bin 729 -> 0 bytes
 .../org/apache/zest/envisage/tree/object.png    |  Bin 737 -> 0 bytes
 .../org/apache/zest/envisage/tree/service.png   |  Bin 803 -> 0 bytes
 .../org/apache/zest/envisage/tree/transient.png |  Bin 761 -> 0 bytes
 .../org/apache/zest/envisage/tree/value.png     |  Bin 620 -> 0 bytes
 .../org/qi4j/envisage/EnvisageFrame.properties  |   16 +
 .../org/qi4j/envisage/detail/APIPane.properties |   18 +
 .../envisage/detail/DependencyPane.properties   |   23 +
 .../envisage/detail/DetailModelPane.properties  |   24 +
 .../qi4j/envisage/detail/GeneralPane.properties |   17 +
 .../envisage/detail/ImportedByPane.properties   |   17 +
 .../qi4j/envisage/detail/MethodPane.properties  |   17 +
 .../org/qi4j/envisage/detail/SPIPane.properties |   18 +
 .../detail/ServiceConfigurationPane.properties  |   19 +
 .../envisage/detail/ServiceUsagePane.properties |   20 +
 .../qi4j/envisage/detail/StatePane.properties   |   17 +
 .../org/qi4j/envisage/detail/private.png        |  Bin 0 -> 506 bytes
 .../org/qi4j/envisage/detail/public.png         |  Bin 0 -> 514 bytes
 .../tree/TreeModelCellRenderer.properties       |   24 +
 .../qi4j/envisage/tree/TreeModelPane.properties |   16 +
 .../org/qi4j/envisage/tree/application.png      |  Bin 0 -> 625 bytes
 .../resources/org/qi4j/envisage/tree/entity.png |  Bin 0 -> 627 bytes
 .../org/qi4j/envisage/tree/importedService.png  |  Bin 0 -> 766 bytes
 .../resources/org/qi4j/envisage/tree/layer.png  |  Bin 0 -> 697 bytes
 .../resources/org/qi4j/envisage/tree/module.png |  Bin 0 -> 729 bytes
 .../resources/org/qi4j/envisage/tree/object.png |  Bin 0 -> 737 bytes
 .../org/qi4j/envisage/tree/service.png          |  Bin 0 -> 803 bytes
 .../org/qi4j/envisage/tree/transient.png        |  Bin 0 -> 761 bytes
 .../resources/org/qi4j/envisage/tree/value.png  |  Bin 0 -> 620 bytes
 .../zest/envisage/sample/EnvisageSample.java    |  151 --
 .../envisage/school/EnvisageSchoolSample.java   |   38 -
 .../zest/envisage/school/SchoolAssembler.java   |  108 --
 .../school/config/mail/MailConfigAssembler.java |   33 -
 .../school/config/mail/MailConfiguration.java   |   29 -
 .../persistence/PersistenceConfigAssembler.java |   40 -
 .../envisage/school/domain/person/Person.java   |   30 -
 .../envisage/school/domain/person/Role.java     |   22 -
 .../domain/person/assembly/PersonEntity.java    |   73 -
 .../person/assembly/PersonModelAssembler.java   |   43 -
 .../initialdata/SamplePersonInitialData.java    |  107 -
 .../envisage/school/domain/school/School.java   |   34 -
 .../school/domain/school/SchoolRepository.java  |   28 -
 .../envisage/school/domain/school/Student.java  |   29 -
 .../envisage/school/domain/school/Subject.java  |   28 -
 .../domain/school/assembly/SchoolEntity.java    |  117 --
 .../school/assembly/SchoolModelAssembler.java   |   44 -
 .../assembly/SchoolRepositoryService.java       |   64 -
 .../domain/school/assembly/StudentEntity.java   |   63 -
 .../domain/school/assembly/SubjectEntity.java   |   69 -
 .../school/infrastructure/mail/Mail.java        |   36 -
 .../school/infrastructure/mail/MailService.java |   27 -
 .../mail/assembly/MailServiceAssembler.java     |   41 -
 .../mail/assembly/MailServiceComposite.java     |   52 -
 .../infrastructure/mail/assembly/MailValue.java |   26 -
 .../persistence/PersistenceAssembler.java       |   50 -
 .../school/ui/admin/AdminAssembler.java         |   43 -
 .../school/ui/admin/pages/ListUserPage.java     |   25 -
 .../school/ui/admin/pages/UserDetailPage.java   |   32 -
 .../composites/ListSchoolsPageComposite.java    |   56 -
 .../pages/composites/ListUserPageComposite.java |   26 -
 .../composites/UserDetailPageComposite.java     |   26 -
 .../pages/mixins/AuthenticationConcern.java     |   42 -
 .../ui/admin/pages/mixins/DetailPage.java       |   24 -
 .../school/ui/admin/pages/mixins/Page.java      |   26 -
 .../school/ui/admin/pages/mixins/PageMixin.java |   28 -
 .../admin/pages/mixins/UserDetailPageMixin.java |   49 -
 .../qi4j/envisage/sample/EnvisageSample.java    |  151 ++
 .../envisage/school/EnvisageSchoolSample.java   |   38 +
 .../qi4j/envisage/school/SchoolAssembler.java   |  108 ++
 .../school/config/mail/MailConfigAssembler.java |   33 +
 .../school/config/mail/MailConfiguration.java   |   29 +
 .../persistence/PersistenceConfigAssembler.java |   40 +
 .../envisage/school/domain/person/Person.java   |   30 +
 .../envisage/school/domain/person/Role.java     |   22 +
 .../domain/person/assembly/PersonEntity.java    |   73 +
 .../person/assembly/PersonModelAssembler.java   |   43 +
 .../initialdata/SamplePersonInitialData.java    |  107 +
 .../envisage/school/domain/school/School.java   |   34 +
 .../school/domain/school/SchoolRepository.java  |   28 +
 .../envisage/school/domain/school/Student.java  |   29 +
 .../envisage/school/domain/school/Subject.java  |   28 +
 .../domain/school/assembly/SchoolEntity.java    |  117 ++
 .../school/assembly/SchoolModelAssembler.java   |   44 +
 .../assembly/SchoolRepositoryService.java       |   64 +
 .../domain/school/assembly/StudentEntity.java   |   63 +
 .../domain/school/assembly/SubjectEntity.java   |   69 +
 .../school/infrastructure/mail/Mail.java        |   36 +
 .../school/infrastructure/mail/MailService.java |   27 +
 .../mail/assembly/MailServiceAssembler.java     |   41 +
 .../mail/assembly/MailServiceComposite.java     |   52 +
 .../infrastructure/mail/assembly/MailValue.java |   26 +
 .../persistence/PersistenceAssembler.java       |   50 +
 .../school/ui/admin/AdminAssembler.java         |   43 +
 .../school/ui/admin/pages/ListUserPage.java     |   25 +
 .../school/ui/admin/pages/UserDetailPage.java   |   32 +
 .../composites/ListSchoolsPageComposite.java    |   56 +
 .../pages/composites/ListUserPageComposite.java |   26 +
 .../composites/UserDetailPageComposite.java     |   26 +
 .../pages/mixins/AuthenticationConcern.java     |   42 +
 .../ui/admin/pages/mixins/DetailPage.java       |   24 +
 .../school/ui/admin/pages/mixins/Page.java      |   26 +
 .../school/ui/admin/pages/mixins/PageMixin.java |   28 +
 .../admin/pages/mixins/UserDetailPageMixin.java |   49 +
 .../descriptor/ActivateeDetailDescriptor.java   |   29 -
 .../descriptor/ActivatorDetailDescriptor.java   |  176 --
 .../descriptor/ApplicationDetailDescriptor.java |  113 --
 .../ApplicationDetailDescriptorBuilder.java     |  484 -----
 .../descriptor/CompositeDetailDescriptor.java   |  144 --
 .../CompositeMethodDetailDescriptor.java        |  134 --
 .../descriptor/ConstructorDetailDescriptor.java |  145 --
 .../descriptor/EntityDetailDescriptor.java      |   43 -
 .../ImportedServiceCompositeDescriptor.java     |   96 -
 .../ImportedServiceDetailDescriptor.java        |   74 -
 .../descriptor/InjectableDetailDescriptor.java  |   42 -
 .../InjectedFieldDetailDescriptor.java          |  129 --
 .../InjectedMethodDetailDescriptor.java         |  142 --
 .../InjectedParametersDetailDescriptor.java     |   85 -
 .../model/descriptor/LayerDetailDescriptor.java |  163 --
 .../MethodConcernDetailDescriptor.java          |  140 --
 .../MethodConcernsDetailDescriptor.java         |   84 -
 .../MethodConstraintDetailDescriptor.java       |   70 -
 .../MethodConstraintsDetailDescriptor.java      |   86 -
 .../MethodSideEffectDetailDescriptor.java       |  139 --
 .../MethodSideEffectsDetailDescriptor.java      |   86 -
 .../model/descriptor/MixinDetailDescriptor.java |  136 --
 .../descriptor/ModuleDetailDescriptor.java      |  244 ---
 .../descriptor/ObjectDetailDescriptor.java      |  129 --
 .../descriptor/ServiceDetailDescriptor.java     |   99 -
 .../tools/model/descriptor/ServiceUsage.java    |   59 -
 .../descriptor/TransientDetailDescriptor.java   |   40 -
 .../model/descriptor/ValueDetailDescriptor.java |   43 -
 .../zest/tools/model/descriptor/package.html    |   21 -
 .../apache/zest/tools/model/util/APIFinder.java |   55 -
 .../model/util/DescriptorNameComparator.java    |   34 -
 .../tools/model/util/DescriptorUtilities.java   |  134 --
 .../zest/tools/model/util/MethodFinder.java     |  114 --
 .../apache/zest/tools/model/util/SPIFinder.java |  169 --
 .../model/util/ServiceConfigurationFinder.java  |  157 --
 .../tools/model/util/ServiceUsageFinder.java    |  161 --
 .../zest/tools/model/util/StateFinder.java      |   95 -
 .../apache/zest/tools/model/util/package.html   |   21 -
 .../descriptor/ActivateeDetailDescriptor.java   |   29 +
 .../descriptor/ActivatorDetailDescriptor.java   |  176 ++
 .../descriptor/ApplicationDetailDescriptor.java |  113 ++
 .../ApplicationDetailDescriptorBuilder.java     |  484 +++++
 .../descriptor/CompositeDetailDescriptor.java   |  144 ++
 .../CompositeMethodDetailDescriptor.java        |  134 ++
 .../descriptor/ConstructorDetailDescriptor.java |  145 ++
 .../descriptor/EntityDetailDescriptor.java      |   43 +
 .../ImportedServiceCompositeDescriptor.java     |   96 +
 .../ImportedServiceDetailDescriptor.java        |   74 +
 .../descriptor/InjectableDetailDescriptor.java  |   42 +
 .../InjectedFieldDetailDescriptor.java          |  129 ++
 .../InjectedMethodDetailDescriptor.java         |  142 ++
 .../InjectedParametersDetailDescriptor.java     |   85 +
 .../model/descriptor/LayerDetailDescriptor.java |  163 ++
 .../MethodConcernDetailDescriptor.java          |  140 ++
 .../MethodConcernsDetailDescriptor.java         |   84 +
 .../MethodConstraintDetailDescriptor.java       |   70 +
 .../MethodConstraintsDetailDescriptor.java      |   86 +
 .../MethodSideEffectDetailDescriptor.java       |  139 ++
 .../MethodSideEffectsDetailDescriptor.java      |   86 +
 .../model/descriptor/MixinDetailDescriptor.java |  136 ++
 .../descriptor/ModuleDetailDescriptor.java      |  244 +++
 .../descriptor/ObjectDetailDescriptor.java      |  129 ++
 .../descriptor/ServiceDetailDescriptor.java     |   99 +
 .../tools/model/descriptor/ServiceUsage.java    |   59 +
 .../descriptor/TransientDetailDescriptor.java   |   40 +
 .../model/descriptor/ValueDetailDescriptor.java |   43 +
 .../qi4j/tools/model/descriptor/package.html    |   21 +
 .../org/qi4j/tools/model/util/APIFinder.java    |   55 +
 .../model/util/DescriptorNameComparator.java    |   34 +
 .../tools/model/util/DescriptorUtilities.java   |  134 ++
 .../org/qi4j/tools/model/util/MethodFinder.java |  114 ++
 .../org/qi4j/tools/model/util/SPIFinder.java    |  169 ++
 .../model/util/ServiceConfigurationFinder.java  |  157 ++
 .../tools/model/util/ServiceUsageFinder.java    |  161 ++
 .../org/qi4j/tools/model/util/StateFinder.java  |   95 +
 .../java/org/qi4j/tools/model/util/package.html |   21 +
 .../zest/tools/model/VisitableDetailTest.java   |  148 --
 .../qi4j/tools/model/VisitableDetailTest.java   |  148 ++
 .../fileTemplates/j2ee/GenericConcernOf.java.ft |    3 +-
 .../zest/tools/shell/AbstractCommand.java       |   30 -
 .../org/apache/zest/tools/shell/Command.java    |   32 -
 .../org/apache/zest/tools/shell/FileUtils.java  |   69 -
 .../zest/tools/shell/HelpNeededException.java   |   23 -
 .../java/org/apache/zest/tools/shell/Main.java  |   79 -
 .../zest/tools/shell/create/CreateProject.java  |   60 -
 .../zest/tools/shell/help/HelpCommand.java      |   59 -
 .../org/qi4j/tools/shell/AbstractCommand.java   |   30 +
 .../main/java/org/qi4j/tools/shell/Command.java |   32 +
 .../java/org/qi4j/tools/shell/FileUtils.java    |   69 +
 .../qi4j/tools/shell/HelpNeededException.java   |   23 +
 .../main/java/org/qi4j/tools/shell/Main.java    |   79 +
 .../qi4j/tools/shell/create/CreateProject.java  |   61 +
 .../org/qi4j/tools/shell/help/HelpCommand.java  |   59 +
 .../apache/zest/tutorials/cargo/package.html    |   43 -
 .../tutorials/cargo/step1/BookingPolicy.java    |   23 -
 .../zest/tutorials/cargo/step1/Cargo.java       |   23 -
 .../cargo/step1/OverbookingPolicy.java          |   28 -
 .../cargo/step1/SequenceGenerator.java          |   23 -
 .../tutorials/cargo/step1/ShippingService.java  |   23 -
 .../zest/tutorials/cargo/step1/Voyage.java      |   25 -
 .../cargo/step1/internal/CargoImpl.java         |   37 -
 .../step1/internal/ShippingServiceImpl.java     |   55 -
 .../step1/internal/SimpleSequenceImpl.java      |   32 -
 .../cargo/step1/internal/VoyageImpl.java        |   62 -
 .../zest/tutorials/cargo/step1/package.html     |   98 -
 .../zest/tutorials/cargo/step2/Cargo.java       |   27 -
 .../tutorials/cargo/step2/CargoComposite.java   |   25 -
 .../zest/tutorials/cargo/step2/HasSequence.java |   23 -
 .../cargo/step2/OverbookingConcern.java         |   40 -
 .../cargo/step2/SequencingConcern.java          |   44 -
 .../tutorials/cargo/step2/ShippingService.java  |   26 -
 .../cargo/step2/ShippingServiceComposite.java   |   27 -
 .../cargo/step2/ShippingServiceMixin.java       |   30 -
 .../zest/tutorials/cargo/step2/Voyage.java      |   27 -
 .../tutorials/cargo/step2/VoyageComposite.java  |   25 -
 .../zest/tutorials/cargo/step2/package.html     |   72 -
 .../java/org/qi4j/tutorials/cargo/package.html  |   43 +
 .../tutorials/cargo/step1/BookingPolicy.java    |   23 +
 .../org/qi4j/tutorials/cargo/step1/Cargo.java   |   23 +
 .../cargo/step1/OverbookingPolicy.java          |   28 +
 .../cargo/step1/SequenceGenerator.java          |   23 +
 .../tutorials/cargo/step1/ShippingService.java  |   23 +
 .../org/qi4j/tutorials/cargo/step1/Voyage.java  |   25 +
 .../cargo/step1/internal/CargoImpl.java         |   37 +
 .../step1/internal/ShippingServiceImpl.java     |   55 +
 .../step1/internal/SimpleSequenceImpl.java      |   32 +
 .../cargo/step1/internal/VoyageImpl.java        |   62 +
 .../org/qi4j/tutorials/cargo/step1/package.html |   98 +
 .../org/qi4j/tutorials/cargo/step2/Cargo.java   |   27 +
 .../tutorials/cargo/step2/CargoComposite.java   |   25 +
 .../qi4j/tutorials/cargo/step2/HasSequence.java |   23 +
 .../cargo/step2/OverbookingConcern.java         |   40 +
 .../cargo/step2/SequencingConcern.java          |   44 +
 .../tutorials/cargo/step2/ShippingService.java  |   26 +
 .../cargo/step2/ShippingServiceComposite.java   |   27 +
 .../cargo/step2/ShippingServiceMixin.java       |   30 +
 .../org/qi4j/tutorials/cargo/step2/Voyage.java  |   27 +
 .../tutorials/cargo/step2/VoyageComposite.java  |   25 +
 .../org/qi4j/tutorials/cargo/step2/package.html |   72 +
 .../tutorials/cargo/step1/Step1TestCase.java    |   85 -
 .../cargo/step2/SequencingConcernTest.java      |  122 --
 .../tutorials/cargo/step2/Step2TestCase.java    |  101 -
 .../tutorials/cargo/step1/Step1TestCase.java    |   85 +
 .../cargo/step2/SequencingConcernTest.java      |  122 ++
 .../tutorials/cargo/step2/Step2TestCase.java    |  101 +
 .../zest/tutorials/composites/package.html      |   48 -
 .../composites/tutorial1/HelloWorld.java        |   69 -
 .../tutorials/composites/tutorial1/package.html |   46 -
 .../tutorial10/HelloWorldComposite.java         |   40 -
 .../composites/tutorial10/HelloWorldMixin.java  |   42 -
 .../composites/tutorial10/HelloWorldState.java  |   38 -
 .../composites/tutorial2/HelloWorld.java        |   34 -
 .../tutorial2/HelloWorldBehaviour.java          |   31 -
 .../composites/tutorial2/HelloWorldMixin.java   |   75 -
 .../composites/tutorial2/HelloWorldState.java   |   42 -
 .../tutorials/composites/tutorial2/package.html |   41 -
 .../composites/tutorial3/HelloWorld.java        |   31 -
 .../tutorial3/HelloWorldBehaviour.java          |   28 -
 .../tutorial3/HelloWorldComposite.java          |   37 -
 .../composites/tutorial3/HelloWorldMixin.java   |   64 -
 .../composites/tutorial3/HelloWorldState.java   |   39 -
 .../tutorials/composites/tutorial3/package.html |   38 -
 .../composites/tutorial4/HelloWorld.java        |   31 -
 .../tutorial4/HelloWorldBehaviour.java          |   36 -
 .../tutorial4/HelloWorldBehaviourMixin.java     |   47 -
 .../tutorial4/HelloWorldComposite.java          |   39 -
 .../composites/tutorial4/HelloWorldState.java   |   45 -
 .../tutorial4/HelloWorldStateMixin.java         |   57 -
 .../tutorials/composites/tutorial4/package.html |   56 -
 .../composites/tutorial5/HelloWorld.java        |   31 -
 .../tutorial5/HelloWorldBehaviour.java          |   34 -
 .../tutorial5/HelloWorldBehaviourConcern.java   |   38 -
 .../tutorial5/HelloWorldBehaviourMixin.java     |   50 -
 .../tutorial5/HelloWorldComposite.java          |   36 -
 .../composites/tutorial5/HelloWorldState.java   |   42 -
 .../tutorial5/HelloWorldStateMixin.java         |   54 -
 .../tutorials/composites/tutorial5/package.html |   60 -
 .../composites/tutorial6/HelloWorld.java        |   31 -
 .../tutorial6/HelloWorldBehaviour.java          |   40 -
 .../tutorial6/HelloWorldBehaviourConcern.java   |   39 -
 .../tutorial6/HelloWorldBehaviourMixin.java     |   48 -
 .../tutorial6/HelloWorldComposite.java          |   36 -
 .../composites/tutorial6/HelloWorldState.java   |   47 -
 .../tutorial6/HelloWorldStateMixin.java         |   54 -
 .../tutorials/composites/tutorial6/package.html |   55 -
 .../composites/tutorial7/HelloWorld.java        |   31 -
 .../tutorial7/HelloWorldBehaviour.java          |   31 -
 .../tutorial7/HelloWorldBehaviourMixin.java     |   45 -
 .../HelloWorldBehaviourSideEffect.java          |   39 -
 .../tutorial7/HelloWorldComposite.java          |   40 -
 .../composites/tutorial7/HelloWorldState.java   |   45 -
 .../tutorial7/HelloWorldStateMixin.java         |   54 -
 .../tutorials/composites/tutorial7/package.html |   69 -
 .../tutorial8/HelloWorldBehaviour.java          |   28 -
 .../tutorial8/HelloWorldBehaviourMixin.java     |   44 -
 .../tutorial8/HelloWorldComposite.java          |   35 -
 .../composites/tutorial8/HelloWorldState.java   |   42 -
 .../tutorial8/HelloWorldStateMixin.java         |   50 -
 .../tutorials/composites/tutorial8/package.html |   57 -
 .../tutorial9/GenericPropertyMixin.java         |   53 -
 .../tutorial9/HelloWorldBehaviour.java          |   28 -
 .../tutorial9/HelloWorldBehaviourMixin.java     |   41 -
 .../tutorial9/HelloWorldComposite.java          |   40 -
 .../composites/tutorial9/HelloWorldState.java   |   39 -
 .../tutorials/composites/tutorial9/package.html |   70 -
 .../org/qi4j/tutorials/composites/package.html  |   48 +
 .../composites/tutorial1/HelloWorld.java        |   69 +
 .../tutorials/composites/tutorial1/package.html |   46 +
 .../tutorial10/HelloWorldComposite.java         |   40 +
 .../composites/tutorial10/HelloWorldMixin.java  |   42 +
 .../composites/tutorial10/HelloWorldState.java  |   38 +
 .../composites/tutorial2/HelloWorld.java        |   34 +
 .../tutorial2/HelloWorldBehaviour.java          |   31 +
 .../composites/tutorial2/HelloWorldMixin.java   |   75 +
 .../composites/tutorial2/HelloWorldState.java   |   42 +
 .../tutorials/composites/tutorial2/package.html |   41 +
 .../composites/tutorial3/HelloWorld.java        |   31 +
 .../tutorial3/HelloWorldBehaviour.java          |   28 +
 .../tutorial3/HelloWorldComposite.java          |   37 +
 .../composites/tutorial3/HelloWorldMixin.java   |   64 +
 .../composites/tutorial3/HelloWorldState.java   |   39 +
 .../tutorials/composites/tutorial3/package.html |   38 +
 .../composites/tutorial4/HelloWorld.java        |   31 +
 .../tutorial4/HelloWorldBehaviour.java          |   36 +
 .../tutorial4/HelloWorldBehaviourMixin.java     |   47 +
 .../tutorial4/HelloWorldComposite.java          |   39 +
 .../composites/tutorial4/HelloWorldState.java   |   45 +
 .../tutorial4/HelloWorldStateMixin.java         |   57 +
 .../tutorials/composites/tutorial4/package.html |   56 +
 .../composites/tutorial5/HelloWorld.java        |   31 +
 .../tutorial5/HelloWorldBehaviour.java          |   34 +
 .../tutorial5/HelloWorldBehaviourConcern.java   |   38 +
 .../tutorial5/HelloWorldBehaviourMixin.java     |   50 +
 .../tutorial5/HelloWorldComposite.java          |   36 +
 .../composites/tutorial5/HelloWorldState.java   |   42 +
 .../tutorial5/HelloWorldStateMixin.java         |   54 +
 .../tutorials/composites/tutorial5/package.html |   60 +
 .../composites/tutorial6/HelloWorld.java        |   31 +
 .../tutorial6/HelloWorldBehaviour.java          |   40 +
 .../tutorial6/HelloWorldBehaviourConcern.java   |   39 +
 .../tutorial6/HelloWorldBehaviourMixin.java     |   48 +
 .../tutorial6/HelloWorldComposite.java          |   36 +
 .../composites/tutorial6/HelloWorldState.java   |   47 +
 .../tutorial6/HelloWorldStateMixin.java         |   54 +
 .../tutorials/composites/tutorial6/package.html |   55 +
 .../composites/tutorial7/HelloWorld.java        |   31 +
 .../tutorial7/HelloWorldBehaviour.java          |   31 +
 .../tutorial7/HelloWorldBehaviourMixin.java     |   45 +
 .../HelloWorldBehaviourSideEffect.java          |   39 +
 .../tutorial7/HelloWorldComposite.java          |   40 +
 .../composites/tutorial7/HelloWorldState.java   |   45 +
 .../tutorial7/HelloWorldStateMixin.java         |   54 +
 .../tutorials/composites/tutorial7/package.html |   69 +
 .../tutorial8/HelloWorldBehaviour.java          |   28 +
 .../tutorial8/HelloWorldBehaviourMixin.java     |   44 +
 .../tutorial8/HelloWorldComposite.java          |   35 +
 .../composites/tutorial8/HelloWorldState.java   |   42 +
 .../tutorial8/HelloWorldStateMixin.java         |   50 +
 .../tutorials/composites/tutorial8/package.html |   57 +
 .../tutorial9/GenericPropertyMixin.java         |   53 +
 .../tutorial9/HelloWorldBehaviour.java          |   28 +
 .../tutorial9/HelloWorldBehaviourMixin.java     |   41 +
 .../tutorial9/HelloWorldComposite.java          |   40 +
 .../composites/tutorial9/HelloWorldState.java   |   39 +
 .../tutorials/composites/tutorial9/package.html |   70 +
 .../composites/tutorial1/HelloWorldTest.java    |   84 -
 .../composites/tutorial10/HelloWorldTest.java   |  138 --
 .../composites/tutorial2/HelloWorldTest.java    |   84 -
 .../composites/tutorial3/HelloWorldTest.java    |   97 -
 .../composites/tutorial4/HelloWorldTest.java    |   96 -
 .../composites/tutorial5/HelloWorldTest.java    |   96 -
 .../composites/tutorial6/HelloWorldTest.java    |  116 --
 .../composites/tutorial7/HelloWorldTest.java    |  116 --
 .../composites/tutorial8/HelloWorldTest.java    |  115 --
 .../composites/tutorial9/HelloWorldTest.java    |  115 --
 .../composites/tutorial1/HelloWorldTest.java    |   84 +
 .../composites/tutorial10/HelloWorldTest.java   |  138 ++
 .../composites/tutorial2/HelloWorldTest.java    |   84 +
 .../composites/tutorial3/HelloWorldTest.java    |   97 +
 .../composites/tutorial4/HelloWorldTest.java    |   96 +
 .../composites/tutorial5/HelloWorldTest.java    |   96 +
 .../composites/tutorial6/HelloWorldTest.java    |  116 ++
 .../composites/tutorial7/HelloWorldTest.java    |  116 ++
 .../composites/tutorial8/HelloWorldTest.java    |  115 ++
 .../composites/tutorial9/HelloWorldTest.java    |  115 ++
 .../org/apache/zest/tutorials/hello/Hello.java  |   65 -
 .../java/org/qi4j/tutorials/hello/Hello.java    |   65 +
 .../apache/zest/tutorials/hello/HelloTest.java  |   54 -
 .../apache/zest/tutorials/hello/HelloTest2.java |   44 -
 .../apache/zest/tutorials/hello/HelloTest3.java |   44 -
 .../apache/zest/tutorials/hello/HelloTest4.java |   59 -
 .../org/qi4j/tutorials/hello/HelloTest.java     |   54 +
 .../org/qi4j/tutorials/hello/HelloTest2.java    |   44 +
 .../org/qi4j/tutorials/hello/HelloTest3.java    |   44 +
 .../org/qi4j/tutorials/hello/HelloTest4.java    |   59 +
 .../zest/demo/intro/StateModelingDocs.java      |  136 --
 .../zest/demo/intro/WhatsAnObjectDocs.java      |   77 -
 .../org/qi4j/demo/intro/StateModelingDocs.java  |  138 ++
 .../org/qi4j/demo/intro/WhatsAnObjectDocs.java  |   77 +
 .../apache/zest/demo/tenminute/Confirmable.java |   22 -
 .../apache/zest/demo/tenminute/HasCustomer.java |   24 -
 .../zest/demo/tenminute/HasLineItems.java       |   25 -
 .../zest/demo/tenminute/HasSequenceNumber.java  |   24 -
 .../zest/demo/tenminute/InventoryConcern.java   |   48 -
 .../apache/zest/demo/tenminute/LineItem.java    |   28 -
 .../demo/tenminute/MailNotifySideEffect.java    |   55 -
 .../org/apache/zest/demo/tenminute/Order.java   |   25 -
 .../apache/zest/demo/tenminute/OrderEntity.java |   34 -
 .../demo/tenminute/PurchaseLimitConcern.java    |   21 -
 .../elsewhere/inventory/InventoryService.java   |   24 -
 .../apache/zest/elsewhere/mail/MailService.java |   22 -
 .../org/qi4j/demo/tenminute/Confirmable.java    |   22 +
 .../org/qi4j/demo/tenminute/HasCustomer.java    |   24 +
 .../org/qi4j/demo/tenminute/HasLineItems.java   |   25 +
 .../qi4j/demo/tenminute/HasSequenceNumber.java  |   24 +
 .../qi4j/demo/tenminute/InventoryConcern.java   |   48 +
 .../java/org/qi4j/demo/tenminute/LineItem.java  |   28 +
 .../demo/tenminute/MailNotifySideEffect.java    |   55 +
 .../java/org/qi4j/demo/tenminute/Order.java     |   25 +
 .../org/qi4j/demo/tenminute/OrderEntity.java    |   34 +
 .../demo/tenminute/PurchaseLimitConcern.java    |   21 +
 .../elsewhere/inventory/InventoryService.java   |   24 +
 .../org/qi4j/elsewhere/mail/MailService.java    |   22 +
 .../demo/thirtyminutes/ThirtyMinutesDocs.java   |  292 ---
 .../demo/thirtyminutes/ThirtyMinutesDocs.java   |  292 +++
 .../org/apache/zest/demo/twominute/Main.java    |   44 -
 .../org/apache/zest/demo/twominute/Speaker.java |   29 -
 .../zest/demo/twominute/SpeakerMixin.java       |   31 -
 .../main/java/org/qi4j/demo/twominute/Main.java |   44 +
 .../java/org/qi4j/demo/twominute/Speaker.java   |   29 +
 .../org/qi4j/demo/twominute/SpeakerMixin.java   |   31 +
 .../zest/tutorials/services/step1/Book.java     |   40 -
 .../zest/tutorials/services/step1/Consumer.java |   35 -
 .../zest/tutorials/services/step1/Library.java  |   33 -
 .../zest/tutorials/services/step1/package.html  |   47 -
 .../zest/tutorials/services/step2/Book.java     |   29 -
 .../zest/tutorials/services/step2/Consumer.java |   33 -
 .../zest/tutorials/services/step2/Library.java  |   26 -
 .../tutorials/services/step2/LibraryMixin.java  |   47 -
 .../services/step2/LibraryService.java          |   28 -
 .../zest/tutorials/services/step2/package.html  |   58 -
 .../zest/tutorials/services/step3/Book.java     |   29 -
 .../zest/tutorials/services/step3/Consumer.java |   33 -
 .../zest/tutorials/services/step3/Library.java  |   28 -
 .../services/step3/LibraryActivator.java        |   34 -
 .../tutorials/services/step3/LibraryMixin.java  |  102 -
 .../services/step3/LibraryService.java          |   30 -
 .../zest/tutorials/services/step3/package.html  |   74 -
 .../zest/tutorials/services/step4/Book.java     |   29 -
 .../zest/tutorials/services/step4/Consumer.java |   33 -
 .../zest/tutorials/services/step4/Library.java  |   26 -
 .../services/step4/LibraryConfiguration.java    |   31 -
 .../tutorials/services/step4/LibraryMixin.java  |  106 -
 .../services/step4/LibraryService.java          |   28 -
 .../zest/tutorials/services/step5/Book.java     |   29 -
 .../zest/tutorials/services/step5/Consumer.java |   33 -
 .../zest/tutorials/services/step5/Library.java  |   26 -
 .../services/step5/LibraryService.java          |  129 --
 .../zest/tutorials/services/step6/Book.java     |   29 -
 .../zest/tutorials/services/step6/Consumer.java |   33 -
 .../zest/tutorials/services/step6/Library.java  |   26 -
 .../services/step6/LibraryService.java          |  121 --
 .../org/qi4j/tutorials/services/step1/Book.java |   40 +
 .../qi4j/tutorials/services/step1/Consumer.java |   35 +
 .../qi4j/tutorials/services/step1/Library.java  |   33 +
 .../qi4j/tutorials/services/step1/package.html  |   47 +
 .../org/qi4j/tutorials/services/step2/Book.java |   29 +
 .../qi4j/tutorials/services/step2/Consumer.java |   33 +
 .../qi4j/tutorials/services/step2/Library.java  |   26 +
 .../tutorials/services/step2/LibraryMixin.java  |   47 +
 .../services/step2/LibraryService.java          |   28 +
 .../qi4j/tutorials/services/step2/package.html  |   58 +
 .../org/qi4j/tutorials/services/step3/Book.java |   29 +
 .../qi4j/tutorials/services/step3/Consumer.java |   33 +
 .../qi4j/tutorials/services/step3/Library.java  |   28 +
 .../services/step3/LibraryActivator.java        |   34 +
 .../tutorials/services/step3/LibraryMixin.java  |  102 +
 .../services/step3/LibraryService.java          |   30 +
 .../qi4j/tutorials/services/step3/package.html  |   74 +
 .../org/qi4j/tutorials/services/step4/Book.java |   29 +
 .../qi4j/tutorials/services/step4/Consumer.java |   33 +
 .../qi4j/tutorials/services/step4/Library.java  |   26 +
 .../services/step4/LibraryConfiguration.java    |   31 +
 .../tutorials/services/step4/LibraryMixin.java  |  106 +
 .../services/step4/LibraryService.java          |   28 +
 .../org/qi4j/tutorials/services/step5/Book.java |   29 +
 .../qi4j/tutorials/services/step5/Consumer.java |   33 +
 .../qi4j/tutorials/services/step5/Library.java  |   26 +
 .../services/step5/LibraryService.java          |  129 ++
 .../org/qi4j/tutorials/services/step6/Book.java |   29 +
 .../qi4j/tutorials/services/step6/Consumer.java |   33 +
 .../qi4j/tutorials/services/step6/Library.java  |   26 +
 .../services/step6/LibraryService.java          |  121 ++
 .../services/step4/LibraryService.properties    |   20 -
 .../services/step5/LibraryService.properties    |   20 -
 .../tutorials/services/step6/Library.properties |   20 -
 .../services/step4/LibraryService.properties    |   20 +
 .../services/step5/LibraryService.properties    |   20 +
 .../tutorials/services/step6/Library.properties |   20 +
 .../tutorials/services/step1/LibraryTest.java   |   31 -
 .../tutorials/services/step2/LibraryTest.java   |   44 -
 .../tutorials/services/step3/LibraryTest.java   |   44 -
 .../tutorials/services/step4/LibraryTest.java   |   47 -
 .../tutorials/services/step5/LibraryTest.java   |   47 -
 .../tutorials/services/step6/LibraryTest.java   |   47 -
 .../tutorials/services/step1/LibraryTest.java   |   31 +
 .../tutorials/services/step2/LibraryTest.java   |   44 +
 .../tutorials/services/step3/LibraryTest.java   |   44 +
 .../tutorials/services/step4/LibraryTest.java   |   47 +
 .../tutorials/services/step5/LibraryTest.java   |   47 +
 .../tutorials/services/step6/LibraryTest.java   |   47 +
 5755 files changed, 257840 insertions(+), 257499 deletions(-)
----------------------------------------------------------------------



[50/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/Documentation.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/Documentation.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/Documentation.groovy
deleted file mode 100644
index 3c06602..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/Documentation.groovy
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2011, Niclas Hedhman. 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.zest.gradle.plugin;
-
-
-import org.gradle.api.DefaultTask
-import org.gradle.api.tasks.TaskAction
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.InputDirectory
-import org.gradle.api.tasks.InputFile
-import org.gradle.api.tasks.InputFiles
-import org.gradle.api.tasks.OutputDirectory
-
-// TODO: try to use dependencies for FOP and execute within the same JVM.
-// TODO: move the bulk of resources into this plugin, instead of sitting in the project.
-class Documentation extends DefaultTask
-{
-  @Input def String docName
-  @Input def String docType
-  void setDocName( String docName ) { this.docName = docName }
-  void setDocType( String docType ) { this.docType = docType }
-
-  @InputDirectory def File getCommonResourcesDir() { project.file( 'src/resources' ) }
-  @InputDirectory def File getConfigDir() { project.file( 'src/conf' ) }
-  @InputDirectory def File getDocsDir() { project.file( 'src/docs') }
-  @InputDirectory def File getSrcMainDir() { project.file( 'src/main') }
-  @InputDirectory def File getXslDir() { project.file( 'src/xsl') }
-  @InputDirectory def File getBuildSrcDir() { project.rootProject.file( 'buildSrc/src' ) }
-
-  @InputFiles def getSubProjectsDocsDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/docs' ) } }
-  @InputFiles def getSubProjectsTestDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/test' ) } }
-
-  @OutputDirectory def File getOutputDir() { project.file( "${project.buildDir}/docs/${docName}/" ) }
-
-  def File getTempAsciidocDir() { project.file( "${project.buildDir}/tmp-asciidoc" ) }
-  def File getTempDir() { project.file( "${project.buildDir}/tmp/docs/${docName}") }
-
-  @TaskAction
-  def void generate()
-  {
-    installAsciidocFilters()
-
-    [ outputDir, tempAsciidocDir, tempDir ]*.deleteDir()
-    [ outputDir, tempAsciidocDir, tempDir ]*.mkdirs()
-
-    copySubProjectsDocsResources()
-    generateAsciidocAccordingToReleaseSpecification()
-    generateXDoc()
-    generateChunkedHtml()
-    // generateSingleHtml()
-    // generatePdf()
-  }
-
-  def void installAsciidocFilters()
-  {
-    def userHome = new File( System.getProperty( 'user.home' ) )
-    def snippetDir = new File( userHome, '.asciidoc/filters/snippet' ).absoluteFile
-    if( !snippetDir.exists() )
-    {
-      println "Installing [snippet] into $snippetDir"
-      snippetDir.mkdirs()
-      project.copy {
-        from "${project.rootDir}/buildSrc/src/bin"
-        into snippetDir
-        include 'snippet.*'
-      }
-      ant.chmod( dir: snippetDir, perm: '755', includes: 'snippet.py' )
-    }
-
-    def devstatusDir = new File( userHome, '.asciidoc/filters/devstatus' ).absoluteFile
-    if( !devstatusDir.exists() )
-    {
-      println "Installing [devstatus] into $devstatusDir"
-      snippetDir.mkdirs()
-      project.copy {
-        from "${project.rootDir}/buildSrc/src/bin"
-        into devstatusDir
-        include 'devstatus.*'
-      }
-      ant.chmod( dir: devstatusDir, perm: '755', includes: 'devstatus.py' )
-    }
-  }
-
-  def void copySubProjectsDocsResources()
-  {
-    project.rootProject.subprojects.each { p ->
-      p.copy {
-        from p.file( 'src/docs/resources' )
-        into outputDir
-        include '**'
-      }
-    }
-  }
-
-  def void generateAsciidocAccordingToReleaseSpecification()
-  {
-    project.copy {
-      from docsDir
-      into tempAsciidocDir
-      include '**'
-    }
-    if( project.version != '0' && !project.version.contains( 'SNAPSHOT' ) ) {
-      def licenseFile = new File( tempAsciidocDir, 'userguide/libraries.txt' )
-      def extensionsFile = new File( tempAsciidocDir, 'userguide/extensions.txt' )
-      def toolsFile = new File( tempAsciidocDir, 'userguide/tools.txt' )
-      [ licenseFile, extensionsFile, toolsFile ].each { asciidocFile ->
-        def filteredFileContent = ''
-        asciidocFile.readLines().each { line ->
-          if( line.startsWith( 'include::' ) ) {
-            def approved = false
-            project.rootProject.releaseApprovedProjects.collect{it.projectDir}.each { approvedProjectDir ->
-              if( line.contains( "${approvedProjectDir.parentFile.name}/${approvedProjectDir.name}" ) ) {
-                approved = true
-              }
-            }
-            if( approved ) {
-              filteredFileContent += "$line\n"
-            }
-          } else {
-            filteredFileContent += "$line\n"
-          }
-        }
-        asciidocFile.text = filteredFileContent
-      }
-    }
-  }
-
-  def void generateXDoc()
-  {
-    project.exec {
-      executable = 'asciidoc'
-      workingDir = '..'
-      def commonResourcesPath = relativePath( project.rootDir, commonResourcesDir )
-      def asciidocConfigPath = relativePath( project.rootDir, new File( configDir, 'asciidoc.conf' ) )
-      def docbookConfigPath = relativePath( project.rootDir, new File( configDir, 'docbook45.conf' ) )
-      def linkimagesConfigPath = relativePath( project.rootDir, new File( configDir, 'linkedimages.conf' ) )
-      def xdocOutputPath =  relativePath( project.rootDir, new File( tempDir, 'xdoc-temp.xml' ) )
-      def asciidocIndexPath = relativePath( project.rootDir, new File( tempAsciidocDir, "$docName/index.txt" ) )
-      args = [
-              '--attribute', 'revnumber=' + project.version,
-              '--attribute', 'level1=' + (docType.equals('article') ? 1 : 0),
-              '--attribute', 'level2=' + (docType.equals('article') ? 2 : 1),
-              '--attribute', 'level3=' + (docType.equals('article') ? 3 : 2),
-              '--attribute', 'level4=' + (docType.equals('article') ? 4 : 3),
-              '--attribute', 'importdir=' + commonResourcesPath,
-              '--backend', 'docbook',
-              '--attribute', 'docinfo1',
-              '--doctype', docType,
-              '--conf-file=' + asciidocConfigPath,
-              '--conf-file=' + docbookConfigPath,
-              '--conf-file=' + linkimagesConfigPath,
-              '--out-file', xdocOutputPath,
-              asciidocIndexPath
-      ]
-    }
-  }
-
-  def void generateChunkedHtml()
-  {
-    project.copy {
-      from commonResourcesDir
-      into outputDir
-      include '**'
-    }
-    project.copy {
-      from "$docsDir/$docName/resources"
-      into outputDir
-      include '**'
-    }
-
-    project.exec {
-      def xsltFile = "$docsDir/$docName/xsl/chunked.xsl"
-      def outputPath = relativePath( project.projectDir, outputDir ) + '/'
-      executable = 'xsltproc'
-      args = [
-              '--nonet',
-              '--noout',
-              '--output', outputPath,
-              xsltFile,
-              "$tempDir/xdoc-temp.xml"
-      ]
-    }
-  }
-
-  def void generateSingleHtml()
-  {
-    project.exec {
-      // XML_CATALOG_FILES=
-      String xsltFile = "$xslDir/xhtml.xsl"
-      executable = 'xsltproc'
-      args = [
-              '--nonet',
-              '--noout',
-              '--output', "$outputDir/${docName}.html",
-              xsltFile,
-              "$tempDir/xdoc-temp.xml"
-      ]
-    }
-  }
-
-  def void generatePdf()
-  {
-    // $ xsltproc --nonet ../docbook-xsl/fo.xsl article.xml > article.fo
-    // $ fop article.fo article.pdf
-    project.exec {
-      String xsltFile = "$xslDir/fo.xsl"
-      executable = 'xsltproc'
-      args = [
-        '--nonet',
-        '--output', "$tempDir/${docName}.fo",
-        xsltFile,
-        "$tempDir/xdoc-temp.xml"
-      ]
-    }
-    project.exec {
-      executable = 'fop'
-      args = [
-        "$tempDir/${docName}.fo",
-        "$outputDir/${docName}.pdf"
-      ]
-    }
-  }
-
-  def String relativePath( File root, File target )
-  {
-    new File( root.toURI().relativize( target.toURI() ).toString() ).path
-  }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/ModuleReleaseSpecification.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/ModuleReleaseSpecification.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/ModuleReleaseSpecification.groovy
deleted file mode 100644
index 2d4e34e..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/plugin/ModuleReleaseSpecification.groovy
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, Niclas Hedhman. 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.zest.gradle.plugin;
-
-import org.gradle.api.Project
-
-class ModuleReleaseSpecification
-{
-  def boolean satisfiedBy( Project project )
-  {
-    def devStatusFile = new File( project.projectDir, "dev-status.xml" )
-    if( !devStatusFile.exists() )
-    {
-      return false
-    }
-    def module = new XmlSlurper().parse( devStatusFile )
-    def codebase = module.status.codebase.text()
-    def docs = module.status.documentation.text()
-    def tests = module.status.unittests.text()
-    def satisfied = ( codebase == 'none' && docs == 'complete' && tests != 'complete' )
-    satisfied |= ( codebase == 'early' && ( docs == 'complete' || docs == 'good') && (tests == 'complete' || tests == 'good' ) )
-    satisfied |= ( codebase == 'beta' && (docs == 'complete' || docs == 'good' || docs == 'brief') && (tests == 'complete' || tests == 'good' || tests == 'some') )
-    satisfied |= ( codebase == 'stable' )
-    satisfied |= ( codebase == 'mature' )
-    println "$project.name($satisfied) -> $codebase, $docs, $tests"
-    return satisfied
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/Documentation.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/Documentation.groovy b/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/Documentation.groovy
new file mode 100644
index 0000000..ad8ca04
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/Documentation.groovy
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2011, Niclas Hedhman. 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.qi4j.gradle.plugin;
+
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputDirectory
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.InputFiles
+import org.gradle.api.tasks.OutputDirectory
+
+// TODO: try to use dependencies for FOP and execute within the same JVM.
+// TODO: move the bulk of resources into this plugin, instead of sitting in the project.
+class Documentation extends DefaultTask
+{
+  @Input def String docName
+  @Input def String docType
+  void setDocName( String docName ) { this.docName = docName }
+  void setDocType( String docType ) { this.docType = docType }
+
+  @InputDirectory def File getCommonResourcesDir() { project.file( 'src/resources' ) }
+  @InputDirectory def File getConfigDir() { project.file( 'src/conf' ) }
+  @InputDirectory def File getDocsDir() { project.file( 'src/docs') }
+  @InputDirectory def File getSrcMainDir() { project.file( 'src/main') }
+  @InputDirectory def File getXslDir() { project.file( 'src/xsl') }
+  @InputDirectory def File getBuildSrcDir() { project.rootProject.file( 'buildSrc/src' ) }
+
+  @InputFiles def getSubProjectsDocsDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/docs' ) } }
+  @InputFiles def getSubProjectsTestDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/test' ) } }
+
+  @OutputDirectory def File getOutputDir() { project.file( "${project.buildDir}/docs/${docName}/" ) }
+
+  def File getTempAsciidocDir() { project.file( "${project.buildDir}/tmp-asciidoc" ) }
+  def File getTempDir() { project.file( "${project.buildDir}/tmp/docs/${docName}") }
+
+  @TaskAction
+  def void generate()
+  {
+    installAsciidocFilters()
+
+    [ outputDir, tempAsciidocDir, tempDir ]*.deleteDir()
+    [ outputDir, tempAsciidocDir, tempDir ]*.mkdirs()
+
+    copySubProjectsDocsResources()
+    generateAsciidocAccordingToReleaseSpecification()
+    generateXDoc()
+    generateChunkedHtml()
+    // generateSingleHtml()
+    // generatePdf()
+  }
+
+  def void installAsciidocFilters()
+  {
+    def userHome = new File( System.getProperty( 'user.home' ) )
+    def snippetDir = new File( userHome, '.asciidoc/filters/snippet' ).absoluteFile
+    if( !snippetDir.exists() )
+    {
+      println "Installing [snippet] into $snippetDir"
+      snippetDir.mkdirs()
+      project.copy {
+        from "${project.rootDir}/buildSrc/src/bin"
+        into snippetDir
+        include 'snippet.*'
+      }
+      ant.chmod( dir: snippetDir, perm: '755', includes: 'snippet.py' )
+    }
+
+    def devstatusDir = new File( userHome, '.asciidoc/filters/devstatus' ).absoluteFile
+    if( !devstatusDir.exists() )
+    {
+      println "Installing [devstatus] into $devstatusDir"
+      snippetDir.mkdirs()
+      project.copy {
+        from "${project.rootDir}/buildSrc/src/bin"
+        into devstatusDir
+        include 'devstatus.*'
+      }
+      ant.chmod( dir: devstatusDir, perm: '755', includes: 'devstatus.py' )
+    }
+  }
+
+  def void copySubProjectsDocsResources()
+  {
+    project.rootProject.subprojects.each { p ->
+      p.copy {
+        from p.file( 'src/docs/resources' )
+        into outputDir
+        include '**'
+      }
+    }
+  }
+
+  def void generateAsciidocAccordingToReleaseSpecification()
+  {
+    project.copy {
+      from docsDir
+      into tempAsciidocDir
+      include '**'
+    }
+    if( project.version != '0' && !project.version.contains( 'SNAPSHOT' ) ) {
+      def licenseFile = new File( tempAsciidocDir, 'userguide/libraries.txt' )
+      def extensionsFile = new File( tempAsciidocDir, 'userguide/extensions.txt' )
+      def toolsFile = new File( tempAsciidocDir, 'userguide/tools.txt' )
+      [ licenseFile, extensionsFile, toolsFile ].each { asciidocFile ->
+        def filteredFileContent = ''
+        asciidocFile.readLines().each { line ->
+          if( line.startsWith( 'include::' ) ) {
+            def approved = false
+            project.rootProject.releaseApprovedProjects.collect{it.projectDir}.each { approvedProjectDir ->
+              if( line.contains( "${approvedProjectDir.parentFile.name}/${approvedProjectDir.name}" ) ) {
+                approved = true
+              }
+            }
+            if( approved ) {
+              filteredFileContent += "$line\n"
+            }
+          } else {
+            filteredFileContent += "$line\n"
+          }
+        }
+        asciidocFile.text = filteredFileContent
+      }
+    }
+  }
+
+  def void generateXDoc()
+  {
+    project.exec {
+      executable = 'asciidoc'
+      workingDir = '..'
+      def commonResourcesPath = relativePath( project.rootDir, commonResourcesDir )
+      def asciidocConfigPath = relativePath( project.rootDir, new File( configDir, 'asciidoc.conf' ) )
+      def docbookConfigPath = relativePath( project.rootDir, new File( configDir, 'docbook45.conf' ) )
+      def linkimagesConfigPath = relativePath( project.rootDir, new File( configDir, 'linkedimages.conf' ) )
+      def xdocOutputPath =  relativePath( project.rootDir, new File( tempDir, 'xdoc-temp.xml' ) )
+      def asciidocIndexPath = relativePath( project.rootDir, new File( tempAsciidocDir, "$docName/index.txt" ) )
+      args = [
+              '--attribute', 'revnumber=' + project.version,
+              '--attribute', 'level1=' + (docType.equals('article') ? 1 : 0),
+              '--attribute', 'level2=' + (docType.equals('article') ? 2 : 1),
+              '--attribute', 'level3=' + (docType.equals('article') ? 3 : 2),
+              '--attribute', 'level4=' + (docType.equals('article') ? 4 : 3),
+              '--attribute', 'importdir=' + commonResourcesPath,
+              '--backend', 'docbook',
+              '--attribute', 'docinfo1',
+              '--doctype', docType,
+              '--conf-file=' + asciidocConfigPath,
+              '--conf-file=' + docbookConfigPath,
+              '--conf-file=' + linkimagesConfigPath,
+              '--out-file', xdocOutputPath,
+              asciidocIndexPath
+      ]
+    }
+  }
+
+  def void generateChunkedHtml()
+  {
+    project.copy {
+      from commonResourcesDir
+      into outputDir
+      include '**'
+    }
+    project.copy {
+      from "$docsDir/$docName/resources"
+      into outputDir
+      include '**'
+    }
+
+    project.exec {
+      def xsltFile = "$docsDir/$docName/xsl/chunked.xsl"
+      def outputPath = relativePath( project.projectDir, outputDir ) + '/'
+      executable = 'xsltproc'
+      args = [
+              '--nonet',
+              '--noout',
+              '--output', outputPath,
+              xsltFile,
+              "$tempDir/xdoc-temp.xml"
+      ]
+    }
+  }
+
+  def void generateSingleHtml()
+  {
+    project.exec {
+      // XML_CATALOG_FILES=
+      String xsltFile = "$xslDir/xhtml.xsl"
+      executable = 'xsltproc'
+      args = [
+              '--nonet',
+              '--noout',
+              '--output', "$outputDir/${docName}.html",
+              xsltFile,
+              "$tempDir/xdoc-temp.xml"
+      ]
+    }
+  }
+
+  def void generatePdf()
+  {
+    // $ xsltproc --nonet ../docbook-xsl/fo.xsl article.xml > article.fo
+    // $ fop article.fo article.pdf
+    project.exec {
+      String xsltFile = "$xslDir/fo.xsl"
+      executable = 'xsltproc'
+      args = [
+        '--nonet',
+        '--output', "$tempDir/${docName}.fo",
+        xsltFile,
+        "$tempDir/xdoc-temp.xml"
+      ]
+    }
+    project.exec {
+      executable = 'fop'
+      args = [
+        "$tempDir/${docName}.fo",
+        "$outputDir/${docName}.pdf"
+      ]
+    }
+  }
+
+  def String relativePath( File root, File target )
+  {
+    new File( root.toURI().relativize( target.toURI() ).toString() ).path
+  }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/ModuleReleaseSpecification.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/ModuleReleaseSpecification.groovy b/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/ModuleReleaseSpecification.groovy
new file mode 100644
index 0000000..1a3e180
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/qi4j/gradle/plugin/ModuleReleaseSpecification.groovy
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, Niclas Hedhman. 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.qi4j.gradle.plugin;
+
+import org.gradle.api.Project
+
+class ModuleReleaseSpecification
+{
+  def boolean satisfiedBy( Project project )
+  {
+    def devStatusFile = new File( project.projectDir, "dev-status.xml" )
+    if( !devStatusFile.exists() )
+    {
+      return false
+    }
+    def module = new XmlSlurper().parse( devStatusFile )
+    def codebase = module.status.codebase.text()
+    def docs = module.status.documentation.text()
+    def tests = module.status.unittests.text()
+    def satisfied = ( codebase == 'none' && docs == 'complete' && tests != 'complete' )
+    satisfied |= ( codebase == 'early' && ( docs == 'complete' || docs == 'good') && (tests == 'complete' || tests == 'good' ) )
+    satisfied |= ( codebase == 'beta' && (docs == 'complete' || docs == 'good' || docs == 'brief') && (tests == 'complete' || tests == 'good' || tests == 'some') )
+    satisfied |= ( codebase == 'stable' )
+    satisfied |= ( codebase == 'mature' )
+    println "$project.name($satisfied) -> $codebase, $docs, $tests"
+    return satisfied
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/Qi4j.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/Qi4j.java b/core/api/src/main/java/org/apache/zest/api/Qi4j.java
deleted file mode 100644
index 470c166..0000000
--- a/core/api/src/main/java/org/apache/zest/api/Qi4j.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.association.AbstractAssociation;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Function;
-
-/**
- * Encapsulation of the Zest API.
- */
-public interface Qi4j
-{
-    /**
-     * If a Modifier gets a reference to the Composite using @This,
-     * then that reference must be dereferenced using this method
-     * before handing it out for others to use.
-     *
-     * @param <T>       Parameterized type of the Composite
-     * @param composite instance reference injected in Modified using @This
-     *
-     * @return the dereferenced Composite
-     */
-    <T> T dereference( T composite );
-
-    /**
-     * Returns the Module or UnitOfWork where the Composite belongs.
-     *
-     * @param compositeOrUow The Composite (Service, Value, Entity or Transient) or UnitOfWork to lookup the Module it
-     *                       belongs to.
-     *
-     * @return The Module instance where the Composite or UnitOfWork belongs to.
-     */
-    Module moduleOf( Object compositeOrUow );
-
-    /**
-     * Returns the ModelDescriptor of the Composite.
-     *
-     * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the
-     *                                    ModelDescriptor
-     *
-     * @return The ModelDescriptor of the Composite
-     */
-    ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference );
-
-    /**
-     * Returns the CompositeDescriptor of the Composite.
-     *
-     * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the
-     *                                    CompositeDescriptor
-     *
-     * @return The CompositeDescriptor of the Composite
-     */
-    CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference );
-
-    /**
-     * Returns the TransientDescriptor of the TransientComposite.
-     *
-     * @param transsient The TransientComposite for which to lookup the TransientDescriptor
-     *
-     * @return The TransientDescriptor of the TransientComposite
-     */
-    TransientDescriptor transientDescriptorFor( Object transsient );
-
-    /**
-     * Returns the EntityDescriptor of the EntityComposite.
-     *
-     * @param entity The EntityComposite for which to lookup the EntityDescriptor
-     *
-     * @return The EntityDescriptor of the EntityComposite
-     */
-    EntityDescriptor entityDescriptorFor( Object entity );
-
-    /**
-     * Returns the ValueDescriptor of the ValueComposite.
-     *
-     * @param value The ValueComposite for which to lookup the ValueDescriptor
-     *
-     * @return The ValueDescriptor of the ValueComposite
-     */
-    ValueDescriptor valueDescriptorFor( Object value );
-
-    /**
-     * Returns the ServiceDescriptor of the ServiceComposite.
-     *
-     * @param service The ServiceComposite for which to lookup the ServiceDescriptor
-     *
-     * @return The ServiceDescriptor of the ServiceComposite
-     */
-    ServiceDescriptor serviceDescriptorFor( Object service );
-
-    /**
-     * Returns the PropertyDescriptor of the Property.
-     *
-     * @param property The Property for which to lookup the PropertyDescriptor
-     *
-     * @return The PropertyDescriptor of the Property
-     */
-    PropertyDescriptor propertyDescriptorFor( Property<?> property );
-
-    /**
-     * Returns the AssociationDescriptor of the Association.
-     *
-     * @param association The Association for which to lookup the AssociationDescriptor
-     *
-     * @return The AssociationDescriptor of the Association
-     */
-    AssociationDescriptor associationDescriptorFor( AbstractAssociation association );
-
-    /**
-     * Function that returns the CompositeDescriptor of a Composite.
-     */
-    Function<Composite, CompositeDescriptor> FUNCTION_DESCRIPTOR_FOR = new Function<Composite, CompositeDescriptor>()
-    {
-        @Override
-        public CompositeDescriptor map( Composite composite )
-        {
-            if( composite instanceof Proxy )
-            {
-                InvocationHandler invocationHandler = Proxy.getInvocationHandler( composite );
-                return ( (CompositeInstance) invocationHandler ).descriptor();
-            }
-            try
-            {
-                Class<? extends Composite> compositeClass = composite.getClass();
-                Field instanceField = compositeClass.getField( "_instance" );
-                Object instance = instanceField.get( composite );
-                return ( (CompositeInstance) instance ).descriptor();
-            }
-            catch( Exception e )
-            {
-                InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" );
-                exception.initCause( e );
-                throw exception;
-            }
-        }
-    };
-
-    /**
-     * Function that returns the CompositeInstance of a Composite.
-     */
-    Function<Composite, CompositeInstance> FUNCTION_COMPOSITE_INSTANCE_OF = new Function<Composite, CompositeInstance>()
-    {
-        @Override
-        public CompositeInstance map( Composite composite )
-        {
-            if( composite instanceof Proxy )
-            {
-                return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) );
-            }
-            try
-            {
-                Class<? extends Composite> compositeClass = composite.getClass();
-                Field instanceField = compositeClass.getField( "_instance" );
-                Object instance = instanceField.get( composite );
-                return (CompositeInstance) instance;
-            }
-            catch( Exception e )
-            {
-                InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" );
-                exception.initCause( e );
-                throw exception;
-            }
-        }
-    };
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/Activation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/Activation.java b/core/api/src/main/java/org/apache/zest/api/activation/Activation.java
deleted file mode 100644
index 5be35e7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/Activation.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.api.activation;
-
-/**
- * Interface used by Structure elements and Services that can be activated and passivated.
- * <p>Application and Layer expose this interface so you can activate and passivate them.</p>
- * <p>Module and ServiceComposite activation/passivation is handled by the Zest runtime.</p>
- */
-public interface Activation
-{
-    /**
-     * Activate.
-     * <p>Fail fast execution order is:</p>
-     * <ul>
-     *   <li>Fire {@link ActivationEvent.EventType#ACTIVATING}</li>
-     *   <li>Call {@link Activator#beforeActivation(java.lang.Object)} on each Activator</li>
-     *   <li>Call {@link #activate()} children</li>
-     *   <li>Call {@link Activator#afterActivation(java.lang.Object)} on each Activator</li>
-     *   <li>Fire {@link ActivationEvent.EventType#ACTIVATED}</li>
-     * </ul>
-     * <p>If an Exception is thrown, already activated nodes are passivated.</p>
-     * @throws ActivationException with first Exception of activation plus the PassivationException if any
-     */
-    void activate()
-        throws ActivationException;
-
-    /**
-     * Passivate.
-     * <p>Fail safe execution order is:</p>
-     * <ul>
-     *   <li>Fire {@link ActivationEvent.EventType#PASSIVATING}</li>
-     *   <li>Call {@link Activator#beforePassivation(java.lang.Object)} on each Activator</li>
-     *   <li>Call {@link #passivate()} children</li>
-     *   <li>Call {@link Activator#afterPassivation(java.lang.Object)} on each Activator</li>
-     *   <li>Fire {@link ActivationEvent.EventType#PASSIVATED}</li>
-     * </ul>
-     * @throws PassivationException after passivation with all Exceptions of passivation if any
-     */
-    void passivate()
-        throws PassivationException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
deleted file mode 100644
index c54f4b8..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- *
- * 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.zest.api.activation;
-
-/**
- * ActivationEvents are fired during activation and passivation of instances in Zest.
- */
-public final class ActivationEvent
-{
-    public enum EventType
-    {
-        ACTIVATING, ACTIVATED, PASSIVATING, PASSIVATED
-    }
-
-    private final long timestamp;
-    private final Object source;
-    private final EventType type;
-
-    public ActivationEvent( Object source, EventType type )
-    {
-        this.timestamp = System.currentTimeMillis();
-        this.source = source;
-        this.type = type;
-    }
-
-    /**
-     * @return the source of the Activation event
-     */
-    public Object source()
-    {
-        return source;
-    }
-
-    /**
-     * @return the type of the Activation event
-     */
-    public EventType type()
-    {
-        return type;
-    }
-
-    /**
-     * @return an informative message describing the event
-     */
-    public String message()
-    {
-        switch( type )
-        {
-        case ACTIVATING:
-            return "Activating " + source;
-        case ACTIVATED:
-            return "Activated " + source;
-        case PASSIVATING:
-            return "Passivating " + source;
-        case PASSIVATED:
-            return "Passivated " + source;
-        }
-        return "";
-    }
-
-    /**
-     * @see #message()
-     */
-    @Override
-    public String toString()
-    {
-        return message();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListener.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListener.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListener.java
deleted file mode 100644
index a6e3bb1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- *
- * 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.zest.api.activation;
-
-/**
- * Listener for ActivationEvent events
- */
-public interface ActivationEventListener
-{
-    void onEvent( ActivationEvent event )
-        throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListenerRegistration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListenerRegistration.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListenerRegistration.java
deleted file mode 100644
index c7d0c2a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEventListenerRegistration.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- *
- * 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.zest.api.activation;
-
-/**
- * Use this to register listeners for ActivationEvents.
- *
- * This is implemented by Application, Layer, Module, for example.
- */
-public interface ActivationEventListenerRegistration
-{
-    /**
-     * @param listener will be notified when Activation events occur
-     */
-    void registerActivationEventListener( ActivationEventListener listener );
-
-    /**
-     * @param listener will not be notified when Activation events occur anymore
-     */
-    void deregisterActivationEventListener( ActivationEventListener listener );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivationException.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivationException.java
deleted file mode 100644
index 0008ec9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2013 Niclas Hedhman.
- *
- * 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.zest.api.activation;
-
-/**
- * Thrown when unable to activate.
- */
-public class ActivationException extends Exception
-{
-    private static final long serialVersionUID = 1L;
-    public ActivationException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/Activator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/Activator.java b/core/api/src/main/java/org/apache/zest/api/activation/Activator.java
deleted file mode 100644
index a57b353..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/Activator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.api.activation;
-
-/**
- * Assemble Activators to hook Services Activation.
- *
- * @param <ActivateeType> Type of the activatee.
- *
- * @see ActivatorAdapter
- * @see org.apache.zest.api.service.ServiceActivation
- */
-public interface Activator<ActivateeType>
-{
-
-    /**
-     * Called before activatee activation.
-     */
-    void beforeActivation( ActivateeType activating )
-        throws Exception;
-
-    /**
-     * Called after activatee activation.
-     */
-    void afterActivation( ActivateeType activated )
-        throws Exception;
-
-    /**
-     * Called before activatee passivation.
-     */
-    void beforePassivation( ActivateeType passivating )
-        throws Exception;
-
-    /**
-     * Called after activatee passivation.
-     */
-    void afterPassivation( ActivateeType passivated )
-        throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivatorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivatorAdapter.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivatorAdapter.java
deleted file mode 100644
index 666b6ec..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivatorAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.api.activation;
-
-/**
- * Adapter for Activator.
- * <p>If you are thinking about Service activation, see {@link org.apache.zest.api.service.ServiceActivatorAdapter}.</p>
- *
- * @param <ActivateeType> Type of the activatee.
- */
-public class ActivatorAdapter<ActivateeType>
-    implements Activator<ActivateeType>
-{
-    /**
-     * Called before activatee activation.
-     * @param activating Activating activatee
-     */
-    @Override
-    public void beforeActivation( ActivateeType activating )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called after activatee activation.
-     * @param activated Activating activatee
-     */
-    @Override
-    public void afterActivation( ActivateeType activated )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called before activatee passivation.
-     * @param passivating Passivating activatee
-     */
-    @Override
-    public void beforePassivation( ActivateeType passivating )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called after activatee passivation.
-     * @param passivated Passivated activatee
-     */
-    @Override
-    public void afterPassivation( ActivateeType passivated )
-        throws Exception
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ActivatorDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivatorDescriptor.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivatorDescriptor.java
deleted file mode 100644
index e6da0b2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivatorDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.activation;
-
-/**
- * Activator Descriptor.
- */
-public interface ActivatorDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/Activators.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/Activators.java b/core/api/src/main/java/org/apache/zest/api/activation/Activators.java
deleted file mode 100644
index d62b989..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/Activators.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.api.activation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used in ServiceComposites to declare Activator implementation classes.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( ElementType.TYPE )
-@Documented
-public @interface Activators
-{
-
-    /**
-     * @return Activator implementation classes.
-     */
-    Class<? extends Activator<?>>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/ApplicationPassivationThread.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ApplicationPassivationThread.java b/core/api/src/main/java/org/apache/zest/api/activation/ApplicationPassivationThread.java
deleted file mode 100644
index f8bbf12..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/ApplicationPassivationThread.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2013 Paul Merlin.
- *
- * 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.zest.api.activation;
-
-import java.io.PrintStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.zest.api.structure.Application;
-
-/**
- * Application Passivation Thread to use as a Shutdown Hook.
- * <pre>Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application ) );</pre>
- * <p>Constructors to control where errors are logged are provided. They support PrintStream (STDOUT/STDERR) and SLF4J
- * Loggers. Defaults to STDERR.</p>
- */
-public final class ApplicationPassivationThread
-    extends Thread
-{
-    /**
-     * Create a new Application Passivation Thread that output errors to STDERR.
-     * @param application The Application to passivate
-     */
-    public ApplicationPassivationThread( final Application application )
-    {
-        this( application, null, null );
-    }
-
-    /**
-     * Create a new Application Passivation Thread that output errors to a Logger.
-     * @param application The Application to passivate
-     * @param logger Logger for errors
-     */
-    public ApplicationPassivationThread( Application application, Logger logger )
-    {
-        this( application, null, logger );
-    }
-
-    /**
-     * Create a new Application Passivation Thread that output errors to a PrintStream.
-     * @param application The Application to passivate
-     * @param output PrintStream for errors
-     */
-    public ApplicationPassivationThread( Application application, PrintStream output )
-    {
-        this( application, output, null );
-    }
-
-    private ApplicationPassivationThread( Application application, PrintStream output, Logger logger )
-    {
-        super( new ApplicationPassivation( application, output, logger ),
-               application.name() + " Passivation Thread" );
-    }
-
-    private static class ApplicationPassivation
-        implements Runnable
-    {
-
-        private final Application application;
-        private final PrintStream output;
-        private final Logger logger;
-
-        private ApplicationPassivation( Application application, PrintStream output, Logger logger )
-        {
-            this.application = application;
-            this.output = output;
-            this.logger = logger;
-        }
-
-        @Override
-        public void run()
-        {
-            try
-            {
-                application.passivate();
-            }
-            catch( PassivationException ex )
-            {
-                String message = application.name() + " " + ex.getMessage();
-                if( logger != null )
-                {
-                    logger.log( Level.SEVERE, message, ex );
-                }
-                else if( output != null )
-                {
-                    output.println( message );
-                    ex.printStackTrace( output );
-                }
-                else
-                {
-                    ex.printStackTrace();
-                }
-            }
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/PassivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/PassivationException.java b/core/api/src/main/java/org/apache/zest/api/activation/PassivationException.java
deleted file mode 100644
index 7b5d195..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/PassivationException.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- * Copyright 2013 Paul Merlin.
- *
- * 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.zest.api.activation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Thrown when unable to passivate.
- *
- * Printed StackTrace contains all causes in order as suppressed exceptions.
- */
-public final class PassivationException
-    extends Exception
-{
-
-    private static final long serialVersionUID = 1L;
-    private final List<Exception> causes;
-
-    /**
-     * Create new PassivationException.
-     * @param exceptions All exceptions encountered during passivation, in order
-     */
-    public PassivationException( Collection<Exception> exceptions )
-    {
-        super( "Passivation Exception - [has " + exceptions.size() + " cause(s)]" );
-        for( Throwable cause : exceptions )
-        {
-            addSuppressed( cause );
-        }
-        this.causes = new ArrayList<>( exceptions );
-    }
-
-    /**
-     * @return All exceptions encountered during passivation, in order
-     */
-    public List<Exception> causes()
-    {
-        return causes;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/activation/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/package.html b/core/api/src/main/java/org/apache/zest/api/activation/package.html
deleted file mode 100644
index 47b333a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/activation/package.html
+++ /dev/null
@@ -1,26 +0,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.
--->
-<html>
-    <body>
-        <h2>Activation API.</h2>
-        <p>
-            The Activation API package contains types used by client code to integrate with the Zest™ Runtime activation
-            mechanism. In assembly, client code can easily listen to Structure (Application, Layers and Modules) and
-            Services activation events, or, declare Structure and Service Activators.
-        </p>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AbstractAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AbstractAssociation.java b/core/api/src/main/java/org/apache/zest/api/association/AbstractAssociation.java
deleted file mode 100644
index d97cf55..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AbstractAssociation.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-/**
- * Base interface for all associations.
- */
-public interface AbstractAssociation
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/Association.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/Association.java b/core/api/src/main/java/org/apache/zest/api/association/Association.java
deleted file mode 100644
index 10ededb..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/Association.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * Association to a single EntityComposite.
- */
-public interface Association<T> extends AbstractAssociation
-{
-    /**
-     * Get the associated entity.
-     *
-     * @return the associated entity
-     */
-    T get();
-
-    /**
-     * Set the associated entity.
-     *
-     * @param associated the entity
-     *
-     * @throws IllegalArgumentException thrown if the entity is not a valid reference for this association
-     * @throws IllegalStateException    thrown if association is immutable
-     */
-    void set( T associated )
-        throws IllegalArgumentException, IllegalStateException;
-
-    /**
-     * @return the the reference of the associated entity.
-     */
-    EntityReference reference();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AssociationDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AssociationDescriptor.java b/core/api/src/main/java/org/apache/zest/api/association/AssociationDescriptor.java
deleted file mode 100644
index 5c8cbb1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AssociationDescriptor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Type;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.structure.MetaInfoHolder;
-
-/**
- * Association Descriptor.
- */
-public interface AssociationDescriptor extends MetaInfoHolder
-{
-    /**
-     * Get the qualified name of the association. This is constructed by
-     * concatenating the name of the declaring interface with the name
-     * of the method, using ":" as separator.
-     * <p>
-     * Example:
-     * </p>
-     * <p>
-     * com.somecompany.MyInterface with association method
-     * </p>
-     * <pre><code>
-     * Association&lt;String&gt; someAssociation();
-     * </code></pre>
-     * will have the qualified name:
-     * <pre><code>
-     * com.somecompany.MyInterface:someAssociation
-     * </code></pre>
-     *
-     * @return the qualified name of the association
-     */
-    QualifiedName qualifiedName();
-
-    /**
-     * Get the type of the associated Entities
-     *
-     * @return the type of the associated Entities
-     */
-    Type type();
-
-    boolean isImmutable();
-
-    boolean isAggregated();
-
-    AccessibleObject accessor();
-
-    boolean queryable();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AssociationMixin.java b/core/api/src/main/java/org/apache/zest/api/association/AssociationMixin.java
deleted file mode 100644
index c6079fd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AssociationMixin.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.injection.scope.State;
-
-/**
- * Generic mixin for associations.
- */
-@AppliesTo( { AssociationMixin.AssociationFilter.class } )
-public final class AssociationMixin
-    implements InvocationHandler
-{
-    @State
-    private AssociationStateHolder associations;
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return associations.associationFor( method );
-    }
-
-    /**
-     * Associations generic mixin AppliesToFilter.
-     */
-    public static class AssociationFilter
-        implements AppliesToFilter
-    {
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
-        {
-            return Association.class.isAssignableFrom( method.getReturnType() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AssociationStateDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AssociationStateDescriptor.java b/core/api/src/main/java/org/apache/zest/api/association/AssociationStateDescriptor.java
deleted file mode 100644
index a6609da..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AssociationStateDescriptor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.association;
-
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.composite.StateDescriptor;
-
-/**
- * Associations State Descriptor.
- */
-public interface AssociationStateDescriptor extends StateDescriptor
-{
-    AssociationDescriptor getAssociationByName( String name )
-        throws IllegalArgumentException;
-
-    AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException;
-
-    AssociationDescriptor getManyAssociationByName( String name )
-        throws IllegalArgumentException;
-
-    AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException;
-
-    AssociationDescriptor getNamedAssociationByName( String name )
-        throws IllegalArgumentException;
-
-    AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException;
-
-    Iterable<? extends AssociationDescriptor> associations();
-
-    Iterable<? extends AssociationDescriptor> manyAssociations();
-
-    Iterable<? extends AssociationDescriptor> namedAssociations();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AssociationStateHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AssociationStateHolder.java b/core/api/src/main/java/org/apache/zest/api/association/AssociationStateHolder.java
deleted file mode 100644
index 2a9c035..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AssociationStateHolder.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.association;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.property.StateHolder;
-
-/**
- * This represents the state of a entity (properties+associations).
- */
-public interface AssociationStateHolder
-    extends StateHolder
-{
-    /**
-     * Get an association for a specific accessor method
-     *
-     * @param associationMethod for the association
-     *
-     * @return the association
-     */
-    <T> Association<T> associationFor( AccessibleObject associationMethod );
-
-    /**
-     * Get all associations
-     *
-     * @return iterable of associations
-     */
-    Iterable<? extends Association<?>> allAssociations();
-
-    /**
-     * Get a many-association for a specific accessor method
-     *
-     * @param manyassociationMethod for the many-association
-     *
-     * @return the association
-     */
-    <T> ManyAssociation<T> manyAssociationFor( AccessibleObject manyassociationMethod );
-
-    /**
-     * Get all ManyAssociations
-     *
-     * @return iterable of many-associations
-     */
-    Iterable<? extends ManyAssociation<?>> allManyAssociations();
-
-    /**
-     * Get a named-association for a specific accessor method
-     *
-     * @param namedassociationMethod for the named-association
-     *
-     * @return the association
-     */
-    <T> NamedAssociation<T> namedAssociationFor( AccessibleObject namedassociationMethod );
-
-    /**
-     * Get all NmaedAssociations
-     *
-     * @return iterable of named-associations
-     */
-    Iterable<? extends NamedAssociation<?>> allNamedAssociations();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/AssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/AssociationWrapper.java b/core/api/src/main/java/org/apache/zest/api/association/AssociationWrapper.java
deleted file mode 100644
index 600756f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/AssociationWrapper.java
+++ /dev/null
@@ -1,79 +0,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.
- */
-package org.apache.zest.api.association;
-
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * If you want to catch getting and setting association, then create a GenericConcern
- * that wraps the Zest-supplied Association instance with AssociationWrappers. Override
- * get() and/or set() to perform your custom code.
- */
-public class AssociationWrapper
-    implements Association<Object>
-{
-    protected Association<Object> next;
-
-    public AssociationWrapper( Association<Object> next )
-    {
-        this.next = next;
-    }
-
-    public Association<Object> next()
-    {
-        return next;
-    }
-
-    @Override
-    public Object get()
-    {
-        return next.get();
-    }
-
-    @Override
-    public void set( Object associated )
-        throws IllegalArgumentException
-    {
-        next.set( associated );
-    }
-
-    @Override
-    public EntityReference reference()
-    {
-        return next.reference();
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return next.hashCode();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        return next.equals( obj );
-    }
-
-    @Override
-    public String toString()
-    {
-        return next.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/GenericAssociationInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/GenericAssociationInfo.java b/core/api/src/main/java/org/apache/zest/api/association/GenericAssociationInfo.java
deleted file mode 100644
index 8641cc5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/GenericAssociationInfo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-import static org.apache.zest.api.util.Classes.typeOf;
-
-/**
- * Generic Association info.
- */
-public final class GenericAssociationInfo
-{
-    public static Type associationTypeOf( AccessibleObject accessor )
-    {
-        return toAssociationType( typeOf( accessor ) );
-    }
-
-    public static Type toAssociationType( Type methodReturnType )
-    {
-        if( methodReturnType instanceof ParameterizedType )
-        {
-            ParameterizedType parameterizedType = (ParameterizedType) methodReturnType;
-            if( AbstractAssociation.class.isAssignableFrom( (Class<?>) parameterizedType.getRawType() ) )
-            {
-                return parameterizedType.getActualTypeArguments()[ 0 ];
-            }
-        }
-
-        Type[] interfaces = ( (Class<?>) methodReturnType ).getGenericInterfaces();
-        for( Type anInterface : interfaces )
-        {
-            Type associationType = toAssociationType( anInterface );
-            if( associationType != null )
-            {
-                return associationType;
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/ManyAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociation.java b/core/api/src/main/java/org/apache/zest/api/association/ManyAssociation.java
deleted file mode 100644
index e24681f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociation.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * Association to a collection of entities.
- */
-public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
-{
-    /**
-     * Returns the number of references in this association.
-     * @return the number of references in this association.
-     */
-    int count();
-
-    boolean contains( T entity );
-
-    boolean add( int i, T entity );
-
-    boolean add( T entity );
-
-    boolean remove( T entity );
-
-    T get( int i );
-
-    List<T> toList();
-
-    Set<T> toSet();
-
-    /**
-     * Returns an unmodifiable Iterable of the references to the associated entities.
-     * @return the references to the associated entities.
-     */
-    Iterable<EntityReference> references();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationMixin.java b/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationMixin.java
deleted file mode 100644
index 9d79dbd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationMixin.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.association;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.injection.scope.State;
-
-/**
- * Generic mixin for associations.
- */
-@AppliesTo( { ManyAssociationMixin.AssociationFilter.class } )
-public final class ManyAssociationMixin
-    implements InvocationHandler
-{
-    @State
-    private AssociationStateHolder associations;
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return associations.manyAssociationFor( method );
-    }
-
-    /**
-     * ManyAssociations generic mixin AppliesToFilter.
-     */
-    public static class AssociationFilter
-        implements AppliesToFilter
-    {
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
-        {
-            return ManyAssociation.class.isAssignableFrom( method.getReturnType() );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationWrapper.java b/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationWrapper.java
deleted file mode 100644
index 3f29dd4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/ManyAssociationWrapper.java
+++ /dev/null
@@ -1,123 +0,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.
- */
-package org.apache.zest.api.association;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * If you want to catch calls to ManyAssociations, then create a GenericConcern
- * that wraps the Zest-supplied ManyAssociation instance with ManyAssociationWrappers. Override
- * methods to perform your custom code.
- */
-public class ManyAssociationWrapper
-    implements ManyAssociation<Object>
-{
-    protected ManyAssociation<Object> next;
-
-    public ManyAssociationWrapper( ManyAssociation<Object> next )
-    {
-        this.next = next;
-    }
-
-    public ManyAssociation<Object> next()
-    {
-        return next;
-    }
-
-    @Override
-    public int count()
-    {
-        return next.count();
-    }
-
-    @Override
-    public boolean contains( Object entity )
-    {
-        return next.contains( entity );
-    }
-
-    @Override
-    public boolean add( int i, Object entity )
-    {
-        return next.add( i, entity );
-    }
-
-    @Override
-    public boolean add( Object entity )
-    {
-        return next.add( entity );
-    }
-
-    @Override
-    public boolean remove( Object entity )
-    {
-        return next.remove( entity );
-    }
-
-    @Override
-    public Object get( int i )
-    {
-        return next.get( i );
-    }
-
-    @Override
-    public List<Object> toList()
-    {
-        return next.toList();
-    }
-
-    @Override
-    public Set<Object> toSet()
-    {
-        return next.toSet();
-    }
-
-    @Override
-    public Iterable<EntityReference> references()
-    {
-        return next.references();
-    }
-
-    @Override
-    public Iterator<Object> iterator()
-    {
-        return next.iterator();
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return next.hashCode();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        return next.equals( obj );
-    }
-
-    @Override
-    public String toString()
-    {
-        return next.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/NamedAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociation.java b/core/api/src/main/java/org/apache/zest/api/association/NamedAssociation.java
deleted file mode 100644
index ed31e29..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociation.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.association;
-
-import java.util.Map;
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * Association to named Entities.
- * The Iterable&lt;String&gt; returns the names in the association set.
- * @param <T> Parameterized associatee type
- */
-public interface NamedAssociation<T>
-    extends Iterable<String>, AbstractAssociation
-{
-    /**
-     * @return The number of named associations in this NamedAssociation.
-     */
-    int count();
-
-    /**
-     * Checks if there is an association with the given name.
-     * @param name The name of the association we are checking if it exists.
-     * @return true if it exists, false otherwise
-     */
-    boolean containsName( String name );
-
-    /**
-     * Adds a named assocation.
-     * @param name The name of the association.
-     * @param entity The entity for this named association.
-     * @return true if putted, false otherwise
-     */
-    boolean put( String name, T entity );
-
-    /**
-     * Remove a named association.
-     * @param name The name of the association.
-     * @return true if removed, false otherwise
-     */
-    boolean remove( String name );
-
-    /**
-     * Retrieves a named association.
-     * @param name The name of the association.
-     * @return The entity that has previously been associated.
-     */
-    T get( String name );
-
-    /**
-     * Checks if the entity is present.
-     * Note that this is potentially a very slow operation, depending on the size of the NamedAssociation.
-     * @param entity The entity to look for.
-     * @return The name of the entity if found, otherwise null.
-     */
-    String nameOf( T entity );
-
-    /**
-     * @return A fully populated Map with the content of this NamedAssociation.
-     */
-    Map<String, T> toMap();
-
-    /**
-     * Returns an unmodifiable Iterable of the references to the associated entities.
-     * @return the references to the associated entities.
-     */
-    Iterable<EntityReference> references();
-
-    /** Returns the EntityReference for the Association with the given name.
-     *
-     * @param name The name of the association to return the EntityReference for
-     * @return The EntityReference of the association.
-     */
-    EntityReference referenceOf( String name );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationMixin.java b/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationMixin.java
deleted file mode 100644
index b289497..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationMixin.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.association;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.injection.scope.State;
-
-/**
- * Generic mixin for NamedAssociations.
- */
-@AppliesTo( NamedAssociationMixin.AssociationFilter.class )
-public final class NamedAssociationMixin
-    implements InvocationHandler
-{
-    @State
-    private AssociationStateHolder associations;
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return associations.namedAssociationFor( method );
-    }
-
-    /**
-     * NamedAssociations generic mixin AppliesToFilter.
-     */
-    public static class AssociationFilter
-        implements AppliesToFilter
-    {
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
-        {
-            return NamedAssociation.class.isAssignableFrom( method.getReturnType() );
-        }
-    }
-
-}


[07/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
deleted file mode 100644
index 0ebfbbb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * Copyright (c) 2008-2012, Rickard Öberg.
- * Copyright (c) 2008-2012, Niclas Hedhman.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.structure;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.zest.api.composite.AmbiguousTypeException;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.composite.TransientModel;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.object.ObjectModel;
-import org.apache.zest.runtime.value.ValueModel;
-import org.apache.zest.spi.module.ModelModule;
-
-import static org.apache.zest.api.common.Visibility.application;
-import static org.apache.zest.api.common.Visibility.layer;
-import static org.apache.zest.api.common.Visibility.module;
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.functional.Iterables.cast;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.toList;
-import static org.apache.zest.functional.Iterables.unique;
-
-/**
- * Central place for Composite Type lookups.
- */
-public class TypeLookup
-{
-
-    // Constructor parameters
-    private final ModuleInstance moduleInstance;
-    // Eager instance objects
-    private final Map<Class<?>, ModelModule<ObjectModel>> objectModels;
-    private final Map<Class<?>, ModelModule<TransientModel>> transientModels;
-    private final Map<Class<?>, ModelModule<ValueModel>> valueModels;
-    private final Map<Class<?>, Iterable<ModelModule<EntityModel>>> allEntityModels;
-    private final Map<Class<?>, ModelModule<EntityModel>> unambiguousEntityModels;
-    private final Map<Type, ServiceReference<?>> serviceReferences;
-    private final Map<Type, Iterable<ServiceReference<?>>> servicesReferences;
-
-    /**
-     * Create a new TypeLookup bound to the given ModuleInstance.
-     *
-     * @param moduleInstance ModuleInstance bound to this TypeLookup
-     */
-    /* package */ TypeLookup( ModuleInstance moduleInstance )
-    {
-        // Constructor parameters
-        this.moduleInstance = moduleInstance;
-
-        // Eager instance objects
-        objectModels = new ConcurrentHashMap<>();
-        transientModels = new ConcurrentHashMap<>();
-        valueModels = new ConcurrentHashMap<>();
-        allEntityModels = new ConcurrentHashMap<>();
-        unambiguousEntityModels = new ConcurrentHashMap<>();
-        serviceReferences = new ConcurrentHashMap<>();
-        servicesReferences = new ConcurrentHashMap<>();
-    }
-
-    /**
-     * Lookup first Object Model matching the given Type.
-     *
-     * <p>First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * @param type Looked up Type
-     *
-     * @return First matching Object Model
-     */
-    @SuppressWarnings( { "raw", "unchecked" } )
-    /* package */ ModelModule<ObjectModel> lookupObjectModel( final Class type )
-    {
-        ModelModule<ObjectModel> model = objectModels.get( type );
-
-        if( model == null )
-        {
-            // Unambiguously and lazily resolve ObjectModel
-            Iterable<ModelModule<ObjectModel>> flatten = flatten(
-                ambiguousTypeCheck( type,
-                                    findModels( new ExactTypeLookupSpecification( type ),
-                                                moduleInstance.visibleObjects( module ),
-                                                moduleInstance.layerInstance().visibleObjects( layer ),
-                                                moduleInstance.layerInstance().visibleObjects( application ),
-                                                moduleInstance.layerInstance()
-                                                    .usedLayersInstance()
-                                                    .visibleObjects() ) ),
-                ambiguousTypeCheck( type,
-                                    findModels( new AssignableTypeLookupSpecification( type ),
-                                                moduleInstance.visibleObjects( module ),
-                                                moduleInstance.layerInstance().visibleObjects( layer ),
-                                                moduleInstance.layerInstance().visibleObjects( application ),
-                                                moduleInstance.layerInstance()
-                                                    .usedLayersInstance()
-                                                    .visibleObjects() ) ) );
-
-            model = first( flatten );
-
-            if( model != null )
-            {
-                objectModels.put( type, model );
-            }
-        }
-
-        return model;
-    }
-
-    /**
-     * Lookup first Transient Model matching the given Type.
-     *
-     * <p>First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * @param type Looked up Type
-     *
-     * @return First matching Transient Model
-     */
-    @SuppressWarnings( { "raw", "unchecked" } )
-    /* package */ ModelModule<TransientModel> lookupTransientModel( final Class type )
-    {
-        ModelModule<TransientModel> model = transientModels.get( type );
-
-        if( model == null )
-        {
-            // Unambiguously and lazily resolve TransientModel
-            Iterable<ModelModule<TransientModel>> allModels = flatten(
-                ambiguousTypeCheck( type,
-                                    findModels( new ExactTypeLookupSpecification( type ),
-                                                moduleInstance.visibleTransients( module ),
-                                                moduleInstance.layerInstance().visibleTransients( layer ),
-                                                moduleInstance.layerInstance().visibleTransients( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleTransients()
-                                    )
-                ),
-
-                ambiguousTypeCheck( type,
-                                    findModels( new AssignableTypeLookupSpecification( type ),
-                                                moduleInstance.visibleTransients( module ),
-                                                moduleInstance.layerInstance().visibleTransients( layer ),
-                                                moduleInstance.layerInstance().visibleTransients( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleTransients()
-                                    )
-                )
-            );
-            model = first( allModels );
-
-            if( model != null )
-            {
-                transientModels.put( type, model );
-            }
-        }
-
-        return model;
-    }
-
-    /**
-     * Lookup first Value Model matching the given Type.
-     *
-     * <p>First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * @param type Looked up Type
-     *
-     * @return First matching Value Model
-     */
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public ModelModule<ValueModel> lookupValueModel( final Class type )
-    {
-        ModelModule<ValueModel> model = valueModels.get( type );
-
-        if( model == null )
-        {
-            // Unambiguously and lazily resolve ValueModel
-            Iterable<ModelModule<ValueModel>> flatten = flatten(
-                ambiguousTypeCheck( type,
-                                    findModels( new ExactTypeLookupSpecification( type ),
-                                                moduleInstance.visibleValues( module ),
-                                                moduleInstance.layerInstance().visibleValues( layer ),
-                                                moduleInstance.layerInstance().visibleValues( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleValues() ) ),
-                ambiguousTypeCheck( type,
-                                    findModels( new AssignableTypeLookupSpecification( type ),
-                                                moduleInstance.visibleValues( module ),
-                                                moduleInstance.layerInstance().visibleValues( layer ),
-                                                moduleInstance.layerInstance().visibleValues( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleValues()
-                                    )
-                )
-            );
-
-            model = first( flatten );
-
-            if( model != null )
-            {
-                valueModels.put( type, model );
-            }
-        }
-
-        return model;
-    }
-
-    /**
-     * Lookup first Entity Model matching the given Type.
-     *
-     * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
-     * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
-     * {@link #lookupEntityModels(java.lang.Class)}.</p>
-     *
-     * @param type Looked up Type
-     *
-     * @return First matching Entity Model
-     */
-    @SuppressWarnings( { "raw", "unchecked" } )
-    /* package */ ModelModule<EntityModel> lookupEntityModel( final Class type )
-    {
-        ModelModule<EntityModel> model = unambiguousEntityModels.get( type );
-
-        if( model == null )
-        {
-            // Unambiguously and lazily resolve EntityModels
-            Iterable<ModelModule<EntityModel>> allModels = flatten(
-                ambiguousTypeCheck( type,
-                                    findModels( new ExactTypeLookupSpecification( type ),
-                                                moduleInstance.visibleEntities( module ),
-                                                moduleInstance.layerInstance().visibleEntities( layer ),
-                                                moduleInstance.layerInstance().visibleEntities( application ),
-                                                moduleInstance.layerInstance()
-                                                    .usedLayersInstance()
-                                                    .visibleEntities() ) ),
-                ambiguousTypeCheck( type,
-                                    findModels( new AssignableTypeLookupSpecification( type ),
-                                                moduleInstance.visibleEntities( module ),
-                                                moduleInstance.layerInstance().visibleEntities( layer ),
-                                                moduleInstance.layerInstance().visibleEntities( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleEntities()
-                                    )
-                )
-            );
-
-            model = first( allModels );
-
-            if( model != null )
-            {
-                unambiguousEntityModels.put( type, model );
-            }
-        }
-
-        return model;
-    }
-
-    /**
-     * Lookup all Entity Models matching the given Type.
-     *
-     * <p>Returned Iterable contains, in order, Entity Models that: </p>
-     *
-     * <ul>
-     * <li>exactly match the given type, in Visibility then Assembly order ;</li>
-     * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
-     * </ul>
-     *
-     * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
-     * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
-     * {@link #lookupEntityModel(java.lang.Class)}.</p>
-     *
-     * @param type Looked up Type
-     *
-     * @return All matching Entity Models
-     */
-    @SuppressWarnings( { "raw", "unchecked" } )
-    /* package */ Iterable<ModelModule<EntityModel>> lookupEntityModels( final Class type )
-    {
-        Iterable<ModelModule<EntityModel>> models = allEntityModels.get( type );
-        if( models == null )
-        {
-            // Ambiguously and lasily resolve EntityModels
-            Iterable<ModelModule<EntityModel>> matchingEntityModels = flatten(
-                ambiguousTypeCheck( type,
-                                    findModels( new ExactTypeLookupSpecification( type ),
-                                                moduleInstance.visibleEntities( module ),
-                                                moduleInstance.layerInstance().visibleEntities( layer ),
-                                                moduleInstance.layerInstance().visibleEntities( application ),
-                                                moduleInstance.layerInstance().usedLayersInstance().visibleEntities()
-                                    )
-                ),
-                findModels( new AssignableTypeLookupSpecification( type ),
-                            moduleInstance.visibleEntities( module ),
-                            moduleInstance.layerInstance().visibleEntities( layer ),
-                            moduleInstance.layerInstance().visibleEntities( application ),
-                            moduleInstance.layerInstance().usedLayersInstance().visibleEntities() ) );
-
-            // Don't return the same EntityModel multiple times
-            matchingEntityModels = unique( matchingEntityModels );
-
-            models = toList( matchingEntityModels );
-            allEntityModels.put( type, models );
-        }
-        return models;
-    }
-
-    /**
-     * Lookup first ServiceReference matching the given Type.
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * <p>See {@link #lookupServiceReferences(java.lang.reflect.Type)}.</p>
-     *
-     * @param <T>         Service Type
-     * @param serviceType Looked up Type
-     *
-     * @return First matching ServiceReference
-     */
-    /* package */
-    @SuppressWarnings( "unchecked" )
-    <T> ServiceReference<T> lookupServiceReference( Type serviceType )
-    {
-        ServiceReference<?> serviceReference = serviceReferences.get( serviceType );
-        if( serviceReference == null )
-        {
-            // Lazily resolve ServiceReference
-            serviceReference = first( lookupServiceReferences( serviceType ) );
-            if( serviceReference != null )
-            {
-                serviceReferences.put( serviceType, serviceReference );
-            }
-        }
-
-        if( serviceReference == null )
-        {
-            throw new NoSuchServiceException( RAW_CLASS.map( serviceType ).getName(), moduleInstance.name() );
-        }
-
-        return (ServiceReference<T>) serviceReference;
-    }
-
-    /**
-     * Lookup all ServiceReferences matching the given Type.
-     *
-     * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
-     *
-     * <ul>
-     * <li>exactly match the given type, in Visibility then Assembly order ;</li>
-     * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
-     * </ul>
-     *
-     * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
-     * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
-     *
-     * <p>Type lookup is done lazily and cached.</p>
-     *
-     * @param <T>         Service Type
-     * @param serviceType Looked up Type
-     *
-     * @return All matching ServiceReferences
-     */
-    @SuppressWarnings( "unchecked" )
-    /* package */ <T> Iterable<ServiceReference<T>> lookupServiceReferences( final Type serviceType )
-    {
-        Iterable<ServiceReference<?>> serviceRefs = servicesReferences.get( serviceType );
-        if( serviceRefs == null )
-        {
-            // Lazily resolve ServicesReferences
-            Iterable<ServiceReference<?>> matchingServices = flatten(
-                findServiceReferences( new ExactTypeLookupSpecification( serviceType ),
-                                       moduleInstance.visibleServices( module ),
-                                       moduleInstance.layerInstance().visibleServices( layer ),
-                                       moduleInstance.layerInstance().visibleServices( application ),
-                                       moduleInstance.layerInstance().usedLayersInstance().visibleServices() ),
-                findServiceReferences( new AssignableTypeLookupSpecification( serviceType ),
-                                       moduleInstance.visibleServices( module ),
-                                       moduleInstance.layerInstance().visibleServices( layer ),
-                                       moduleInstance.layerInstance().visibleServices( application ),
-                                       moduleInstance.layerInstance().usedLayersInstance().visibleServices() ) );
-
-            // Don't return the same ServiceReference multiple times
-            matchingServices = unique( matchingServices );
-
-            serviceRefs = toList( matchingServices );
-            servicesReferences.put( serviceType, serviceRefs );
-        }
-
-        return cast( serviceRefs );
-    }
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    private static <T extends ModelDescriptor> Iterable<ModelModule<T>> findModels( Specification<Iterable<Class<?>>> specification,
-                                                                                    Iterable<ModelModule<T>>... models
-    )
-    {
-        Specification<ModelModule<T>> spec = Specifications.translate( new ModelModuleTypesFunction(), specification );
-        Iterable<ModelModule<T>> flattened = flattenIterables( iterable( models ) );
-        return filter( spec, flattened );
-    }
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    private static Iterable<ServiceReference<?>> findServiceReferences( Specification<Iterable<Class<?>>> specification,
-                                                                        Iterable<ServiceReference<?>>... references
-    )
-    {
-        Specification<ServiceReference<?>> spec = Specifications.translate( new ServiceReferenceTypesFunction(), specification );
-        Iterable<ServiceReference<?>> flattened = flattenIterables( iterable( references ) );
-        return filter( spec, flattened );
-    }
-
-    /**
-     * Check if the list of models contains several ones with the same visibility. If yes, then
-     * throw an AmbiguousTypeException
-     */
-    @SuppressWarnings( "raw" )
-    private static <T extends ModelDescriptor> Iterable<ModelModule<T>> ambiguousTypeCheck( final Class type,
-                                                                                            final Iterable<ModelModule<T>> models
-    )
-    {
-        return new Iterable<ModelModule<T>>()
-        {
-
-            @Override
-            public Iterator<ModelModule<T>> iterator()
-            {
-                ModelModule<T> current = null;
-                List<ModelModule<T>> ambiguous = null;
-                List<ModelModule<T>> results = new ArrayList<>();
-                for( ModelModule<T> model : models )
-                {
-                    if( current != null && !model.equals( current ) )
-                    {
-                        if( model.model().visibility() == current.model().visibility() )
-                        {
-                            if( ambiguous == null )
-                            {
-                                ambiguous = new ArrayList<>();
-                            }
-                            ambiguous.add( model );
-                        }
-                    }
-                    else
-                    {
-                        current = model;
-                    }
-                    results.add( model );
-                }
-                if( ambiguous != null )
-                {
-                    // Check if we had any ambiguities
-                    ambiguous.add( current );
-                    throw new AmbiguousTypeException( "More than one type matches " + type.getName() + ":" + ambiguous );
-                }
-                // Ambiguity check done, and no ambiguities found. Return results
-                return results.iterator();
-            }
-        };
-    }
-
-    private static class ModelModuleTypesFunction<T extends ModelDescriptor>
-        implements Function<ModelModule<T>, Iterable<Class<?>>>
-    {
-
-        @Override
-        public Iterable<Class<?>> map( ModelModule<T> modelModule )
-        {
-            return modelModule.model().types();
-        }
-    }
-
-    private static class ServiceReferenceTypesFunction
-        implements Function<ServiceReference<?>, Iterable<Class<?>>>
-    {
-
-        @Override
-        public Iterable<Class<?>> map( ServiceReference<?> serviceReference )
-        {
-            return serviceReference.types();
-        }
-    }
-
-    private static abstract class AbstractTypeLookupSpecification
-        implements Specification<Iterable<Class<?>>>
-    {
-
-        protected final Type lookedUpType;
-
-        private AbstractTypeLookupSpecification( Type lookedUpType )
-        {
-            this.lookedUpType = lookedUpType;
-        }
-
-        @Override
-        public final boolean satisfiedBy( Iterable<Class<?>> types )
-        {
-            if( lookedUpType instanceof Class )
-            {
-                // Straight class assignability check
-                return checkClassMatch( types, (Class) lookedUpType );
-            }
-            else
-            {
-                if( lookedUpType instanceof ParameterizedType )
-                {
-                    // Foo<Bar> check
-                    // First check Foo
-                    ParameterizedType parameterizedType = (ParameterizedType) lookedUpType;
-                    if( !checkClassMatch( types, (Class) parameterizedType.getRawType() ) )
-                    {
-                        return false;
-                    }
-                    // Then check Bar
-                    for( Type intf : interfacesOf( types ) )
-                    {
-                        if( intf.equals( lookedUpType ) )
-                        {
-                            // All parameters are the same - ok!
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-                else if( lookedUpType instanceof WildcardType )
-                {
-                    return true;
-                }
-                return false;
-            }
-        }
-
-        private boolean checkClassMatch( Iterable<Class<?>> candidates, Class<?> lookedUpType )
-        {
-            for( Class<?> candidate : candidates )
-            {
-                if( checkClassMatch( candidate, lookedUpType ) )
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        protected abstract boolean checkClassMatch( Class<?> candidate, Class<?> lookedUpType );
-    }
-
-    private static final class ExactTypeLookupSpecification
-        extends AbstractTypeLookupSpecification
-    {
-
-        private ExactTypeLookupSpecification( Type lookedupType )
-        {
-            super( lookedupType );
-        }
-
-        @Override
-        protected boolean checkClassMatch( Class<?> candidate, Class<?> lookedUpType )
-        {
-            return candidate.equals( lookedUpType );
-        }
-    }
-
-    private static final class AssignableTypeLookupSpecification
-        extends AbstractTypeLookupSpecification
-    {
-
-        private AssignableTypeLookupSpecification( Type lookedupType )
-        {
-            super( lookedupType );
-        }
-
-        @Override
-        protected boolean checkClassMatch( Class<?> candidate, Class<?> lookedUpType )
-        {
-            return !candidate.equals( lookedUpType ) && lookedUpType.isAssignableFrom( candidate );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
deleted file mode 100644
index 12893cf..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.structure;
-
-import java.util.List;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Function;
-import org.apache.zest.spi.module.ModelModule;
-
-import static org.apache.zest.functional.Iterables.*;
-
-/**
- * JAVADOC
- */
-public final class UsedLayersInstance
-{
-    private final List<LayerInstance> usedLayerInstances;
-
-    public UsedLayersInstance( List<LayerInstance> usedLayerInstances )
-    {
-        this.usedLayerInstances = usedLayerInstances;
-    }
-
-    /* package */ Iterable<ModelModule<ObjectDescriptor>> visibleObjects()
-    {
-        return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<ObjectDescriptor>>>()
-        {
-            @Override
-            public Iterable<ModelModule<ObjectDescriptor>> map( LayerInstance layerInstance )
-            {
-                return layerInstance.visibleObjects( Visibility.application );
-            }
-        }, usedLayerInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<TransientDescriptor>> visibleTransients()
-    {
-        return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<TransientDescriptor>>>()
-        {
-            @Override
-            public Iterable<ModelModule<TransientDescriptor>> map( LayerInstance layerInstance )
-            {
-                return layerInstance.visibleTransients( Visibility.application );
-            }
-        }, usedLayerInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<EntityDescriptor>> visibleEntities()
-    {
-        return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<EntityDescriptor>>>()
-        {
-            @Override
-            public Iterable<ModelModule<EntityDescriptor>> map( LayerInstance layerInstance )
-            {
-                return layerInstance.visibleEntities( Visibility.application );
-            }
-        }, usedLayerInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<ValueDescriptor>> visibleValues()
-    {
-        return flattenIterables( map( new Function<LayerInstance, Iterable<ModelModule<ValueDescriptor>>>()
-        {
-            @Override
-            public Iterable<ModelModule<ValueDescriptor>> map( LayerInstance layerInstance )
-            {
-                return layerInstance.visibleValues( Visibility.application );
-            }
-        }, usedLayerInstances ) );
-    }
-
-    /* package */ Iterable<ServiceReference<?>> visibleServices()
-    {
-        return flattenIterables( map( new Function<LayerInstance, Iterable<ServiceReference<?>>>()
-        {
-            @Override
-            public Iterable<ServiceReference<?>> map( LayerInstance layerInstance )
-            {
-                return layerInstance.visibleServices( Visibility.application );
-            }
-        }, usedLayerInstances ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
deleted file mode 100644
index 1f098a9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.structure;
-
-import java.util.List;
-import org.apache.zest.api.structure.UsedLayersDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class UsedLayersModel
-    implements UsedLayersDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final List<LayerModel> usedLayers;
-
-    public UsedLayersModel( List<LayerModel> usedLayers )
-    {
-        this.usedLayers = usedLayers;
-    }
-
-    @Override
-    public Iterable<LayerModel> layers()
-    {
-        return usedLayers;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( LayerModel usedLayer : usedLayers )
-            {
-                if( !usedLayer.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-
-        return visitor.visitLeave( this );
-    }
-
-    public UsedLayersInstance newInstance( List<LayerInstance> usedLayerInstances )
-    {
-        return new UsedLayersInstance( usedLayerInstances );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/VisibilitySpecification.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/VisibilitySpecification.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/VisibilitySpecification.java
deleted file mode 100644
index bb646eb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/VisibilitySpecification.java
+++ /dev/null
@@ -1,47 +0,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.
- */
-package org.apache.zest.runtime.structure;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.functional.Specification;
-
-/**
- * TODO
- */
-public class VisibilitySpecification
-    implements Specification<ModelDescriptor>
-{
-    public static final Specification<ModelDescriptor> MODULE = new VisibilitySpecification( Visibility.module );
-    public static final Specification<ModelDescriptor> LAYER = new VisibilitySpecification( Visibility.layer );
-    public static final Specification<ModelDescriptor> APPLICATION = new VisibilitySpecification( Visibility.application );
-
-    private final Visibility visibility;
-
-    public VisibilitySpecification( Visibility visibility )
-    {
-        this.visibility = visibility;
-    }
-
-    @Override
-    public boolean satisfiedBy( ModelDescriptor item )
-    {
-        return item.visibility().ordinal() >= visibility.ordinal();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
deleted file mode 100644
index 2c7951c..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.runtime.types;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.api.type.EnumType;
-import org.apache.zest.api.type.MapType;
-import org.apache.zest.api.type.Serialization;
-import org.apache.zest.api.type.ValueCompositeType;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.property.PropertiesModel;
-import org.apache.zest.runtime.structure.LayerModel;
-import org.apache.zest.runtime.structure.ModuleModel;
-import org.apache.zest.runtime.structure.UsedLayersModel;
-import org.apache.zest.runtime.value.ValueModel;
-import org.apache.zest.runtime.value.ValueStateModel;
-import org.apache.zest.runtime.value.ValuesModel;
-
-public class ValueTypeFactory
-{
-    private static final ValueTypeFactory instance = new ValueTypeFactory();
-
-    public static ValueTypeFactory instance()
-    {
-        return instance;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public ValueType newValueType( Type type,
-                                   Class declaringClass,
-                                   Class compositeType,
-                                   LayerModel layer,
-                                   ModuleModel module,
-                                   Serialization.Variant variant
-    )
-    {
-        ValueType valueType = null;
-        if( CollectionType.isCollection( type ) )
-        {
-            if( type instanceof ParameterizedType )
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                Type collectionType = pt.getActualTypeArguments()[ 0 ];
-                if( collectionType instanceof TypeVariable )
-                {
-                    TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
-                    collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
-                }
-                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module, variant );
-                valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType );
-            }
-            else
-            {
-                ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType );
-            }
-        }
-        else if( MapType.isMap( type ) )
-        {
-            if( type instanceof ParameterizedType )
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                Type keyType = pt.getActualTypeArguments()[ 0 ];
-                if( keyType instanceof TypeVariable )
-                {
-                    TypeVariable keyTypeVariable = (TypeVariable) keyType;
-                    keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
-                }
-                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module, variant );
-                Type valType = pt.getActualTypeArguments()[ 1 ];
-                if( valType instanceof TypeVariable )
-                {
-                    TypeVariable valueTypeVariable = (TypeVariable) valType;
-                    valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
-                }
-                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module, variant );
-                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyedType, valuedType, variant );
-            }
-            else
-            {
-                ValueType keyType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyType, valuesType, variant );
-            }
-        }
-        else if( ValueCompositeType.isValueComposite( type ) )
-        {
-            // Find ValueModel in module/layer/used layers
-            ValueModel model = new ValueFinder( layer, module, Classes.RAW_CLASS.map( type ) ).getFoundModel();
-
-            if( model == null )
-            {
-                if( type.equals( ValueComposite.class ) )
-                {
-                    // Create default model
-                    MixinsModel mixinsModel = new MixinsModel();
-                    Iterable valueComposite = (Iterable) Iterables.iterable( ValueComposite.class );
-                    ValueStateModel valueStateModel = new ValueStateModel( new PropertiesModel(),
-                                                                           new AssociationsModel(),
-                                                                           new ManyAssociationsModel(),
-                                                                           new NamedAssociationsModel() );
-                    model = new ValueModel( valueComposite, Visibility.application, new MetaInfo(),
-                                            mixinsModel, valueStateModel, new CompositeMethodsModel( mixinsModel ) );
-                }
-                else
-                {
-                    throw new InvalidApplicationException( "[" + module.name() + "] Could not find ValueComposite of type " + type );
-                }
-            }
-
-            return model.valueType();
-        }
-        else if( EnumType.isEnum( type ) )
-        {
-            valueType = new EnumType( Classes.RAW_CLASS.map( type ) );
-        }
-        else
-        {
-            valueType = new ValueType( Classes.RAW_CLASS.map( type ) );
-        }
-
-        return valueType;
-    }
-
-    @SuppressWarnings( "raw" )
-    private static class ValueFinder
-        extends HierarchicalVisitorAdapter<Object, Object, RuntimeException>
-    {
-        private Class type;
-        private ValueModel foundModel;
-        private Visibility visibility;
-
-        private ValueFinder( LayerModel layer, ModuleModel module, Class type )
-        {
-            this.type = type;
-
-            visibility = Visibility.module;
-            module.accept( this );
-
-            if( foundModel == null )
-            {
-                visibility = Visibility.layer;
-                layer.accept( this );
-
-                if( foundModel == null )
-                {
-                    visibility = Visibility.application;
-                    layer.usedLayers().accept( this );
-                }
-            }
-        }
-
-        public ValueModel getFoundModel()
-        {
-            return foundModel;
-        }
-
-        @Override
-        public boolean visitEnter( Object visited )
-            throws RuntimeException
-        {
-            if( visited instanceof ValuesModel )
-            {
-                return true;
-            }
-            else if( visited instanceof ModuleModel )
-            {
-                return true;
-            }
-            else if (visited instanceof LayerModel )
-            {
-                return true;
-            }
-            else if (visited instanceof UsedLayersModel )
-            {
-                return true;
-            }
-            else if( visited instanceof ValueModel )
-            {
-                ValueModel valueModel = (ValueModel) visited;
-                boolean typeEquality = Specifications.in( valueModel.types() ).satisfiedBy( type );
-                if( typeEquality && valueModel.visibility().ordinal() >= visibility.ordinal() )
-                {
-                    foundModel = valueModel;
-                }
-            }
-
-            return false;
-        }
-
-        @Override
-        public boolean visitLeave( Object visited )
-            throws RuntimeException
-        {
-            return foundModel == null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
deleted file mode 100644
index a390874..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2009-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2009-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.unitofwork;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.entity.ManyAssociationState;
-import org.apache.zest.spi.entity.NamedAssociationState;
-
-/**
- * Implementation of EntityState for use through EntityBuilder.
- */
-public final class BuilderEntityState
-    implements EntityState
-{
-    private final EntityDescriptor entityType;
-    private final EntityReference reference;
-    private final Map<QualifiedName, Object> properties = new HashMap<>();
-    private final Map<QualifiedName, EntityReference> associations = new HashMap<>();
-    private final Map<QualifiedName, ManyAssociationState> manyAssociations = new HashMap<>();
-    private final Map<QualifiedName, NamedAssociationState> namedAssociations = new HashMap<>();
-
-    public BuilderEntityState( EntityDescriptor type, EntityReference reference )
-    {
-        this.entityType = type;
-        this.reference = reference;
-    }
-
-    @Override
-    public EntityReference identity()
-    {
-        return reference;
-    }
-
-    @Override
-    public String version()
-    {
-        return "";
-    }
-
-    @Override
-    public long lastModified()
-    {
-        return 0;
-    }
-
-    @Override
-    public void remove()
-    {
-    }
-
-    @Override
-    public EntityStatus status()
-    {
-        return EntityStatus.NEW;
-    }
-
-    @Override
-    public boolean isAssignableTo( Class<?> type )
-    {
-        return Classes.exactTypeSpecification( type ).satisfiedBy( entityType );
-    }
-
-    @Override
-    public EntityDescriptor entityDescriptor()
-    {
-        return entityType;
-    }
-
-    @Override
-    public Object propertyValueOf( QualifiedName stateName )
-    {
-        return properties.get( stateName );
-    }
-
-    @Override
-    public EntityReference associationValueOf( QualifiedName stateName )
-    {
-        return associations.get( stateName );
-    }
-
-    @Override
-    public void setPropertyValue( QualifiedName stateName, Object newValue )
-    {
-        properties.put( stateName, newValue );
-    }
-
-    @Override
-    public void setAssociationValue( QualifiedName stateName, EntityReference newEntity )
-    {
-        associations.put( stateName, newEntity );
-    }
-
-    @Override
-    public ManyAssociationState manyAssociationValueOf( QualifiedName stateName )
-    {
-        ManyAssociationState state = manyAssociations.get( stateName );
-        if( state == null )
-        {
-            state = new BuilderManyAssociationState();
-            manyAssociations.put( stateName, state );
-        }
-        return state;
-    }
-
-    @Override
-    public NamedAssociationState namedAssociationValueOf( QualifiedName stateName )
-    {
-        NamedAssociationState state = namedAssociations.get( stateName );
-        if( state == null )
-        {
-            state = new BuilderNamedAssociationState();
-            namedAssociations.put( stateName, state );
-        }
-        return state;
-    }
-
-    public void copyTo( EntityState newEntityState )
-    {
-        for( Map.Entry<QualifiedName, Object> fromPropertyEntry : properties.entrySet() )
-        {
-            newEntityState.setPropertyValue( fromPropertyEntry.getKey(), fromPropertyEntry.getValue() );
-        }
-        for( Map.Entry<QualifiedName, EntityReference> fromAssociationEntry : associations.entrySet() )
-        {
-            newEntityState.setAssociationValue( fromAssociationEntry.getKey(), fromAssociationEntry.getValue() );
-        }
-        for( Map.Entry<QualifiedName, ManyAssociationState> fromManyAssociationEntry : manyAssociations.entrySet() )
-        {
-            QualifiedName qName = fromManyAssociationEntry.getKey();
-            ManyAssociationState fromManyAssoc = fromManyAssociationEntry.getValue();
-            ManyAssociationState toManyAssoc = newEntityState.manyAssociationValueOf( qName );
-            for( EntityReference entityReference : fromManyAssoc )
-            {
-                toManyAssoc.add( 0, entityReference );
-            }
-        }
-        for( Map.Entry<QualifiedName, NamedAssociationState> fromNamedAssociationEntry : namedAssociations.entrySet() )
-        {
-            QualifiedName qName = fromNamedAssociationEntry.getKey();
-            NamedAssociationState fromNamedAssoc = fromNamedAssociationEntry.getValue();
-            NamedAssociationState toNamedAssoc = newEntityState.namedAssociationValueOf( qName );
-            for( String name : fromNamedAssoc )
-            {
-                toNamedAssoc.put( name, fromNamedAssoc.get( name ) );
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderManyAssociationState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderManyAssociationState.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderManyAssociationState.java
deleted file mode 100644
index d549c2a..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderManyAssociationState.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.runtime.unitofwork;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.spi.entity.ManyAssociationState;
-
-/**
- * Default implementation of ManyAssociationState that also
- * keeps a list of changes that can be extracted at any time.
- */
-public final class BuilderManyAssociationState
-    implements ManyAssociationState
-{
-    private List<EntityReference> references;
-
-    public BuilderManyAssociationState()
-    {
-        references = new ArrayList<EntityReference>();
-    }
-
-    @Override
-    public int count()
-    {
-        return references.size();
-    }
-
-    @Override
-    public boolean contains( EntityReference entityReference )
-    {
-        return references.contains( entityReference );
-    }
-
-    @Override
-    public boolean add( int i, EntityReference entityReference )
-    {
-        if( references.contains( entityReference ) )
-        {
-            return false;
-        }
-
-        references.add( i, entityReference );
-        return true;
-    }
-
-    @Override
-    public boolean remove( EntityReference entityReference )
-    {
-        return references.remove( entityReference );
-    }
-
-    @Override
-    public EntityReference get( int i )
-    {
-        return references.get( i );
-    }
-
-    @Override
-    public Iterator<EntityReference> iterator()
-    {
-        return references.iterator();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderNamedAssociationState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderNamedAssociationState.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderNamedAssociationState.java
deleted file mode 100644
index 8ec7a4b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderNamedAssociationState.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.unitofwork;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.spi.entity.NamedAssociationState;
-
-/**
- * Default implementation of NamedAssociationState that also
- * keeps a list of changes that can be extracted at any time.
- */
-public final class BuilderNamedAssociationState
-    implements NamedAssociationState
-{
-    private final Map<String, EntityReference> references;
-
-    public BuilderNamedAssociationState()
-    {
-        references = new HashMap<>();
-    }
-
-    @Override
-    public int count()
-    {
-        return references.size();
-    }
-
-    @Override
-    public boolean containsName( String name )
-    {
-        return references.containsKey( name );
-    }
-
-    @Override
-    public boolean put( String name, EntityReference entityReference )
-    {
-        return references.put( name, entityReference ) != null;
-    }
-
-    @Override
-    public boolean remove( String name )
-    {
-        return references.remove( name ) != null;
-    }
-
-    @Override
-    public EntityReference get( String name )
-    {
-        return references.get( name );
-    }
-
-    @Override
-    public String nameOf( EntityReference entityReference )
-    {
-        for( Map.Entry<String, EntityReference> entry : references.entrySet() )
-        {
-            if( entry.getValue().equals( entityReference ) )
-            {
-                return entry.getKey();
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public Iterator<String> iterator()
-    {
-        return references.keySet().iterator();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
deleted file mode 100644
index 014c28c..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2007-2009, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Alin Dreghiciu. All Rights Reserved.
- * Copyright (c) 2008, Edward Yakop. All Rights Reserved.
- * Copyright (c) 2014-2015, Paul Merlin. 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.zest.runtime.unitofwork;
-
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.LifecycleException;
-import org.apache.zest.runtime.composite.FunctionStateResolver;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-
-/**
- * Implementation of EntityBuilder. Maintains an instance of the entity which
- * will not have its state validated until it is created by calling newInstance().
- */
-public final class EntityBuilderInstance<T>
-    implements EntityBuilder<T>
-{
-    private static final QualifiedName IDENTITY_STATE_NAME;
-
-    private final ModelModule<EntityModel> model;
-    private final ModuleUnitOfWork uow;
-    private final EntityStoreUnitOfWork store;
-    private String identity;
-
-    private final BuilderEntityState entityState;
-    private final EntityInstance prototypeInstance;
-
-    static
-    {
-        try
-        {
-            IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: EntityBuilderInstance" );
-        }
-    }
-
-    public EntityBuilderInstance(
-        ModelModule<EntityModel> model,
-        ModuleUnitOfWork uow,
-        EntityStoreUnitOfWork store,
-        String identity
-    )
-    {
-        this( model, uow, store, identity, null );
-    }
-
-    public EntityBuilderInstance(
-        ModelModule<EntityModel> model,
-        ModuleUnitOfWork uow,
-        EntityStoreUnitOfWork store,
-        String identity,
-        FunctionStateResolver stateResolver
-    )
-    {
-        this.model = model;
-        this.uow = uow;
-        this.store = store;
-        this.identity = identity;
-        EntityReference reference = new EntityReference( identity );
-        entityState = new BuilderEntityState( model.model(), reference );
-        model.model().initState( model.module(), entityState );
-        if( stateResolver != null )
-        {
-            stateResolver.populateState( model.model(), entityState );
-        }
-        entityState.setPropertyValue( IDENTITY_STATE_NAME, identity );
-        prototypeInstance = model.model().newInstance( uow, model.module(), entityState );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    @Override
-    public T instance()
-    {
-        checkValid();
-        return prototypeInstance.<T>proxy();
-    }
-
-    @Override
-    public <K> K instanceFor( Class<K> mixinType )
-    {
-        checkValid();
-        return prototypeInstance.newProxy( mixinType );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public T newInstance()
-        throws LifecycleException
-    {
-        checkValid();
-
-        String identity;
-
-        // Figure out whether to use given or generated identity
-        identity = (String) entityState.propertyValueOf( IDENTITY_STATE_NAME );
-        EntityState newEntityState = model.model().newEntityState( store, uow.module(),
-                                                                   EntityReference.parseEntityReference( identity ) );
-
-        prototypeInstance.invokeCreate();
-
-        // Check constraints
-        prototypeInstance.checkConstraints();
-
-        entityState.copyTo( newEntityState );
-
-        EntityInstance instance = model.model().newInstance( uow, model.module(), newEntityState );
-
-        Object proxy = instance.proxy();
-
-        // Add entity in UOW
-        uow.addEntity( instance );
-
-        // Invalidate builder
-        this.identity = null;
-
-        return (T) proxy;
-    }
-
-    private void checkValid()
-        throws IllegalStateException
-    {
-        if( identity == null )
-        {
-            throw new IllegalStateException( "EntityBuilder is not valid after call to newInstance()" );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
deleted file mode 100644
index 6afe68e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.runtime.unitofwork;
-
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * JAVADOC
- */
-final class EntityStateStore
-{
-    AssociationStateHolder stateHolder;
-    EntityState state;
-
-    @Override
-    public String toString()
-    {
-        return state.identity().toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
deleted file mode 100644
index 2136528..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright (c) 2007-2013, Niclas Hedhman. 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.zest.runtime.unitofwork;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Stack;
-import java.util.concurrent.TimeUnit;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.metrics.MetricsCounter;
-import org.apache.zest.api.metrics.MetricsCounterFactory;
-import org.apache.zest.api.metrics.MetricsProvider;
-import org.apache.zest.api.metrics.MetricsTimer;
-import org.apache.zest.api.metrics.MetricsTimerFactory;
-import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
-import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.unitofwork.UnitOfWorkException;
-import org.apache.zest.api.unitofwork.UnitOfWorkOptions;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.entitystore.ConcurrentEntityStateModificationException;
-import org.apache.zest.spi.entitystore.EntityNotFoundException;
-import org.apache.zest.spi.entitystore.EntityStore;
-import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.entitystore.StateCommitter;
-import org.apache.zest.spi.metrics.DefaultMetric;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.COMPLETED;
-import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.DISCARDED;
-import static org.apache.zest.functional.Iterables.map;
-
-public final class UnitOfWorkInstance
-{
-    private static final ThreadLocal<Stack<UnitOfWorkInstance>> current = new ThreadLocal<Stack<UnitOfWorkInstance>>()
-    {
-        @Override
-        protected Stack<UnitOfWorkInstance> initialValue()
-        {
-            return new Stack<>();
-        }
-    };
-    private MetricsTimer.Context metricsTimer;
-
-    public static Stack<UnitOfWorkInstance> getCurrent()
-    {
-        return current.get();
-    }
-
-    private long currentTime;
-    private MetricsProvider metrics;
-    final HashMap<EntityReference, EntityInstance> instanceCache;
-    final HashMap<EntityStore, EntityStoreUnitOfWork> storeUnitOfWork;
-
-    private boolean open;
-
-    private boolean paused;
-
-    /**
-     * Lazy query builder factory.
-     */
-    private Usecase usecase;
-
-    private MetaInfo metaInfo;
-
-    private List<UnitOfWorkCallback> callbacks;
-
-    public UnitOfWorkInstance( Usecase usecase, long currentTime, MetricsProvider metrics )
-    {
-        this.currentTime = currentTime;
-        this.open = true;
-        instanceCache = new HashMap<>();
-        storeUnitOfWork = new HashMap<>();
-        getCurrent().push( this );
-        paused = false;
-        this.usecase = usecase;
-        startCapture( metrics );
-    }
-
-    public long currentTime()
-    {
-        return currentTime;
-    }
-
-    public EntityStoreUnitOfWork getEntityStoreUnitOfWork( EntityStore store, ModuleSpi module )
-    {
-        EntityStoreUnitOfWork uow = storeUnitOfWork.get( store );
-        if( uow == null )
-        {
-            uow = store.newUnitOfWork( usecase, module, currentTime );
-            storeUnitOfWork.put( store, uow );
-        }
-        return uow;
-    }
-
-    public <T> T get( EntityReference identity,
-                      ModuleUnitOfWork uow,
-                      Iterable<ModelModule<EntityModel>> potentialModels,
-                      Class<T> mixinType
-    )
-        throws EntityTypeNotFoundException, NoSuchEntityException
-    {
-        checkOpen();
-
-        EntityInstance entityInstance = instanceCache.get( identity );
-        if( entityInstance == null )
-        {   // Not yet in cache
-
-            // Check if this is a root UoW, or if no parent UoW knows about this entity
-            EntityState entityState = null;
-            EntityModel model = null;
-            ModuleSpi module = null;
-            // Figure out what EntityStore to use
-            for( ModelModule<EntityModel> potentialModel : potentialModels )
-            {
-                EntityStore store = potentialModel.module().entityStore();
-                EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store, potentialModel.module() );
-                try
-                {
-                    entityState = storeUow.entityStateOf( potentialModel.module(), identity );
-                }
-                catch( EntityNotFoundException e )
-                {
-                    continue;
-                }
-
-                // Get the selected model
-                model = (EntityModel) entityState.entityDescriptor();
-                module = potentialModel.module();
-            }
-
-            // Check if model was found
-            if( model == null )
-            {
-                // Check if state was found
-                if( entityState == null )
-                {
-                    throw new NoSuchEntityException( identity, mixinType, usecase );
-                }
-                else
-                {
-                    throw new EntityTypeNotFoundException( mixinType.getName(),
-                                                           module.name(),
-                                                           map( ModelModule.toStringFunction,
-                                                                module.findVisibleEntityTypes()
-                                                           ) );
-                }
-            }
-
-            // Create instance
-            entityInstance = new EntityInstance( uow, module, model, entityState );
-
-            instanceCache.put( identity, entityInstance );
-        }
-        else
-        {
-            // Check if it has been removed
-            if( entityInstance.status() == EntityStatus.REMOVED )
-            {
-                throw new NoSuchEntityException( identity, mixinType, usecase );
-            }
-        }
-
-        return entityInstance.proxy();
-    }
-
-    public Usecase usecase()
-    {
-        return usecase;
-    }
-
-    public MetaInfo metaInfo()
-    {
-        if( metaInfo == null )
-        {
-            metaInfo = new MetaInfo();
-        }
-
-        return metaInfo;
-    }
-
-    public void pause()
-    {
-        if( !paused )
-        {
-            paused = true;
-            getCurrent().pop();
-
-            UnitOfWorkOptions unitOfWorkOptions = metaInfo().get( UnitOfWorkOptions.class );
-            if( unitOfWorkOptions == null )
-            {
-                unitOfWorkOptions = usecase().metaInfo( UnitOfWorkOptions.class );
-            }
-
-            if( unitOfWorkOptions != null )
-            {
-                if( unitOfWorkOptions.isPruneOnPause() )
-                {
-                    List<EntityReference> prunedInstances = null;
-                    for( EntityInstance entityInstance : instanceCache.values() )
-                    {
-                        if( entityInstance.status() == EntityStatus.LOADED )
-                        {
-                            if( prunedInstances == null )
-                            {
-                                prunedInstances = new ArrayList<>();
-                            }
-                            prunedInstances.add( entityInstance.identity() );
-                        }
-                    }
-                    if( prunedInstances != null )
-                    {
-                        for( EntityReference prunedInstance : prunedInstances )
-                        {
-                            instanceCache.remove( prunedInstance );
-                        }
-                    }
-                }
-            }
-        }
-        else
-        {
-            throw new UnitOfWorkException( "Unit of work is not active" );
-        }
-    }
-
-    public void resume()
-    {
-        if( paused )
-        {
-            paused = false;
-            getCurrent().push( this );
-        }
-        else
-        {
-            throw new UnitOfWorkException( "Unit of work has not been paused" );
-        }
-    }
-
-    public void complete()
-        throws UnitOfWorkCompletionException
-    {
-        checkOpen();
-
-        // Copy list so that it cannot be modified during completion
-        List<UnitOfWorkCallback> currentCallbacks = callbacks == null ? null : new ArrayList<>( callbacks );
-
-        // Commit state to EntityStores
-        List<StateCommitter> committers = applyChanges();
-
-        // Check callbacks
-        notifyBeforeCompletion( currentCallbacks );
-
-        // Commit all changes
-        for( StateCommitter committer : committers )
-        {
-            committer.commit();
-        }
-
-        close();
-
-        // Call callbacks
-        notifyAfterCompletion( currentCallbacks, COMPLETED );
-
-        callbacks = currentCallbacks;
-    }
-
-    public void discard()
-    {
-        if( !isOpen() )
-        {
-            return;
-        }
-        close();
-
-        // Copy list so that it cannot be modified during completion
-        List<UnitOfWorkCallback> currentCallbacks = callbacks == null ? null : new ArrayList<>( callbacks );
-
-        // Call callbacks
-        notifyAfterCompletion( currentCallbacks, DISCARDED );
-
-        for( EntityStoreUnitOfWork entityStoreUnitOfWork : storeUnitOfWork.values() )
-        {
-            entityStoreUnitOfWork.discard();
-        }
-
-        callbacks = currentCallbacks;
-    }
-
-    private void close()
-    {
-        checkOpen();
-
-        if( !isPaused() )
-        {
-            getCurrent().pop();
-        }
-        endCapture();
-        open = false;
-    }
-
-    public boolean isOpen()
-    {
-        return open;
-    }
-
-    public void addUnitOfWorkCallback( UnitOfWorkCallback callback )
-    {
-        if( callbacks == null )
-        {
-            callbacks = new ArrayList<>();
-        }
-
-        callbacks.add( callback );
-    }
-
-    public void removeUnitOfWorkCallback( UnitOfWorkCallback callback )
-    {
-        if( callbacks != null )
-        {
-            callbacks.remove( callback );
-        }
-    }
-
-    public void addEntity( EntityInstance instance )
-    {
-        instanceCache.put( instance.identity(), instance );
-    }
-
-    private List<StateCommitter> applyChanges()
-        throws UnitOfWorkCompletionException
-    {
-        List<StateCommitter> committers = new ArrayList<>();
-        for( EntityStoreUnitOfWork entityStoreUnitOfWork : storeUnitOfWork.values() )
-        {
-            try
-            {
-                StateCommitter committer = entityStoreUnitOfWork.applyChanges();
-                committers.add( committer );
-            }
-            catch( Exception e )
-            {
-                // Cancel all previously prepared stores
-                for( StateCommitter committer : committers )
-                {
-                    committer.cancel();
-                }
-
-                if( e instanceof ConcurrentEntityStateModificationException )
-                {
-                    // If we cancelled due to concurrent modification, then create the proper exception for it!
-                    ConcurrentEntityStateModificationException mee = (ConcurrentEntityStateModificationException) e;
-                    Collection<EntityReference> modifiedEntityIdentities = mee.modifiedEntities();
-                    Collection<EntityComposite> modifiedEntities = new ArrayList<>();
-                    for( EntityReference modifiedEntityIdentity : modifiedEntityIdentities )
-                    {
-                        Collection<EntityInstance> instances = instanceCache.values();
-                        for( EntityInstance instance : instances )
-                        {
-                            if( instance.identity().equals( modifiedEntityIdentity ) )
-                            {
-                                modifiedEntities.add( instance.<EntityComposite>proxy() );
-                            }
-                        }
-                    }
-                    throw new ConcurrentEntityModificationException( modifiedEntities );
-                }
-                else
-                {
-                    throw new UnitOfWorkCompletionException( e );
-                }
-            }
-        }
-        return committers;
-    }
-
-    private void notifyBeforeCompletion( List<UnitOfWorkCallback> callbacks )
-        throws UnitOfWorkCompletionException
-    {
-        // Notify explicitly registered callbacks
-        if( callbacks != null )
-        {
-            for( UnitOfWorkCallback callback : callbacks )
-            {
-                callback.beforeCompletion();
-            }
-        }
-
-        // Notify entities
-        try
-        {
-            for( EntityInstance instance : instanceCache.values() )
-            {
-                boolean isCallback = instance.proxy() instanceof UnitOfWorkCallback;
-                boolean isNotRemoved = !instance.status().equals( EntityStatus.REMOVED );
-                if( isCallback && isNotRemoved )
-                {
-                    UnitOfWorkCallback callback = UnitOfWorkCallback.class.cast( instance.proxy() );
-                    callback.beforeCompletion();
-                }
-            }
-        }
-        catch( UnitOfWorkCompletionException e )
-        {
-            throw e;
-        }
-        catch( Exception e )
-        {
-            throw new UnitOfWorkCompletionException( e );
-        }
-    }
-
-    private void notifyAfterCompletion( List<UnitOfWorkCallback> callbacks,
-                                        final UnitOfWorkCallback.UnitOfWorkStatus status
-    )
-    {
-        if( callbacks != null )
-        {
-            for( UnitOfWorkCallback callback : callbacks )
-            {
-                try
-                {
-                    callback.afterCompletion( status );
-                }
-                catch( Exception e )
-                {
-                    // Ignore
-                }
-            }
-        }
-
-        // Notify entities
-        try
-        {
-            for( EntityInstance instance : instanceCache.values() )
-            {
-                boolean isCallback = instance.proxy() instanceof UnitOfWorkCallback;
-                boolean isNotRemoved = !instance.status().equals( EntityStatus.REMOVED );
-                if( isCallback && isNotRemoved )
-                {
-                    UnitOfWorkCallback callback = UnitOfWorkCallback.class.cast( instance.proxy() );
-                    callback.afterCompletion( status );
-                }
-            }
-        }
-        catch( Exception e )
-        {
-            // Ignore
-        }
-    }
-
-    public void checkOpen()
-    {
-        if( !isOpen() )
-        {
-            throw new UnitOfWorkException( "Unit of work has been closed" );
-        }
-    }
-
-    public boolean isPaused()
-    {
-        return paused;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "UnitOfWork " + hashCode() + "(" + usecase + "): entities:" + instanceCache.size();
-    }
-
-    public void remove( EntityReference entityReference )
-    {
-        instanceCache.remove( entityReference );
-    }
-
-    private void incrementCount()
-    {
-        MetricsCounter counter = getCounter();
-        counter.increment();
-    }
-
-    private void decrementCount()
-    {
-        MetricsCounter counter = getCounter();
-        counter.decrement();
-    }
-
-    private MetricsCounter getCounter()
-    {
-        if( metrics != null )
-        {
-            MetricsCounterFactory metricsFactory = metrics.createFactory( MetricsCounterFactory.class );
-            return metricsFactory.createCounter( getClass(), "UnitOfWork Counter" );
-        }
-        return new DefaultMetric();
-    }
-
-    private void endCapture()
-    {
-        decrementCount();
-        metricsTimer.stop();
-    }
-
-    private void startCapture( MetricsProvider metrics )
-    {
-        this.metrics = metrics;
-        incrementCount();
-        startTimer( metrics );
-    }
-
-    private void startTimer( MetricsProvider metrics )
-    {
-        MetricsTimerFactory metricsFactory = metrics.createFactory( MetricsTimerFactory.class );
-        String name = "UnitOfWork Timer";
-        MetricsTimer timer = metricsFactory.createTimer( getClass(), name, TimeUnit.MILLISECONDS, TimeUnit.SECONDS );
-        metricsTimer = timer.start();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ManyAssociationValueState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ManyAssociationValueState.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ManyAssociationValueState.java
deleted file mode 100644
index 6056d9b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ManyAssociationValueState.java
+++ /dev/null
@@ -1,105 +0,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.
- */
-package org.apache.zest.runtime.value;
-
-import java.util.Iterator;
-import java.util.List;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.spi.entity.ManyAssociationState;
-
-/**
- * ManyAssociationState implementation for Value composites.
- */
-public class ManyAssociationValueState
-    implements ManyAssociationState
-{
-    private List<EntityReference> references;
-
-    public ManyAssociationValueState( List<EntityReference> references )
-    {
-        this.references = references;
-    }
-
-    @Override
-    public int count()
-    {
-        return references.size();
-    }
-
-    @Override
-    public boolean contains( EntityReference entityReference )
-    {
-        return references.contains( entityReference );
-    }
-
-    @Override
-    public boolean add( int i, EntityReference entityReference )
-    {
-        if( references.contains( entityReference ) )
-        {
-            return false;
-        }
-
-        references.add( i, entityReference );
-        return true;
-    }
-
-    @Override
-    public boolean remove( EntityReference entity )
-    {
-        boolean removed = references.remove( entity );
-        return removed;
-    }
-
-    @Override
-    public EntityReference get( int i )
-    {
-        return references.get( i );
-    }
-
-    @Override
-    public Iterator<EntityReference> iterator()
-    {
-        final Iterator<EntityReference> iter = references.iterator();
-
-        return new Iterator<EntityReference>()
-        {
-            EntityReference current;
-
-            @Override
-            public boolean hasNext()
-            {
-                return iter.hasNext();
-            }
-
-            @Override
-            public EntityReference next()
-            {
-                current = iter.next();
-                return current;
-            }
-
-            @Override
-            public void remove()
-            {
-                iter.remove();
-            }
-        };
-    }
-}


[48/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java b/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
deleted file mode 100644
index 92f2e7b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
+++ /dev/null
@@ -1,580 +0,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.
- */
-package org.apache.zest.api.composite;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Dates;
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- * Transfer java.util.Properties to Composite properties
- */
-public final class PropertyMapper
-{
-
-    private final static Map<Type, MappingStrategy> STRATEGY;
-
-    static
-    {
-        STRATEGY = new HashMap<>();
-        STRATEGY.put( Integer.class, new IntegerMapper() );
-        STRATEGY.put( Long.class, new LongMapper() );
-        STRATEGY.put( Short.class, new ShortMapper() );
-        STRATEGY.put( Byte.class, new ByteMapper() );
-        STRATEGY.put( String.class, new StringMapper() );
-        STRATEGY.put( Character.class, new CharMapper() );
-        STRATEGY.put( Float.class, new FloatMapper() );
-        STRATEGY.put( Double.class, new DoubleMapper() );
-        STRATEGY.put( Date.class, new DateMapper() );
-        STRATEGY.put( Boolean.class, new BooleanMapper() );
-        STRATEGY.put( BigDecimal.class, new BigDecimalMapper() );
-        STRATEGY.put( BigInteger.class, new BigIntegerMapper() );
-        STRATEGY.put( Enum.class, new EnumMapper() );
-        STRATEGY.put( Array.class, new ArrayMapper() );
-        STRATEGY.put( Map.class, new MapMapper() );
-        STRATEGY.put( List.class, new ListMapper() );
-        STRATEGY.put( Set.class, new SetMapper() );
-        STRATEGY.put( ValueComposite.class, new ValueCompositeMapper() );
-    }
-
-    /**
-     * Populate the Composite with properties from the given properties object.
-     *
-     * @param props     properties object
-     * @param composite the composite instance
-     *
-     * @throws IllegalArgumentException if properties could not be transferred to composite
-     */
-    public static void map( Properties props, Composite composite )
-        throws IllegalArgumentException
-    {
-        for( Map.Entry<Object, Object> objectObjectEntry : props.entrySet() )
-        {
-            try
-            {
-                String methodName = objectObjectEntry.getKey().toString();
-                Method propertyMethod = composite.getClass().getInterfaces()[ 0 ].getMethod( methodName );
-                propertyMethod.setAccessible( true );
-                Object value = objectObjectEntry.getValue();
-                Type propertyType = GenericPropertyInfo.propertyTypeOf( propertyMethod );
-
-                value = mapToType( composite, propertyType, value.toString() );
-
-                @SuppressWarnings( "unchecked" )
-                Property<Object> property = (Property<Object>) propertyMethod.invoke( composite );
-                property.set( value );
-            }
-            catch( NoSuchMethodException e )
-            {
-                throw new IllegalArgumentException( "Could not find any property named " + objectObjectEntry.getKey() );
-            }
-            catch( IllegalAccessException e )
-            {
-                //noinspection ThrowableInstanceNeverThrown
-                throw new IllegalArgumentException( "Could not populate property named " + objectObjectEntry.getKey(), e );
-            }
-            catch( InvocationTargetException e )
-            {
-                //noinspection ThrowableInstanceNeverThrown
-                String message = "Could not populate property named " + objectObjectEntry.getKey();
-                throw new IllegalArgumentException( message, e );
-            }
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    private static Object mapToType( Composite composite, Type propertyType, Object value )
-    {
-        final String stringValue = value.toString();
-        MappingStrategy strategy;
-        if( propertyType instanceof Class )
-        {
-            Class type = (Class) propertyType;
-            if( type.isArray() )
-            {
-                strategy = STRATEGY.get( Array.class );
-            }
-            else if( Enum.class.isAssignableFrom( Classes.RAW_CLASS.map( propertyType ) ) )
-            {
-                strategy = STRATEGY.get( Enum.class );
-            }
-            else
-            {
-                strategy = STRATEGY.get( type );
-            }
-            if( strategy == null  ) // If null, try with the ValueComposite Mapper...
-            {
-                strategy = STRATEGY.get( ValueComposite.class );
-            }
-        }
-        else if( propertyType instanceof ParameterizedType )
-        {
-            ParameterizedType type = ( (ParameterizedType) propertyType );
-
-            if( type.getRawType() instanceof Class )
-            {
-                Class clazz = (Class) type.getRawType();
-                if( List.class.isAssignableFrom( clazz ) )
-                {
-                    strategy = STRATEGY.get( List.class );
-                }
-                else if( Set.class.isAssignableFrom( clazz ) )
-                {
-                    strategy = STRATEGY.get( Set.class );
-                }
-                else if( Map.class.isAssignableFrom( clazz ) )
-                {
-                    strategy = STRATEGY.get( Map.class );
-                }
-                else
-                {
-                    throw new IllegalArgumentException( propertyType + " is not supported." );
-                }
-            }
-            else
-            {
-                throw new IllegalArgumentException( propertyType + " is not supported." );
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException( propertyType + " is not supported." );
-        }
-
-        if( strategy == null )
-        {
-            throw new IllegalArgumentException( propertyType + " is not supported." );
-        }
-
-        return strategy.map( composite, propertyType, stringValue );
-    }
-
-    /**
-     * Load a Properties object from the given stream, close it, and then populate
-     * the Composite with the properties.
-     *
-     * @param propertyInputStream properties input stream
-     * @param composite           the instance
-     *
-     * @throws IOException if the stream could not be read
-     */
-
-    public static void map( InputStream propertyInputStream, Composite composite )
-        throws IOException
-    {
-        if( propertyInputStream != null )
-        {
-            Properties configProps = new Properties();
-            try
-            {
-                configProps.load( propertyInputStream );
-            }
-            finally
-            {
-                propertyInputStream.close();
-            }
-            map( configProps, composite );
-        }
-    }
-
-    /**
-     * Create Properties object which is backed by the given Composite.
-     *
-     * @param composite the instance
-     *
-     * @return properties instance
-     */
-    public static Properties toJavaProperties( final Composite composite )
-    {
-        return new Properties()
-        {
-            private static final long serialVersionUID = 3550125427530538865L;
-
-            @Override
-            public Object get( Object o )
-            {
-                try
-                {
-                    Method propertyMethod = composite.getClass().getMethod( o.toString() );
-                    Property<?> property = (Property<?>) propertyMethod.invoke( composite );
-                    return property.get();
-                }
-                catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e )
-                {
-                    return null;
-                }
-            }
-
-            @Override
-            public Object put( Object o, Object o1 )
-            {
-                Object oldValue = get( o );
-
-                try
-                {
-                    Method propertyMethod = composite.getClass().getMethod( o.toString(), Object.class );
-                    propertyMethod.invoke( composite, o1 );
-                }
-                catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e )
-                {
-                    e.printStackTrace();
-                }
-
-                return oldValue;
-            }
-        };
-    }
-
-    private static void tokenize( String valueString, boolean mapSyntax, TokenizerCallback callback )
-    {
-        char[] data = valueString.toCharArray();
-
-        int oldPos = 0;
-        for( int pos = 0; pos < data.length; pos++ )
-        {
-            char ch = data[ pos ];
-            if( ch == '\"' )
-            {
-                pos = resolveQuotes( valueString, callback, data, pos, '\"' );
-                oldPos = pos;
-            }
-            if( ch == '\'' )
-            {
-                pos = resolveQuotes( valueString, callback, data, pos, '\'' );
-                oldPos = pos;
-            }
-            if( ch == ',' || ( mapSyntax && ch == ':' ) )
-            {
-                String token = new String( data, oldPos, pos - oldPos );
-                callback.token( token );
-                oldPos = pos + 1;
-            }
-        }
-        String token = new String( data, oldPos, data.length - oldPos );
-        callback.token( token );
-    }
-
-    private static int resolveQuotes( String valueString,
-                                      TokenizerCallback callback,
-                                      char[] data,
-                                      int pos, char quote
-    )
-    {
-        boolean found = false;
-        for( int j = pos + 1; j < data.length; j++ )
-        {
-            if( !found )
-            {
-                if( data[ j ] == quote )
-                {
-                    String token = new String( data, pos + 1, j - pos - 1 );
-                    callback.token( token );
-                    found = true;
-                }
-            }
-            else
-            {
-                if( data[ j ] == ',' )
-                {
-                    return j + 1;
-                }
-            }
-        }
-        if( !found )
-        {
-            throw new IllegalArgumentException( "String is not quoted correctly: " + valueString );
-        }
-        return data.length;
-    }
-
-    private interface TokenizerCallback
-    {
-        void token( String token );
-    }
-
-    private interface MappingStrategy
-    {
-        Object map( Composite composite, Type type, String value );
-    }
-
-    private static class StringMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return value;
-        }
-    }
-
-    private static class IntegerMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Integer( value.trim() );
-        }
-    }
-
-    private static class FloatMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Float( value.trim() );
-        }
-    }
-
-    private static class DoubleMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Double( value.trim() );
-        }
-    }
-
-    private static class LongMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Long( value.trim() );
-        }
-    }
-
-    private static class ShortMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Short( value.trim() );
-        }
-    }
-
-    private static class ByteMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new Byte( value.trim() );
-        }
-    }
-
-    private static class CharMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return value.trim().charAt( 0 );
-        }
-    }
-
-    private static class BigDecimalMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new BigDecimal( value.trim() );
-        }
-    }
-
-    private static class BigIntegerMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return new BigInteger( value.trim() );
-        }
-    }
-
-    private static class EnumMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public Object map( Composite composite, Type type, String value )
-        {
-            return Enum.valueOf( (Class<Enum>) type, value );
-        }
-    }
-
-    private static class DateMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( Composite composite, Type type, String value )
-        {
-            return Dates.fromString( value.trim() );
-        }
-    }
-
-    private static class ValueCompositeMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public Object map( Composite composite, Type type, String value )
-        {
-            return Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( composite ).module().newValueFromSerializedState( (Class<Object>) type, value );
-        }
-    }
-
-    private static class ArrayMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Object map( final Composite composite, Type type, String value )
-        {
-            final Class arrayType = ( (Class) type ).getComponentType();
-            final ArrayList result = new ArrayList();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, arrayType, token ) );
-                }
-            } );
-            return result.toArray( (Object[]) Array.newInstance( arrayType, result.size() ) );
-        }
-    }
-
-    private static class BooleanMapper
-        implements MappingStrategy
-    {
-        @Override
-        public Object map( final Composite composite, Type type, String value )
-        {
-            return Boolean.valueOf( value.trim() );
-        }
-    }
-
-    private static class ListMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Object map( final Composite composite, Type type, String value )
-        {
-            final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
-            final Collection result = new ArrayList();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, dataType, token ) );
-                }
-            } );
-            return result;
-        }
-    }
-
-    private static class SetMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Object map( final Composite composite, Type type, String value )
-        {
-            final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
-            final Collection result = new HashSet();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, dataType, token ) );
-                }
-            } );
-            return result;
-        }
-    }
-
-    private static class MapMapper
-        implements MappingStrategy
-    {
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Object map( final Composite composite, Type generictype, String value )
-        {
-            ParameterizedType type = (ParameterizedType) generictype;
-            final Type keyType = type.getActualTypeArguments()[ 0 ];
-            final Type valueType = type.getActualTypeArguments()[ 0 ];
-            final Map result = new HashMap();
-            tokenize( value, true, new TokenizerCallback()
-            {
-                boolean keyArrivingNext = true;
-                String key;
-
-                @Override
-                public void token( String token )
-                {
-                    if( keyArrivingNext )
-                    {
-                        key = token;
-                        keyArrivingNext = false;
-                    }
-                    else
-                    {
-                        result.put( mapToType( composite, keyType, key ), mapToType( composite, valueType, token ) );
-                        keyArrivingNext = true;
-                    }
-                }
-            } );
-            return result;
-        }
-    }
-
-    private PropertyMapper()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/StateDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/StateDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/StateDescriptor.java
deleted file mode 100644
index 2d3ac07..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/StateDescriptor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.property.PropertyDescriptor;
-
-/**
- * Composite State Descriptor.
- */
-public interface StateDescriptor
-{
-    PropertyDescriptor findPropertyModelByName( String name )
-        throws IllegalArgumentException;
-
-    PropertyDescriptor findPropertyModelByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException;
-
-    Iterable<? extends PropertyDescriptor> properties();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/StatefulCompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/StatefulCompositeDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/StatefulCompositeDescriptor.java
deleted file mode 100644
index 58c38f9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/StatefulCompositeDescriptor.java
+++ /dev/null
@@ -1,27 +0,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.
- */
-package org.apache.zest.api.composite;
-
-/**
- * Stateful Composite Descriptor.
- */
-public interface StatefulCompositeDescriptor
-{
-    StateDescriptor state();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilder.java b/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilder.java
deleted file mode 100644
index b54682e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilder.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * TransientBuilders are used to instantiate TransientComposites. They can be acquired from
- * {@link TransientBuilderFactory#newTransientBuilder(Class)} and allows the client
- * to provide additional settings before instantiating the TransientComposite.
- */
-public interface TransientBuilder<T>
-{
-    /**
-     * Provide objects that can be injected into mixins that has the @Uses
-     * dependency injection annotation.
-     *
-     * @param usedObjects The objects that can be injected into mixins.
-     *
-     * @return the transient builder instance
-     *
-     * @see org.apache.zest.api.injection.scope.Uses
-     */
-    TransientBuilder<T> use( Object... usedObjects );
-
-    /**
-     * Get a representation of the state for the new Composite.
-     * It is possible to access and update properties and associations,
-     * even immutable ones since the builder represents the initial state.
-     *
-     * @return a proxy implementing the Composite type
-     */
-    T prototype();
-
-    /**
-     * Get a representation of the state of the given type for the new Composite.
-     * This is primarily used if you want to provide state for a private mixin type.
-     *
-     * @param mixinType the mixin which you want to provide state for
-     *
-     * @return a proxy implementing the given mixin type
-     */
-    <K> K prototypeFor( Class<K> mixinType );
-
-    /**
-     * Create a new Composite instance.
-     *
-     * @return a new Composite instance
-     *
-     * @throws ConstructionException thrown if it was not possible to instantiate the Composite
-     */
-    T newInstance()
-        throws ConstructionException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilderFactory.java b/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilderFactory.java
deleted file mode 100644
index 0e64cde..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/TransientBuilderFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.composite;
-
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * This factory creates TransientComposites and the TransientBuilders.
- *
- * TransientComposite instances are very flexible in what it can reference, but are restricted in where they
- * can be used. So, TransientComposites are mainly recommended where Values, Entities and Services can not be used,
- * but they can also not be used to store state, be serialized across a network or have automatic equals/hashCode
- * calculations.
- */
-public interface TransientBuilderFactory
-{
-    /**
-     * Create a builder for creating new TransientComposites that implements the given TransientComposite type.
-     *
-     * @param mixinType an interface that describes the TransientComposite to be instantiated
-     *
-     * @return a TransientBuilder for creation of TransientComposites implementing the interface
-     *
-     * @throws NoSuchTransientException if no composite extending the mixinType has been registered
-     */
-    <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
-        throws NoSuchTransientException;
-
-    /**
-     * Instantiate a TransientComposite of the given type.
-     *
-     * @param mixinType the TransientComposite type to instantiate
-     *
-     * @return a new TransientComposite instance
-     *
-     * @throws NoSuchTransientException if no composite extending the mixinType has been registered
-     * @throws org.apache.zest.api.common.ConstructionException
-     *                                  if the composite could not be instantiated
-     */
-    <T> T newTransient( Class<T> mixinType, Object... uses )
-        throws NoSuchTransientException, ConstructionException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/TransientComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/TransientComposite.java b/core/api/src/main/java/org/apache/zest/api/composite/TransientComposite.java
deleted file mode 100644
index f3b1952..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/TransientComposite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-/**
- * Transient Composite Type.
- *
- * TransientComposites have the following criteria;
- * <ul>
- * <li>Does not persist its state, and is not serializable</li>
- * <li>Can not be referenced from Properties, Associations, ValueComposites nor Entities</li>
- * <li>Can reference all types</li>
- * <li>No lifecycle</li>
- * <li>equals/hashCode is delegated to a single Mixin implementing the methods, like any other method</li>
- * </ul>
- */
-public interface TransientComposite
-    extends Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/TransientDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/TransientDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/TransientDescriptor.java
deleted file mode 100644
index ec5bf24..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/TransientDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-/**
- * TransientComposite Descriptor.
- */
-public interface TransientDescriptor
-    extends CompositeDescriptor, StatefulCompositeDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/package.html b/core/api/src/main/java/org/apache/zest/api/composite/package.html
deleted file mode 100644
index 00feaed..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Composite API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/ConcernDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/ConcernDescriptor.java b/core/api/src/main/java/org/apache/zest/api/concern/ConcernDescriptor.java
deleted file mode 100644
index 05ac497..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/ConcernDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.concern;
-
-/**
- * Concern descriptor.
- */
-public interface ConcernDescriptor
-{
-    Class modifierClass();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/ConcernOf.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/ConcernOf.java b/core/api/src/main/java/org/apache/zest/api/concern/ConcernOf.java
deleted file mode 100644
index 24e4faa..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/ConcernOf.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.concern;
-
-import org.apache.zest.api.concern.internal.ConcernFor;
-
-/**
- * Base class for Concerns. It introduces a typed "next" pointer
- * that Concerns can use to invoke the next Concern (or mixin) in
- * the chain.
- * <p>
- * Generic Concerns should subclass {@link GenericConcern} instead.
- * </p>
- * <p>
- * Concerns implementations must be thread-safe in their implementation,
- * as multiple threads may share instances.
- * </p>
- */
-public abstract class ConcernOf<T>
-{
-    /**
-     * The "next" pointer. This points to
-     * the next concern in the chain or the mixin
-     * to be invoked.
-     */
-    final
-    @ConcernFor
-    protected T next = null;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/Concerns.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/Concerns.java b/core/api/src/main/java/org/apache/zest/api/concern/Concerns.java
deleted file mode 100644
index d871fc1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/Concerns.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.concern;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used by composites and mixins to declare what Concerns
- * should be applied to the type or specific method.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface Concerns
-{
-    Class<?>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/ConcernsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/ConcernsDescriptor.java b/core/api/src/main/java/org/apache/zest/api/concern/ConcernsDescriptor.java
deleted file mode 100644
index 261c18b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/ConcernsDescriptor.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*  Copyright 2008 Edward Yakop.
-*
-* 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.zest.api.concern;
-
-/**
- * Concerns descriptor.
- */
-public interface ConcernsDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/GenericConcern.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/GenericConcern.java b/core/api/src/main/java/org/apache/zest/api/concern/GenericConcern.java
deleted file mode 100644
index 33777bc..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/GenericConcern.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.concern;
-
-import java.lang.reflect.InvocationHandler;
-
-/**
- * Base class for generic Concerns. Subclass
- * and implement the "invoke" method. Use the
- * "next" field in {@link ConcernOf} to continue the invocation
- * chain.
- */
-public abstract class GenericConcern
-    extends ConcernOf<InvocationHandler>
-    implements InvocationHandler
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/internal/ConcernFor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/internal/ConcernFor.java b/core/api/src/main/java/org/apache/zest/api/concern/internal/ConcernFor.java
deleted file mode 100644
index dc5169d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/internal/ConcernFor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.concern.internal;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * This annotation is required once in each Concern, to mark the
- * field where the next element in the call sequence should be
- * injected.
- * <p>
- * The type of the field must be of the same type as the Concern
- * itself, or an InvocationHandler.
- * </p>
- * <p>
- * Example;
- * </p>
- * <pre><code>
- * public interface MyStuff
- * {
- *     void doSomething();
- * }
- *
- * public class MyStuffConcern
- *     implements MyStuff
- * {
- *     &#64;ConcernFor MyStuff next;
- *
- *     public void doSomething()
- *     {
- *         // HERE DO THE MODIFIER STUFF.
- *
- *         // Delegate to the underlying mixin/modifier.
- *         next.doSomething();
- *     }
- * }
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface ConcernFor
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/internal/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/internal/package.html b/core/api/src/main/java/org/apache/zest/api/concern/internal/package.html
deleted file mode 100644
index 9351f10..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/internal/package.html
+++ /dev/null
@@ -1,25 +0,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.
--->
-<html>
-    <body>
-        <h1>Internal/Private package for the Concern API.</h1>
-        <p>
-            This is an internal package, and no classes in this package is part of the API and compatibility
-            with these classes will not be attempted.
-        </p>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/concern/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/concern/package.html b/core/api/src/main/java/org/apache/zest/api/concern/package.html
deleted file mode 100644
index fcc7ef7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/concern/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Concern API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java b/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
deleted file mode 100644
index 9125dac..0000000
--- a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.api.configuration;
-
-import java.io.IOException;
-import java.io.InputStream;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.PropertyMapper;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.qualifier.ServiceTags;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.api.value.ValueSerialization;
-
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Provide Configurations for Services. A Service that wants to be configurable
- * should inject a reference to Configuration with the Configuration type:
- * <pre><code>
- *  * &#64;This Configuration&#60;MyServiceConfiguration&#62; config;
- * </code></pre>
- * <p>
- * where MyServiceConfiguration extends {@link ConfigurationComposite}, which itself is an ordinary
- * {@link org.apache.zest.api.entity.EntityComposite}. The Configuration implementation
- * will either locate an instance of the given Configuration type in the
- * persistent store using the identity of the Service, or create a new such instance
- * if one doesn't already exist.
- * </p>
- * <p>
- * If a new Configuration instance is created then it will be populated with properties
- * from the properties file whose filesystem name is the same as the identity (e.g. "MyService.properties").
- * If a service is not given a name via the {@code org.qi4j.bootstrap.ServiceDeclaration#identifiedBy(String)}, the
- * name will default to the FQCN of the ServiceComposite type.
- * </p>
- * <p>
- * The Configuration instance can be modified externally just like any other EntityComposite, but
- * its values will not be updated in the Service until {@link #refresh()} is called. This allows
- * safe reloads of Configuration state to ensure that it is not reloaded while the Service is handling
- * a request.
- * </p>
- * <p>
- * The Configuration will be automatically refreshed when the Service is activated by the Zest runtime.
- * Any refreshes at other points will have to be done manually or triggered through some other
- * mechanism.
- * </p>
- * <p>
- * The user configuration entity is part of a long running {@link UnitOfWork}, and to persist changes to it the
- * {@link #save()} method must be called. No other actions are required. Example;
- * </p>
- * <pre><code>
- *
- * public interface MyConfiguration extends ConfigurationComposite
- * {
- *     Property&lt;Long&gt; timeout();
- * }
- *
- * :
- *
- * &#64;This Configuration&lt;MyConfiguration&gt; config;
- * :
- * private void setTimeoutConfiguration( long timeout )
- * {
- *     config.get().timeout().set( timeout );
- *     config.save();
- * }
- * </code></pre>
- * <p>
- * And even if a separate thread is using the {@code timeout()} configuration when this is happening, the
- * {@link UnitOfWork} isolation will ensure that the other thread is not affected. That thread, on the other hand
- * will need to do a {@link #refresh()} at an appropriate time to pick up the timeout change. For instance;
- * </p>
- * <pre><code>
- *
- * &#64;Service InventoryService remoteInventoryService;
- *
- * public void restockInventoryItem( InventoryItemId id, int itemCount )
- * {
- *     config.refresh();
- *     long timeout = config.get().timeout().get();
- *
- *     remoteInventoryService.restock( id, itemCount, timeout );
- *
- *     :
- *     :
- * }
- * </code></pre>
- */
-@SuppressWarnings( "JavadocReference" )
-@Mixins( Configuration.ConfigurationMixin.class )
-public interface Configuration<T>
-{
-    /**
-     * Retrieves the user configuration instance managed by this Configuration.
-     * <p>
-     * Even if the user configuration is initialized from properties file, the consistency rules of Zest composites
-     * still applies. If the the properties file is missing a value, then the initialization will fail with a
-     * RuntimeException. If Constraints has been defined, those will need to be satisfied as well. The user
-     * configuration instance returned will fulfill the constraints and consistency normal to all composites, and
-     * can therefor safely be used with additional checks.
-     * </p>
-     *
-     * @return The fully initialized and ready-to-use user configuration instance.
-     */
-    T get();
-
-    /**
-     * Updates the values of the managed user ConfigurationComposite instance from the underlying
-     * {@code org.qi4j.spi.entitystore.EntityStore}.  Any modified values in the current user configuration that
-     * has not been saved, via {@link #save()} method, will be lost.
-     */
-    void refresh();
-
-    /**
-     * Persists the modified values in the user configuration instance to the underlying store.
-     */
-    void save();
-
-    /**
-     * Implementation of Configuration.
-     * <p>
-     * This is effectively an internal class in Zest and should never be used directly by user code.
-     * </p>
-     *
-     * @param <T>
-     */
-    public class ConfigurationMixin<T>
-        implements Configuration<T>
-    {
-        private T configuration;
-        private UnitOfWork uow;
-
-        @Structure
-        private Qi4j api;
-
-        @This
-        private ServiceComposite me;
-
-        @Structure
-        private Module module;
-
-        @Service
-        private Iterable<ServiceReference<ValueSerialization>> valueSerialization;
-
-        public ConfigurationMixin()
-        {
-        }
-
-        @Override
-        public synchronized T get()
-        {
-            if( configuration == null )
-            {
-                Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
-                uow = module.newUnitOfWork( usecase );
-                try
-                {
-                    configuration = this.findConfigurationInstanceFor( me, uow );
-                }
-                catch( InstantiationException e )
-                {
-                    throw new IllegalStateException( e );
-                }
-            }
-
-            return configuration;
-        }
-
-        @Override
-        public synchronized void refresh()
-        {
-            if( configuration != null )
-            {
-                configuration = null;
-                uow.discard();
-                uow = null;
-            }
-        }
-
-        @Override
-        public void save()
-        {
-            if( uow != null )
-            {
-                try
-                {
-                    uow.complete();
-                    uow = null;
-                }
-                catch( UnitOfWorkCompletionException e )
-                {
-                    // Should be impossible
-                    e.printStackTrace();
-                }
-
-                configuration = null; // Force refresh
-            }
-        }
-
-        @SuppressWarnings( "unchecked" )
-        public <V> V findConfigurationInstanceFor( ServiceComposite serviceComposite, UnitOfWork uow )
-            throws InstantiationException
-        {
-            ServiceDescriptor serviceModel = api.serviceDescriptorFor( serviceComposite );
-
-            String identity = serviceComposite.identity().get();
-            V configuration;
-            try
-            {
-                configuration = uow.get( serviceModel.<V>configurationType(), identity );
-                uow.pause();
-            }
-            catch( NoSuchEntityException | EntityTypeNotFoundException e )
-            {
-                return (V) initializeConfigurationInstance( serviceComposite, uow, serviceModel, identity );
-            }
-            return configuration;
-        }
-
-        @SuppressWarnings( "unchecked" )
-        private <V extends Identity> V initializeConfigurationInstance( ServiceComposite serviceComposite,
-                                                                        UnitOfWork uow,
-                                                                        ServiceDescriptor serviceModel,
-                                                                        String identity
-        )
-            throws InstantiationException
-        {
-            Module module = api.moduleOf( serviceComposite );
-            Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
-            UnitOfWork buildUow = module.newUnitOfWork( usecase );
-
-            Class<?> type = first( api.serviceDescriptorFor( serviceComposite ).types() );
-            Class<V> configType = serviceModel.configurationType();
-
-            // Check for defaults
-            V config = tryLoadPropertiesFile( buildUow, type, configType, identity );
-            if( config == null )
-            {
-                config = tryLoadJsonFile( buildUow, type, configType, identity );
-                if( config == null )
-                {
-                    config = tryLoadYamlFile( buildUow, type, configType, identity );
-                    if( config == null )
-                    {
-                        config = tryLoadXmlFile( buildUow, type, configType, identity );
-                        if( config == null )
-                        {
-                            try
-                            {
-                                EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( serviceModel.<V>configurationType(), identity );
-                                configBuilder.newInstance();
-                            }
-                            catch( ConstraintViolationException e )
-                            {
-                                throw new NoSuchConfigurationException( configType, identity, e );
-                            }
-                        }
-                    }
-                }
-            }
-
-            try
-            {
-                buildUow.complete();
-
-                // Try again
-                return (V) findConfigurationInstanceFor( serviceComposite, uow );
-            }
-            catch( Exception e1 )
-            {
-                InstantiationException ex = new InstantiationException(
-                    "Could not instantiate configuration, and no configuration initialization file was found (" + identity + ")" );
-                ex.initCause( e1 );
-                throw ex;
-            }
-        }
-
-        private <C, V> V tryLoadPropertiesFile( UnitOfWork buildUow,
-                                                Class<C> compositeType,
-                                                Class<V> configType,
-                                                String identity
-        )
-            throws InstantiationException
-        {
-            EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( configType, identity );
-            String resourceName = identity + ".properties";
-            InputStream asStream = getResource( compositeType, resourceName );
-            if( asStream != null )
-            {
-                try
-                {
-                    PropertyMapper.map( asStream, (Composite) configBuilder.instance() );
-                    return configBuilder.newInstance();
-                }
-                catch( IOException e1 )
-                {
-                    InstantiationException exception = new InstantiationException(
-                        "Could not read underlying Properties file." );
-                    exception.initCause( e1 );
-                    throw exception;
-                }
-            }
-            return null;
-        }
-
-        private InputStream getResource( Class<?> type, String resourceName )
-        {
-            // Load defaults from classpath root if available
-            if( type.getResource( resourceName ) == null && type.getResource( "/" + resourceName ) != null )
-            {
-                resourceName = "/" + resourceName;
-            }
-            return type.getResourceAsStream( resourceName );
-        }
-
-        private <C, V extends Identity> V tryLoadJsonFile( UnitOfWork uow,
-                                                           Class<C> compositeType,
-                                                           Class<V> configType,
-                                                           String identity
-        )
-        {
-            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.JSON, ".json" );
-        }
-
-        private <C, V extends Identity> V tryLoadYamlFile( UnitOfWork uow,
-                                                           Class<C> compositeType,
-                                                           Class<V> configType,
-                                                           String identity
-        )
-        {
-            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.YAML, ".yaml" );
-        }
-
-        private <C, V extends Identity> V tryLoadXmlFile( UnitOfWork uow,
-                                                          Class<C> compositeType,
-                                                          Class<V> configType,
-                                                          String identity
-        )
-        {
-            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.XML, ".xml" );
-        }
-
-        private <C, V extends Identity> V readConfig( UnitOfWork uow,
-                                                      Class<C> compositeType,
-                                                      Class<V> configType,
-                                                      String identity,
-                                                      String format,
-                                                      String extension
-        )
-        {
-            for( ServiceReference<ValueSerialization> serializerRef : valueSerialization )
-            {
-                ServiceTags serviceTags = serializerRef.metaInfo( ServiceTags.class );
-                if( serviceTags.hasTag( format ) )
-                {
-                    String resourceName = identity + extension;
-                    InputStream asStream = getResource( compositeType, resourceName );
-                    if( asStream != null )
-                    {
-                        V configObject = serializerRef.get().deserialize( configType, asStream );
-                        return uow.toEntity( configType, configObject );
-                    }
-                }
-            }
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java b/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java
deleted file mode 100644
index 881e52a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.configuration;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.Queryable;
-
-/**
- * Services that want to be configurable should have a ConfigurationComposite that contains all the settings.
- * They are treated as EntityComposites, and are therefore stored in an EntityStore. There will be one instance
- * per service instance that uses each ConfigurationComposite, and the identity of the entity is the same as that
- * of the service.
- */
-@Queryable( false )
-public interface ConfigurationComposite
-    extends Identity, Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/configuration/Enabled.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/Enabled.java b/core/api/src/main/java/org/apache/zest/api/configuration/Enabled.java
deleted file mode 100644
index 4eb8cc7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/configuration/Enabled.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.api.configuration;
-
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.property.Property;
-
-/**
- * Common configuration for setting whether a service is enabled or not. A disabled service
- * is not considered to be available. Let your own ConfigurationComposite extend this interface to use.
- */
-public interface Enabled
-{
-    @UseDefaults
-    Property<Boolean> enabled();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java b/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java
deleted file mode 100644
index c3ad366..0000000
--- a/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java
+++ /dev/null
@@ -1,48 +0,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.
- *
- */
-
-package org.apache.zest.api.configuration;
-
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.Identity;
-
-public class NoSuchConfigurationException extends RuntimeException
-{
-    private final Class<? extends Identity> configType;
-    private final String identity;
-
-    public NoSuchConfigurationException( Class<? extends Identity> configType,
-                                         String identity,
-                                         ConstraintViolationException cause
-    )
-    {
-        super( "No configuration found for '" + identity + "' and configuration " + configType.getName() + " has one or more non-Optional properties.", cause );
-        this.configType = configType;
-        this.identity = identity;
-    }
-
-    public Class<? extends Identity> configType()
-    {
-        return configType;
-    }
-
-    public String identity()
-    {
-        return identity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/configuration/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/package.html b/core/api/src/main/java/org/apache/zest/api/configuration/package.html
deleted file mode 100644
index 7f8a892..0000000
--- a/core/api/src/main/java/org/apache/zest/api/configuration/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Configuration API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java b/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java
deleted file mode 100644
index 9fb4f22..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.constraint;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-
-/**
- * All Constraints must implement this interface, which is used for each
- * value validation.
- */
-public interface Constraint<ANNOTATION extends Annotation, TYPE>
-    extends Serializable
-{
-    /**
-     * For each value or parameter which should be checked this method will be invoked.
-     * If the method returns true the value is valid. If it returns false the value
-     * is considered invalid. When all constraints have been checked a ConstraintViolationException
-     * will be thrown with all the constraint violations that were found.
-     *
-     * @param annotation the annotation to match
-     * @param value      the value to be checked
-     *
-     * @return true if valid, false if invalid
-     */
-    boolean isValid( ANNOTATION annotation, TYPE value );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java
deleted file mode 100644
index 9a74935..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.constraint;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * All annotations that are used to trigger Constraints must have this annotation.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( ElementType.ANNOTATION_TYPE )
-@Documented
-public @interface ConstraintDeclaration
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java
deleted file mode 100644
index aa08d58..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.constraint;
-
-import java.lang.annotation.Annotation;
-
-/**
- * Constraint Descriptor.
- */
-public interface ConstraintDescriptor
-{
-    Annotation annotation();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java
deleted file mode 100644
index e66a90a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.constraint;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-
-/**
- * This exception is thrown if a Constraint implementation can not be found.
- */
-public class ConstraintImplementationNotFoundException
-    extends InvalidApplicationException
-{
-    public ConstraintImplementationNotFoundException( String message )
-    {
-        super( message );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java
deleted file mode 100644
index 4ecf027..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.constraint;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-
-/**
- * When a constraint violation has occurred (ie Constraint.isValid has returned false) it
- * is put in a collection of all violations that have occurred for this value check.
- */
-public final class ConstraintViolation
-    implements Serializable
-{
-    private String name;
-    private final Annotation constraint;
-    private final Object value;
-
-    public ConstraintViolation( String name, Annotation constraint, Object value )
-    {
-        this.name = name;
-        this.constraint = constraint;
-        this.value = value;
-    }
-
-    public String name()
-    {
-        return name;
-    }
-
-    public Annotation constraint()
-    {
-        return constraint;
-    }
-
-    public Object value()
-    {
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java
deleted file mode 100644
index 67c0702..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.constraint;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-
-/**
- * This Exception is thrown when there is one or more Constraint Violations in a method
- * call.
- * <p>
- * The Constraint Violations are aggregated per method, and this exception will contain those
- * violations, together with the Composite instance it happened on as well as the Method that
- * was invoked. The Exception also has support for localized messages of these violations.
- * </p>
- */
-public class ConstraintViolationException
-    extends IllegalArgumentException
-{
-    private static final long serialVersionUID = 1L;
-
-    private final Collection<ConstraintViolation> constraintViolations;
-    private String methodName;
-    private String mixinTypeName;
-    private String instanceToString;
-    private Iterable<Class<?>> instanceTypes;
-
-    public ConstraintViolationException( Composite instance, Member method,
-                                         Collection<ConstraintViolation> constraintViolations
-    )
-    {
-        this( instance.toString(), Qi4j.FUNCTION_DESCRIPTOR_FOR.map( instance ).types(), method, constraintViolations );
-    }
-
-    public ConstraintViolationException( String instanceToString,
-                                         Iterable<Class<?>> instanceTypes,
-                                         Member method,
-                                         Collection<ConstraintViolation> violations
-    )
-    {
-        this.instanceToString = instanceToString;
-        this.instanceTypes = instanceTypes;
-        mixinTypeName = method.getDeclaringClass().getName();
-        methodName = method.getName();
-        this.constraintViolations = violations;
-    }
-
-    public ConstraintViolationException( String instanceToString,
-                                         Iterable<Class<?>> instanceTypes,
-                                         String mixinTypeName,
-                                         String methodName,
-                                         Collection<ConstraintViolation> violations
-    )
-    {
-        this.instanceToString = instanceToString;
-        this.instanceTypes = instanceTypes;
-        this.mixinTypeName = mixinTypeName;
-        this.methodName = methodName;
-        this.constraintViolations = violations;
-    }
-
-    public Collection<ConstraintViolation> constraintViolations()
-    {
-        return constraintViolations;
-    }
-
-    /**
-     * Creates localized messages of all the constraint violations that has occured.
-     * <p>
-     * The key "<code>Qi4j_ConstraintViolation_<i><strong>CompositeType</strong></i></code>" will be used to lookup the text formatting
-     * pattern from the ResourceBundle, where <strong><code><i>CompositeType</i></code></strong> is the
-     * class name of the Composite where the constraint was violated. If such key does not exist, then the
-     * key &nbsp;"<code>Qi4j_ConstraintViolation</code>" will be used, and if that one also doesn't exist, or
-     * the resourceBundle argument is null, then the default patterns will be used;
-     * </p>
-     * <table summary="Localization of constraint vioations.">
-     * <tr><th>Type of Composite</th><th>Pattern used</th></tr>
-     * <tr><td>Composite</td>
-     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1}</code></td>
-     * </tr>
-     * <tr><td>EntityComposite</td>
-     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}]</code></td>
-     * </tr>
-     * <tr><td>ServiceComposite</td>
-     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in service {0}</code></td>
-     * </tr>
-     * </table>
-     * Then format each ConstraintViolation according to such pattern, where the following argument are passed;
-     * <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr>
-     * <tr>
-     * <td>{0}</td>
-     * <td>Composite instance toString()</td>
-     * </tr>
-     * <tr>
-     * <td>{1}</td>
-     * <td>CompositeType class name</td>
-     * </tr>
-     * <tr>
-     * <td>{2}</td>
-     * <td>MixinType class name</td>
-     * </tr>
-     * <tr>
-     * <td>{3}</td>
-     * <td>MixinType method name</td>
-     * </tr>
-     * <tr>
-     * <td>{4}</td>
-     * <td>Annotation toString()</td>
-     * </tr>
-     * <tr>
-     * <td>{5}</td>
-     * <td>toString() of value passed as the argument, or "null" text if argument was null.</td>
-     * </tr>
-     * </table>
-     * <p>
-     * <b>NOTE!!!</b> This class is still under construction and will be modified further.
-     * </p>
-     *
-     * @param bundle The ResourceBundle for Localization, or null if default formatting and locale to be used.
-     *
-     * @return An array of localized messages of the violations incurred.
-     */
-    public String[] localizedMessagesFrom( ResourceBundle bundle )
-    {
-        String pattern = "Constraint violation in {0}.{1} for method ''{3}'' with constraint \"{4}({6})\", for value ''{5}''";
-
-        ArrayList<String> list = new ArrayList<String>();
-        for( ConstraintViolation violation : constraintViolations )
-        {
-            Locale locale;
-            if( bundle != null )
-            {
-                try
-                {
-                    pattern = bundle.getString( "qi4j.constraint." + mixinTypeName + "." + methodName );
-                }
-                catch( MissingResourceException e1 )
-                {
-                    try
-                    {
-                        pattern = bundle.getString( "qi4j.constraint" );
-                    }
-                    catch( MissingResourceException e2 )
-                    {
-                        // ignore. The default pattern will be used.
-                    }
-                }
-                locale = bundle.getLocale();
-            }
-            else
-            {
-                locale = Locale.getDefault();
-            }
-            MessageFormat format = new MessageFormat( pattern, locale );
-
-            Annotation annotation = violation.constraint();
-            String name = violation.name();
-            Object value = violation.value();
-            String classes;
-            if( Iterables.count( instanceTypes ) == 1 )
-            {
-                classes = Iterables.first( instanceTypes ).getSimpleName();
-            }
-            else
-            {
-                classes = "[" + Iterables.<Class<?>>toString( instanceTypes, new Function<Class<?>, String>()
-                {
-                    @Override
-                    public String map( Class<?> from )
-                    {
-                        return from.getSimpleName();
-                    }
-                }, "," ) + "]";
-            }
-            Object[] args = new Object[]
-                {
-                    instanceToString,
-                    classes,
-                    mixinTypeName,
-                    methodName,
-                    annotation.toString(),
-                    "" + value,
-                    name
-                };
-            StringBuffer text = new StringBuffer();
-            format.format( args, text, null );
-            list.add( text.toString() );
-        }
-        String[] result = new String[ list.size() ];
-        list.toArray( result );
-        return result;
-    }
-
-    public String localizedMessage()
-    {
-        String[] messages = localizedMessagesFrom( null );
-        StringBuilder result = new StringBuilder();
-        boolean first = true;
-        for( String message : messages )
-        {
-            if( !first )
-            {
-                result.append( ',' );
-            }
-            first = false;
-            result.append( message );
-        }
-        return result.toString();
-    }
-
-    @Override
-    public String getLocalizedMessage()
-    {
-        return localizedMessage();
-    }
-
-    @Override
-    public String getMessage()
-    {
-        return localizedMessage();
-    }
-
-    public String methodName()
-    {
-        return methodName;
-    }
-
-    public String mixinTypeName()
-    {
-        return mixinTypeName;
-    }
-}
\ No newline at end of file


[39/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/QualifiedName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/QualifiedName.java b/core/api/src/main/java/org/qi4j/api/common/QualifiedName.java
new file mode 100644
index 0000000..a869791
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/QualifiedName.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.common;
+
+import java.io.Serializable;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import org.qi4j.api.util.NullArgumentException;
+
+/**
+ * QualifiedName is a representation of Property names to their full declaration.
+ * <p>
+ * A QualifiedName is created by combining the name of a method and the name of the type that declares the method.
+ * This class also contains many static utility methods to manage QualifiedName instances.
+ * </p>
+ * <p>
+ * <strong>NOTE: Unless you do very generic libraries, entity stores and other extensions that is deeply coupled into
+ * the Zest runtime, it is very unlikely you will need to use this class directly.</strong>
+ * </p>
+ * <p>
+ * It is also important to notice that the QualifiedName needs to be long-term stable, as the names are written
+ * to persistent storage. So any changes in the formatting <strong>must be made in a backward-compatible manner
+ * </strong>.
+ * </p>
+ * <p>
+ * The QualifiedName has two intrinsic parts, one being the {@code type} and the other the {@code name}. The
+ * {@code type} comes from the class where the QualifiedName originates from and internally kept as a {@link TypeName}
+ * instance. The name is the name from the method name. When the QualifiedName instance is converted to an external
+ * string representation, via the offical and formal {@link #toString()} method, the {@code type} is normalized, i.e.
+ * any dollar characters ($) in the name are replaced by dashes (-), to make them URI friendly.
+ * </p>
+ * <p>
+ * QualifiedName instances are immutable, implements {@link #hashCode()} and {@link #equals(Object)} as a value
+ * object and can safely be used as keys in {@link java.util.Map}.
+ */
+public final class QualifiedName
+    implements Comparable<QualifiedName>, Serializable
+{
+    private final TypeName typeName;
+    private final String name;
+
+    /**
+     * Creates a QualifiedName from a method.
+     * <p>
+     * This factory method will create a QualifiedName from the Method itself.
+     *
+     * </p>
+     *
+     * @param method Type method that returns a Property, for which the QualifiedName will be representing.
+     *
+     * @return A QualifiedName representing this method.
+     *
+     * @throws NullArgumentException If the {@code method} argument passed is null.
+     */
+    public static QualifiedName fromAccessor( AccessibleObject method )
+    {
+        NullArgumentException.validateNotNull( "method", method );
+        return fromClass( ( (Member) method ).getDeclaringClass(), ( (Member) method ).getName() );
+    }
+
+    /**
+     * Creates a QualifiedName instance from the Class and a given name.
+     * <p>
+     * This factory method converts the {@code type} to a {@link TypeName} and appends the given {@code name}.
+     *
+     * @param type The Class that is the base of the QualifiedName.
+     * @param name The qualifier name which will be appended to the base name derived from the {@code type} argument.
+     *
+     * @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
+     *
+     * @throws NullArgumentException if any of the two arguments are {@code null}, or if the name string is empty.
+     */
+    public static QualifiedName fromClass( Class type, String name )
+    {
+        return new QualifiedName( TypeName.nameOf( type ), name );
+    }
+
+    /**
+     * Creates a Qualified name from a type as string and a name qualifier.
+     *
+     * @param type The type name as a a string, which must be properly formatted. No checks for correctly formatted
+     *             type name is performed.
+     * @param name The qualifier name which will be appended to the base name derived from the {@code type} argument.
+     *
+     * @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
+     *
+     * @throws NullArgumentException if any of the two arguments are {@code null} or either string is empty.
+     */
+    public static QualifiedName fromName( String type, String name )
+    {
+        return new QualifiedName( TypeName.nameOf( type ), name );
+    }
+
+    /**
+     * Creates a QualifiedName from the external string format of QualifiedName.
+     * <p>
+     * This factory method is the reverse of {@link QualifiedName#toString() }  method, and creates a new QualifiedName
+     * instance from the string representation of the QualifiedName.
+     * </p>
+     *
+     * @param fullQualifiedName The QualifiedName external string representation to be converted back into a QualifiedName
+     *                      instance.
+     *
+     * @return The QualifiedName instance represented by the {@code qualifiedName} argument.
+     *
+     * @throws IllegalArgumentException If the {@code qualifiedName} argument has wrong format.
+     */
+    public static QualifiedName fromFQN( String fullQualifiedName )
+    {
+        NullArgumentException.validateNotEmpty( "qualifiedName", fullQualifiedName );
+        int idx = fullQualifiedName.lastIndexOf( ":" );
+        if( idx == -1 )
+        {
+            throw new IllegalArgumentException( "Name '" + fullQualifiedName + "' is not a qualified name" );
+        }
+        final String type = fullQualifiedName.substring( 0, idx );
+        final String name = fullQualifiedName.substring( idx + 1 );
+        return new QualifiedName( TypeName.nameOf( type ), name );
+    }
+
+    QualifiedName( TypeName typeName, String name )
+    {
+        NullArgumentException.validateNotNull( "typeName", typeName );
+        NullArgumentException.validateNotEmpty( "name", name );
+        this.typeName = typeName;
+        this.name = name;
+    }
+
+    /**
+     * Returns the normalized string of the type part of the QualifiedName.
+     *
+     * <p>
+     * The normalized type name means that all dollar ($) characters have been replaced by dashes (-).
+     * </p>
+     *
+     * @return the normalized string of the type part of the QualifiedName.
+     */
+    public String type()
+    {
+        return typeName.normalized();
+    }
+
+    /**
+     * Returns the name component of the QualifiedName.
+     *
+     * @return the name component of the QualifiedName.
+     */
+    public String name()
+    {
+        return name;
+    }
+
+    /**
+     * Returns the URI of the QualifiedName.
+     *
+     * <p>
+     * The URI is the {@link #toNamespace()} followed by the {@code name} component.
+     * <p>
+     *
+     * @return the URI of the QualifiedName.
+     *
+     * @see #toNamespace()
+     */
+    public String toURI()
+    {
+        return toNamespace() + name;
+    }
+
+    /**
+     * Return the URI of the {@link TypeName} component of the QualifiedName.
+     * <p>
+     * The URI of the {@link TypeName} component is in the form of;
+     * </p>
+     * <pre>
+     * "urn:qi4j:type:" normalizedClassName
+     * </pre>
+     * <p>
+     * where {@code normalizedClassName} is the fully-qualified class name having had any dollar ($) characters replaced
+     * by URI friendly dashes (-), with a trailing hash (#). Examples;
+     * </p>
+     * <pre>
+     * urn:qi4j:type:org.qi4j.api.common.QualifiedName#
+     * urn:qi4j:type:org.qi4j.samples.MyClass-MyInnerClass#
+     * </pre>
+     *
+     * @return the URI of the {@link TypeName} component of the QualifiedName.
+     */
+    public String toNamespace()
+    {
+        return typeName.toURI() + "#";
+    }
+
+    /**
+     * Return the formal and official, long-term stable, external string representation of a QualifiedName.
+     * <p>
+     * This returns the {@link org.qi4j.api.common.TypeName#toString()} followed by the {@code name} component.
+     * </p>
+     *
+     * @return the formal and official, long-term stable, external string representation of a QualifiedName.
+     */
+    @Override
+    public String toString()
+    {
+        return typeName + ":" + name;
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        QualifiedName that = (QualifiedName) o;
+
+        return name.equals( that.name ) && typeName.equals( that.typeName );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return 31 * typeName.hashCode() + name.hashCode();
+    }
+
+    @Override
+    public int compareTo( QualifiedName other )
+    {
+        final int result = typeName.compareTo( other.typeName );
+        if( result != 0 )
+        {
+            return result;
+        }
+        return name.compareTo( other.name );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/TypeName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/TypeName.java b/core/api/src/main/java/org/qi4j/api/common/TypeName.java
new file mode 100644
index 0000000..6a485e6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/TypeName.java
@@ -0,0 +1,111 @@
+/*
+ * 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.qi4j.api.common;
+
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.util.NullArgumentException;
+
+/**
+ * Represents a Type name.
+ */
+public final class TypeName
+    implements Serializable, Comparable<TypeName>
+{
+    private final String name;
+
+    public static TypeName nameOf( Class type )
+    {
+        NullArgumentException.validateNotNull( "type", type );
+        return new TypeName( type.getName() );
+    }
+
+    public static TypeName nameOf( Type type )
+    {
+        return nameOf( Classes.RAW_CLASS.map( type ) );
+    }
+
+    public static TypeName nameOf( String typeName )
+    {
+        return new TypeName( typeName );
+    }
+
+    private TypeName( String name )
+    {
+        NullArgumentException.validateNotEmpty( "name", name );
+        this.name = name;
+    }
+
+    public String normalized()
+    {
+        return Classes.normalizeClassToURI( name );
+    }
+
+    public String toURI()
+    {
+        return Classes.toURI( name );
+    }
+
+    public String name()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+
+    public boolean isClass( final Class<?> type )
+    {
+        return type.getName().equals( name );
+    }
+
+    @Override
+    public boolean equals( final Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        final TypeName other = (TypeName) o;
+
+        return name.equals( other.name );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return name.hashCode();
+    }
+
+    @Override
+    public int compareTo( final TypeName typeName )
+    {
+        return this.name.compareTo( typeName.name );
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/UseDefaults.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/UseDefaults.java b/core/api/src/main/java/org/qi4j/api/common/UseDefaults.java
new file mode 100644
index 0000000..94f4446
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/UseDefaults.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.common;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to denote that the initial value of a Property will be the default value for the type if none is
+ * specified during construction.
+ * <p>
+ * These are the default values used for various types:
+ * </p>
+ * <pre>
+ * Byte: 0
+ * Short: 0
+ * Character: 0
+ * Integer: 0
+ * Long: 0L
+ * Double: 0.0d
+ * Float: 0.0f
+ * Boolean: false
+ * String: ""
+ * List: empty java.util.ArrayList
+ * Set: empty java.util.HashSet
+ * Collection: empty java.util.ArrayList
+ * enum: first declared value
+ * </pre>
+ * <p>
+ * If this annotation is not used, the property will be set to null, and unless {@code &#64;Optional} is declared
+ * is not allowed.
+ * </p>
+ * <p>
+ * It is also possible to change the default values for Composites during the assembly. This is done by calling the
+ * {@code org.qi4j.bootstrap.ModuleAssembly#forMixin(Class)} method.
+ * </p>
+ * <p>
+ * Example;
+ * Let's assume that we have the following mixin type;
+ *
+ * <pre><code>
+ * public interface SomeType
+ * {
+ *     &#64;UseDefaults
+ *     Property&lt;String&gt; someValue();
+ * }
+ * </code></pre>
+ * And that we want to have {@code someValue()} to be initialized to "&lt;unknown&gt;" instead of the empty string.
+ * Then we need to declare the default for that with the following in the assembler.
+ * <pre><code>
+ * public void assemble( ModuleAssembly module )
+ * {
+ *     module.forMixin( SomeType.class ).declareDefaults().someValue().set( "&lt;unknown&gt;" );
+ * }
+ * }
+ * </code></pre>
+ */
+@SuppressWarnings( "JavadocReference" )
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.METHOD, ElementType.FIELD } )
+@Documented
+public @interface UseDefaults
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/Visibility.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/Visibility.java b/core/api/src/main/java/org/qi4j/api/common/Visibility.java
new file mode 100644
index 0000000..0f38f36
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/Visibility.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.common;
+
+/**
+ * Visibility is a core concept in the Zest structure system. It defines the locale of composites and objects, i.e.
+ * how far they can be 'seen' and therefor be used.
+ * <p>
+ * When a Composite or Object is declared in the assembly phase, and no visibility is set, only other
+ * composites/objects within the same module can use that declaration. For a declared composite/object to be usable
+ * from other modules a higher visibility must be set, either that the Composite/Object can be used by others within
+ * the same Layer, or even to be used by those in the layer above.
+ * </p>
+ */
+public enum Visibility
+{
+    /**
+     * Artifact is visible only in the declaring module (default)
+     */
+    module,
+    /**
+     * Artifact is visible to all modules in the same layer
+     */
+    layer,
+    /**
+     * Artifact is visible to other modules in the same layer and any modules in extending layers
+     */
+    application
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/package.html b/core/api/src/main/java/org/qi4j/api/common/package.html
new file mode 100644
index 0000000..f29de5d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/package.html
@@ -0,0 +1,81 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Common API.</h2>
+        <p>
+            The Common API package is a collection of really low-level types needed at the core of the Zest™ Runtime. It is also
+            a collection of types that are not particularly cohesive, and effectively this package contains the loose ends
+            that does not belong elsewhere.
+        </p>
+        <p>
+            In this package, you can safely ignore the following classes;
+        </p>
+        <ul>
+            <li>MetaInfo</li>
+            <li>QualifiedName</li>
+            <li>TypeName</li>
+        </ul>
+        <p>UNLESS you are into deep integration into the Zest™ Runtime.</p>
+
+        <h3>&#64;AppliesTo and AppliesToFilter</h3>
+        <p>
+            This tandem of interface + annotation are primarily used for Generic Fragments, to indicate which methods on the
+            interface the fragment should be applied to.
+        </p>
+
+        <h3>&#64;Optional</h3>
+        <p>
+            In Zest™, method arguments, property values and injected fields are not allowed to be null by default. To allow
+            any of these to be null, i.e. undeclared, it is required that the argument, field or method is marked with the
+            &#64;Optional annotation.
+        </p>
+
+        <h3>&#64;UseDefaults</h3>
+        <p>
+            Since null is not allowed without the &#64;Optional annotation, it can sometimes by tedious to initialize all
+            the property values. And the &#64;UseDefaults annotation allows us to declare that Zest™ should set the Property
+            to a default value. These are either the pre-defined ones, or can be set per property declaration during the
+            assembly.
+        </p>
+
+        <h3>&#64;Visibility</h3>
+        <p>
+            Visibility is another innovative concept in Zest™, which leverage the structure system (Application, Layer, Module)
+            to limit the 'reach' when requesting composites and objects. The Visibility is declared per Composite/Object,
+            preferably in the most restrictive mode possible, and the visibility resolver will ensure a predictable resolution
+            algorithm;
+        </p>
+        <ol>
+            <li>Search the module of the caller first. If one and only one composite type fulfilling the request is available
+                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
+                continue to the next step.
+            </li>
+            <li>Search all modules in the Layer of the caller for composite that has a declaration other than
+                <code>Visibility.module</code>. If one and only one composite type fulfilling the request is available
+                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
+                continue to the next step.
+            </li>
+            <li>Search all modules in the Layer(s) (if any) directly below of the caller for composite that has a declaration of
+                <code>Visibility.application</code>. If one and only one composite type fulfilling the request is available
+                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
+                continue to the next step.
+            </li>
+            <li>Throw an NoSuchCompositeException (or related) exception.</li>
+        </ol>
+    </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/AmbiguousTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/AmbiguousTypeException.java b/core/api/src/main/java/org/qi4j/api/composite/AmbiguousTypeException.java
new file mode 100644
index 0000000..34f3653
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/AmbiguousTypeException.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.composite;
+
+/**
+ * This Exception is thrown when more than one Composite implements a MixinType
+ * that one tries to use to create a Composite instance from.
+ * <p>
+ * For instance;
+ * </p>
+ * <pre><code>
+ * public interface AbcComposite extends TransientComposite, Abc
+ * {}
+ *
+ * public interface DefComposite extends TransientComposite, Def
+ * {}
+ *
+ * public interface Abc
+ * {}
+ *
+ * public interface Def extends Abc
+ * {}
+ *
+ *
+ * TransientBuilder cb = factory.newTransientBuilder( Abc.class );
+ * </code></pre>
+ * <p>
+ * In the code above, both the AbcComposite and DefComposite implement Abc, and therefore
+ * the <code>newTransientBuilder</code> method can not unambiguously figure out which
+ * one is intended.
+ * </p>
+ */
+public class AmbiguousTypeException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 1L;
+
+    public AmbiguousTypeException( String message )
+    {
+        super( message );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/Composite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/Composite.java b/core/api/src/main/java/org/qi4j/api/composite/Composite.java
new file mode 100644
index 0000000..91662fb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/Composite.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.composite;
+
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.PropertyMixin;
+
+/**
+ * Base Composite interface.
+ * <p>
+ * All Composite objects must implement this interface. Let the
+ * Composite interface extend this one. An implementation will be provided
+ * by the framework.
+ * </p>
+ * <p>
+ * Properties and associations are handled by default.
+ * </p>
+ */
+@Mixins( { PropertyMixin.class } )
+public interface Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/CompositeContext.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/CompositeContext.java b/core/api/src/main/java/org/qi4j/api/composite/CompositeContext.java
new file mode 100644
index 0000000..d8a2aa7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/CompositeContext.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.structure.Module;
+import org.qi4j.functional.Iterables;
+
+import static org.qi4j.functional.Iterables.toArray;
+
+/**
+ * Thread-associated composites. This is basically a ThreadLocal which maintains a reference
+ * to a TransientComposite instance for each thread. This can be used to implement various context
+ * patterns without having to pass the context explicitly as a parameter to methods.
+ */
+public class CompositeContext<T extends TransientComposite>
+    extends ThreadLocal<T>
+{
+    private Module module;
+    private Class<T> type;
+
+    public CompositeContext( Module module, Class<T> type )
+    {
+        this.module = module;
+        this.type = type;
+    }
+
+    @Override
+    protected T initialValue()
+    {
+        return module.newTransient( type );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public T proxy()
+    {
+        TransientComposite composite = get();
+
+        Iterable<Class<?>> types = Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( composite ).types();
+        return (T) Proxy.newProxyInstance(
+            composite.getClass().getClassLoader(),
+            toArray( Class.class, Iterables.<Class>cast( types ) ),
+            new ContextInvocationhandler() );
+    }
+
+    private class ContextInvocationhandler
+        implements InvocationHandler
+    {
+
+        @Override
+        public Object invoke( Object object, Method method, Object[] objects )
+            throws Throwable
+        {
+            try
+            {
+                return method.invoke( get(), objects );
+            }
+            catch( InvocationTargetException e )
+            {
+                throw e.getTargetException();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/CompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/CompositeDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/CompositeDescriptor.java
new file mode 100644
index 0000000..40b4462
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/CompositeDescriptor.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.composite;
+
+/**
+ * Composite Descriptor.
+ */
+public interface CompositeDescriptor
+    extends ModelDescriptor
+{
+    Class<?> primaryType();
+
+    Iterable<Class<?>> mixinTypes();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/CompositeInstance.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/CompositeInstance.java b/core/api/src/main/java/org/qi4j/api/composite/CompositeInstance.java
new file mode 100644
index 0000000..79f8d62
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/CompositeInstance.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.InvocationHandler;
+import org.qi4j.api.property.StateHolder;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * Composite Instance.
+ */
+public interface CompositeInstance
+    extends InvocationHandler, CompositeInvoker, HasTypes, MetaInfoHolder
+{
+    <T> T proxy();
+
+    <T> T newProxy( Class<T> mixinType )
+        throws IllegalArgumentException;
+
+    Module module();
+
+    CompositeDescriptor descriptor();
+
+    StateHolder state();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/CompositeInvoker.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/CompositeInvoker.java b/core/api/src/main/java/org/qi4j/api/composite/CompositeInvoker.java
new file mode 100644
index 0000000..5bd8d11
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/CompositeInvoker.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.Method;
+
+/**
+ * Composite method invoker.
+ * <p>
+ * All composites must implement this interface. Methods that are invoked
+ * may reside either in the public Composite interface or in any internal mixins.
+ * </p>
+ * <p>
+ * <strong><i>NOTE:</i></strong>Client code should never use method in this class. We have not been able to hide this
+ * from client code, but IF we find a way to do, this interface may disappear.
+ * </p>
+ */
+public interface CompositeInvoker
+{
+
+    Object invokeComposite( Method method, Object[] args )
+        throws Throwable;
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java
new file mode 100644
index 0000000..6e74dd9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * Composite constructor descriptor.
+ */
+public interface ConstructorDescriptor
+{
+    Constructor<?> constructor();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/DecoratorMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/DecoratorMixin.java b/core/api/src/main/java/org/qi4j/api/composite/DecoratorMixin.java
new file mode 100644
index 0000000..6b81844
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/DecoratorMixin.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.injection.scope.Uses;
+
+/**
+ * Generic decorator mixin that allows a Composite to wrap
+ * any other Composite as long as they share an interface.
+ * <p>
+ * Can be used to effectively implement
+ * singleton mixins, since the decorated object can be shared between
+ * many instances.
+ * </p>
+ */
+public class DecoratorMixin
+    implements InvocationHandler
+{
+    private Object delegate;
+
+    public DecoratorMixin( @Uses Object delegate )
+    {
+        if( delegate instanceof Class )
+        {
+            Thread.dumpStack();
+        }
+        this.delegate = delegate;
+    }
+
+    @Override
+    public Object invoke( Object object, Method method, Object[] args )
+        throws Throwable
+    {
+        if( delegate instanceof InvocationHandler )
+        {
+            InvocationHandler handler = (InvocationHandler) delegate;
+            return handler.invoke( object, method, args );
+        }
+        else
+        {
+            try
+            {
+                return method.invoke( delegate, args );
+            }
+            catch( InvocationTargetException e )
+            {
+                throw e.getCause();
+            }
+            catch( IllegalArgumentException e )
+            {
+                String message = constructMessage( method, args );
+                throw new IllegalArgumentException( message, e );
+            }
+        }
+    }
+
+    private String constructMessage( Method method, Object[] args )
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append( "\nmethod: " );
+        builder.append( method.getDeclaringClass().getName() );
+        builder.append( "." );
+        builder.append( method.getName() );
+        builder.append( "\ndelegate: " );
+        builder.append( delegate );
+        builder.append( "\ndelegateType: " );
+        builder.append( delegate == null ? "n/a" : delegate.getClass().getName() );
+        builder.append( "\narguments: \n" );
+        for( Object arg : args )
+        {
+            builder.append( "    " );
+            Class argClass = arg.getClass();
+            if( Proxy.isProxyClass( argClass ) )
+            {
+                builder.append( Proxy.getInvocationHandler( arg ).getClass().getName() );
+            }
+            else
+            {
+                builder.append( argClass.getName() );
+            }
+            builder.append( '\n' );
+        }
+        return builder.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/DependencyDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/DependencyDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/DependencyDescriptor.java
new file mode 100644
index 0000000..70d7d06
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/DependencyDescriptor.java
@@ -0,0 +1,38 @@
+/*  Copyright 2008 Edward Yakop.
+*
+* 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.qi4j.api.composite;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+/**
+ * Composite dependency descriptor.
+ */
+public interface DependencyDescriptor
+{
+    Annotation injectionAnnotation();
+
+    Type injectionType();
+
+    Class<?> injectedClass();
+
+    Class<?> rawInjectionType();
+
+    boolean optional();
+
+    Annotation[] annotations();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/InjectedFieldDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/InjectedFieldDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/InjectedFieldDescriptor.java
new file mode 100644
index 0000000..2f7297e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/InjectedFieldDescriptor.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.Field;
+
+/**
+ * Composite injected field descriptor.
+ */
+public interface InjectedFieldDescriptor
+{
+    Field field();
+
+    DependencyDescriptor dependency();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/InjectedMethodDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/InjectedMethodDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/InjectedMethodDescriptor.java
new file mode 100644
index 0000000..8888d32
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/InjectedMethodDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.Method;
+
+/**
+ * Composite injected method descriptor.
+ */
+public interface InjectedMethodDescriptor
+{
+    Method method();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/InjectedParametersDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/InjectedParametersDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/InjectedParametersDescriptor.java
new file mode 100644
index 0000000..301c56d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/InjectedParametersDescriptor.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+/**
+ * Composite constructors and method injected parameters descriptor.
+ */
+public interface InjectedParametersDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/InvalidCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/InvalidCompositeException.java b/core/api/src/main/java/org/qi4j/api/composite/InvalidCompositeException.java
new file mode 100644
index 0000000..e5b86c0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/InvalidCompositeException.java
@@ -0,0 +1,29 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+/**
+ * This exception is thrown if a Composite is invalid.
+ */
+public class InvalidCompositeException
+    extends RuntimeException
+{
+    public InvalidCompositeException( String message )
+    {
+        super( message );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/InvalidValueCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/InvalidValueCompositeException.java b/core/api/src/main/java/org/qi4j/api/composite/InvalidValueCompositeException.java
new file mode 100644
index 0000000..60a48dd
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/InvalidValueCompositeException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+/**
+ * This exception is thrown if a ValueComposite is invalid.
+ */
+public class InvalidValueCompositeException
+    extends RuntimeException
+{
+    public InvalidValueCompositeException( String message )
+    {
+        super( message );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/MethodDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/MethodDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/MethodDescriptor.java
new file mode 100644
index 0000000..2f88f35
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/MethodDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import java.lang.reflect.Method;
+
+/**
+ * Composite Method Descriptor.
+ */
+public interface MethodDescriptor
+{
+    Method method();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/MissingMethodException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/MissingMethodException.java b/core/api/src/main/java/org/qi4j/api/composite/MissingMethodException.java
new file mode 100644
index 0000000..ae362cb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/MissingMethodException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+/**
+ * This exception is thrown if client code tries to invoke a non-existing Composite method.
+ */
+public class MissingMethodException
+    extends RuntimeException
+{
+    public MissingMethodException( String message )
+    {
+        super( message );
+    }
+
+    public MissingMethodException( String message, NoSuchMethodException e )
+    {
+        super(message,e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/ModelDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/ModelDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/ModelDescriptor.java
new file mode 100644
index 0000000..b0651f0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/ModelDescriptor.java
@@ -0,0 +1,33 @@
+/*
+ * 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.qi4j.api.composite;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * Composite ModelDescriptor.
+ */
+public interface ModelDescriptor extends HasTypes, MetaInfoHolder
+{
+    Visibility visibility();
+
+    boolean isAssignableTo( Class<?> type );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/NoSuchCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/NoSuchCompositeException.java b/core/api/src/main/java/org/qi4j/api/composite/NoSuchCompositeException.java
new file mode 100644
index 0000000..b404779
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/NoSuchCompositeException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.composite;
+
+import org.qi4j.api.common.InvalidApplicationException;
+
+/**
+ * This exception is thrown if client code tries to create a non-existing Composite type.
+ */
+public class NoSuchCompositeException
+    extends InvalidApplicationException
+{
+    private static final long serialVersionUID = 1L;
+
+    private final String compositeType;
+    private final String moduleName;
+
+    protected NoSuchCompositeException( String metaType, String compositeType, String moduleName )
+    {
+        super( "Could not find any visible " + metaType + " of type [" + compositeType + "] in module [" +
+               moduleName + "]." );
+        this.compositeType = compositeType;
+        this.moduleName = moduleName;
+    }
+
+    public String compositeType()
+    {
+        return compositeType;
+    }
+
+    public String moduleName()
+    {
+        return moduleName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/NoSuchTransientException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/NoSuchTransientException.java b/core/api/src/main/java/org/qi4j/api/composite/NoSuchTransientException.java
new file mode 100644
index 0000000..e6a6f61
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/NoSuchTransientException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.composite;
+
+/**
+ * This exception is thrown if client code tries to create a non-existing TransientComposite type.
+ */
+public class NoSuchTransientException extends NoSuchCompositeException
+{
+    public NoSuchTransientException( String typeName, String moduleName )
+    {
+        super( "TransientComposite", typeName, moduleName );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java b/core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java
new file mode 100644
index 0000000..054a369
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java
@@ -0,0 +1,580 @@
+/*
+ * 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.qi4j.api.composite;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.util.Dates;
+import org.qi4j.api.value.ValueComposite;
+
+/**
+ * Transfer java.util.Properties to Composite properties
+ */
+public final class PropertyMapper
+{
+
+    private final static Map<Type, MappingStrategy> STRATEGY;
+
+    static
+    {
+        STRATEGY = new HashMap<>();
+        STRATEGY.put( Integer.class, new IntegerMapper() );
+        STRATEGY.put( Long.class, new LongMapper() );
+        STRATEGY.put( Short.class, new ShortMapper() );
+        STRATEGY.put( Byte.class, new ByteMapper() );
+        STRATEGY.put( String.class, new StringMapper() );
+        STRATEGY.put( Character.class, new CharMapper() );
+        STRATEGY.put( Float.class, new FloatMapper() );
+        STRATEGY.put( Double.class, new DoubleMapper() );
+        STRATEGY.put( Date.class, new DateMapper() );
+        STRATEGY.put( Boolean.class, new BooleanMapper() );
+        STRATEGY.put( BigDecimal.class, new BigDecimalMapper() );
+        STRATEGY.put( BigInteger.class, new BigIntegerMapper() );
+        STRATEGY.put( Enum.class, new EnumMapper() );
+        STRATEGY.put( Array.class, new ArrayMapper() );
+        STRATEGY.put( Map.class, new MapMapper() );
+        STRATEGY.put( List.class, new ListMapper() );
+        STRATEGY.put( Set.class, new SetMapper() );
+        STRATEGY.put( ValueComposite.class, new ValueCompositeMapper() );
+    }
+
+    /**
+     * Populate the Composite with properties from the given properties object.
+     *
+     * @param props     properties object
+     * @param composite the composite instance
+     *
+     * @throws IllegalArgumentException if properties could not be transferred to composite
+     */
+    public static void map( Properties props, Composite composite )
+        throws IllegalArgumentException
+    {
+        for( Map.Entry<Object, Object> objectObjectEntry : props.entrySet() )
+        {
+            try
+            {
+                String methodName = objectObjectEntry.getKey().toString();
+                Method propertyMethod = composite.getClass().getInterfaces()[ 0 ].getMethod( methodName );
+                propertyMethod.setAccessible( true );
+                Object value = objectObjectEntry.getValue();
+                Type propertyType = GenericPropertyInfo.propertyTypeOf( propertyMethod );
+
+                value = mapToType( composite, propertyType, value.toString() );
+
+                @SuppressWarnings( "unchecked" )
+                Property<Object> property = (Property<Object>) propertyMethod.invoke( composite );
+                property.set( value );
+            }
+            catch( NoSuchMethodException e )
+            {
+                throw new IllegalArgumentException( "Could not find any property named " + objectObjectEntry.getKey() );
+            }
+            catch( IllegalAccessException e )
+            {
+                //noinspection ThrowableInstanceNeverThrown
+                throw new IllegalArgumentException( "Could not populate property named " + objectObjectEntry.getKey(), e );
+            }
+            catch( InvocationTargetException e )
+            {
+                //noinspection ThrowableInstanceNeverThrown
+                String message = "Could not populate property named " + objectObjectEntry.getKey();
+                throw new IllegalArgumentException( message, e );
+            }
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    private static Object mapToType( Composite composite, Type propertyType, Object value )
+    {
+        final String stringValue = value.toString();
+        MappingStrategy strategy;
+        if( propertyType instanceof Class )
+        {
+            Class type = (Class) propertyType;
+            if( type.isArray() )
+            {
+                strategy = STRATEGY.get( Array.class );
+            }
+            else if( Enum.class.isAssignableFrom( Classes.RAW_CLASS.map( propertyType ) ) )
+            {
+                strategy = STRATEGY.get( Enum.class );
+            }
+            else
+            {
+                strategy = STRATEGY.get( type );
+            }
+            if( strategy == null  ) // If null, try with the ValueComposite Mapper...
+            {
+                strategy = STRATEGY.get( ValueComposite.class );
+            }
+        }
+        else if( propertyType instanceof ParameterizedType )
+        {
+            ParameterizedType type = ( (ParameterizedType) propertyType );
+
+            if( type.getRawType() instanceof Class )
+            {
+                Class clazz = (Class) type.getRawType();
+                if( List.class.isAssignableFrom( clazz ) )
+                {
+                    strategy = STRATEGY.get( List.class );
+                }
+                else if( Set.class.isAssignableFrom( clazz ) )
+                {
+                    strategy = STRATEGY.get( Set.class );
+                }
+                else if( Map.class.isAssignableFrom( clazz ) )
+                {
+                    strategy = STRATEGY.get( Map.class );
+                }
+                else
+                {
+                    throw new IllegalArgumentException( propertyType + " is not supported." );
+                }
+            }
+            else
+            {
+                throw new IllegalArgumentException( propertyType + " is not supported." );
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException( propertyType + " is not supported." );
+        }
+
+        if( strategy == null )
+        {
+            throw new IllegalArgumentException( propertyType + " is not supported." );
+        }
+
+        return strategy.map( composite, propertyType, stringValue );
+    }
+
+    /**
+     * Load a Properties object from the given stream, close it, and then populate
+     * the Composite with the properties.
+     *
+     * @param propertyInputStream properties input stream
+     * @param composite           the instance
+     *
+     * @throws IOException if the stream could not be read
+     */
+
+    public static void map( InputStream propertyInputStream, Composite composite )
+        throws IOException
+    {
+        if( propertyInputStream != null )
+        {
+            Properties configProps = new Properties();
+            try
+            {
+                configProps.load( propertyInputStream );
+            }
+            finally
+            {
+                propertyInputStream.close();
+            }
+            map( configProps, composite );
+        }
+    }
+
+    /**
+     * Create Properties object which is backed by the given Composite.
+     *
+     * @param composite the instance
+     *
+     * @return properties instance
+     */
+    public static Properties toJavaProperties( final Composite composite )
+    {
+        return new Properties()
+        {
+            private static final long serialVersionUID = 3550125427530538865L;
+
+            @Override
+            public Object get( Object o )
+            {
+                try
+                {
+                    Method propertyMethod = composite.getClass().getMethod( o.toString() );
+                    Property<?> property = (Property<?>) propertyMethod.invoke( composite );
+                    return property.get();
+                }
+                catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e )
+                {
+                    return null;
+                }
+            }
+
+            @Override
+            public Object put( Object o, Object o1 )
+            {
+                Object oldValue = get( o );
+
+                try
+                {
+                    Method propertyMethod = composite.getClass().getMethod( o.toString(), Object.class );
+                    propertyMethod.invoke( composite, o1 );
+                }
+                catch( NoSuchMethodException | IllegalAccessException | InvocationTargetException e )
+                {
+                    e.printStackTrace();
+                }
+
+                return oldValue;
+            }
+        };
+    }
+
+    private static void tokenize( String valueString, boolean mapSyntax, TokenizerCallback callback )
+    {
+        char[] data = valueString.toCharArray();
+
+        int oldPos = 0;
+        for( int pos = 0; pos < data.length; pos++ )
+        {
+            char ch = data[ pos ];
+            if( ch == '\"' )
+            {
+                pos = resolveQuotes( valueString, callback, data, pos, '\"' );
+                oldPos = pos;
+            }
+            if( ch == '\'' )
+            {
+                pos = resolveQuotes( valueString, callback, data, pos, '\'' );
+                oldPos = pos;
+            }
+            if( ch == ',' || ( mapSyntax && ch == ':' ) )
+            {
+                String token = new String( data, oldPos, pos - oldPos );
+                callback.token( token );
+                oldPos = pos + 1;
+            }
+        }
+        String token = new String( data, oldPos, data.length - oldPos );
+        callback.token( token );
+    }
+
+    private static int resolveQuotes( String valueString,
+                                      TokenizerCallback callback,
+                                      char[] data,
+                                      int pos, char quote
+    )
+    {
+        boolean found = false;
+        for( int j = pos + 1; j < data.length; j++ )
+        {
+            if( !found )
+            {
+                if( data[ j ] == quote )
+                {
+                    String token = new String( data, pos + 1, j - pos - 1 );
+                    callback.token( token );
+                    found = true;
+                }
+            }
+            else
+            {
+                if( data[ j ] == ',' )
+                {
+                    return j + 1;
+                }
+            }
+        }
+        if( !found )
+        {
+            throw new IllegalArgumentException( "String is not quoted correctly: " + valueString );
+        }
+        return data.length;
+    }
+
+    private interface TokenizerCallback
+    {
+        void token( String token );
+    }
+
+    private interface MappingStrategy
+    {
+        Object map( Composite composite, Type type, String value );
+    }
+
+    private static class StringMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return value;
+        }
+    }
+
+    private static class IntegerMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Integer( value.trim() );
+        }
+    }
+
+    private static class FloatMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Float( value.trim() );
+        }
+    }
+
+    private static class DoubleMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Double( value.trim() );
+        }
+    }
+
+    private static class LongMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Long( value.trim() );
+        }
+    }
+
+    private static class ShortMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Short( value.trim() );
+        }
+    }
+
+    private static class ByteMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new Byte( value.trim() );
+        }
+    }
+
+    private static class CharMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return value.trim().charAt( 0 );
+        }
+    }
+
+    private static class BigDecimalMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new BigDecimal( value.trim() );
+        }
+    }
+
+    private static class BigIntegerMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return new BigInteger( value.trim() );
+        }
+    }
+
+    private static class EnumMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public Object map( Composite composite, Type type, String value )
+        {
+            return Enum.valueOf( (Class<Enum>) type, value );
+        }
+    }
+
+    private static class DateMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( Composite composite, Type type, String value )
+        {
+            return Dates.fromString( value.trim() );
+        }
+    }
+
+    private static class ValueCompositeMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public Object map( Composite composite, Type type, String value )
+        {
+            return Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( composite ).module().newValueFromSerializedState( (Class<Object>) type, value );
+        }
+    }
+
+    private static class ArrayMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( {"raw", "unchecked"} )
+        public Object map( final Composite composite, Type type, String value )
+        {
+            final Class arrayType = ( (Class) type ).getComponentType();
+            final ArrayList result = new ArrayList();
+            tokenize( value, false, new TokenizerCallback()
+            {
+                @Override
+                public void token( String token )
+                {
+                    result.add( mapToType( composite, arrayType, token ) );
+                }
+            } );
+            return result.toArray( (Object[]) Array.newInstance( arrayType, result.size() ) );
+        }
+    }
+
+    private static class BooleanMapper
+        implements MappingStrategy
+    {
+        @Override
+        public Object map( final Composite composite, Type type, String value )
+        {
+            return Boolean.valueOf( value.trim() );
+        }
+    }
+
+    private static class ListMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( {"raw", "unchecked"} )
+        public Object map( final Composite composite, Type type, String value )
+        {
+            final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
+            final Collection result = new ArrayList();
+            tokenize( value, false, new TokenizerCallback()
+            {
+                @Override
+                public void token( String token )
+                {
+                    result.add( mapToType( composite, dataType, token ) );
+                }
+            } );
+            return result;
+        }
+    }
+
+    private static class SetMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( {"raw", "unchecked"} )
+        public Object map( final Composite composite, Type type, String value )
+        {
+            final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
+            final Collection result = new HashSet();
+            tokenize( value, false, new TokenizerCallback()
+            {
+                @Override
+                public void token( String token )
+                {
+                    result.add( mapToType( composite, dataType, token ) );
+                }
+            } );
+            return result;
+        }
+    }
+
+    private static class MapMapper
+        implements MappingStrategy
+    {
+        @Override
+        @SuppressWarnings( {"raw", "unchecked"} )
+        public Object map( final Composite composite, Type generictype, String value )
+        {
+            ParameterizedType type = (ParameterizedType) generictype;
+            final Type keyType = type.getActualTypeArguments()[ 0 ];
+            final Type valueType = type.getActualTypeArguments()[ 0 ];
+            final Map result = new HashMap();
+            tokenize( value, true, new TokenizerCallback()
+            {
+                boolean keyArrivingNext = true;
+                String key;
+
+                @Override
+                public void token( String token )
+                {
+                    if( keyArrivingNext )
+                    {
+                        key = token;
+                        keyArrivingNext = false;
+                    }
+                    else
+                    {
+                        result.put( mapToType( composite, keyType, key ), mapToType( composite, valueType, token ) );
+                        keyArrivingNext = true;
+                    }
+                }
+            } );
+            return result;
+        }
+    }
+
+    private PropertyMapper()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/StateDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/StateDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/StateDescriptor.java
new file mode 100644
index 0000000..3eebcd4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/StateDescriptor.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.property.PropertyDescriptor;
+
+/**
+ * Composite State Descriptor.
+ */
+public interface StateDescriptor
+{
+    PropertyDescriptor findPropertyModelByName( String name )
+        throws IllegalArgumentException;
+
+    PropertyDescriptor findPropertyModelByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException;
+
+    Iterable<? extends PropertyDescriptor> properties();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/StatefulCompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/StatefulCompositeDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/StatefulCompositeDescriptor.java
new file mode 100644
index 0000000..ba44494
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/StatefulCompositeDescriptor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.qi4j.api.composite;
+
+/**
+ * Stateful Composite Descriptor.
+ */
+public interface StatefulCompositeDescriptor
+{
+    StateDescriptor state();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/TransientBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/TransientBuilder.java b/core/api/src/main/java/org/qi4j/api/composite/TransientBuilder.java
new file mode 100644
index 0000000..58b4ef6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/TransientBuilder.java
@@ -0,0 +1,68 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * TransientBuilders are used to instantiate TransientComposites. They can be acquired from
+ * {@link TransientBuilderFactory#newTransientBuilder(Class)} and allows the client
+ * to provide additional settings before instantiating the TransientComposite.
+ */
+public interface TransientBuilder<T>
+{
+    /**
+     * Provide objects that can be injected into mixins that has the @Uses
+     * dependency injection annotation.
+     *
+     * @param usedObjects The objects that can be injected into mixins.
+     *
+     * @return the transient builder instance
+     *
+     * @see org.qi4j.api.injection.scope.Uses
+     */
+    TransientBuilder<T> use( Object... usedObjects );
+
+    /**
+     * Get a representation of the state for the new Composite.
+     * It is possible to access and update properties and associations,
+     * even immutable ones since the builder represents the initial state.
+     *
+     * @return a proxy implementing the Composite type
+     */
+    T prototype();
+
+    /**
+     * Get a representation of the state of the given type for the new Composite.
+     * This is primarily used if you want to provide state for a private mixin type.
+     *
+     * @param mixinType the mixin which you want to provide state for
+     *
+     * @return a proxy implementing the given mixin type
+     */
+    <K> K prototypeFor( Class<K> mixinType );
+
+    /**
+     * Create a new Composite instance.
+     *
+     * @return a new Composite instance
+     *
+     * @throws ConstructionException thrown if it was not possible to instantiate the Composite
+     */
+    T newInstance()
+        throws ConstructionException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/TransientBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/TransientBuilderFactory.java b/core/api/src/main/java/org/qi4j/api/composite/TransientBuilderFactory.java
new file mode 100644
index 0000000..b06c58f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/TransientBuilderFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.composite;
+
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * This factory creates TransientComposites and the TransientBuilders.
+ *
+ * TransientComposite instances are very flexible in what it can reference, but are restricted in where they
+ * can be used. So, TransientComposites are mainly recommended where Values, Entities and Services can not be used,
+ * but they can also not be used to store state, be serialized across a network or have automatic equals/hashCode
+ * calculations.
+ */
+public interface TransientBuilderFactory
+{
+    /**
+     * Create a builder for creating new TransientComposites that implements the given TransientComposite type.
+     *
+     * @param mixinType an interface that describes the TransientComposite to be instantiated
+     *
+     * @return a TransientBuilder for creation of TransientComposites implementing the interface
+     *
+     * @throws NoSuchTransientException if no composite extending the mixinType has been registered
+     */
+    <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
+        throws NoSuchTransientException;
+
+    /**
+     * Instantiate a TransientComposite of the given type.
+     *
+     * @param mixinType the TransientComposite type to instantiate
+     *
+     * @return a new TransientComposite instance
+     *
+     * @throws NoSuchTransientException if no composite extending the mixinType has been registered
+     * @throws org.qi4j.api.common.ConstructionException
+     *                                  if the composite could not be instantiated
+     */
+    <T> T newTransient( Class<T> mixinType, Object... uses )
+        throws NoSuchTransientException, ConstructionException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/TransientComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/TransientComposite.java b/core/api/src/main/java/org/qi4j/api/composite/TransientComposite.java
new file mode 100644
index 0000000..8b21e88
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/TransientComposite.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+/**
+ * Transient Composite Type.
+ *
+ * TransientComposites have the following criteria;
+ * <ul>
+ * <li>Does not persist its state, and is not serializable</li>
+ * <li>Can not be referenced from Properties, Associations, ValueComposites nor Entities</li>
+ * <li>Can reference all types</li>
+ * <li>No lifecycle</li>
+ * <li>equals/hashCode is delegated to a single Mixin implementing the methods, like any other method</li>
+ * </ul>
+ */
+public interface TransientComposite
+    extends Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/TransientDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/TransientDescriptor.java b/core/api/src/main/java/org/qi4j/api/composite/TransientDescriptor.java
new file mode 100644
index 0000000..0df706c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/TransientDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.composite;
+
+/**
+ * TransientComposite Descriptor.
+ */
+public interface TransientDescriptor
+    extends CompositeDescriptor, StatefulCompositeDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/composite/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/composite/package.html b/core/api/src/main/java/org/qi4j/api/composite/package.html
new file mode 100644
index 0000000..00feaed
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/composite/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Composite API.</h2>
+    </body>
+</html>


[32/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Base64Encoder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Base64Encoder.java b/core/api/src/main/java/org/qi4j/api/util/Base64Encoder.java
new file mode 100644
index 0000000..9246b13
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Base64Encoder.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2009 Alin Dreghiciu.
+ *
+ * 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.qi4j.api.util;
+
+/**
+ * Base64Encoder.
+ */
+public final class Base64Encoder
+{
+
+    /**
+     * Utility class. ment to be used via static methods.
+     */
+    private Base64Encoder()
+    {
+        // utility class
+    }
+
+    /**
+     * Encodes a String into a base 64 String. The resulting encoding is chunked at 76 bytes.
+     *
+     * @param s String to encode.
+     *
+     * @return encoded string.
+     */
+    public static String encode( String s, boolean includePadding )
+    {
+        byte[] sBytes = s.getBytes();
+        sBytes = encode( sBytes, includePadding );
+        s = new String( sBytes );
+        return s;
+    }
+
+    /**
+     * Decodes a base 64 String into a String.
+     *
+     * @param s String to decode.
+     *
+     * @return encoded string.
+     *
+     * @throws java.lang.IllegalArgumentException
+     *          _ If the given byte array was not valid base64 encoding.
+     */
+    public static String decode( String s )
+        throws IllegalArgumentException
+    {
+        s = s.replaceAll( "\n", "" );
+        s = s.replaceAll( "\r", "" );
+        byte[] sBytes = s.getBytes();
+        sBytes = decode( sBytes );
+        s = new String( sBytes );
+        return s;
+    }
+
+    private static final byte[] ALPHASET =
+        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".getBytes();
+
+    private static final int I6O2 = 255 - 3;
+    private static final int O6I2 = 3;
+    private static final int I4O4 = 255 - 15;
+    private static final int O4I4 = 15;
+    private static final int I2O6 = 255 - 63;
+    private static final int O2I6 = 63;
+
+    /**
+     * Encodes a byte array into a base 64 byte array.
+     *
+     * @param dData byte array to encode.
+     *
+     * @return encoded byte array.
+     */
+    public static byte[] encode( byte[] dData, boolean includePadding )
+    {
+        if( dData == null )
+        {
+            throw new IllegalArgumentException( "Cannot encode null" );
+        }
+        byte[] eData = new byte[ ( ( dData.length + 2 ) / 3 ) * 4 ];
+
+        int eIndex = 0;
+        for( int i = 0; i < dData.length; i += 3 )
+        {
+            int d1;
+            int d2 = 0;
+            int d3 = 0;
+            int e1;
+            int e2;
+            int e3;
+            int e4;
+            int pad = 0;
+
+            d1 = dData[ i ];
+            if( ( i + 1 ) < dData.length )
+            {
+                d2 = dData[ i + 1 ];
+                if( ( i + 2 ) < dData.length )
+                {
+                    d3 = dData[ i + 2 ];
+                }
+                else
+                {
+                    pad = 1;
+                }
+            }
+            else
+            {
+                pad = 2;
+            }
+
+            e1 = ALPHASET[ ( d1 & I6O2 ) >> 2 ];
+            e2 = ALPHASET[ ( d1 & O6I2 ) << 4 | ( d2 & I4O4 ) >> 4 ];
+            e3 = ALPHASET[ ( d2 & O4I4 ) << 2 | ( d3 & I2O6 ) >> 6 ];
+            e4 = ALPHASET[ ( d3 & O2I6 ) ];
+
+            eData[ eIndex++ ] = (byte) e1;
+            eData[ eIndex++ ] = (byte) e2;
+            eData[ eIndex++ ] = ( pad < 2 ) ? (byte) e3 : (byte) '=';
+            eData[ eIndex++ ] = ( pad < 1 ) ? (byte) e4 : (byte) '=';
+
+            if( pad > 0 && !includePadding )
+            {
+                byte[] neweData = new byte[ eData.length - pad ];
+                System.arraycopy( eData, 0, neweData, 0, eIndex - pad );
+                eData = neweData;
+            }
+        }
+
+        return eData;
+    }
+
+    private final static int[] CODES = new int[ 256 ];
+
+    static
+    {
+        for( int i = 0; i < CODES.length; i++ )
+        {
+            CODES[ i ] = 64;
+        }
+        for( int i = 0; i < ALPHASET.length; i++ )
+        {
+            CODES[ ALPHASET[ i ] ] = i;
+        }
+    }
+
+    /**
+     * Decodes a base64 byte array into a byte array.
+     * <p>
+     *
+     * @param eData byte array to decode.
+     *
+     * @return decoded byte array.
+     *
+     * @throws java.lang.IllegalArgumentException
+     *          thrown if the given byte array was not valid com.sun.syndication.io.impl.Base64 encoding.
+     */
+    public static byte[] decode( byte[] eData )
+    {
+        if( eData == null )
+        {
+            throw new IllegalArgumentException( "Cannot decode null" );
+        }
+        byte[] cleanEData = eData.clone();
+        int cleanELength = 0;
+        for( byte anEData : eData )
+        {
+            if( anEData < 256 && CODES[ anEData ] < 64 )
+            {
+                cleanEData[ cleanELength++ ] = anEData;
+            }
+        }
+
+        int dLength = ( cleanELength / 4 ) * 3;
+        switch( cleanELength % 4 )
+        {
+        case 3:
+            dLength += 2;
+            break;
+        case 2:
+            dLength++;
+            break;
+        }
+
+        byte[] dData = new byte[ dLength ];
+        int dIndex = 0;
+        for( int i = 0; i < eData.length; i += 4 )
+        {
+            if( ( i + 3 ) > eData.length )
+            {
+                throw new IllegalArgumentException(
+                    "byte array is not a valid base64 encoding"
+                );
+            }
+            int e1 = CODES[ cleanEData[ i ] ];
+            int e2 = CODES[ cleanEData[ i + 1 ] ];
+            int e3 = CODES[ cleanEData[ i + 2 ] ];
+            int e4 = CODES[ cleanEData[ i + 3 ] ];
+            dData[ dIndex++ ] = (byte) ( ( e1 << 2 ) | ( e2 >> 4 ) );
+            if( dIndex < dData.length )
+            {
+                dData[ dIndex++ ] = (byte) ( ( e2 << 4 ) | ( e3 >> 2 ) );
+            }
+            if( dIndex < dData.length )
+            {
+                dData[ dIndex++ ] = (byte) ( ( e3 << 6 ) | ( e4 ) );
+            }
+        }
+        return dData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Classes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Classes.java b/core/api/src/main/java/org/qi4j/api/util/Classes.java
new file mode 100644
index 0000000..34f4b05
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Classes.java
@@ -0,0 +1,699 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.qi4j.api.composite.ModelDescriptor;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.functional.Iterables.cast;
+import static org.qi4j.functional.Iterables.empty;
+import static org.qi4j.functional.Iterables.flatten;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.map;
+import static org.qi4j.functional.Iterables.matchesAny;
+import static org.qi4j.functional.Iterables.prepend;
+
+/**
+ * Useful methods for handling Classes.
+ */
+public final class Classes
+{
+    private final static Map<Type, Type> wrapperClasses = new HashMap<>();
+
+    static
+    {
+        wrapperClasses.put( boolean.class, Boolean.class );
+        wrapperClasses.put( byte.class, Byte.class );
+        wrapperClasses.put( short.class, Short.class );
+        wrapperClasses.put( char.class, Character.class );
+        wrapperClasses.put( int.class, Integer.class );
+        wrapperClasses.put( long.class, Long.class );
+        wrapperClasses.put( float.class, Float.class );
+        wrapperClasses.put( double.class, Double.class );
+    }
+
+    private final static Map<Type, Type> primitiveClasses = new HashMap<>();
+
+    static
+    {
+        primitiveClasses.put( boolean.class, Boolean.class );
+        primitiveClasses.put( byte.class, Byte.class );
+        primitiveClasses.put( short.class, Short.class );
+        primitiveClasses.put( char.class, Character.class );
+        primitiveClasses.put( int.class, Integer.class );
+        primitiveClasses.put( long.class, Long.class );
+        primitiveClasses.put( float.class, Float.class );
+        primitiveClasses.put( double.class, Double.class );
+    }
+
+    /**
+     * Convert from primitive class (int, short, double, etc.) to wrapper class (Integer, Short, Double, etc.).
+     * Return the same class if it's not a primitive class. This can therefore safely be used on all types
+     * to ensure that they are not primitives.
+     */
+    private static final Function<Type, Type> WRAPPER_CLASS = new Function<Type, Type>()
+    {
+        @Override
+        public Type map( Type aClass )
+        {
+            Type wrapperClass = wrapperClasses.get( aClass );
+            return wrapperClass == null ? aClass : wrapperClass;
+        }
+    };
+
+    /**
+     * Convert from wrapper class (Integer, Short, Double, etc.) to primitive class (int, short, double, etc.).
+     * Return the same class if it's not a wrapper class. This can therefore safely be used on all types
+     * to ensure that they are primitives if possible.
+     */
+    @SuppressWarnings( "UnusedDeclaration" )
+    private static final Function<Type, Type> PRIMITIVE_CLASS = new Function<Type, Type>()
+    {
+        @Override
+        public Type map( Type aClass )
+        {
+            Type primitiveClass = primitiveClasses.get( aClass );
+            return primitiveClass == null ? aClass : primitiveClass;
+        }
+    };
+
+    /**
+     * Function that extract the raw class of a type.
+     */
+    public static final Function<Type, Class<?>> RAW_CLASS = new Function<Type, Class<?>>()
+    {
+        @Override
+        public Class<?> map( Type genericType )
+        {
+            // Calculate raw type
+            if( genericType instanceof Class )
+            {
+                return (Class<?>) genericType;
+            }
+            else if( genericType instanceof ParameterizedType )
+            {
+                return (Class<?>) ( (ParameterizedType) genericType ).getRawType();
+            }
+            else if( genericType instanceof TypeVariable )
+            {
+                return (Class<?>) ( (TypeVariable) genericType ).getGenericDeclaration();
+            }
+            else if( genericType instanceof WildcardType )
+            {
+                return (Class<?>) ( (WildcardType) genericType ).getUpperBounds()[ 0];
+            }
+            else if( genericType instanceof GenericArrayType )
+            {
+                Object temp = Array.newInstance( (Class<?>) ( (GenericArrayType) genericType ).getGenericComponentType(), 0 );
+                return temp.getClass();
+            }
+            throw new IllegalArgumentException( "Could not extract the raw class of " + genericType );
+        }
+    };
+
+    private static final Function<AccessibleObject, Type> TYPE_OF = new Function<AccessibleObject, Type>()
+    {
+        @Override
+        public Type map( AccessibleObject accessor )
+        {
+            return accessor instanceof Method ? ( (Method) accessor ).getGenericReturnType() : ( (Field) accessor ).getGenericType();
+        }
+    };
+
+    private static final Function<Type, Iterable<Class<?>>> CLASS_HIERARCHY = new Function<Type, Iterable<Class<?>>>()
+    {
+        @Override
+        @SuppressWarnings( {"raw", "unchecked"} )
+        public Iterable<Class<?>> map( Type type )
+        {
+            if( type == null )
+            {
+                return empty();
+            }
+            if( type.equals( Object.class ) )
+            {
+                Class<?> aClass = (Class<?>) type;
+                return cast( iterable( aClass ) );
+            }
+            else
+            {
+                type = RAW_CLASS.map( type );
+                Class superclass = ( (Class) type ).getSuperclass();
+                return prepend( (Class<?>) type, map( superclass ) );
+            }
+        }
+    };
+
+    @SuppressWarnings( "raw" )
+    private static final Function<Type, Iterable<Type>> INTERFACES_OF = new Function<Type, Iterable<Type>>()
+    {
+        @Override
+        public Iterable<Type> map( Type type )
+        {
+            Class clazz = RAW_CLASS.map( type );
+
+            if( clazz.isInterface() )
+            {
+                Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() );
+                Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) );
+                return prepend( type, flattenIterables );
+            }
+            else
+            {
+                if( type.equals( Object.class ) )
+                {
+                    return iterable( clazz.getGenericInterfaces() );
+                }
+                else
+                {
+                    return flatten( flattenIterables( Iterables.map( INTERFACES_OF,
+                                                                     iterable( clazz.getGenericInterfaces() ) ) ),
+                                    INTERFACES_OF.map( RAW_CLASS.map( type ).getSuperclass() ) );
+                }
+            }
+        }
+    };
+
+    @SuppressWarnings( "raw" )
+    private static final Function<Type, Iterable<Type>> TYPES_OF = new Function<Type, Iterable<Type>>()
+    {
+        @Override
+        public Iterable<Type> map( Type type )
+        {
+            Class clazz = RAW_CLASS.map( type );
+
+            if( clazz.isInterface() )
+            {
+                Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() );
+                Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) );
+                return prepend( clazz, flattenIterables );
+            }
+            else
+            {
+                return flatten( CLASS_HIERARCHY.map( type ),
+                                flattenIterables( Iterables.map( INTERFACES_OF, CLASS_HIERARCHY.map( type ) ) ) );
+            }
+        }
+    };
+
+    public static Type typeOf( AccessibleObject from )
+    {
+        return TYPE_OF.map( from );
+    }
+
+    public static Iterable<Type> typesOf( Iterable<Type> types )
+    {
+        Iterable<Type> result = empty();
+        for( Type type : types )
+        {
+            result = flatten( result, typesOf( type ) );
+        }
+        return result;
+    }
+
+    public static Iterable<Type> typesOf( Type type )
+    {
+        return TYPES_OF.map( type );
+    }
+
+    public static Iterable<? extends Type> interfacesOf( Iterable<? extends Type> types )
+    {
+        Iterable<Type> result = empty();
+        for( Type type : types )
+        {
+            result = flatten( result, interfacesOf( type ) );
+        }
+        return result;
+    }
+
+    public static Iterable<Type> interfacesOf( Type type )
+    {
+        return INTERFACES_OF.map( type );
+    }
+
+    public static Iterable<Class<?>> classHierarchy( Class<?> type )
+    {
+        return CLASS_HIERARCHY.map( type );
+    }
+
+    public static Type wrapperClass( Type type )
+    {
+        return WRAPPER_CLASS.map( type );
+    }
+
+    public static Specification<Class<?>> isAssignableFrom( final Class clazz )
+    {
+        return new Specification<Class<?>>()
+        {
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public boolean satisfiedBy( Class<?> item )
+            {
+                return clazz.isAssignableFrom( item );
+            }
+        };
+    }
+
+    @SuppressWarnings( "raw" )
+    public static Specification<Object> instanceOf( final Class clazz )
+    {
+        return new Specification<Object>()
+        {
+            @Override
+            public boolean satisfiedBy( Object item )
+            {
+                return clazz.isInstance( item );
+            }
+        };
+    }
+
+    public static Specification<Class<?>> hasModifier( final int classModifier )
+    {
+        return new Specification<Class<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( Class<?> item )
+            {
+                return ( item.getModifiers() & classModifier ) != 0;
+            }
+        };
+    }
+
+    public static <T> Function<Type, Iterable<T>> forClassHierarchy( final Function<Class<?>, Iterable<T>> function )
+    {
+        return new Function<Type, Iterable<T>>()
+        {
+            @Override
+            public Iterable<T> map( Type type )
+            {
+                return flattenIterables( Iterables.map( function, CLASS_HIERARCHY.map( type ) ) );
+            }
+        };
+    }
+
+    public static <T> Function<Type, Iterable<T>> forTypes( final Function<Type, Iterable<T>> function )
+    {
+        return new Function<Type, Iterable<T>>()
+        {
+            @Override
+            public Iterable<T> map( Type type )
+            {
+                return flattenIterables( Iterables.map( function, TYPES_OF.map( type ) ) );
+            }
+        };
+    }
+
+    @SuppressWarnings( "raw" )
+    public static Set<Class<?>> interfacesWithMethods( Set<Class<?>> interfaces )
+    {
+        Set<Class<?>> newSet = new LinkedHashSet<>();
+        for( Class type : interfaces )
+        {
+            if( type.isInterface() && type.getDeclaredMethods().length > 0 )
+            {
+                newSet.add( type );
+            }
+        }
+
+        return newSet;
+    }
+
+    public static String simpleGenericNameOf( Type type )
+    {
+        StringBuilder sb = new StringBuilder();
+        simpleGenericNameOf( sb, type );
+        return sb.toString();
+    }
+
+    @SuppressWarnings( "raw" )
+    private static void simpleGenericNameOf( StringBuilder sb, Type type )
+    {
+        if( type instanceof Class )
+        {
+            sb.append( ( (Class) type ).getSimpleName() );
+        }
+        else if( type instanceof ParameterizedType )
+        {
+            ParameterizedType pt = (ParameterizedType) type;
+            simpleGenericNameOf( sb, pt.getRawType() );
+            sb.append( "<" );
+            boolean atLeastOne = false;
+            for( Type typeArgument : pt.getActualTypeArguments() )
+            {
+                if( atLeastOne )
+                {
+                    sb.append( ", " );
+                }
+                simpleGenericNameOf( sb, typeArgument );
+                atLeastOne = true;
+            }
+            sb.append( ">" );
+        }
+        else if( type instanceof GenericArrayType )
+        {
+            GenericArrayType gat = (GenericArrayType) type;
+            simpleGenericNameOf( sb, gat.getGenericComponentType() );
+            sb.append( "[]" );
+        }
+        else if( type instanceof TypeVariable )
+        {
+            TypeVariable tv = (TypeVariable) type;
+            sb.append( tv.getName() );
+        }
+        else if( type instanceof WildcardType )
+        {
+            WildcardType wt = (WildcardType) type;
+            sb.append( "? extends " );
+            boolean atLeastOne = false;
+            for( Type typeArgument : wt.getUpperBounds() )
+            {
+                if( atLeastOne )
+                {
+                    sb.append( ", " );
+                }
+                simpleGenericNameOf( sb, typeArgument );
+                atLeastOne = true;
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException( "Don't know how to deal with type:" + type );
+        }
+    }
+
+    @SuppressWarnings( "UnusedDeclaration" )
+    public static <AnnotationType extends Annotation>
+        AnnotationType findAnnotationOfTypeOrAnyOfSuperTypes( Class<?> type, Class<AnnotationType> annotationClass )
+    {
+        AnnotationType result = null;
+        for( Type clazz : Classes.TYPES_OF.map( type ) )
+        {
+            result = Classes.RAW_CLASS.map( clazz ).getAnnotation( annotationClass );
+            if( result != null )
+            {
+                break;
+            }
+        }
+
+        return result;
+    }
+
+    public static Specification<Member> memberNamed( final String name )
+    {
+        return new Specification<Member>()
+        {
+            @Override
+            public boolean satisfiedBy( Member item )
+            {
+                return item.getName().equals( name );
+            }
+        };
+    }
+
+    /**
+     * Given a type variable, find what it resolves to given the declaring class where type
+     * variable was found and a top class that extends the declaring class.
+     *
+     * @param name The TypeVariable name.
+     * @param declaringClass The class where the TypeVariable is declared.
+     * @param topClass The top class that extends the declaringClass
+     *
+     * @return The Type instance of the given TypeVariable
+     */
+    @SuppressWarnings( "raw" )
+    public static Type resolveTypeVariable( TypeVariable name, Class declaringClass, Class topClass )
+    {
+        Type type = resolveTypeVariable( name, declaringClass, new HashMap<TypeVariable, Type>(), topClass );
+        if( type == null )
+        {
+            type = Object.class;
+        }
+        return type;
+    }
+
+    @SuppressWarnings( "raw" )
+    private static Type resolveTypeVariable( TypeVariable name,
+                                             Class declaringClass,
+                                             Map<TypeVariable, Type> mappings,
+                                             Class current
+    )
+    {
+        if( current.equals( declaringClass ) )
+        {
+            Type resolvedType = name;
+            while( resolvedType instanceof TypeVariable )
+            {
+                resolvedType = mappings.get( resolvedType );
+            }
+            return resolvedType;
+        }
+
+        List<Type> types = new ArrayList<>();
+        for( Type type : current.getGenericInterfaces() )
+        {
+            Iterable<Type> interfaces = Classes.INTERFACES_OF.map( type );
+            for( Type anInterface : interfaces )
+            {
+                if( !types.contains( anInterface ) )
+                {
+                    types.add( anInterface );
+                }
+            }
+            types.add( type );
+        }
+
+        if( current.getGenericSuperclass() != null )
+        {
+            types.add( current.getGenericSuperclass() );
+        }
+
+        for( Type type : types )
+        {
+            Class subClass;
+            if( type instanceof ParameterizedType )
+            {
+                ParameterizedType pt = (ParameterizedType) type;
+                Type[] args = pt.getActualTypeArguments();
+                Class clazz = (Class) pt.getRawType();
+                TypeVariable[] vars = clazz.getTypeParameters();
+                for( int i = 0; i < vars.length; i++ )
+                {
+                    TypeVariable var = vars[ i];
+                    Type mappedType = args[ i];
+                    mappings.put( var, mappedType );
+                }
+                subClass = (Class) pt.getRawType();
+            }
+            else
+            {
+                subClass = (Class) type;
+            }
+
+            Type resolvedType = resolveTypeVariable( name, declaringClass, mappings, subClass );
+            if( resolvedType != null )
+            {
+                return resolvedType;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Get URI for a class.
+     *
+     * @param clazz class
+     *
+     * @return URI
+     *
+     * @throws NullPointerException if clazz is null
+     */
+    @SuppressWarnings( "raw" )
+    public static String toURI( final Class clazz )
+        throws NullPointerException
+    {
+        return toURI( clazz.getName() );
+    }
+
+    /**
+     * Get URI for a class name.
+     * <p>
+     * Example:
+     * </p>
+     * <p>
+     * Class name com.example.Foo$Bar is converted to URI urn:qi4j:com.example.Foo-Bar
+     * </p>
+     *
+     * @param className class name
+     *
+     * @return URI
+     *
+     * @throws NullPointerException if className is null
+     */
+    public static String toURI( String className )
+        throws NullPointerException
+    {
+        className = normalizeClassToURI( className );
+        return "urn:qi4j:type:" + className;
+    }
+
+    /**
+     * Get class name from a URI
+     *
+     * @param uri URI
+     *
+     * @return class name
+     *
+     * @throws NullPointerException if uri is null
+     */
+    public static String toClassName( String uri )
+        throws NullPointerException
+    {
+        uri = uri.substring( "urn:qi4j:type:".length() );
+        uri = denormalizeURIToClass( uri );
+        return uri;
+    }
+
+    public static String normalizeClassToURI( String className )
+    {
+        return className.replace( '$', '-' );
+    }
+
+    public static String denormalizeURIToClass( String uriPart )
+    {
+        return uriPart.replace( '-', '$' );
+    }
+
+    public static Specification<ModelDescriptor> modelTypeSpecification( final String className )
+    {
+        return new Specification<ModelDescriptor>()
+        {
+            @Override
+            public boolean satisfiedBy( ModelDescriptor item )
+            {
+                return matchesAny( new Specification<String>()
+                {
+                    @Override
+                    public boolean satisfiedBy( String item )
+                    {
+                        return item.equals( className );
+                    }
+                }, map( new Function<Class<?>, String>()
+                {
+                    @Override
+                    public String map( Class<?> item )
+                    {
+                        return item.getName();
+                    }
+                }, item.types() ) );
+            }
+        };
+    }
+
+    @SuppressWarnings( "raw" )
+    public static Specification<ModelDescriptor> exactTypeSpecification( final Class type )
+    {
+        return new Specification<ModelDescriptor>()
+        {
+            @Override
+            public boolean satisfiedBy( ModelDescriptor item )
+            {
+                return matchesAny( new Specification<Class<?>>()
+                {
+                    @Override
+                    public boolean satisfiedBy( Class<?> item )
+                    {
+                        return item.equals( type );
+                    }
+                }, item.types() );
+            }
+        };
+    }
+
+    @SuppressWarnings( "raw" )
+    public static Specification<ModelDescriptor> assignableTypeSpecification( final Class type )
+    {
+        return new Specification<ModelDescriptor>()
+        {
+            @Override
+            public boolean satisfiedBy( ModelDescriptor item )
+            {
+                return matchesAny( new Specification<Class<?>>()
+                {
+                    @Override
+                    @SuppressWarnings( "unchecked" )
+                    public boolean satisfiedBy( Class<?> itemType )
+                    {
+                        return !type.equals( itemType ) && type.isAssignableFrom( itemType );
+                    }
+                }, item.types() );
+            }
+        };
+    }
+
+    @SuppressWarnings( "raw" )
+    public static String toString( Iterable<? extends Class> type )
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append( "[" );
+        boolean first = true;
+        for( Class c : type )
+        {
+            if( !first )
+            {
+                builder.append( "," );
+            }
+            first = false;
+            builder.append( c.getSimpleName() );
+        }
+        builder.append( "]" );
+        return builder.toString();
+    }
+
+    public static Function<Type, String> toClassName()
+    {
+        return new Function<Type, String>()
+        {
+            @Override
+            public String map( Type type )
+            {
+                return RAW_CLASS.map( type ).getName();
+            }
+        };
+    }
+
+    private Classes()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Constructors.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Constructors.java b/core/api/src/main/java/org/qi4j/api/util/Constructors.java
new file mode 100644
index 0000000..17062ca
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Constructors.java
@@ -0,0 +1,40 @@
+/*
+ * 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.qi4j.api.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
+import org.qi4j.functional.Function;
+
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * Useful methods for handling Constructors.
+ */
+public final class Constructors
+{
+    public static final Function<Type, Iterable<Constructor<?>>> CONSTRUCTORS_OF = Classes.forClassHierarchy( new Function<Class<?>, Iterable<Constructor<?>>>()
+    {
+        @Override
+        public Iterable<Constructor<?>> map( Class<?> type )
+        {
+            return iterable( type.getDeclaredConstructors() );
+        }
+    } );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Dates.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Dates.java b/core/api/src/main/java/org/qi4j/api/util/Dates.java
new file mode 100644
index 0000000..3324df2
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Dates.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.util;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Useful methods for handling Dates.
+ */
+public final class Dates
+{
+    // Formatters are not thread-safe. Create one per thread
+    private static final ThreadLocal<DateFormat> ISO8601 = new ThreadLocal<DateFormat>()
+    {
+        @Override
+        protected DateFormat initialValue()
+        {
+            return new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
+        }
+    };
+
+    private static final ThreadLocal<DateFormat> ISO8601_UTC = new ThreadLocal<DateFormat>()
+    {
+        @Override
+        protected DateFormat initialValue()
+        {
+            SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
+            dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+            return dateFormat;
+        }
+    };
+
+    /**
+     * @param stringDate a string representing a date as either ISO8601, @millis@ or /Date() formats
+     * @return a Date
+     */
+    public static Date fromString( String stringDate )
+    {
+        try
+        {
+            Date date = ISO8601_UTC.get().parse( stringDate );
+            return date;
+        }
+        catch( ParseException e )
+        {
+            try
+            {
+                Date date = ISO8601.get().parse( stringDate );
+                return date;
+            }
+            catch( ParseException e1 )
+            {
+                // @millis@ format
+                if( stringDate.startsWith( "@" ) && stringDate.endsWith( "@" ) )
+                {
+                    long time = Long.parseLong( stringDate.substring( 1, stringDate.length() - 1 ) );
+                    Date date = new Date( time );
+                    return date;
+                }
+                else if( stringDate.startsWith( "/Date(" ) && stringDate.endsWith( ")/" ) ) // Microsoft format
+                {
+                    long time = Long.parseLong( stringDate.substring( 6, stringDate.length() - 2 ) );
+                    Date date = new Date( time );
+                    return date;
+                }
+                throw new IllegalStateException( "Illegal date:" + stringDate );
+            }
+        }
+    }
+
+    /**
+     * @param date a Date
+     * @return String representation in ISO8601 UTC
+     */
+    public static String toUtcString( Date date )
+    {
+        return ISO8601_UTC.get().format( date );
+    }
+
+    private Dates()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Fields.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Fields.java b/core/api/src/main/java/org/qi4j/api/util/Fields.java
new file mode 100644
index 0000000..c68d131
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Fields.java
@@ -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.
+ */
+package org.qi4j.api.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Function2;
+import org.qi4j.functional.Iterables;
+
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * Useful methods for handling Fields.
+ */
+public final class Fields
+{
+    public static final Function2<Class<?>, String, Field> FIELD_NAMED = new Function2<Class<?>, String, Field>()
+    {
+        @Override
+        public Field map( Class<?> aClass, String name )
+        {
+            return Iterables.first( Iterables.filter( Classes.memberNamed( name ), FIELDS_OF.map( aClass ) ) );
+        }
+    };
+
+    public static final Function<Type, Iterable<Field>> FIELDS_OF = Classes.forClassHierarchy( new Function<Class<?>, Iterable<Field>>()
+    {
+        @Override
+        public Iterable<Field> map( Class<?> type )
+        {
+            return iterable( type.getDeclaredFields() );
+        }
+    } );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/ListMap.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/ListMap.java b/core/api/src/main/java/org/qi4j/api/util/ListMap.java
new file mode 100644
index 0000000..56778b8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/ListMap.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Map whose values are Lists of things. Create
+ * one ArrayList for each key that is added. The list does not allow
+ * duplicates.
+ */
+public final class ListMap<K, V>
+    extends HashMap<K, List<V>>
+{
+    public void add( K key, V value )
+    {
+        List<V> list = get( key );
+        if( list == null )
+        {
+            list = new ArrayList<V>();
+            put( key, list );
+        }
+        if( !list.contains( value ) )
+        {
+            list.add( value );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Methods.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Methods.java b/core/api/src/main/java/org/qi4j/api/util/Methods.java
new file mode 100644
index 0000000..93b78cf
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Methods.java
@@ -0,0 +1,50 @@
+/*
+ * 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.qi4j.api.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * Useful methods for handling Methods.
+ */
+public class Methods
+{
+    public static final Specification<Type> HAS_METHODS = new Specification<Type>()
+    {
+        @Override
+        public boolean satisfiedBy( Type item )
+        {
+            return Classes.RAW_CLASS.map( item ).getDeclaredMethods().length > 0;
+        }
+    };
+
+    public static final Function<Type, Iterable<Method>> METHODS_OF = Classes.forTypes( new Function<Type, Iterable<Method>>()
+    {
+        @Override
+        public Iterable<Method> map( Type type )
+        {
+            return iterable( Classes.RAW_CLASS.map( type ).getDeclaredMethods() );
+        }
+    } );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/NullArgumentException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/NullArgumentException.java b/core/api/src/main/java/org/qi4j/api/util/NullArgumentException.java
new file mode 100644
index 0000000..58e514f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/NullArgumentException.java
@@ -0,0 +1,56 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.util;
+
+/**
+ * Thrown if an argument to a method was null, and the method required
+ * it to be non-null.
+ */
+public class NullArgumentException
+    extends IllegalArgumentException
+{
+    private static final long serialVersionUID = 4815431779868729780L;
+
+    private NullArgumentException( String message )
+    {
+        super( message );
+    }
+
+    public static void validateNotNull( String parameterName, Object value )
+    {
+        if( value != null )
+        {
+            return;
+        }
+        String message = parameterName + " was null.";
+        throw new NullArgumentException( message );
+    }
+
+    public static void validateNotEmpty( String parameterName, String value )
+    {
+        if( value == null )
+        {
+            String message = parameterName + " was null.";
+            throw new NullArgumentException( message );
+        }
+        if( value.length() == 0 )
+        {
+            String message = parameterName + " was empty.";
+            throw new NullArgumentException( message );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/package.html b/core/api/src/main/java/org/qi4j/api/util/package.html
new file mode 100644
index 0000000..ea75db3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>API Utilities.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/NoSuchValueException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/NoSuchValueException.java b/core/api/src/main/java/org/qi4j/api/value/NoSuchValueException.java
new file mode 100644
index 0000000..256e9fc
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/NoSuchValueException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.value;
+
+import org.qi4j.api.composite.NoSuchCompositeException;
+
+/**
+ * Thrown when no visible value of the requested type is found.
+ */
+public class NoSuchValueException
+    extends NoSuchCompositeException
+{
+    public NoSuchValueException( String valueType, String moduleName )
+    {
+        super( "ValueComposite", valueType, moduleName );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueBuilder.java b/core/api/src/main/java/org/qi4j/api/value/ValueBuilder.java
new file mode 100644
index 0000000..1073a0d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueBuilder.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.value;
+
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * Builder for Values.
+ */
+public interface ValueBuilder<T>
+{
+    AssociationStateHolder state();
+
+    /**
+     * Get a representation of the state for the new Value.
+     * It is possible to access and update properties and associations,
+     * even immutable ones since the builder represents the initial state.
+     *
+     * @return a mutable instance of the Value type
+     */
+    T prototype();
+
+    /**
+     * Get a representation of the state of the given type for the new ValueComposite.
+     * This is primarily used if you want to provide state for a private mixin type.
+     *
+     * @param mixinType the mixin which you want to provide state for
+     *
+     * @return a proxy implementing the given mixin type
+     */
+    <K> K prototypeFor( Class<K> mixinType );
+
+    /**
+     * Create a new Composite instance.
+     *
+     * @return a new Composite instance
+     *
+     * @throws org.qi4j.api.common.ConstructionException
+     *          thrown if it was not possible to instantiate the Composite
+     */
+    T newInstance()
+        throws ConstructionException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueBuilderFactory.java b/core/api/src/main/java/org/qi4j/api/value/ValueBuilderFactory.java
new file mode 100644
index 0000000..57c4e29
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueBuilderFactory.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.value;
+
+import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.property.PropertyDescriptor;
+import org.qi4j.functional.Function;
+
+/**
+ * Factory for Values and ValueBuilders.
+ */
+public interface ValueBuilderFactory
+{
+
+    /**
+     * Instantiate a Value of the given type.
+     *
+     * @param valueType the Value type to instantiate
+     *
+     * @return a new Value instance
+     *
+     * @throws NoSuchValueException if no value extending the mixinType has been registered
+     * @throws ConstructionException if the value could not be instantiated
+     */
+    <T> T newValue( Class<T> valueType )
+        throws NoSuchValueException, ConstructionException;
+
+    /**
+     * Create a builder for creating new Values that implements the given Value type.
+     * <p>The returned ValueBuilder can be reused to create several Values instances.</p>
+     *
+     * @param valueType an interface that describes the Composite to be instantiated
+     *
+     * @return a ValueBuilder for creation of ValueComposites implementing the interface
+     *
+     * @throws NoSuchValueException if no value extending the mixinType has been registered
+     */
+    <T> ValueBuilder<T> newValueBuilder( Class<T> valueType )
+        throws NoSuchValueException;
+
+    /**
+     * Create a builder for creating a new Value starting with the given prototype.
+     * <p>The returned ValueBuilder can only be used ONCE.</p>
+     *
+     * @param prototype a prototype the builder will use
+     *
+     * @return a ValueBuilder for creation of ValueComposites implementing the interface of the prototype
+     *
+     * @throws NoSuchValueException if no value extending the mixinType has been registered
+     */
+    <T> ValueBuilder<T> newValueBuilderWithPrototype( T prototype );
+
+    /**
+     * Create a builder for creating a new Value starting with the given state.
+     * <p>The returned ValueBuilder can only be used ONCE.</p>
+     *
+     * @param mixinType an interface that describes the Composite to be instantiated
+     * @param propertyFunction a function providing the state of properties
+     * @param associationFunction a function providing the state of associations
+     * @param manyAssociationFunction a function providing the state of many associations
+     * @param namedAssociationFunction a function providing the state of named associations
+     *
+     * @return a ValueBuilder for creation of ValueComposites implementing the interface
+     *
+     * @throws NoSuchValueException if no value extending the mixinType has been registered
+     */
+    <T> ValueBuilder<T> newValueBuilderWithState( Class<T> mixinType,
+                                                  Function<PropertyDescriptor, Object> propertyFunction,
+                                                  Function<AssociationDescriptor, EntityReference> associationFunction,
+                                                  Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
+                                                  Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction );
+
+    /**
+     * Instantiate a Value of the given type using the serialized state given as String.
+     *
+     * @param valueType the Value type to instantiate
+     * @param serializedState  the state of the Value
+     *
+     * @return a new Value instance
+     *
+     * @throws NoSuchValueException if no value extending the mixinType has been registered
+     * @throws ConstructionException if the value could not be instantiated
+     */
+    <T> T newValueFromSerializedState( Class<T> valueType, String serializedState );
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueBuilderTemplate.java b/core/api/src/main/java/org/qi4j/api/value/ValueBuilderTemplate.java
new file mode 100644
index 0000000..11cbddb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueBuilderTemplate.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.value;
+
+import org.qi4j.api.structure.Module;
+
+/**
+ * Builder template for Values.
+ */
+public abstract class ValueBuilderTemplate<T>
+{
+    Class<T> type;
+
+    protected ValueBuilderTemplate( Class<T> type )
+    {
+        this.type = type;
+    }
+
+    protected abstract void build( T prototype );
+
+    public T newInstance( Module module )
+    {
+        ValueBuilder<T> builder = module.newValueBuilder( type );
+        build( builder.prototype() );
+        return builder.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueComposite.java b/core/api/src/main/java/org/qi4j/api/value/ValueComposite.java
new file mode 100644
index 0000000..7d5f48f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueComposite.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.value;
+
+import org.qi4j.api.association.AssociationMixin;
+import org.qi4j.api.association.ManyAssociationMixin;
+import org.qi4j.api.association.NamedAssociationMixin;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Immutable;
+
+/**
+ * ValueComposites are Composites that has state, and equality is defined from its values and not any identity nor
+ * instance references.
+ *
+ * <ul>
+ * <li>No Identity</li>
+ * <li>No Lifecycle</li>
+ * <li>Immutable</li>
+ * <li>equals()/hashCode() operates on the Properties</li>
+ * <li>Can have property and associations methods.</li>
+ * <li>Can not reference Services</li>
+ * <li>Can not have @Uses</li>
+ * </ul>
+ */
+@Immutable
+@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } )
+public interface ValueComposite
+    extends Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueDescriptor.java b/core/api/src/main/java/org/qi4j/api/value/ValueDescriptor.java
new file mode 100644
index 0000000..710de89
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueDescriptor.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.value;
+
+import org.qi4j.api.association.AssociationStateDescriptor;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.StatefulCompositeDescriptor;
+import org.qi4j.api.type.ValueCompositeType;
+
+/**
+ * Descriptor for ValueComposites.
+ */
+public interface ValueDescriptor
+    extends CompositeDescriptor, StatefulCompositeDescriptor
+{
+    ValueCompositeType valueType();
+
+    @Override
+    AssociationStateDescriptor state();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueDeserializer.java b/core/api/src/main/java/org/qi4j/api/value/ValueDeserializer.java
new file mode 100644
index 0000000..175b176
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueDeserializer.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2012, Paul Merlin. 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.qi4j.api.value;
+
+import java.io.InputStream;
+import org.qi4j.api.type.ValueType;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Function2;
+
+/**
+ * Use a ValueDeserializer to create new values instances from serialized state.
+ *
+ * <p>
+ *     Serialized state must be one of:
+ * </p>
+ * <ul>
+ *     <li>a ValueComposite,</li>
+ *     <li>an EntityReference,</li>
+ *     <li>a Collection,</li>
+ *     <li>a Map,</li>
+ *     <li>a Plain Value.</li>
+ * </ul>
+ * <p>
+ *     Nested plain values, EntityReferences, Collections, Maps, ValueComposites are supported.
+ *     EntityReferences are deserialized as their identity string.
+ * </p>
+ * <p>
+ *     Plain values can be one of:
+ * </p>
+ * <ul>
+ *     <li>String,</li>
+ *     <li>Character or char,</li>
+ *     <li>Boolean or boolean,</li>
+ *     <li>Integer or int,</li>
+ *     <li>Long or long,</li>
+ *     <li>Short or short,</li>
+ *     <li>Byte or byte,</li>
+ *     <li>Float or float,</li>
+ *     <li>Double or double,</li>
+ *     <li>BigInteger,</li>
+ *     <li>BigDecimal,</li>
+ *     <li>Date,</li>
+ *     <li>DateTime (JodaTime),</li>
+ *     <li>LocalDateTime (JodaTime),</li>
+ *     <li>LocalDate (JodaTime).</li>
+ * </ul>
+ * <p>
+ *     Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are deserialized
+ *     from base64 encoded bytes using pure Java serialization. If it happens that the input is invalid, a
+ *     ValueSerializationException is thrown.
+ * </p>
+ * <p>
+ *     Having type information in the serialized payload allows to keep actual ValueComposite types and by so
+ *     circumvent {@link org.qi4j.api.composite.AmbiguousTypeException} when deserializing.
+ * </p>
+ */
+public interface ValueDeserializer
+{
+
+    /**
+     * Factory method for a typed deserialize function.
+     *
+     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
+     *
+     * @param type the value type
+     * @param <T> the parametrized function return type
+     * @return a deserialization function
+     */
+    <T> Function<String, T> deserialize( Class<T> type );
+
+    /**
+     * Factory method for a typed deserialize function.
+     *
+     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
+     *
+     * @param valueType the value type
+     * @param <T> the parametrized function return type
+     * @return a deserialization function
+     */
+    <T> Function<String, T> deserialize( ValueType valueType );
+
+    /**
+     * Factory method for an untyped deserialize function.
+     *
+     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
+     *
+     * @param <T> the parametrized function return type
+     * @return a deserialization function
+     */
+    <T> Function2<ValueType, String, T> deserialize();
+
+    /**
+     * Deserialize a value from a state.
+     *
+     * @param <T> the parametrized returned type
+     * @param type the value type
+     * @param input the state
+     * @return the value
+     * @throws ValueSerializationException if the deserialization failed
+     */
+    <T> T deserialize( Class<?> type, String input )
+        throws ValueSerializationException;
+
+    /**
+     * Deserialize a value from a state.
+     *
+     * @param <T> the parametrized returned type
+     * @param valueType the value type
+     * @param input the state
+     * @return the value
+     * @throws ValueSerializationException if the deserialization failed
+     */
+    <T> T deserialize( ValueType valueType, String input )
+        throws ValueSerializationException;
+
+    /**
+     * Deserialize a value from a state.
+     *
+     * @param <T> the parametrized returned type
+     * @param type the value type
+     * @param input the state stream
+     * @return the value
+     * @throws ValueSerializationException if the deserialization failed
+     */
+    <T> T deserialize( Class<?> type, InputStream input )
+        throws ValueSerializationException;
+
+    /**
+     * Deserialize a value from a state.
+     *
+     * @param <T> the parametrized returned type
+     * @param valueType the value type
+     * @param input the state stream
+     * @return the value
+     * @throws ValueSerializationException if the deserialization failed
+     */
+    <T> T deserialize( ValueType valueType, InputStream input )
+        throws ValueSerializationException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueSerialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueSerialization.java b/core/api/src/main/java/org/qi4j/api/value/ValueSerialization.java
new file mode 100644
index 0000000..31a4af0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueSerialization.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, Paul Merlin. 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.qi4j.api.value;
+
+/**
+ * ValueSerialization API.
+ *
+ * See {@link ValueSerializer} and {@link ValueDeserializer}.
+ */
+public interface ValueSerialization
+    extends ValueSerializer, ValueDeserializer
+{
+
+    /**
+     * Serialization format @Service tags.
+     *
+     * <p>
+     *     ValueSerialization implementations should be tagged with theses at assembly time so that consumers can
+     *     specify which format they need.
+     * </p>
+     */
+    interface Formats
+    {
+
+        /**
+         * Tag a ValueSerialization service that support the JSON format.
+         */
+        String JSON = "json";
+        /**
+         * Tag a ValueSerialization service that support the XML format.
+         */
+        String XML = "xml";
+        /**
+         * Tag a ValueSerialization service that support the YAML format.
+         */
+        String YAML = "yaml";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueSerializationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueSerializationException.java b/core/api/src/main/java/org/qi4j/api/value/ValueSerializationException.java
new file mode 100644
index 0000000..e1f3d44
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueSerializationException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Paul Merlin. 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.qi4j.api.value;
+
+/**
+ * Thrown when an error occur during value state (de)serialization.
+ */
+public class ValueSerializationException
+    extends RuntimeException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public ValueSerializationException()
+    {
+        super();
+    }
+
+    public ValueSerializationException( String message )
+    {
+        super( message );
+    }
+
+    public ValueSerializationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public ValueSerializationException( Throwable cause )
+    {
+        super( cause.getClass().getName() + ": " + cause.getMessage(), cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/ValueSerializer.java b/core/api/src/main/java/org/qi4j/api/value/ValueSerializer.java
new file mode 100644
index 0000000..337c37e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/ValueSerializer.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2012-2014, Paul Merlin. 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.qi4j.api.value;
+
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import org.qi4j.api.composite.AmbiguousTypeException;
+import org.qi4j.functional.Function;
+
+/**
+ * Use a ValueSerializer to serialize values state.
+ *
+ * <p>
+ *     Serialized object must be one of:
+ * </p>
+ * <ul>
+ *     <li>a ValueComposite,</li>
+ *     <li>an EntityComposite or EntityReference,</li>
+ *     <li>an Iterable,</li>
+ *     <li>a Map,</li>
+ *     <li>a Plain Value.</li>
+ * </ul>
+ * <p>
+ *     Nested plain values, EntityReferences, Iterables, Maps, ValueComposites and EntityComposites are supported.
+ *     EntityComposites and EntityReferences are serialized as their identity string.
+ * </p>
+ * <p>
+ *     Plain values can be one of:
+ * </p>
+ * <ul>
+ *     <li>String,</li>
+ *     <li>Character or char,</li>
+ *     <li>Boolean or boolean,</li>
+ *     <li>Integer or int,</li>
+ *     <li>Long or long,</li>
+ *     <li>Short or short,</li>
+ *     <li>Byte or byte,</li>
+ *     <li>Float or float,</li>
+ *     <li>Double or double,</li>
+ *     <li>BigInteger,</li>
+ *     <li>BigDecimal,</li>
+ *     <li>Date,</li>
+ *     <li>DateTime (JodaTime),</li>
+ *     <li>LocalDateTime (JodaTime),</li>
+ *     <li>LocalDate (JodaTime).</li>
+ * </ul>
+ * <p>
+ *     Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are serialized to
+ *     base64 encoded bytes using pure Java serialization. If it happens that the value is not Serializable, a
+ *     ValueSerializationException is thrown.
+ * </p>
+ * <p>
+ *     Having type information in the serialized payload allows to keep actual ValueComposite types and by so
+ *     circumvent {@link AmbiguousTypeException} when deserializing.
+ * </p>
+ */
+public interface ValueSerializer
+{
+
+    /**
+     * Factory method for a serialize function.
+     *
+     * @param <T> the parametrized function input type
+     * @return a serialization function.
+     */
+    <T> Function<T, String> serialize();
+
+    /**
+     * Factory method for a serialize function.
+     *
+     * @param <T> the parametrized function input type
+     * @param options ValueSerializer Options
+     * @return a serialization function.
+     */
+    <T> Function<T, String> serialize( Options options );
+
+    /**
+     * Factory method for a serialize function.
+     *
+     * @param <T> the parametrized function input type
+     * @param includeTypeInfo if type information should be included in the output
+     * @return a serialization function.
+     */
+    @Deprecated
+    <T> Function<T, String> serialize( boolean includeTypeInfo );
+
+    /**
+     * Serialize the state of a value with type information.
+     *
+     * @param object an Object to serialize
+     * @return the state
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    String serialize( Object object )
+        throws ValueSerializationException;
+
+    /**
+     * Serialize the state of a value.
+     *
+     * @param options ValueSerializer Options
+     * @param object an Object to serialize
+     * @return the state
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    String serialize( Options options, Object object )
+        throws ValueSerializationException;
+
+    /**
+     * Serialize the state of a value.
+     *
+     * @param object an Object to serialize
+     * @param includeTypeInfo if type information should be included in the output
+     * @return the state
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    @Deprecated
+    String serialize( Object object, boolean includeTypeInfo )
+        throws ValueSerializationException;
+
+    /**
+     * Serialize the state of a value with type information.
+     *
+     * @param object an Object to serialize
+     * @param output that will be used as output
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    void serialize( Object object, OutputStream output )
+        throws ValueSerializationException;
+
+    /**
+     * Serialize the state of a value.
+     *
+     * @param options ValueSerializer Options
+     * @param object an Object to serialize
+     * @param output that will be used as output
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    void serialize( Options options, Object object, OutputStream output )
+        throws ValueSerializationException;
+
+    /**
+     * Serialize the state of a value.
+     *
+     * @param object an Object to serialize
+     * @param output that will be used as output
+     * @param includeTypeInfo if type information should be included in the output
+     * @throws ValueSerializationException if the Value serialization failed
+     */
+    @Deprecated
+    void serialize( Object object, OutputStream output, boolean includeTypeInfo )
+        throws ValueSerializationException;
+
+    /**
+     * Serialization options.
+     */
+    final class Options
+    {
+        /**
+         * Boolean flag to include type information.
+         * Default to TRUE.
+         */
+        public static final String INCLUDE_TYPE_INFO = "includeTypeInfo";
+        public static final String MAP_ENTRIES_AS_OBJECTS = "mapentriesasobjects";
+        private final Map<String, String> options = new HashMap<>();
+
+        /**
+         * Create new default ValueSerializer Options.
+         */
+        public Options()
+        {
+            this.options.put( INCLUDE_TYPE_INFO, "true" );
+            this.options.put( MAP_ENTRIES_AS_OBJECTS, "false" );
+        }
+
+        /**
+         * Set {@link #INCLUDE_TYPE_INFO} option to TRUE.
+         * @return This
+         */
+        public Options withTypeInfo()
+        {
+            return put( INCLUDE_TYPE_INFO, true );
+        }
+
+        /**
+         * Set {@link #INCLUDE_TYPE_INFO} option to FALSE.
+         * @return This
+         */
+        public Options withoutTypeInfo()
+        {
+            return put( INCLUDE_TYPE_INFO, false );
+        }
+
+        public Options withMapEntriesAsObjects()
+        {
+            return put( MAP_ENTRIES_AS_OBJECTS, true );
+        }
+
+        public Options withMapEntriesAsKeyValuePairs()
+        {
+            return put( MAP_ENTRIES_AS_OBJECTS, false );
+        }
+
+        /**
+         * Get Boolean option value.
+         * @param option The option
+         * @return The boolean value of the option, or null if absent
+         */
+        public Boolean getBoolean( String option )
+        {
+            if( !options.containsKey( option ) )
+            {
+                return null;
+            }
+            return Boolean.valueOf( options.get( option ) );
+        }
+
+        /**
+         * Get Integer option value.
+         * @param option The option
+         * @return The integer value of the option, or null if absent
+         */
+        public Integer getInteger( String option )
+        {
+            if( !options.containsKey( option ) )
+            {
+                return null;
+            }
+            return Integer.valueOf( options.get( option ) );
+        }
+
+        /**
+         * Get String option value.
+         * @param option The option
+         * @return The string value of the option, or null if absent
+         */
+        public String getString( String option )
+        {
+            return options.get( option );
+        }
+
+        /**
+         * Put an option String value.
+         * @param option The option
+         * @param value The value
+         * @return This Options instance
+         */
+        public Options put( String option, String value )
+        {
+            if( value == null )
+            {
+                return remove( option );
+            }
+            options.put( option, value );
+            return this;
+        }
+
+        /**
+         * Put an option boolean value.
+         * @param option The option
+         * @param value The value
+         * @return This Options instance
+         */
+        public Options put( String option, Boolean value )
+        {
+            if( value == null )
+            {
+                return remove( option );
+            }
+            options.put( option, Boolean.toString( value ) );
+            return this;
+        }
+
+        /**
+         * Put an option Integer value.
+         * @param option The option
+         * @param value The value
+         * @return This Options instance
+         */
+        public Options put( String option, Integer value )
+        {
+            if( value == null )
+            {
+                return remove( option );
+            }
+            options.put( option, value.toString() );
+            return this;
+        }
+
+        /**
+         * Remove an option value.
+         * @param option The option
+         * @return This Options instance
+         */
+        public Options remove( String option )
+        {
+            options.remove( option );
+            return this;
+        }
+
+        /**
+         * Get all defined options as a Map.
+         * @return All defined options in a new Map
+         */
+        public Map<String, String> toMap()
+        {
+            return new HashMap<>( options );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/value/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/value/package.html b/core/api/src/main/java/org/qi4j/api/value/package.html
new file mode 100644
index 0000000..540b3f6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/value/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Value API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java b/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
deleted file mode 100644
index 2f4301a..0000000
--- a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
+++ /dev/null
@@ -1,115 +0,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.
- */
-package org.apache.zest.api;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.test.EntityTestAssembler;
-
-/**
- * TODO
- */
-public class OperatorsTest
-{
-    @Test
-    public void testOperators()
-        throws UnitOfWorkCompletionException, ActivationException, AssemblyException
-    {
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                new EntityTestAssembler().assemble( module );
-
-                module.entities( TestEntity.class );
-                module.values( TestValue.class );
-                module.forMixin( TestEntity.class ).declareDefaults().foo().set( "Bar" );
-                module.forMixin( TestValue.class ).declareDefaults().bar().set( "Xyz" );
-            }
-        };
-
-        UnitOfWork uow = assembler.module().newUnitOfWork();
-
-        try
-        {
-            EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, "123" );
-            entityBuilder.instance().value().set( assembler.module().newValue( TestValue.class ) );
-            TestEntity testEntity = entityBuilder.newInstance();
-
-            uow.complete();
-            uow = assembler.module().newUnitOfWork();
-
-            Iterable<TestEntity> entities = Iterables.iterable( testEntity = uow.get( testEntity ) );
-
-            QueryBuilder<TestEntity> builder = assembler.module().newQueryBuilder( TestEntity.class );
-
-            {
-                Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
-                                                                          .foo(), "Bar" );
-                Assert.assertTrue( where.satisfiedBy( testEntity ) );
-                System.out.println( where );
-            }
-            {
-                Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
-                                                                          .value()
-                                                                          .get()
-                                                                          .bar(), "Xyz" );
-                Assert.assertTrue( where.satisfiedBy( testEntity ) );
-                System.out.println( where );
-
-                Assert.assertTrue( builder.where( where ).newQuery( entities ).find().equals( testEntity ) );
-            }
-        }
-        finally
-        {
-            uow.discard();
-        }
-    }
-
-    public interface TestEntity
-        extends EntityComposite
-    {
-        Property<String> foo();
-
-        Property<TestValue> value();
-    }
-
-    public interface TestValue
-        extends ValueComposite
-    {
-        Property<String> bar();
-    }
-}


[15/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java
deleted file mode 100644
index c199bee..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/LayerAssemblyImpl.java
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyVisitor;
-import org.apache.zest.bootstrap.EntityAssembly;
-import org.apache.zest.bootstrap.EntityDeclaration;
-import org.apache.zest.bootstrap.ImportedServiceAssembly;
-import org.apache.zest.bootstrap.ImportedServiceDeclaration;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ObjectAssembly;
-import org.apache.zest.bootstrap.ObjectDeclaration;
-import org.apache.zest.bootstrap.ServiceAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-import org.apache.zest.bootstrap.TransientAssembly;
-import org.apache.zest.bootstrap.TransientDeclaration;
-import org.apache.zest.bootstrap.ValueAssembly;
-import org.apache.zest.bootstrap.ValueDeclaration;
-import org.apache.zest.functional.Specification;
-
-/**
- * Assembly of a Layer. From here you can create more ModuleAssemblies for
- * the Layer that is being assembled. It is also here that you define
- * what other Layers this Layer is using by calling {@link org.apache.zest.runtime.bootstrap.LayerAssemblyImpl#uses()}.
- */
-public final class LayerAssemblyImpl
-    implements LayerAssembly
-{
-    private final ApplicationAssembly applicationAssembly;
-    private final HashMap<String, ModuleAssemblyImpl> moduleAssemblies;
-    private final Set<LayerAssembly> uses;
-
-    private String name;
-    private final MetaInfo metaInfo = new MetaInfo();
-    private final List<Class<? extends Activator<Layer>>> activators = new ArrayList<>();
-
-    public LayerAssemblyImpl( ApplicationAssembly applicationAssembly, String name )
-    {
-        this.applicationAssembly = applicationAssembly;
-        this.name = name;
-
-        moduleAssemblies = new LinkedHashMap<>();
-        uses = new LinkedHashSet<>();
-    }
-
-    @Override
-    public ModuleAssembly module( String name )
-    {
-        if( name != null )
-        {
-            ModuleAssemblyImpl existing = moduleAssemblies.get( name );
-            if( existing != null )
-            {
-                return existing;
-            }
-        }
-        ModuleAssemblyImpl moduleAssembly = new ModuleAssemblyImpl( this, name );
-        moduleAssemblies.put( name, moduleAssembly );
-        return moduleAssembly;
-    }
-
-    @Override
-    public ApplicationAssembly application()
-    {
-        return applicationAssembly;
-    }
-
-    @Override
-    public LayerAssembly setName( String name )
-    {
-        this.name = name;
-        return this;
-    }
-
-    @Override
-    public LayerAssembly setMetaInfo( Object info )
-    {
-        metaInfo.set( info );
-        return this;
-    }
-
-    @Override
-    public LayerAssembly uses( LayerAssembly... layerAssembly )
-        throws IllegalArgumentException
-    {
-        uses.addAll( Arrays.asList( layerAssembly ) );
-        return this;
-    }
-
-    @Override
-    @SafeVarargs
-    public final LayerAssembly withActivators( Class<? extends Activator<Layer>>... activators )
-    {
-        this.activators.addAll( Arrays.asList( activators ) );
-        return this;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType
-    {
-        visitor.visitLayer( this );
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            moduleAssembly.visit( visitor );
-        }
-    }
-
-    @Override
-    public EntityDeclaration entities( Specification<? super EntityAssembly> specification )
-    {
-        final List<EntityDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.entities( specification ) );
-        }
-
-        return new EntityDeclaration()
-        {
-            @Override
-            public EntityDeclaration setMetaInfo( Object info )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( info );
-                }
-                return this;
-            }
-
-            @Override
-            public EntityDeclaration visibleIn( Visibility visibility )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-
-            @Override
-            public EntityDeclaration withConcerns( Class<?>... concerns )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.withConcerns( concerns );
-                }
-                return this;
-            }
-
-            @Override
-            public EntityDeclaration withSideEffects( Class<?>... sideEffects )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.withSideEffects( sideEffects );
-                }
-                return this;
-            }
-
-            @Override
-            public EntityDeclaration withMixins( Class<?>... mixins )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.withMixins( mixins );
-                }
-                return this;
-            }
-
-            @Override
-            public EntityDeclaration withTypes( Class<?>... types )
-            {
-                for( EntityDeclaration declaration : declarations )
-                {
-                    declaration.withTypes( types );
-                }
-                return this;
-            }
-        };
-    }
-
-    @Override
-    public ServiceDeclaration services( Specification<? super ServiceAssembly> specification )
-    {
-        final List<ServiceDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.services( specification ) );
-        }
-
-        return new ServiceDeclaration()
-        {
-            @Override
-            public ServiceDeclaration setMetaInfo( Object serviceAttribute )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( serviceAttribute );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration visibleIn( Visibility visibility )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration withConcerns( Class<?>... concerns )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.withConcerns( concerns );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration withSideEffects( Class<?>... sideEffects )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.withSideEffects( sideEffects );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration withMixins( Class<?>... mixins )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.withMixins( mixins );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration withTypes( Class<?>... types )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.withTypes( types );
-                }
-                return this;
-            }
-
-            @Override
-            @SafeVarargs
-            public final ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.withActivators( activators );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration identifiedBy( String identity )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.identifiedBy( identity );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration taggedWith( String... tags )
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.taggedWith( tags );
-                }
-                return this;
-            }
-
-            @Override
-            public ServiceDeclaration instantiateOnStartup()
-            {
-                for( ServiceDeclaration declaration : declarations )
-                {
-                    declaration.instantiateOnStartup();
-                }
-
-                return this;
-            }
-        };
-    }
-
-    @Override
-    public TransientDeclaration transients( Specification<? super TransientAssembly> specification )
-    {
-        final List<TransientDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.transients( specification ) );
-        }
-
-        return new TransientDeclaration()
-        {
-            @Override
-            public TransientDeclaration setMetaInfo( Object info )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( info );
-                }
-                return this;
-            }
-
-            @Override
-            public TransientDeclaration visibleIn( Visibility visibility )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-
-            @Override
-            public TransientDeclaration withConcerns( Class<?>... concerns )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.withConcerns( concerns );
-                }
-                return this;
-            }
-
-            @Override
-            public TransientDeclaration withSideEffects( Class<?>... sideEffects )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.withSideEffects( sideEffects );
-                }
-                return this;
-            }
-
-            @Override
-            public TransientDeclaration withMixins( Class<?>... mixins )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.withMixins( mixins );
-                }
-                return this;
-            }
-
-            @Override
-            public TransientDeclaration withTypes( Class<?>... types )
-            {
-                for( TransientDeclaration declaration : declarations )
-                {
-                    declaration.withTypes( types );
-                }
-                return this;
-            }
-        };
-    }
-
-    @Override
-    public ValueDeclaration values( Specification<? super ValueAssembly> specification )
-    {
-        final List<ValueDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.values( specification ) );
-        }
-        return new ValueDeclaration()
-        {
-            @Override
-            public ValueDeclaration setMetaInfo( Object info )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( info );
-                }
-                return this;
-            }
-
-            @Override
-            public ValueDeclaration visibleIn( Visibility visibility )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-
-            @Override
-            public ValueDeclaration withConcerns( Class<?>... concerns )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.withConcerns( concerns );
-                }
-                return this;
-            }
-
-            @Override
-            public ValueDeclaration withSideEffects( Class<?>... sideEffects )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.withSideEffects( sideEffects );
-                }
-                return this;
-            }
-
-            @Override
-            public ValueDeclaration withMixins( Class<?>... mixins )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.withMixins( mixins );
-                }
-                return this;
-            }
-
-            @Override
-            public ValueDeclaration withTypes( Class<?>... types )
-            {
-                for( ValueDeclaration declaration : declarations )
-                {
-                    declaration.withTypes( types );
-                }
-                return this;
-            }
-        };
-    }
-
-    @Override
-    public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification )
-    {
-        final List<ObjectDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.objects( specification ) );
-        }
-        return new ObjectDeclaration()
-        {
-            @Override
-            public ObjectDeclaration setMetaInfo( Object info )
-            {
-                for( ObjectDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( info );
-                }
-                return this;
-            }
-
-            @Override
-            public ObjectDeclaration visibleIn( Visibility visibility )
-                throws IllegalStateException
-            {
-                for( ObjectDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-        };
-    }
-
-    @Override
-    public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification )
-    {
-        final List<ImportedServiceDeclaration> declarations = new ArrayList<>();
-
-        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
-        {
-            declarations.add( moduleAssembly.importedServices( specification ) );
-        }
-        return new ImportedServiceDeclaration()
-        {
-
-            @Override
-            public ImportedServiceDeclaration importOnStartup()
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.importOnStartup();
-                }
-                return this;
-            }
-
-            @Override
-            public ImportedServiceDeclaration visibleIn( Visibility visibility )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.visibleIn( visibility );
-                }
-                return this;
-            }
-
-            @Override
-            public ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.importedBy( serviceImporterClass );
-                }
-                return this;
-            }
-
-            @Override
-            public ImportedServiceDeclaration identifiedBy( String identity )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.identifiedBy( identity );
-                }
-                return this;
-            }
-
-            @Override
-            public ImportedServiceDeclaration taggedWith( String... tags )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.taggedWith( tags );
-                }
-                return this;
-            }
-
-            @Override
-            public ImportedServiceDeclaration setMetaInfo( Object serviceAttribute )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.setMetaInfo( serviceAttribute );
-                }
-                return this;
-            }
-
-            @Override
-            @SafeVarargs
-            public final ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
-            {
-                for( ImportedServiceDeclaration declaration : declarations )
-                {
-                    declaration.withActivators( activators );
-                }
-                return this;
-            }
-
-        };
-    }
-
-    Collection<ModuleAssemblyImpl> moduleAssemblies()
-    {
-        return moduleAssemblies.values();
-    }
-
-    Set<LayerAssembly> uses()
-    {
-        return uses;
-    }
-
-    public MetaInfo metaInfo()
-    {
-        return metaInfo;
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public List<Class<? extends Activator<Layer>>> activators()
-    {
-        return activators;
-    }
-
-    @Override
-    public final String toString()
-    {
-        return "LayerAssembly [" + name + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
deleted file mode 100644
index 673dfe7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.TransientComposite;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.service.DuplicateServiceIdentityException;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.api.type.MatchTypeSpecification;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.AssemblySpecifications;
-import org.apache.zest.bootstrap.AssemblyVisitor;
-import org.apache.zest.bootstrap.ConfigurationDeclaration;
-import org.apache.zest.bootstrap.EntityAssembly;
-import org.apache.zest.bootstrap.EntityDeclaration;
-import org.apache.zest.bootstrap.ImportedServiceAssembly;
-import org.apache.zest.bootstrap.ImportedServiceDeclaration;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.MetaInfoDeclaration;
-import org.apache.zest.bootstrap.MixinDeclaration;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ObjectAssembly;
-import org.apache.zest.bootstrap.ObjectDeclaration;
-import org.apache.zest.bootstrap.ServiceAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-import org.apache.zest.bootstrap.TransientAssembly;
-import org.apache.zest.bootstrap.TransientDeclaration;
-import org.apache.zest.bootstrap.ValueAssembly;
-import org.apache.zest.bootstrap.ValueDeclaration;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.composite.TransientModel;
-import org.apache.zest.runtime.composite.TransientsModel;
-import org.apache.zest.runtime.entity.EntitiesModel;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.object.ObjectModel;
-import org.apache.zest.runtime.object.ObjectsModel;
-import org.apache.zest.runtime.service.ImportedServiceModel;
-import org.apache.zest.runtime.service.ImportedServicesModel;
-import org.apache.zest.runtime.service.ServiceModel;
-import org.apache.zest.runtime.service.ServicesModel;
-import org.apache.zest.runtime.structure.ModuleModel;
-import org.apache.zest.runtime.value.ValueModel;
-import org.apache.zest.runtime.value.ValuesModel;
-
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * Assembly of a Module. This is where you register all objects, Composites,
- * Services. Each "add" method returns a declaration that you can use to add
- * additional information and metadata. If you call an "add" method with many
- * parameters then the declared metadata will apply to all types in the method
- * call.
- */
-public final class ModuleAssemblyImpl
-    implements ModuleAssembly
-{
-    private final LayerAssembly layerAssembly;
-    private String name;
-    private final MetaInfo metaInfo = new MetaInfo();
-    private final List<Class<? extends Activator<Module>>> activators = new ArrayList<>();
-
-    private final List<ServiceAssemblyImpl> serviceAssemblies = new ArrayList<>();
-    private final Map<Class<?>, ImportedServiceAssemblyImpl> importedServiceAssemblies = new LinkedHashMap<>();
-    private final Map<Class<? extends EntityComposite>, EntityAssemblyImpl> entityAssemblies = new LinkedHashMap<>();
-    private final Map<Class<? extends ValueComposite>, ValueAssemblyImpl> valueAssemblies = new LinkedHashMap<>();
-    private final Map<Class<? extends TransientComposite>, TransientAssemblyImpl> transientAssemblies = new LinkedHashMap<>();
-    private final Map<Class<?>, ObjectAssemblyImpl> objectAssemblies = new LinkedHashMap<>();
-
-    private final MetaInfoDeclaration metaInfoDeclaration = new MetaInfoDeclaration();
-
-    public ModuleAssemblyImpl( LayerAssembly layerAssembly, String name )
-    {
-        this.layerAssembly = layerAssembly;
-        this.name = name;
-    }
-
-    @Override
-    public LayerAssembly layer()
-    {
-        return layerAssembly;
-    }
-
-    @Override
-    public ModuleAssembly module( String layerName, String moduleName )
-    {
-        return layerAssembly.application().module( layerName, moduleName );
-    }
-
-    @Override
-    public ModuleAssembly setName( String name )
-    {
-        this.name = name;
-        return this;
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public ModuleAssembly setMetaInfo( Object info )
-    {
-        metaInfo.set( info );
-        return this;
-    }
-
-    @Override
-    @SafeVarargs
-    public final ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators )
-    {
-        this.activators.addAll( Arrays.asList( activators ) );
-        return this;
-    }
-
-    @Override
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public ValueDeclaration values( Class<?>... valueTypes )
-    {
-        List<ValueAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class valueType : valueTypes )
-        {
-            if( valueAssemblies.containsKey( valueType ) )
-            {
-                assemblies.add( valueAssemblies.get( valueType ) );
-            }
-            else
-            {
-                ValueAssemblyImpl valueAssembly = new ValueAssemblyImpl( valueType );
-                valueAssemblies.put( valueType, valueAssembly );
-                assemblies.add( valueAssembly );
-            }
-        }
-
-        return new ValueDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ValueDeclaration values( Specification<? super ValueAssembly> specification )
-    {
-        List<ValueAssemblyImpl> assemblies = new ArrayList<>();
-        for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() )
-        {
-            if( specification.satisfiedBy( transientAssembly ) )
-            {
-                assemblies.add( transientAssembly );
-            }
-        }
-
-        return new ValueDeclarationImpl( assemblies );
-    }
-
-    @Override
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public TransientDeclaration transients( Class<?>... transientTypes )
-    {
-        List<TransientAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class valueType : transientTypes )
-        {
-            if( transientAssemblies.containsKey( valueType ) )
-            {
-                assemblies.add( transientAssemblies.get( valueType ) );
-            }
-            else
-            {
-                TransientAssemblyImpl transientAssembly = new TransientAssemblyImpl( valueType );
-                transientAssemblies.put( valueType, transientAssembly );
-                assemblies.add( transientAssembly );
-            }
-        }
-
-        return new TransientDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public TransientDeclaration transients( Specification<? super TransientAssembly> specification )
-    {
-        List<TransientAssemblyImpl> assemblies = new ArrayList<>();
-        for( TransientAssemblyImpl transientAssembly : transientAssemblies.values() )
-        {
-            if( specification.satisfiedBy( transientAssembly ) )
-            {
-                assemblies.add( transientAssembly );
-            }
-        }
-
-        return new TransientDeclarationImpl( assemblies );
-    }
-
-    @Override
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public EntityDeclaration entities( Class<?>... entityTypes )
-    {
-        List<EntityAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class entityType : entityTypes )
-        {
-            if( entityAssemblies.containsKey( entityType ) )
-            {
-                assemblies.add( entityAssemblies.get( entityType ) );
-            }
-            else
-            {
-                EntityAssemblyImpl entityAssembly = new EntityAssemblyImpl( entityType );
-                entityAssemblies.put( entityType, entityAssembly );
-                assemblies.add( entityAssembly );
-            }
-        }
-
-        return new EntityDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public EntityDeclaration entities( Specification<? super EntityAssembly> specification )
-    {
-        List<EntityAssemblyImpl> assemblies = new ArrayList<>();
-        for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() )
-        {
-            if( specification.satisfiedBy( entityAssembly ) )
-            {
-                assemblies.add( entityAssembly );
-            }
-        }
-
-        return new EntityDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ConfigurationDeclaration configurations( Class<?>... configurationTypes )
-    {
-        List<EntityAssemblyImpl> entityAssemblyList = new ArrayList<>();
-
-        for( Class entityType : configurationTypes )
-        {
-            if( this.entityAssemblies.containsKey( entityType ) )
-            {
-                entityAssemblyList.add( this.entityAssemblies.get( entityType ) );
-            }
-            else
-            {
-                EntityAssemblyImpl entityAssembly = new EntityAssemblyImpl( entityType );
-                this.entityAssemblies.put( entityType, entityAssembly );
-                entityAssemblyList.add( entityAssembly );
-            }
-        }
-
-        List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>();
-
-        for( Class valueType : configurationTypes )
-        {
-            if( valueAssemblies.containsKey( valueType ) )
-            {
-                valueAssemblyList.add( valueAssemblies.get( valueType ) );
-            }
-            else
-            {
-                ValueAssemblyImpl valueAssembly = new ValueAssemblyImpl( valueType );
-                valueAssemblies.put( valueType, valueAssembly );
-                valueAssemblyList.add( valueAssembly );
-                valueAssembly.types.add( Identity.class );
-            }
-        }
-
-        return new ConfigurationDeclarationImpl( entityAssemblyList, valueAssemblyList  );
-    }
-
-    @Override
-    public ConfigurationDeclaration configurations( Specification<HasTypes> specification )
-    {
-        Specification<HasTypes> isConfigurationComposite = new MatchTypeSpecification( Identity.class );
-        specification = Specifications.and( specification, isConfigurationComposite );
-        List<EntityAssemblyImpl> entityAssmblyList = new ArrayList<>();
-        for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() )
-        {
-            if( specification.satisfiedBy( entityAssembly ) )
-            {
-                entityAssmblyList.add( entityAssembly );
-            }
-        }
-        List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>();
-        for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() )
-        {
-            if( specification.satisfiedBy( transientAssembly ) )
-            {
-                valueAssemblyList.add( transientAssembly );
-            }
-        }
-        return new ConfigurationDeclarationImpl( entityAssmblyList, valueAssemblyList );
-    }
-
-    @Override
-    public ObjectDeclaration objects( Class<?>... objectTypes )
-        throws AssemblyException
-    {
-        List<ObjectAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class<?> objectType : objectTypes )
-        {
-            if( objectType.isInterface() )
-            {
-                throw new AssemblyException( "Interfaces can not be Zest Objects." );
-            }
-            if( objectAssemblies.containsKey( objectType ) )
-            {
-                assemblies.add( objectAssemblies.get( objectType ) );
-            }
-            else
-            {
-                ObjectAssemblyImpl objectAssembly = new ObjectAssemblyImpl( objectType );
-                objectAssemblies.put( objectType, objectAssembly );
-                assemblies.add( objectAssembly );
-            }
-        }
-
-        return new ObjectDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification )
-    {
-        List<ObjectAssemblyImpl> assemblies = new ArrayList<>();
-        for( ObjectAssemblyImpl objectAssembly : objectAssemblies.values() )
-        {
-            if( specification.satisfiedBy( objectAssembly ) )
-            {
-                assemblies.add( objectAssembly );
-            }
-        }
-
-        return new ObjectDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ServiceDeclaration addServices( Class<?>... serviceTypes )
-    {
-        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class<?> serviceType : serviceTypes )
-        {
-            ServiceAssemblyImpl serviceAssembly = new ServiceAssemblyImpl( serviceType );
-            serviceAssemblies.add( serviceAssembly );
-            assemblies.add( serviceAssembly );
-        }
-
-        return new ServiceDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ServiceDeclaration services( Class<?>... serviceTypes )
-    {
-        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class<?> serviceType : serviceTypes )
-        {
-            if( Iterables.matchesAny( AssemblySpecifications.types( serviceType ), serviceAssemblies ) )
-            {
-                Iterables.addAll( assemblies, Iterables.filter( AssemblySpecifications.types( serviceType ), serviceAssemblies ) );
-            }
-            else
-            {
-                ServiceAssemblyImpl serviceAssembly = new ServiceAssemblyImpl( serviceType );
-                serviceAssemblies.add( serviceAssembly );
-                assemblies.add( serviceAssembly );
-            }
-        }
-
-        return new ServiceDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ServiceDeclaration services( Specification<? super ServiceAssembly> specification )
-    {
-        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            if( specification.satisfiedBy( serviceAssembly ) )
-            {
-                assemblies.add( serviceAssembly );
-            }
-        }
-
-        return new ServiceDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ImportedServiceDeclaration importedServices( Class<?>... serviceTypes )
-    {
-        List<ImportedServiceAssemblyImpl> assemblies = new ArrayList<>();
-
-        for( Class<?> serviceType : serviceTypes )
-        {
-            if( importedServiceAssemblies.containsKey( serviceType ) )
-            {
-                assemblies.add( importedServiceAssemblies.get( serviceType ) );
-            }
-            else
-            {
-                ImportedServiceAssemblyImpl serviceAssembly = new ImportedServiceAssemblyImpl( serviceType, this );
-                importedServiceAssemblies.put( serviceType, serviceAssembly );
-                assemblies.add( serviceAssembly );
-            }
-        }
-
-        return new ImportedServiceDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification )
-    {
-        List<ImportedServiceAssemblyImpl> assemblies = new ArrayList<>();
-        for( ImportedServiceAssemblyImpl objectAssembly : importedServiceAssemblies.values() )
-        {
-            if( specification.satisfiedBy( objectAssembly ) )
-            {
-                assemblies.add( objectAssembly );
-            }
-        }
-
-        return new ImportedServiceDeclarationImpl( assemblies );
-    }
-
-    @Override
-    public <T> MixinDeclaration<T> forMixin( Class<T> mixinType )
-    {
-        return metaInfoDeclaration.on( mixinType );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType
-    {
-        visitor.visitModule( this );
-
-        for( TransientAssemblyImpl compositeDeclaration : transientAssemblies.values() )
-        {
-            visitor.visitComposite( new TransientDeclarationImpl( iterable( compositeDeclaration ) ) );
-        }
-
-        for( EntityAssemblyImpl entityDeclaration : entityAssemblies.values() )
-        {
-            visitor.visitEntity( new EntityDeclarationImpl( iterable( entityDeclaration ) ) );
-        }
-
-        for( ObjectAssemblyImpl objectDeclaration : objectAssemblies.values() )
-        {
-            visitor.visitObject( new ObjectDeclarationImpl( iterable( objectDeclaration ) ) );
-        }
-
-        for( ServiceAssemblyImpl serviceDeclaration : serviceAssemblies )
-        {
-            visitor.visitService( new ServiceDeclarationImpl( iterable( serviceDeclaration ) ) );
-        }
-
-        for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
-        {
-            visitor.visitImportedService( new ImportedServiceDeclarationImpl( iterable( importedServiceDeclaration ) ) );
-        }
-
-        for( ValueAssemblyImpl valueDeclaration : valueAssemblies.values() )
-        {
-            visitor.visitValue( new ValueDeclarationImpl( iterable( valueDeclaration ) ) );
-        }
-    }
-
-    ModuleModel assembleModule( AssemblyHelper helper )
-        throws AssemblyException
-    {
-        List<TransientModel> transientModels = new ArrayList<>();
-        List<ObjectModel> objectModels = new ArrayList<>();
-        List<ValueModel> valueModels = new ArrayList<>();
-        List<ServiceModel> serviceModels = new ArrayList<>();
-        List<ImportedServiceModel> importedServiceModels = new ArrayList<>();
-
-        if( name == null )
-        {
-            throw new AssemblyException( "Module must have name set" );
-        }
-
-        for( TransientAssemblyImpl compositeDeclaration : transientAssemblies.values() )
-        {
-            transientModels.add( compositeDeclaration.newTransientModel( metaInfoDeclaration, helper ) );
-        }
-
-        for( ValueAssemblyImpl valueDeclaration : valueAssemblies.values() )
-        {
-            valueModels.add( valueDeclaration.newValueModel( metaInfoDeclaration, helper ) );
-        }
-
-        List<EntityModel> entityModels = new ArrayList<>();
-        for( EntityAssemblyImpl entityDeclaration : entityAssemblies.values() )
-        {
-            entityModels.add( entityDeclaration.newEntityModel( metaInfoDeclaration, 
-                                                                metaInfoDeclaration, 
-                                                                metaInfoDeclaration, 
-                                                                metaInfoDeclaration, 
-                                                                helper ) );
-        }
-
-        for( ObjectAssemblyImpl objectDeclaration : objectAssemblies.values() )
-        {
-            objectDeclaration.addObjectModel( objectModels );
-        }
-
-        for( ServiceAssemblyImpl serviceDeclaration : serviceAssemblies )
-        {
-            if( serviceDeclaration.identity == null )
-            {
-                serviceDeclaration.identity = generateId( serviceDeclaration.types() );
-            }
-
-            serviceModels.add( serviceDeclaration.newServiceModel( metaInfoDeclaration, helper ) );
-        }
-
-        for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
-        {
-            importedServiceDeclaration.addImportedServiceModel( importedServiceModels );
-        }
-
-        ModuleModel moduleModel = new ModuleModel( name,
-                                                   metaInfo,
-                                                   new ActivatorsModel<>( activators ),
-                                                   new TransientsModel( transientModels ),
-                                                   new EntitiesModel( entityModels ),
-                                                   new ObjectsModel( objectModels ),
-                                                   new ValuesModel( valueModels ),
-                                                   new ServicesModel( serviceModels ),
-                                                   new ImportedServicesModel( importedServiceModels ) );
-
-        // Check for duplicate service identities
-        Set<String> identities = new HashSet<>();
-        for( ServiceModel serviceModel : serviceModels )
-        {
-            String identity = serviceModel.identity();
-            if( identities.contains( identity ) )
-            {
-                throw new DuplicateServiceIdentityException(
-                    "Duplicated service identity: " + identity + " in module " + moduleModel.name()
-                );
-            }
-            identities.add( identity );
-        }
-        for( ImportedServiceModel serviceModel : importedServiceModels )
-        {
-            String identity = serviceModel.identity();
-            if( identities.contains( identity ) )
-            {
-                throw new DuplicateServiceIdentityException(
-                    "Duplicated service identity: " + identity + " in module " + moduleModel.name()
-                );
-            }
-            identities.add( identity );
-        }
-
-        for( ImportedServiceModel importedServiceModel : importedServiceModels )
-        {
-            boolean found = false;
-            for( ObjectModel objectModel : objectModels )
-            {
-                if( first( objectModel.types() ).equals( importedServiceModel.serviceImporter() ) )
-                {
-                    found = true;
-                    break;
-                }
-            }
-            if( !found )
-            {
-                @SuppressWarnings( "raw" )
-                Class<? extends ServiceImporter> serviceFactoryType = importedServiceModel.serviceImporter();
-                ObjectModel objectModel = new ObjectModel( serviceFactoryType, Visibility.module, new MetaInfo() );
-                objectModels.add( objectModel );
-            }
-        }
-
-        return moduleModel;
-    }
-
-    private String generateId( Iterable<Class<?>> serviceTypes )
-    {
-        // Find service identity that is not yet used
-        Class<?> serviceType = serviceTypes.iterator()
-            .next(); // Use the first Iterable, which *SHOULD* be the main serviceType
-        int idx = 0;
-        String id = serviceType.getSimpleName();
-        boolean invalid;
-        do
-        {
-            invalid = false;
-            for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-            {
-                if( serviceAssembly.identity() != null && serviceAssembly.identity().equals( id ) )
-                {
-                    idx++;
-                    id = serviceType.getSimpleName() + "_" + idx;
-                    invalid = true;
-                    break;
-                }
-            }
-        }
-        while( invalid );
-        return id;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
deleted file mode 100644
index f4fdd9c..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Modifier;
-import java.util.List;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.bootstrap.ObjectAssembly;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.object.ObjectModel;
-
-/**
- * Assembly of an Object.
- */
-public final class ObjectAssemblyImpl
-    implements ObjectAssembly
-{
-    private Class<?> objectType;
-    MetaInfo metaInfo = new MetaInfo();
-    Visibility visibility = Visibility.module;
-
-    public ObjectAssemblyImpl( Class<?> clazz )
-    {
-        // best try to find out if the class is a concrete class
-        if( clazz.isEnum() ||
-            ( !Composite.class.isAssignableFrom( clazz ) && Modifier.isAbstract( clazz.getModifiers() ) ) )
-        {
-            throw new IllegalArgumentException( "Declared objects must be concrete classes: " + clazz );
-        }
-        this.objectType = clazz;
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return Iterables.<Class<?>>iterable( objectType );
-    }
-
-    void addObjectModel( List<ObjectModel> objectModels )
-    {
-        try
-        {
-            ObjectModel objectModel = new ObjectModel( objectType, visibility, metaInfo );
-            objectModels.add( objectModel );
-        }
-        catch( Throwable e )
-        {
-            throw new InvalidApplicationException( "Could not register " + objectType.getName(), e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectDeclarationImpl.java
deleted file mode 100644
index 8a1af93..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectDeclarationImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.ObjectDeclaration;
-
-/**
- * Declaration of an Object. Created by {@link org.apache.zest.runtime.bootstrap.ModuleAssemblyImpl#objects(Class[])}.
- */
-public final class ObjectDeclarationImpl
-    implements ObjectDeclaration
-{
-    private final Iterable<ObjectAssemblyImpl> assemblies;
-
-    public ObjectDeclarationImpl( Iterable<ObjectAssemblyImpl> assemblies )
-    {
-        this.assemblies = assemblies;
-    }
-
-    @Override
-    public ObjectDeclaration setMetaInfo( Object info )
-    {
-        for( ObjectAssemblyImpl assembly : assemblies )
-        {
-            assembly.metaInfo.set( info );
-        }
-        return this;
-    }
-
-    @Override
-    public ObjectDeclaration visibleIn( Visibility visibility )
-        throws IllegalStateException
-    {
-        for( ObjectAssemblyImpl assembly : assemblies )
-        {
-            assembly.visibility = visibility;
-        }
-        return this;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/OrAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/OrAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/OrAppliesToFilter.java
deleted file mode 100644
index 90136b1..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/OrAppliesToFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class OrAppliesToFilter
-    implements AppliesToFilter
-{
-    private final AppliesToFilter left;
-    private final AppliesToFilter right;
-
-    OrAppliesToFilter( AppliesToFilter left, AppliesToFilter right )
-    {
-        this.left = left;
-        this.right = right;
-    }
-
-    @Override
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        return left.appliesTo( method, mixin, compositeType, fragmentClass ) ||
-               right.appliesTo( method, mixin, compositeType, fragmentClass );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
deleted file mode 100644
index 530aeb7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.activation.Activators;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.ServiceAssembly;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.service.ServiceModel;
-
-/**
- * Assembly of a Service.
- */
-public final class ServiceAssemblyImpl extends CompositeAssemblyImpl
-    implements ServiceAssembly
-{
-    String identity;
-    boolean instantiateOnStartup = false;
-    List<Class<? extends Activator<?>>> activators = new ArrayList<>();
-
-    public ServiceAssemblyImpl( Class<?> serviceType )
-    {
-        super( serviceType );
-        // The composite must always implement ServiceComposite, as a marker interface
-        if( !ServiceComposite.class.isAssignableFrom( serviceType ) )
-        {
-            types.add( ServiceComposite.class );
-        }
-    }
-
-    @Override
-    public String identity()
-    {
-        return identity;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    ServiceModel newServiceModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
-    {
-        try
-        {
-            buildComposite( helper, stateDeclarations );
-            List<Class<? extends Activator<?>>> activatorClasses = Iterables.toList(
-                    Iterables.<Class<? extends Activator<?>>>flatten( activators, activatorsDeclarations( types ) ) );
-            return new ServiceModel( types, visibility, metaInfo,
-                                     new ActivatorsModel( activatorClasses ),
-                                     mixinsModel, stateModel, compositeMethodsModel,
-                                     identity, instantiateOnStartup );
-        }
-        catch( Exception e )
-        {
-            throw new InvalidApplicationException( "Could not register " + types, e );
-        }
-    }
-    
-    private Iterable<Class<? extends Activator<?>>> activatorsDeclarations( Iterable<? extends Class<?>> typess )
-    {
-        // Find activator declarations
-        ArrayList<Type> allTypes = new ArrayList<>();
-        for( Class<?> type : typess )
-        {
-            Iterable<Type> types = Classes.typesOf( type );
-            Iterables.addAll( allTypes, types );
-        }
-        // Find all activators and flattern them into an iterable
-        Function<Type, Iterable<Class<? extends Activator<?>>>> function = new Function<Type, Iterable<Class<? extends Activator<?>>>>()
-        {
-            @Override
-            public Iterable<Class<? extends Activator<?>>> map( Type type )
-            {
-                Activators activators = Annotations.annotationOn( type, Activators.class );
-                if( activators == null )
-                {
-                    return Iterables.empty();
-                }
-                else
-                {
-                    return Iterables.iterable( activators.value() );
-                }
-            }
-        };
-        Iterable<Class<? extends Activator<?>>> flatten = Iterables.flattenIterables( Iterables.map( function, allTypes ) );
-        return Iterables.toList( flatten );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceDeclarationImpl.java
deleted file mode 100644
index 78c5ddb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceDeclarationImpl.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.qualifier.ServiceTags;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a Service. Created by {@link org.apache.zest.runtime.bootstrap.ModuleAssemblyImpl#services(Class[])}.
- */
-public final class ServiceDeclarationImpl
-    implements ServiceDeclaration
-{
-    private final Iterable<ServiceAssemblyImpl> serviceAssemblies;
-
-    public ServiceDeclarationImpl( Iterable<ServiceAssemblyImpl> serviceAssemblies )
-    {
-        this.serviceAssemblies = serviceAssemblies;
-    }
-
-    @Override
-    public ServiceDeclaration visibleIn( Visibility visibility )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration identifiedBy( String identity )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.identity = identity;
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration taggedWith( String... tags )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            ServiceTags previousTags = serviceAssembly.metaInfo.get( ServiceTags.class );
-            if( previousTags != null )
-            {
-                List<String> tagList = new ArrayList<>();
-                tagList.addAll( asList( previousTags.tags() ) );
-                tagList.addAll( asList( tags ) );
-                serviceAssembly.metaInfo.set( new ServiceTags( tagList.toArray( new String[ tagList.size() ] ) ) );
-            }
-            else
-            {
-                serviceAssembly.metaInfo.set( new ServiceTags( tags ) );
-            }
-        }
-
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration instantiateOnStartup()
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.instantiateOnStartup = true;
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration setMetaInfo( Object serviceAttribute )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.metaInfo.set( serviceAttribute );
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration withConcerns( Class<?>... concerns )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.concerns.addAll( asList( concerns ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration withSideEffects( Class<?>... sideEffects )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.sideEffects.addAll( asList( sideEffects ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration withMixins( Class<?>... mixins )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.mixins.addAll( asList( mixins ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ServiceDeclaration withTypes( Class<?>... types )
-    {
-        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
-        {
-            serviceAssembly.types.addAll( asList( types ) );
-        }
-        return this;
-    }
-
-    @Override
-    @SafeVarargs
-    public final ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
-    {
-        for ( ServiceAssemblyImpl serviceAssembly : serviceAssemblies ) {
-            serviceAssembly.activators.addAll( asList( activators ) );
-        }
-        return this;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
deleted file mode 100644
index 8f3dcdc..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.composite.TransientComposite;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.bootstrap.TransientAssembly;
-import org.apache.zest.runtime.composite.TransientModel;
-
-/**
- * Declaration of a TransientComposite.
- */
-public final class TransientAssemblyImpl extends CompositeAssemblyImpl
-    implements TransientAssembly
-{
-    public TransientAssemblyImpl( Class<?> transientType )
-    {
-        super( transientType );
-
-        // The composite must always implement TransientComposite, as a marker interface
-        if( !TransientComposite.class.isAssignableFrom( transientType ) )
-        {
-            types.add( TransientComposite.class );
-        }
-
-        // If type is a class, register it as a mixin
-        if( !transientType.isInterface() )
-        {
-            mixins.add( transientType );
-        }
-    }
-
-    TransientModel newTransientModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
-    {
-        try
-        {
-            buildComposite( helper, stateDeclarations );
-            TransientModel transientModel = new TransientModel(
-                types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-
-            return transientModel;
-        }
-        catch( Exception e )
-        {
-            throw new InvalidApplicationException( "Could not register " + types, e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientDeclarationImpl.java
deleted file mode 100644
index c137202..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientDeclarationImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.TransientDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a Composite. Created by {@link org.apache.zest.bootstrap.ModuleAssembly#transients(Class[])}.
- */
-public final class TransientDeclarationImpl
-    implements TransientDeclaration
-{
-    private final Iterable<TransientAssemblyImpl> assemblies;
-
-    public TransientDeclarationImpl( Iterable<TransientAssemblyImpl> assemblies )
-    {
-        this.assemblies = assemblies;
-    }
-
-    @Override
-    public TransientDeclaration setMetaInfo( Object info )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.metaInfo.set( info );
-        }
-        return this;
-    }
-
-    @Override
-    public TransientDeclaration visibleIn( Visibility visibility )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    public TransientDeclaration withConcerns( Class<?>... concerns )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.concerns.addAll( asList( concerns ) );
-        }
-        return this;
-    }
-
-    @Override
-    public TransientDeclaration withSideEffects( Class<?>... sideEffects )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.sideEffects.addAll( asList( sideEffects ) );
-        }
-        return this;
-    }
-
-    @Override
-    public TransientDeclaration withMixins( Class<?>... mixins )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.mixins.addAll( asList( mixins ) );
-        }
-        return this;
-    }
-
-    @Override
-    public TransientDeclaration withTypes( Class<?>... types )
-    {
-        for( TransientAssemblyImpl assembly : assemblies )
-        {
-            assembly.types.addAll( asList( types ) );
-        }
-        return this;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypeCheckAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypeCheckAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypeCheckAppliesToFilter.java
deleted file mode 100644
index 519ad4f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypeCheckAppliesToFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class TypeCheckAppliesToFilter
-    implements AppliesToFilter
-{
-    @SuppressWarnings( "raw" )
-    private final Class type;
-
-    @SuppressWarnings( "raw" )
-    TypeCheckAppliesToFilter( Class type )
-    {
-        this.type = type;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        return type.isAssignableFrom( compositeType );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypedFragmentAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypedFragmentAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypedFragmentAppliesToFilter.java
deleted file mode 100644
index f2bf128..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TypedFragmentAppliesToFilter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class TypedFragmentAppliesToFilter
-    implements AppliesToFilter
-{
-    @Override
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        return method.getDeclaringClass().isAssignableFrom( fragmentClass );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
deleted file mode 100644
index 268ba75..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.bootstrap.ValueAssembly;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.composite.ValueConstraintsModel;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.value.ValueModel;
-import org.apache.zest.runtime.value.ValueStateModel;
-
-import static org.apache.zest.api.util.Annotations.isType;
-import static org.apache.zest.api.util.Classes.typeOf;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Declaration of a ValueComposite.
- */
-public final class ValueAssemblyImpl
-    extends CompositeAssemblyImpl
-    implements ValueAssembly
-{
-    private AssociationsModel associationsModel;
-    private ManyAssociationsModel manyAssociationsModel;
-    private NamedAssociationsModel namedAssociationsModel;
-
-    public ValueAssemblyImpl( Class<?> compositeType )
-    {
-        super( compositeType );
-        // The composite must always implement ValueComposite, as a marker interface
-        if( !ValueComposite.class.isAssignableFrom( compositeType ) )
-        {
-            types.add( ValueComposite.class );
-        }
-    }
-
-    @Override
-    protected StateModel createStateModel()
-    {
-        return new ValueStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
-    }
-
-    ValueModel newValueModel(
-        StateDeclarations stateDeclarations,
-        AssemblyHelper helper
-    )
-    {
-        try
-        {
-            associationsModel = new AssociationsModel();
-            manyAssociationsModel = new ManyAssociationsModel();
-            namedAssociationsModel = new NamedAssociationsModel();
-            buildComposite( helper, stateDeclarations );
-
-            ValueModel valueModel = new ValueModel(
-                types, visibility, metaInfo, mixinsModel, (ValueStateModel) stateModel, compositeMethodsModel );
-
-            return valueModel;
-        }
-        catch( Exception e )
-        {
-            throw new InvalidApplicationException( "Could not register " + types, e );
-        }
-    }
-
-    @Override
-    protected void addStateFor( AccessibleObject accessor,
-                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        String stateName = QualifiedName.fromAccessor( accessor ).name();
-
-        if( registeredStateNames.contains( stateName ) )
-        {
-            return; // Skip already registered names
-        }
-
-        Class<?> accessorType = Classes.RAW_CLASS.map( typeOf( accessor ) );
-        if( Property.class.isAssignableFrom( accessorType ) )
-        {
-            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( Association.class.isAssignableFrom( accessorType ) )
-        {
-            associationsModel.addAssociation( newAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( ManyAssociation.class.isAssignableFrom( accessorType ) )
-        {
-            manyAssociationsModel.addManyAssociation( newManyAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( NamedAssociation.class.isAssignableFrom( accessorType ) )
-        {
-            namedAssociationsModel.addNamedAssociation( newNamedAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-    }
-
-    @Override
-    protected PropertyModel newPropertyModel( AccessibleObject accessor,
-                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member) accessor )
-            .getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
-        Object initialValue = stateDeclarations.initialValueOf( accessor );
-        return new PropertyModel( accessor, true, useDefaults, valueConstraintsInstance, metaInfo, initialValue );
-    }
-
-    public AssociationModel newAssociationModel( AccessibleObject accessor,
-                                                 Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for Association references
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the Association itself
-        valueConstraintsModel = constraintsFor( annotations, Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance associationValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            associationValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        AssociationModel associationModel = new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-
-    public ManyAssociationModel newManyAssociationModel( AccessibleObject accessor,
-                                                         Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for entities in ManyAssociation
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the ManyAssociation itself
-        valueConstraintsModel = constraintsFor( annotations, ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance manyValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            manyValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        ManyAssociationModel associationModel = new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-    
-    public NamedAssociationModel newNamedAssociationModel( AccessibleObject accessor,
-                                                           Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for entities in NamedAssociation
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the NamedAssociation itself
-        valueConstraintsModel = constraintsFor( annotations, NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance namedValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            namedValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        NamedAssociationModel associationModel = new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueDeclarationImpl.java
deleted file mode 100644
index 24c9c8e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueDeclarationImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.ValueDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a ValueComposite.
- */
-public final class ValueDeclarationImpl
-    implements ValueDeclaration
-{
-    private final Iterable<ValueAssemblyImpl> assemblies;
-
-    public ValueDeclarationImpl( Iterable<ValueAssemblyImpl> assemblies )
-    {
-        this.assemblies = assemblies;
-    }
-
-    @Override
-    public ValueDeclaration setMetaInfo( Object info )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.metaInfo.set( info );
-        }
-        return this;
-    }
-
-    @Override
-    public ValueDeclaration visibleIn( Visibility visibility )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    public ValueDeclaration withConcerns( Class<?>... concerns )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.concerns.addAll( asList( concerns ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ValueDeclaration withSideEffects( Class<?>... sideEffects )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.sideEffects.addAll( asList( sideEffects ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ValueDeclaration withMixins( Class<?>... mixins )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.mixins.addAll( asList( mixins ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ValueDeclaration withTypes( Class<?>... types )
-    {
-        for( ValueAssemblyImpl assembly : assemblies )
-        {
-            assembly.types.addAll( asList( types ) );
-        }
-        return this;
-    }
-}
\ No newline at end of file


[31/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/activation/ActivationEventsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/activation/ActivationEventsTest.java b/core/api/src/test/java/org/apache/zest/api/activation/ActivationEventsTest.java
deleted file mode 100644
index f4861ad..0000000
--- a/core/api/src/test/java/org/apache/zest/api/activation/ActivationEventsTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.api.activation;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationEvent.EventType;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-
-import static org.junit.Assert.*;
-import static org.apache.zest.api.activation.ActivationEvent.EventType.*;
-
-public class ActivationEventsTest
-{
-
-    public static interface TestService
-    {
-        void test();
-    }
-
-    public static class TestServiceInstance
-            implements TestService
-    {
-
-        @Override
-        public void test()
-        {
-        }
-
-    }
-
-    @Mixins( TestServiceInstance.class )
-    public static interface TestServiceComposite
-        extends TestService, ServiceComposite
-    {
-    }
-
-    @Test
-    public void testSingleModuleSingleService()
-        throws Exception
-    {
-        final List<ActivationEvent> events = new ArrayList<>();
-
-        new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                module.services( TestServiceComposite.class ).instantiateOnStartup();
-            }
-
-            @Override
-            protected void beforeActivation( Application application )
-            {
-                application.registerActivationEventListener( new EventsRecorder( events ) );
-            }
-
-
-        }.application().passivate();
-
-        Iterator<ActivationEvent> it = events.iterator();
-
-        // Activation
-        assertEvent( it.next(), ACTIVATING, "Application" );
-        assertEvent( it.next(), ACTIVATING, "Layer" );
-        assertEvent( it.next(), ACTIVATING, "Module" );
-        assertEvent( it.next(), ACTIVATING, "TestService" );
-        assertEvent( it.next(), ACTIVATED, "TestService" );
-        assertEvent( it.next(), ACTIVATED, "Module" );
-        assertEvent( it.next(), ACTIVATED, "Layer" );
-        assertEvent( it.next(), ACTIVATED, "Application" );
-
-        // Passivation
-        assertEvent( it.next(), PASSIVATING, "Application" );
-        assertEvent( it.next(), PASSIVATING, "Layer" );
-        assertEvent( it.next(), PASSIVATING, "Module" );
-        assertEvent( it.next(), PASSIVATING, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "Module" );
-        assertEvent( it.next(), PASSIVATED, "Layer" );
-        assertEvent( it.next(), PASSIVATED, "Application" );
-
-        assertFalse( it.hasNext() );
-    }
-
-    @Test
-    public void testSingleModuleSingleImportedService()
-            throws Exception
-    {
-        final List<ActivationEvent> events = new ArrayList<>();
-
-        new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                module.importedServices( TestService.class ).
-                        setMetaInfo( new TestServiceInstance() ).
-                        importOnStartup();
-            }
-
-            @Override
-            protected void beforeActivation( Application application )
-            {
-                application.registerActivationEventListener( new EventsRecorder( events ) );
-            }
-
-
-        }.application().passivate();
-
-        Iterator<ActivationEvent> it = events.iterator();
-
-        // Activation
-        assertEvent( it.next(), ACTIVATING, "Application" );
-        assertEvent( it.next(), ACTIVATING, "Layer" );
-        assertEvent( it.next(), ACTIVATING, "Module" );
-        assertEvent( it.next(), ACTIVATING, "TestService" );
-        assertEvent( it.next(), ACTIVATED, "TestService" );
-        assertEvent( it.next(), ACTIVATED, "Module" );
-        assertEvent( it.next(), ACTIVATED, "Layer" );
-        assertEvent( it.next(), ACTIVATED, "Application" );
-
-        // Passivation
-        assertEvent( it.next(), PASSIVATING, "Application" );
-        assertEvent( it.next(), PASSIVATING, "Layer" );
-        assertEvent( it.next(), PASSIVATING, "Module" );
-        assertEvent( it.next(), PASSIVATING, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "Module" );
-        assertEvent( it.next(), PASSIVATED, "Layer" );
-        assertEvent( it.next(), PASSIVATED, "Application" );
-
-        assertFalse( it.hasNext() );
-    }
-
-    @Test
-    public void testSingleModuleSingleLazyService()
-            throws Exception
-    {
-        final List<ActivationEvent> events = new ArrayList<>();
-
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-
-            @Override
-            public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-            {
-                module.services( TestServiceComposite.class );
-            }
-
-            @Override
-            protected void beforeActivation( Application application )
-            {
-                application.registerActivationEventListener( new EventsRecorder( events ) );
-            }
-
-        };
-        Application application = assembler.application();
-        application.passivate();
-
-        Iterator<ActivationEvent> it = events.iterator();
-
-        // Activation
-        assertEvent( it.next(), ACTIVATING, "Application" );
-        assertEvent( it.next(), ACTIVATING, "Layer" );
-        assertEvent( it.next(), ACTIVATING, "Module" );
-        // Lazy Service NOT activated
-        assertEvent( it.next(), ACTIVATED, "Module" );
-        assertEvent( it.next(), ACTIVATED, "Layer" );
-        assertEvent( it.next(), ACTIVATED, "Application" );
-
-        // Passivation
-        assertEvent( it.next(), PASSIVATING, "Application" );
-        assertEvent( it.next(), PASSIVATING, "Layer" );
-        assertEvent( it.next(), PASSIVATING, "Module" );
-        // Lazy Service NOT passivated
-        assertEvent( it.next(), PASSIVATED, "Module" );
-        assertEvent( it.next(), PASSIVATED, "Layer" );
-        assertEvent( it.next(), PASSIVATED, "Application" );
-
-        assertFalse( it.hasNext() );
-
-        events.clear();
-        application.activate();
-        Module module = assembler.module();
-        module.findService( TestService.class ).get().test();
-        application.passivate();
-
-        for( ActivationEvent event : events ) {
-            System.out.println( event );
-        }
-
-        it = events.iterator();
-
-        // Activation
-        assertEvent( it.next(), ACTIVATING, "Application" );
-        assertEvent( it.next(), ACTIVATING, "Layer" );
-        assertEvent( it.next(), ACTIVATING, "Module" );
-        assertEvent( it.next(), ACTIVATED, "Module" );
-        assertEvent( it.next(), ACTIVATED, "Layer" );
-        assertEvent( it.next(), ACTIVATED, "Application" );
-
-        // Lazy Service Activation
-        assertEvent( it.next(), ACTIVATING, "TestService" );
-        assertEvent( it.next(), ACTIVATED, "TestService" );
-
-        // Passivation
-        assertEvent( it.next(), PASSIVATING, "Application" );
-        assertEvent( it.next(), PASSIVATING, "Layer" );
-        assertEvent( it.next(), PASSIVATING, "Module" );
-        assertEvent( it.next(), PASSIVATING, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "TestService" );
-        assertEvent( it.next(), PASSIVATED, "Module" );
-        assertEvent( it.next(), PASSIVATED, "Layer" );
-        assertEvent( it.next(), PASSIVATED, "Application" );
-
-        assertFalse( it.hasNext() );
-    }
-
-    private static class EventsRecorder
-            implements ActivationEventListener
-    {
-
-        private final List<ActivationEvent> events;
-
-        private EventsRecorder( List<ActivationEvent> events )
-        {
-            this.events = events;
-        }
-
-        @Override
-        public void onEvent( ActivationEvent event )
-        {
-            events.add( event );
-        }
-
-    }
-
-    // WARN This assertion depends on ApplicationInstance, LayerInstance, ModuleInstance and ServiceReferenceInstance toString() method.
-    private static void assertEvent( ActivationEvent event, EventType expectedType, String expected )
-    {
-        boolean wrongEvent = expectedType != event.type();
-        boolean wrongMessage = ! event.message().contains( expected );
-        if( wrongEvent || wrongMessage )
-        {
-            StringBuilder sb = new StringBuilder();
-            sb.append("Event (").append( event ).append( ") has");
-            if( wrongEvent )
-            {
-                sb.append( " wrong type (expected:'" ).append( expectedType ).
-                        append( "' but was:'" ).append( event.type() ).append( "')" );
-                if( wrongMessage )
-                {
-                    sb.append( ";" );
-                }
-            }
-            if( wrongMessage )
-            {
-                sb.append( " wrong message (expected:'" ).append( expected ).
-                        append( "' but was:'" ).append( event.message() ).append( "')" );
-            }
-            fail( sb.toString() );
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/activation/PassivationExceptionTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/activation/PassivationExceptionTest.java b/core/api/src/test/java/org/apache/zest/api/activation/PassivationExceptionTest.java
deleted file mode 100644
index dcd2848..0000000
--- a/core/api/src/test/java/org/apache/zest/api/activation/PassivationExceptionTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 2013-2014, Paul Merlin. 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.zest.api.activation;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collections;
-import org.junit.Test;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.builder.ApplicationBuilder;
-
-import static org.hamcrest.core.StringContains.containsString;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-public class PassivationExceptionTest
-{
-    private static String stack( Exception ex )
-    {
-        StringWriter writer = new StringWriter();
-        ex.printStackTrace( new PrintWriter( writer ) );
-        return writer.toString();
-    }
-
-    @Test
-    public void testEmptyPassivationException()
-    {
-        PassivationException empty = new PassivationException( Collections.<Exception>emptyList() );
-        assertThat( empty.getMessage(), containsString( "has 0 cause" ) );
-    }
-
-    @Test
-    public void testSinglePassivationException()
-    {
-        PassivationException single = new PassivationException( Collections.singletonList( new Exception( "single" ) ) );
-        String stack = stack( single );
-        assertThat( single.getMessage(), containsString( "has 1 cause" ) );
-        assertThat( stack, containsString( "Suppressed: java.lang.Exception: single" ) );
-    }
-
-    @Test
-    public void testMultiplePassivationException()
-    {
-        PassivationException multi = new PassivationException( Arrays.asList( new Exception( "one" ),
-                                                                              new Exception( "two" ),
-                                                                              new Exception( "three" ) ) );
-        String stack = stack( multi );
-        assertThat( multi.getMessage(), containsString( "has 3 cause(s)" ) );
-        assertThat( stack, containsString( "Suppressed: java.lang.Exception: one" ) );
-        assertThat( stack, containsString( "Suppressed: java.lang.Exception: two" ) );
-        assertThat( stack, containsString( "Suppressed: java.lang.Exception: three" ) );
-    }
-
-    @Test
-    public void testPassivationExceptionsAccrossStructure()
-        throws AssemblyException, ActivationException
-    {
-        ApplicationBuilder appBuilder = new ApplicationBuilder( "TestApplication" );
-        appBuilder.withLayer( "Layer 1" ).withModule( "Module A" ).withAssembler( new Assembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                module.services( TestService.class ).
-                    identifiedBy( "TestService_Module.A" ).
-                    withActivators( FailBeforePassivationServiceActivator.class ).
-                    instantiateOnStartup();
-            }
-        } );
-        appBuilder.withLayer( "Layer 2" ).withModule( "Module B" ).withAssembler( new Assembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                module.services( TestService.class ).
-                    identifiedBy( "TestService_Module.B" ).
-                    withActivators( FailAfterPassivationServiceActivator.class ).
-                    instantiateOnStartup();
-            }
-        } );
-        appBuilder.registerActivationEventListener( new TestActivationEventListener() );
-
-        Application app = appBuilder.newApplication();
-
-        try
-        {
-            Module moduleA = app.findModule( "Layer 1", "Module A" );
-            TestService service = moduleA.findService( TestService.class ).get();
-            assertThat( service.hello(), equalTo( "Hello Zest!" ) );
-        }
-        finally
-        {
-            try
-            {
-                app.passivate();
-                fail( "No PassivationException" );
-            }
-            catch( PassivationException ex )
-            {
-                ex.printStackTrace();
-                String stack = stack( ex );
-                assertThat( ex.getMessage(), containsString( "has 12 cause(s)" ) );
-                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for TestApplication" ) );
-                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Layer 2" ) );
-                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Module B" ) );
-                assertThat( stack, containsString( "ACTIVATOR: FAIL AFTER PASSIVATION for TestService_Module.B(active=false,module='Module B')" ) );
-                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Module B" ) );
-                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Layer 2" ) );
-                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Layer 1" ) );
-                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Module A" ) );
-                assertThat( stack, containsString( "ACTIVATOR: FAIL BEFORE PASSIVATION for TestService_Module.A(active=true,module='Module A')" ) );
-                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Module A" ) );
-                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Layer 1" ) );
-                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for TestApplication" ) );
-            }
-        }
-    }
-
-    @Mixins( TestService.Mixin.class )
-    public interface TestService
-    {
-        String hello();
-
-        static class Mixin
-            implements TestService
-        {
-            @Structure
-            private Module module;
-
-            @Override
-            public String hello()
-            {
-                module.name();
-                return "Hello Zest!";
-            }
-        }
-
-    }
-
-    public static class FailBeforePassivationServiceActivator
-        extends ActivatorAdapter<ServiceReference<TestService>>
-    {
-        @Override
-        public void beforePassivation( ServiceReference<TestService> passivated )
-            throws Exception
-        {
-            throw new Exception( "ACTIVATOR: FAIL BEFORE PASSIVATION for " + passivated );
-        }
-    }
-
-    public static class FailAfterPassivationServiceActivator
-        extends ActivatorAdapter<ServiceReference<TestService>>
-    {
-        @Override
-        public void afterPassivation( ServiceReference<TestService> passivated )
-            throws Exception
-        {
-            throw new Exception( "ACTIVATOR: FAIL AFTER PASSIVATION for " + passivated );
-        }
-    }
-
-    public static class TestActivationEventListener
-        implements ActivationEventListener
-    {
-        @Override
-        public void onEvent( ActivationEvent event )
-            throws Exception
-        {
-            if( !( event.source() instanceof Application )
-                && !( event.source() instanceof Layer )
-                && !( event.source() instanceof Module ) )
-            {
-                return;
-            }
-            switch( event.type() )
-            {
-                case PASSIVATING:
-                    throw new Exception( "EVENT: FAIL BEFORE PASSIVATION for " + event.source() );
-                case PASSIVATED:
-                    throw new Exception( "EVENT: FAIL AFTER PASSIVATION for " + event.source() );
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/annotation/MixinsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/annotation/MixinsTest.java b/core/api/src/test/java/org/apache/zest/api/annotation/MixinsTest.java
deleted file mode 100644
index 73755f0..0000000
--- a/core/api/src/test/java/org/apache/zest/api/annotation/MixinsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007 Alin Dreghiciu. 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.zest.api.annotation;
-
-import java.lang.annotation.Annotation;
-import org.junit.Test;
-import org.apache.zest.api.mixin.Mixins;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests public api exposed by Mixins annotation.
- * This will ensure that the public api does not get changed by mistake.
- */
-public class MixinsTest
-{
-
-    @Test
-    public void retention()
-    {
-        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
-        assertNotNull( "annotations should not be null", annotations );
-        assertEquals( "number of annotations", 1, annotations.length );
-        assertEquals( "annotation type", Mixins.class, annotations[ 0 ].annotationType() );
-    }
-
-    @Mixins( Object.class )
-    private static class Annotated
-    {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/annotation/ModifiedByTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/annotation/ModifiedByTest.java b/core/api/src/test/java/org/apache/zest/api/annotation/ModifiedByTest.java
deleted file mode 100644
index 660c762..0000000
--- a/core/api/src/test/java/org/apache/zest/api/annotation/ModifiedByTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007 Alin Dreghiciu. 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.zest.api.annotation;
-
-import java.lang.annotation.Annotation;
-import org.junit.Test;
-import org.apache.zest.api.concern.Concerns;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests public api exposed by Concerns annotation.
- * This will ensure that the public api does not get changed by mistake.
- */
-public class ModifiedByTest
-{
-
-    @Test
-    public void retention()
-    {
-        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
-        assertNotNull( "annotations should not be null", annotations );
-        assertEquals( "number of annotations", 1, annotations.length );
-        assertEquals( "annotation type", Concerns.class, annotations[ 0 ].annotationType() );
-    }
-
-    @Concerns( Object.class )
-    private static class Annotated
-    {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/annotation/scope/ModifiesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/annotation/scope/ModifiesTest.java b/core/api/src/test/java/org/apache/zest/api/annotation/scope/ModifiesTest.java
deleted file mode 100644
index 9eea244..0000000
--- a/core/api/src/test/java/org/apache/zest/api/annotation/scope/ModifiesTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2007 Alin Dreghiciu. 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.zest.api.annotation.scope;
-
-import java.lang.annotation.Annotation;
-import org.junit.Test;
-import org.apache.zest.api.concern.internal.ConcernFor;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests public api exposed by Modified annotation.
- * This will ensure that the public api does not get changed by mistake.
- */
-public class ModifiesTest
-{
-
-    @Test
-    public void retention()
-        throws NoSuchFieldException
-    {
-        Annotation[] annotations = Annotated.class.getDeclaredField( "modified" ).getDeclaredAnnotations();
-        assertNotNull( "annotations should not be null", annotations );
-        assertEquals( "number of annotations", 1, annotations.length );
-        assertEquals( "annotation type", ConcernFor.class, annotations[ 0 ].annotationType() );
-    }
-
-    private static class Annotated
-    {
-        @ConcernFor
-        String modified;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/common/AppliesToTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/common/AppliesToTest.java b/core/api/src/test/java/org/apache/zest/api/common/AppliesToTest.java
deleted file mode 100644
index 7a491fe..0000000
--- a/core/api/src/test/java/org/apache/zest/api/common/AppliesToTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2007 Alin Dreghiciu. 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.zest.api.common;
-
-import java.lang.annotation.Annotation;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests public api exposed by AppliesTo annotation.
- * This will ensure that the public api does not get changed by mistake.
- */
-public class AppliesToTest
-{
-
-    @Test
-    public void retention()
-    {
-        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
-        assertNotNull( "annotations should not be null", annotations );
-        assertEquals( "number of annotations", 1, annotations.length );
-        assertEquals( "annotation type", AppliesTo.class, annotations[ 0 ].annotationType() );
-    }
-
-    @AppliesTo( Object.class )
-    private static class Annotated
-    {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/common/QualifiedNameTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/common/QualifiedNameTest.java b/core/api/src/test/java/org/apache/zest/api/common/QualifiedNameTest.java
deleted file mode 100644
index 5fa0e8b..0000000
--- a/core/api/src/test/java/org/apache/zest/api/common/QualifiedNameTest.java
+++ /dev/null
@@ -1,83 +0,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.
- */
-package org.apache.zest.api.common;
-
-import org.junit.Test;
-import org.apache.zest.api.util.NullArgumentException;
-
-import static org.junit.Assert.assertEquals;
-
-public class QualifiedNameTest
-{
-    @Test
-    public void testQualifiedNameWithDollar()
-    {
-        assertEquals( "Name containing dollar is modified", "Test-Test",
-                      new QualifiedName( TypeName.nameOf( "Test$Test" ), "satisfiedBy" ).type() );
-    }
-
-    @Test
-    public void testQualifiedNameFromQNWithDollar()
-    {
-        assertEquals( "Name containing dollar is cleaned up", "Test-Test",
-                      QualifiedName.fromFQN( "Test$Test:satisfiedBy" ).type() );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments1()
-    {
-        new QualifiedName( TypeName.nameOf( "Test" ), null );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments2()
-    {
-        new QualifiedName( null, "satisfiedBy" );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments3()
-    {
-        new QualifiedName( null, null );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments4()
-    {
-        QualifiedName.fromFQN( null );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments5()
-    {
-        QualifiedName.fromAccessor( null );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments6()
-    {
-        QualifiedName.fromClass( null, "satisfiedBy" );
-    }
-
-    @Test( expected = NullArgumentException.class )
-    public void nonNullArguments7()
-    {
-        QualifiedName.fromClass( null, null );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/composite/PropertyMapperTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/composite/PropertyMapperTest.java b/core/api/src/test/java/org/apache/zest/api/composite/PropertyMapperTest.java
deleted file mode 100644
index f30f887..0000000
--- a/core/api/src/test/java/org/apache/zest/api/composite/PropertyMapperTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class PropertyMapperTest
-{
-    private final static Method MAP_TO_TYPE;
-
-    static
-    {
-        try
-        {
-            MAP_TO_TYPE = PropertyMapper.class.getDeclaredMethod( "mapToType", Composite.class, Type.class, Object.class );
-            MAP_TO_TYPE.setAccessible( true );
-        }
-        catch( NoSuchMethodException e )
-        {
-            InternalError error = new InternalError();
-            error.initCause( e );
-            throw error;
-        }
-    }
-
-    @Test
-    public void testMappingOfInteger()
-        throws Exception
-    {
-        assertEquals( 5, mapToType( null, Integer.class, "5" ) );
-        assertEquals( -5, mapToType( null, Integer.class, "-5" ) );
-        assertEquals( Integer.class, mapToType( null, Integer.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfLong()
-        throws Exception
-    {
-        assertEquals( 5L, mapToType( null, Long.class, "5" ) );
-        assertEquals( 5876328476238746238L, mapToType( null, Long.class, "5876328476238746238" ) );
-        assertEquals( Long.class, mapToType( null, Long.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfBoolean()
-        throws Exception
-    {
-        assertEquals( false, mapToType( null, Boolean.class, "false" ) );
-        assertEquals( true, mapToType( null, Boolean.class, "true" ) );
-        assertEquals( Boolean.class, mapToType( null, Boolean.class, "false" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfFloat()
-        throws Exception
-    {
-        assertEquals( 5.1234f, mapToType( null, Float.class, "5.1234" ) );
-        assertEquals( 5876328476.6238f, mapToType( null, Float.class, "5876328476.6238" ) );
-        assertEquals( Float.class, mapToType( null, Float.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfDouble()
-        throws Exception
-    {
-        assertEquals( 5.1234, mapToType( null, Double.class, "5.1234" ) );
-        assertEquals( 5876328476.623823, mapToType( null, Double.class, "5876328476.623823" ) );
-        assertEquals( Double.class, mapToType( null, Double.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfBigDecimal()
-        throws Exception
-    {
-        assertEquals( new BigDecimal( 3 ), mapToType( null, BigDecimal.class, "3" ) );
-        assertEquals( new BigDecimal( "12345.67891011" ), mapToType( null, BigDecimal.class, "12345.67891011" ) );
-        assertEquals( BigDecimal.class, mapToType( null, BigDecimal.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfBigInteger()
-        throws Exception
-    {
-        assertEquals( new BigInteger( "20", 16 ), mapToType( null, BigInteger.class, "32" ) );
-        assertEquals( new BigInteger( "1234567891011" ), mapToType( null, BigInteger.class, "1234567891011" ) );
-        assertEquals( BigInteger.class, mapToType( null, BigInteger.class, "5" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfEnum()
-        throws Exception
-    {
-        assertEquals( TestEnum.FIRST, mapToType( null, TestEnum.class, "FIRST" ) );
-        assertEquals( TestEnum.SECOND, mapToType( null, TestEnum.class, "SECOND" ) );
-        assertEquals( TestEnum.class, mapToType( null, TestEnum.class, "SECOND" ).getClass() );
-    }
-
-    @Test
-    public void testMappingOfIntegerArray()
-        throws Exception
-    {
-        Object[] value = (Object[]) mapToType( null, Integer[].class, "5,4 , 3   ,2,1" );
-        assertEquals( 5, value.length );
-        assertEquals( 5, value[ 0 ] );
-        assertEquals( 4, value[ 1 ] );
-        assertEquals( 3, value[ 2 ] );
-        assertEquals( 2, value[ 3 ] );
-        assertEquals( 1, value[ 4 ] );
-    }
-
-    @Test
-    public void testMappingOfStringArray()
-        throws Exception
-    {
-        {
-            Object[] value = (Object[]) mapToType( null, String[].class, "5,4 , 3   ,2,1" );
-            assertEquals( 5, value.length );
-            assertEquals( "5", value[ 0 ] );
-            assertEquals( "4 ", value[ 1 ] );
-            assertEquals( " 3   ", value[ 2 ] );
-            assertEquals( "2", value[ 3 ] );
-            assertEquals( "1", value[ 4 ] );
-        }
-        {
-            Object[] value = (Object[]) mapToType( null, String[].class, "5,4 ,\" 3,   \",  \" 2\" ,1" );
-            assertEquals( "5", value[ 0 ] );
-            assertEquals( "4 ", value[ 1 ] );
-            assertEquals( " 3,   ", value[ 2 ] );
-            assertEquals( " 2", value[ 3 ] );
-            assertEquals( "1", value[ 4 ] );
-            assertEquals( 5, value.length );
-        }
-    }
-
-    @Test
-    public void testMappingOfBooleanArray()
-        throws Exception
-    {
-        Object[] value = (Object[]) mapToType( null, Boolean[].class, " true,false,  false, true ,true,false" );
-        assertEquals( true, value[ 0 ] );
-        assertEquals( false, value[ 1 ] );
-        assertEquals( false, value[ 2 ] );
-        assertEquals( true, value[ 3 ] );
-        assertEquals( true, value[ 4 ] );
-        assertEquals( false, value[ 5 ] );
-        assertEquals( 6, value.length );
-    }
-
-    @Test
-    public void testMappingOfList()
-        throws Exception
-    {
-        Type type = Testing.class.getDeclaredMethod( "list" ).getGenericReturnType();
-        List<String> value = (List<String>) mapToType( null, type, "5,4 ,\" 3,   \",  \" 2\" ,1" );
-        assertEquals( "5", value.get( 0 ) );
-        assertEquals( "4 ", value.get( 1 ) );
-        assertEquals( " 3,   ", value.get( 2 ) );
-        assertEquals( " 2", value.get( 3 ) );
-        assertEquals( "1", value.get( 4 ) );
-        assertEquals( 5, value.size() );
-    }
-
-    @Test
-    public void testMappingOfSet()
-        throws Exception
-    {
-        Type type = Testing.class.getDeclaredMethod( "set" ).getGenericReturnType();
-        Set<String> value = (Set<String>) mapToType( null, type, "5,4 ,\" 3,   \",  \" 2\" ,1" );
-        assertTrue( value.contains( "5" ) );
-        assertTrue( value.contains( "4 " ) );
-        assertTrue( value.contains( " 3,   " ) );
-        assertTrue( value.contains( " 2" ) );
-        assertTrue( value.contains( "1" ) );
-        assertEquals( 5, value.size() );
-    }
-
-    @Test
-    public void testMappingOfMap()
-        throws Exception
-    {
-        Type type = Testing.class.getDeclaredMethod( "map" ).getGenericReturnType();
-        Map<String, String> value = (Map<String, String>) mapToType( null, type, "first:5,second:4 , third:\" 3,   \", fourth:  \" 2\" ,fifth : 1" );
-        assertEquals( "5", value.get( "first" ) );
-        assertEquals( "4 ", value.get( "second" ) );
-        assertEquals( " 3,   ", value.get( " third" ) );
-        assertEquals( " 2", value.get( " fourth" ) );
-        assertEquals( " 1", value.get( "fifth " ) );
-        assertEquals( 5, value.size() );
-    }
-
-    private Object mapToType( Composite composite, Type propertyType, Object value )
-        throws IllegalAccessException, InvocationTargetException
-    {
-        return MAP_TO_TYPE.invoke( null, composite, propertyType, value );
-    }
-
-    interface Testing
-    {
-        List<String> list();
-
-        Set<String> set();
-
-        Map<String, String> map();
-    }
-
-    enum TestEnum
-    {
-        FIRST,
-        SECOND
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/concern/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/concern/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/concern/DocumentationSupport.java
deleted file mode 100644
index b9aefc1..0000000
--- a/core/api/src/test/java/org/apache/zest/api/concern/DocumentationSupport.java
+++ /dev/null
@@ -1,100 +0,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.
- */
-package org.apache.zest.api.concern;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.injection.InjectionScope;
-
-public class DocumentationSupport
-{
-// START SNIPPET: class
-    @AppliesTo( java.sql.Connection.class )
-    public class CacheConcern extends GenericConcern
-        implements InvocationHandler
-    {
-// END SNIPPET: class
-        @Override
-        public Object invoke( Object proxy, Method method, Object[] args )
-            throws Throwable
-        {
-            return null;
-        }
-    }
-
-// START SNIPPET: filter
-    @AppliesTo( BusinessAppliesToFilter.class )
-    public class BusinessConcern extends GenericConcern
-        implements InvocationHandler
-    {
-// END SNIPPET: filter
-        @Override
-        public Object invoke( Object proxy, Method method, Object[] args )
-            throws Throwable
-        {
-            return null;
-        }
-    }
-
-// START SNIPPET: filter
-    public class BusinessAppliesToFilter
-        implements AppliesToFilter
-    {
-
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass
-        )
-        {
-            return true; // Some criteria for when a method is wrapped with the concern.
-        }
-    }
-// END SNIPPET: filter
-
-
-// START SNIPPET: annotation
-    @AppliesTo( Audited.class )
-    public class AuditConcern extends GenericConcern
-        implements InvocationHandler
-    {
-// START SNIPPET: annotation
-        @Override
-        public Object invoke( Object proxy, Method method, Object[] args )
-            throws Throwable
-        {
-            return null;
-        }
-    }
-
-// START SNIPPET: annotation
-    @Retention( RetentionPolicy.RUNTIME )
-    @Target( { ElementType.METHOD } )
-    @Documented
-    @InjectionScope
-    public @interface Audited
-    {
-    }
-// END SNIPPET: annotation
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java b/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
deleted file mode 100644
index 8d67f6c..0000000
--- a/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
+++ /dev/null
@@ -1,109 +0,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.
- */
-package org.apache.zest.api.configuration;
-
-import org.junit.Test;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class ConfigurationTest extends AbstractQi4jTest
-{
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.services( MyService.class ).instantiateOnStartup();
-        module.entities( MyConfig.class );
-        module.values( PersonDetails.class, Address.class, City.class, Country.class );
-        new EntityTestAssembler().assemble( module );
-    }
-
-    @Test
-    public void testConfiguration()
-        throws Exception
-    {
-        MyService service = module.findService( MyService.class ).get();
-        PersonDetails details = service.details();
-        assertThat(details.name().get(), equalTo( "Niclas" ) );
-        assertThat(details.address().get().street1().get(), equalTo( "Henan Lu 555" ) );
-        assertThat(details.address().get().street2().get(), equalTo( "Block 15" ) );
-        assertThat(details.address().get().city().get().cityName().get(), equalTo( "Shanghai" ) );
-        assertThat(details.address().get().city().get().country().get().countryName().get(), equalTo( "China" ) );
-    }
-
-    @Mixins(MyServiceMixin.class)
-    public interface MyService extends ServiceComposite
-    {
-        PersonDetails details();
-    }
-
-    public abstract class MyServiceMixin
-        implements MyService
-    {
-        @This
-        Configuration<MyConfig> myconf;
-
-        @Override
-        public PersonDetails details()
-        {
-            return myconf.get().me().get();
-        }
-    }
-
-    public interface MyConfig extends ConfigurationComposite
-    {
-        Property<PersonDetails> me();
-    }
-
-    public interface PersonDetails extends ValueComposite
-    {
-        Property<String> name();
-        Property<Address> address();
-
-    }
-
-    public interface Address extends ValueComposite
-    {
-        Property<String> street1();
-        Property<String> street2();
-        Property<City> city();
-    }
-
-    public interface City extends ValueComposite
-    {
-        Property<String> cityName();
-        Property<Country> country();
-    }
-
-    public interface Country extends ValueComposite
-    {
-        Property<String> countryName();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java b/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
deleted file mode 100644
index dbc8b18..0000000
--- a/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.api.configuration;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-public class DeclareConfigurationDefaultsTest
-        extends AbstractQi4jTest
-{
-
-    @Mixins( FooServiceMixin.class )
-    public static interface FooServiceComposite
-            extends ServiceComposite
-    {
-
-        String configuredFoo();
-
-    }
-
-    public static abstract class FooServiceMixin
-            implements FooServiceComposite
-    {
-
-        @This
-        private Configuration<FooConfigurationComposite> config;
-
-        public String configuredFoo()
-        {
-            return config.get().foo().get();
-        }
-
-    }
-
-    public static interface FooConfigurationComposite
-            extends ConfigurationComposite
-    {
-
-        Property<String> foo();
-
-    }
-
-    public void assemble( ModuleAssembly module )
-            throws AssemblyException
-    {
-        module.services( FooServiceComposite.class ).identifiedBy( "bazar" );
-        module.entities( FooConfigurationComposite.class );
-        new EntityTestAssembler().assemble( module );
-        FooConfigurationComposite config = module.forMixin( FooConfigurationComposite.class ).declareDefaults();
-        config.foo().set( "bar" );
-    }
-
-    @Test
-    public void testConfigurationDefaults()
-    {
-        FooServiceComposite fooService = module.findService( FooServiceComposite.class ).get();
-        Assert.assertEquals( "bar", fooService.configuredFoo() );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/configuration/MailService.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/MailService.java b/core/api/src/test/java/org/apache/zest/api/configuration/MailService.java
deleted file mode 100644
index ff0311e..0000000
--- a/core/api/src/test/java/org/apache/zest/api/configuration/MailService.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.api.configuration;
-
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.library.constraints.annotation.Email;
-import org.apache.zest.library.constraints.annotation.MinLength;
-
-// Documentation Support
-@Mixins( MailService.MailServiceMixin.class )
-public interface MailService
-{
-    void sendMail( @Email String to, @MinLength( 8 ) String subject, String body );
-    
-    // START SNIPPET: write
-    void changeExternalMailService( String hostName, int port );
-    // END SNIPPET: write
-    
-    public class MailServiceMixin
-        implements MailService
-    {
-        // START SNIPPET: read        
-        @This
-        private Configuration<MailServiceConfiguration> config;
-
-        @Override
-        public void sendMail( @Email String to, @MinLength( 8 ) String subject, String body )
-        {
-            config.refresh();
-            MailServiceConfiguration conf = config.get();
-            String hostName = conf.hostName().get();
-            int port = conf.port().get();
-            // END SNIPPET: read
-
-            // START SNIPPET: read        
-        }
-        // END SNIPPET: read        
-
-        // START SNIPPET: write        
-        @Override
-        public void changeExternalMailService( String hostName, int port )
-        {
-            MailServiceConfiguration conf = config.get();
-            conf.hostName().set( hostName );
-            conf.port().set( port );
-            config.save();
-        }
-        // START SNIPPET: write        
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/configuration/MailServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/MailServiceConfiguration.java b/core/api/src/test/java/org/apache/zest/api/configuration/MailServiceConfiguration.java
deleted file mode 100644
index 4129bd4..0000000
--- a/core/api/src/test/java/org/apache/zest/api/configuration/MailServiceConfiguration.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.configuration;
-
-import org.apache.zest.api.property.Property;
-
-// Documentation Support class
-// START SNIPPET: configuration
-public interface MailServiceConfiguration extends ConfigurationComposite
-{
-    Property<String> hostName();
-
-    Property<Integer> port();
-}
-// END SNIPPET: configuration

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java b/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
deleted file mode 100644
index 352edb6..0000000
--- a/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
+++ /dev/null
@@ -1,61 +0,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.
- */
-package org.apache.zest.api.dataset.iterable;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.apache.zest.api.dataset.DataSet;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.test.AbstractQi4jTest;
-
-/**
- * TODO
- */
-@Ignore( "Not implemented yet" )
-public class IterableDataSetTest
-    extends AbstractQi4jTest
-{
-    DataSet<TestValue> dataSet;
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.values( TestValue.class );
-    }
-
-    @Before
-    public void setUp()
-    {
-        dataSet = new IterableDataSet<TestValue>( Iterables.iterable( newTestValue( "Rickard" ), newTestValue( "Niclas" ), newTestValue( "Paul" ) ) );
-    }
-
-    private TestValue newTestValue( String name )
-    {
-        return module.newValueFromSerializedState( TestValue.class, "{name:'" + name + "'}" );
-    }
-
-    interface TestValue
-    {
-        Property<String> name();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/docsupport/ApplicationDocs.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/docsupport/ApplicationDocs.java b/core/api/src/test/java/org/apache/zest/api/docsupport/ApplicationDocs.java
deleted file mode 100644
index 7685a35..0000000
--- a/core/api/src/test/java/org/apache/zest/api/docsupport/ApplicationDocs.java
+++ /dev/null
@@ -1,274 +0,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.
- */
-package org.apache.zest.api.docsupport;
-
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-
-public class ApplicationDocs
-{
-    public static void someMethod( String[] args )
-        throws Exception
-    {
-        {
-// START SNIPPET: application1
-            SingletonAssembler qi4j = new SingletonAssembler()
-            {
-                public void assemble( ModuleAssembly assembly )
-                    throws AssemblyException
-                {
-                    assembly.values( MyStuffValueComposite.class );
-                }
-            };
-// END SNIPPET: application1
-        }
-        {
-            Assembler customerListEditAssembler = new DummyAssembler();
-            Assembler customerEditAssembler = new DummyAssembler();
-            Assembler customerSearchAssembler = new DummyAssembler();
-            Assembler accountsListEditAssembler = new DummyAssembler();
-            Assembler accountsEditAssembler = new DummyAssembler();
-            Assembler accountsSearchAssembler = new DummyAssembler();
-            Assembler customerDomainAssembler = new DummyAssembler();
-            Assembler accountsDomainAssembler = new DummyAssembler();
-// START SNIPPET: application2
-            final Assembler[][][] assemblers =
-                {
-                    { // web layer
-                      { // Customer Module
-                        customerListEditAssembler,
-                        customerEditAssembler,
-                        customerSearchAssembler
-                      },
-                      { // Accounts Module
-                        accountsListEditAssembler,
-                        accountsEditAssembler,
-                        accountsSearchAssembler
-                      }
-                    },
-                    { // domain layer
-                      { // Customer Module
-                        customerDomainAssembler,
-                      },
-                      { // Accounts Module
-                        accountsDomainAssembler,
-                      }
-                    }
-                };
-            Energy4Java qi4j = new Energy4Java();
-            Application app = qi4j.newApplication( new ApplicationAssembler()
-            {
-
-                @Override
-                public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-                    throws AssemblyException
-                {
-                    return applicationFactory.newApplicationAssembly( assemblers );
-                }
-            } );
-            app.activate();
-// END SNIPPET: application2
-        }
-    }
-
-    public interface MyStuffValueComposite
-    {
-    }
-
-    private static class DummyAssembler implements Assembler
-    {
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-
-        }
-    }
-
-    // START SNIPPET: application3
-    private static Energy4Java qi4j;
-
-    public static void main( String[] args )
-        throws Exception
-    {
-        qi4j = new Energy4Java();
-        ApplicationDescriptor model = qi4j.newApplicationModel( new ApplicationAssembler()
-        {
-            @Override
-            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-                throws AssemblyException
-            {
-                return createAssembly( applicationFactory );
-            }
-        } );
-        Application application = model.newInstance( qi4j.spi() );
-    }
-
-    private static ApplicationAssembly createAssembly( ApplicationAssemblyFactory factory )
-        throws AssemblyException
-    {
-        String applicationName = "Example Application";
-        ApplicationAssembly app = factory.newApplicationAssembly();
-        app.setName( applicationName );
-        LayerAssembly webLayer = createWebLayer( app );
-        LayerAssembly domainLayer = createDomainLayer( app );
-        LayerAssembly infraLayer = createInfrastructureLayer( app );
-        webLayer.uses( domainLayer );
-        webLayer.uses( infraLayer );  // Accesses the WebService
-        domainLayer.uses( infraLayer ); // For persistence
-        return app;
-    }
-
-    private static LayerAssembly createWebLayer(
-        ApplicationAssembly application
-    )
-    {
-        LayerAssembly layer = application.layer( "Web Layer" );
-        createCustomerWebModule( layer );
-        return layer;
-    }
-
-    private static LayerAssembly createDomainLayer(
-        ApplicationAssembly application
-    )
-    {
-        LayerAssembly layer = application.layer( "Domain Layer" );
-        createCustomerDomainModule( layer );
-        // :
-        // :
-        return layer;
-    }
-
-    private static LayerAssembly createInfrastructureLayer(
-        ApplicationAssembly application
-    )
-        throws AssemblyException
-    {
-        LayerAssembly layer = application.layer( "Infrastructure Layer" );
-        createWebServiceModule( layer );
-        createPersistenceModule( layer );
-        return layer;
-    }
-
-    private static void createCustomerWebModule( LayerAssembly layer )
-    {
-        ModuleAssembly assembly = layer.module( "Customer Web Module" );
-        assembly.transients( CustomerViewComposite.class );
-        assembly.transients( CustomerEditComposite.class );
-        assembly.transients( CustomerListViewComposite.class );
-        assembly.transients( CustomerSearchComposite.class );
-    }
-
-    private static void createCustomerDomainModule( LayerAssembly layer )
-    {
-        ModuleAssembly assembly = layer.module( "Customer Domain Module" );
-        assembly.entities( CustomerEntity.class );
-        assembly.entities( CountryEntity.class );
-        assembly.transients( AddressComposite.class );
-    }
-
-    private static void createWebServiceModule( LayerAssembly layer )
-        throws AssemblyException
-    {
-        ModuleAssembly assembly = layer.module( "Web Service Module" );
-        // Someone has created an assembler for a Jetty Web Service.
-        JettyAssembler jetty = new JettyAssembler( 8080 );
-        jetty.assemble( assembly );
-    }
-
-    private static void createPersistenceModule( LayerAssembly layer )
-        throws AssemblyException
-    {
-        ModuleAssembly assembly = layer.module( "Persistence Module" );
-        // Someone has created an assembler for the Neo EntityStore
-        NeoAssembler neo = new NeoAssembler( "./neostore" );
-        neo.assemble( assembly );
-    }
-// START SNIPPET: application3
-
-    public static class CustomerViewComposite
-    {
-
-    }
-    public static class CustomerEditComposite
-    {
-
-    }
-    public static class CustomerListViewComposite
-    {
-
-    }
-    public static class CustomerSearchComposite
-    {
-
-    }
-
-
-    public static class CustomerEntity
-    {
-
-    }
-    public static class CountryEntity
-    {
-
-    }
-    public static class AddressComposite
-    {
-
-    }
-
-    public static class JettyAssembler
-        implements Assembler
-    {
-
-        public JettyAssembler( int port )
-        {
-        }
-
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-        }
-    }
-    public static class NeoAssembler
-        implements Assembler
-    {
-
-        public NeoAssembler( String s )
-        {
-        }
-
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/docsupport/CompositionDocs.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/docsupport/CompositionDocs.java b/core/api/src/test/java/org/apache/zest/api/docsupport/CompositionDocs.java
deleted file mode 100644
index 8009677..0000000
--- a/core/api/src/test/java/org/apache/zest/api/docsupport/CompositionDocs.java
+++ /dev/null
@@ -1,56 +0,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.
- */
-package org.apache.zest.api.docsupport;
-
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public class CompositionDocs
-{
-// START SNIPPET: comp1
-    @Mixins( { BalanceCheckMixin.class } )
-    public interface BankAccount
-    {
-        Money checkBalance();
-// END SNIPPET: comp1
-// START SNIPPET: comp1
-    }
-// END SNIPPET: comp1
-
-// START SNIPPET: comp2
-    public void assemble( ModuleAssembly module )
-    {
-        module.entities( BankAccount.class );
-    }
-// END SNIPPET: comp2
-
-    public static class BalanceCheckMixin
-        implements BankAccount
-    {
-        @Override
-        public Money checkBalance()
-        {
-            return null;
-        }
-    }
-
-    public static class Money
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/docsupport/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/docsupport/package.html b/core/api/src/test/java/org/apache/zest/api/docsupport/package.html
deleted file mode 100644
index f6fa115..0000000
--- a/core/api/src/test/java/org/apache/zest/api/docsupport/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-<body>
-This package exists to contain snippets for documentation.
-</body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java b/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
deleted file mode 100644
index 07f98b0..0000000
--- a/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.injection.scope;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-/**
- * Define a field to be a Property
- */
-public class StateFieldTest
-    extends AbstractQi4jTest
-{
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        new EntityTestAssembler().assemble( module );
-        module.entities( PersonEntity.class );
-    }
-
-    @Test
-    public void givenEntityWithFieldPropertiesWhenUpdatedThenReturnCorrect()
-        throws Exception
-    {
-        UnitOfWork unitOfWork = module.newUnitOfWork();
-        try
-        {
-            PersonEntity charles = unitOfWork.newEntity( PersonEntity.class );
-            charles.changeName( "Charles" );
-            Assert.assertEquals( charles.getName(), "Charles" );
-
-            PersonEntity daniel = unitOfWork.newEntity( PersonEntity.class );
-            daniel.changeName( "Daniel" );
-            Assert.assertEquals( daniel.getName(), "Daniel" );
-
-            PersonEntity lisa = unitOfWork.newEntity( PersonEntity.class );
-            lisa.changeName( "Lisa" );
-            Assert.assertEquals( lisa.getName(), "Lisa" );
-
-            charles.befriend( daniel );
-            charles.befriend( lisa );
-            charles.marry( lisa );
-
-            unitOfWork.complete();
-
-            unitOfWork = module.newUnitOfWork();
-
-            charles = unitOfWork.get( charles );
-            daniel = unitOfWork.get( daniel );
-            Assert.assertTrue( charles.isFriend( daniel ) );
-
-            unitOfWork.complete();
-        }
-        finally
-        {
-            unitOfWork.discard();
-        }
-    }
-
-    @Mixins( PersonEntity.Mixin.class )
-    public interface PersonEntity
-        extends EntityComposite
-    {
-        void changeName( String newName );
-
-        void marry( PersonEntity entity );
-
-        void befriend( PersonEntity entity );
-
-        boolean isFriend( PersonEntity entity );
-
-        String getName();
-
-        abstract class Mixin
-            implements PersonEntity
-        {
-            @State
-            @UseDefaults
-            public Property<String> name;
-
-            @State
-            @Optional
-            public Association<PersonEntity> spouse;
-
-            @State
-            public ManyAssociation<PersonEntity> friends;
-
-            @Override
-            public void changeName( String newName )
-            {
-                name.set( newName );
-            }
-
-            @Override
-            public void marry( PersonEntity entity )
-            {
-                spouse.set( entity );
-            }
-
-            @Override
-            public void befriend( PersonEntity entity )
-            {
-                friends.add( entity );
-            }
-
-            @Override
-            public String getName()
-            {
-                return name.get();
-            }
-
-            @Override
-            public boolean isFriend( PersonEntity entity )
-            {
-                return friends.contains( entity );
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/injection/scope/ThisTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/injection/scope/ThisTest.java b/core/api/src/test/java/org/apache/zest/api/injection/scope/ThisTest.java
deleted file mode 100644
index b2e753b..0000000
--- a/core/api/src/test/java/org/apache/zest/api/injection/scope/ThisTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007 Alin Dreghiciu. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Annotation;
-import org.junit.Test;
-import org.apache.zest.api.common.Optional;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests public api exposed by This annotation.
- * This will ensure that the public api does not get changed by mistake.
- */
-public class ThisTest
-{
-
-    @Test
-    public void retention()
-        throws NoSuchFieldException
-    {
-        Annotation[] annotations = Annotated.class.getDeclaredField( "uses" ).getDeclaredAnnotations();
-        assertNotNull( "annotations should not be null", annotations );
-        assertEquals( "number of annotations", 1, annotations.length );
-        assertEquals( "annotation type", This.class, annotations[ 0 ].annotationType() );
-    }
-
-    private static class Annotated
-    {
-        @This
-        String uses;
-        @Optional
-        @This
-        String usesOptional;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/metrics/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/metrics/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/metrics/DocumentationSupport.java
deleted file mode 100644
index 9bba670..0000000
--- a/core/api/src/test/java/org/apache/zest/api/metrics/DocumentationSupport.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import org.apache.zest.api.injection.scope.Service;
-
-public class DocumentationSupport
-{
-    // START SNIPPET: common
-    @Service
-    private MetricsProvider provider;
-    // END SNIPPET: common
-
-    public void forDocumentationOnly()
-    {
-        // START SNIPPET: gauge
-        final BlockingQueue queue = new LinkedBlockingQueue( 20 );
-        // END SNIPPET: gauge
-        // START SNIPPET: gauge
-        MetricsGaugeFactory gaugeFactory = provider.createFactory( MetricsGaugeFactory.class );
-        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( getClass(), "Sample Gauge", new MetricsGauge<Integer>()
-        {
-            @Override
-            public Integer value()
-            {
-                return queue.size();
-            }
-        } );
-        // END SNIPPET: gauge
-
-        // START SNIPPET: counter
-        MetricsCounterFactory counterFactory = provider.createFactory( MetricsCounterFactory.class );
-        MetricsCounter counter = counterFactory.createCounter( getClass(), "Sample Counter" );
-        // END SNIPPET: counter
-
-        // START SNIPPET: histogram
-        MetricsHistogramFactory histoFactory = provider.createFactory( MetricsHistogramFactory.class );
-        MetricsHistogram histogram = histoFactory.createHistogram( getClass(), "Sample Histogram" );
-        // END SNIPPET: histogram
-
-        // START SNIPPET: meter
-        MetricsMeterFactory meterFactory = provider.createFactory( MetricsMeterFactory.class );
-        MetricsMeter meter = meterFactory.createMeter( getClass(), "Sample Meter", "requests", TimeUnit.MINUTES );
-        // END SNIPPET: meter
-
-        // START SNIPPET: timer
-        MetricsTimerFactory timerFactory = provider.createFactory( MetricsTimerFactory.class );
-        MetricsTimer timer = timerFactory.createTimer( getClass(), "Sample Timer", TimeUnit.SECONDS, TimeUnit.HOURS );
-        // END SNIPPET: timer
-
-        // START SNIPPET: healthcheck
-        MetricsHealthCheckFactory healthFactory = provider.createFactory( MetricsHealthCheckFactory.class );
-        MetricsHealthCheck healthCheck = healthFactory.registerHealthCheck(
-            getClass(),
-            "Sample Healthcheck",
-            new MetricsHealthCheck()
-            {
-                @Override
-                public Result check()
-                    throws Exception
-                {
-                    ServiceStatus status = pingMyService();
-                    return new Result( status.isOk(), status.getErrorMessage(), status.getException() );
-                }
-            } );
-        // END SNIPPET: healthcheck
-
-    }
-
-    private ServiceStatus pingMyService()
-    {
-        return new ServiceStatus();
-    }
-
-    private static class ServiceStatus
-    {
-        String errorMessage;
-        Exception exception;
-
-        public String getErrorMessage()
-        {
-            return errorMessage;
-        }
-
-        public Exception getException()
-        {
-            return exception;
-        }
-
-        public boolean isOk()
-        {
-            return errorMessage.equals( "OK" );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/BankAccount.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/BankAccount.java b/core/api/src/test/java/org/apache/zest/api/mixin/BankAccount.java
deleted file mode 100644
index 65de035..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/BankAccount.java
+++ /dev/null
@@ -1,30 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-
-// START SNIPPET: mixinType
-public interface BankAccount
-{
-    Money checkBalance();
-}
-// END SNIPPET: mixinType
-
-class Money {}
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/Car.java b/core/api/src/test/java/org/apache/zest/api/mixin/Car.java
deleted file mode 100644
index 7bbc83a..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/Car.java
+++ /dev/null
@@ -1,26 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-// START SNIPPET: mixins
-@Mixins( { StartMixin.class, VehicleMixin.class } )
-public interface Car extends Startable, Vehicle
-{}
-// END SNIPPET: mixins
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/Something.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/Something.java b/core/api/src/test/java/org/apache/zest/api/mixin/Something.java
deleted file mode 100644
index 8597cc2..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/Something.java
+++ /dev/null
@@ -1,27 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-// START SNIPPET: something
-@Mixins( SomethingMixin.class )
-public interface Something
-{}
-// END SNIPPET: something
-
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/SomethingMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/SomethingMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/SomethingMixin.java
deleted file mode 100644
index d623625..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/SomethingMixin.java
+++ /dev/null
@@ -1,32 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-// START SNIPPET: something
-public class SomethingMixin
-        implements Something
-{
-    // State is allowed.
-
-    public void doSomething()
-    {
-        // do stuff...
-    }
-}
-// END SNIPPET: something


[38/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/ConcernDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/ConcernDescriptor.java b/core/api/src/main/java/org/qi4j/api/concern/ConcernDescriptor.java
new file mode 100644
index 0000000..a98adf7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/ConcernDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.concern;
+
+/**
+ * Concern descriptor.
+ */
+public interface ConcernDescriptor
+{
+    Class modifierClass();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/ConcernOf.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/ConcernOf.java b/core/api/src/main/java/org/qi4j/api/concern/ConcernOf.java
new file mode 100644
index 0000000..33cdd01
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/ConcernOf.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.concern;
+
+import org.qi4j.api.concern.internal.ConcernFor;
+
+/**
+ * Base class for Concerns. It introduces a typed "next" pointer
+ * that Concerns can use to invoke the next Concern (or mixin) in
+ * the chain.
+ * <p>
+ * Generic Concerns should subclass {@link GenericConcern} instead.
+ * </p>
+ * <p>
+ * Concerns implementations must be thread-safe in their implementation,
+ * as multiple threads may share instances.
+ * </p>
+ */
+public abstract class ConcernOf<T>
+{
+    /**
+     * The "next" pointer. This points to
+     * the next concern in the chain or the mixin
+     * to be invoked.
+     */
+    final
+    @ConcernFor
+    protected T next = null;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/Concerns.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/Concerns.java b/core/api/src/main/java/org/qi4j/api/concern/Concerns.java
new file mode 100644
index 0000000..9213035
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/Concerns.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.concern;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used by composites and mixins to declare what Concerns
+ * should be applied to the type or specific method.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Concerns
+{
+    Class<?>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/ConcernsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/ConcernsDescriptor.java b/core/api/src/main/java/org/qi4j/api/concern/ConcernsDescriptor.java
new file mode 100644
index 0000000..dd9a91b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/ConcernsDescriptor.java
@@ -0,0 +1,24 @@
+/*  Copyright 2008 Edward Yakop.
+*
+* 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.qi4j.api.concern;
+
+/**
+ * Concerns descriptor.
+ */
+public interface ConcernsDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/GenericConcern.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/GenericConcern.java b/core/api/src/main/java/org/qi4j/api/concern/GenericConcern.java
new file mode 100644
index 0000000..2986ff8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/GenericConcern.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.concern;
+
+import java.lang.reflect.InvocationHandler;
+
+/**
+ * Base class for generic Concerns. Subclass
+ * and implement the "invoke" method. Use the
+ * "next" field in {@link ConcernOf} to continue the invocation
+ * chain.
+ */
+public abstract class GenericConcern
+    extends ConcernOf<InvocationHandler>
+    implements InvocationHandler
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/internal/ConcernFor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/internal/ConcernFor.java b/core/api/src/main/java/org/qi4j/api/concern/internal/ConcernFor.java
new file mode 100644
index 0000000..de3e1b4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/internal/ConcernFor.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.concern.internal;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * This annotation is required once in each Concern, to mark the
+ * field where the next element in the call sequence should be
+ * injected.
+ * <p>
+ * The type of the field must be of the same type as the Concern
+ * itself, or an InvocationHandler.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ * public interface MyStuff
+ * {
+ *     void doSomething();
+ * }
+ *
+ * public class MyStuffConcern
+ *     implements MyStuff
+ * {
+ *     &#64;ConcernFor MyStuff next;
+ *
+ *     public void doSomething()
+ *     {
+ *         // HERE DO THE MODIFIER STUFF.
+ *
+ *         // Delegate to the underlying mixin/modifier.
+ *         next.doSomething();
+ *     }
+ * }
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface ConcernFor
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/internal/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/internal/package.html b/core/api/src/main/java/org/qi4j/api/concern/internal/package.html
new file mode 100644
index 0000000..9351f10
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/internal/package.html
@@ -0,0 +1,25 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h1>Internal/Private package for the Concern API.</h1>
+        <p>
+            This is an internal package, and no classes in this package is part of the API and compatibility
+            with these classes will not be attempted.
+        </p>
+    </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/concern/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/concern/package.html b/core/api/src/main/java/org/qi4j/api/concern/package.html
new file mode 100644
index 0000000..fcc7ef7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/concern/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Concern API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/configuration/Configuration.java b/core/api/src/main/java/org/qi4j/api/configuration/Configuration.java
new file mode 100644
index 0000000..77c373d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/configuration/Configuration.java
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.api.configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.PropertyMapper;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.EntityBuilder;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.injection.scope.Service;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.api.service.ServiceDescriptor;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.api.service.qualifier.ServiceTags;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.unitofwork.EntityTypeNotFoundException;
+import org.qi4j.api.unitofwork.NoSuchEntityException;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.unitofwork.UnitOfWorkCompletionException;
+import org.qi4j.api.usecase.Usecase;
+import org.qi4j.api.usecase.UsecaseBuilder;
+import org.qi4j.api.value.ValueSerialization;
+
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Provide Configurations for Services. A Service that wants to be configurable
+ * should inject a reference to Configuration with the Configuration type:
+ * <pre><code>
+ *  * &#64;This Configuration&#60;MyServiceConfiguration&#62; config;
+ * </code></pre>
+ * <p>
+ * where MyServiceConfiguration extends {@link ConfigurationComposite}, which itself is an ordinary
+ * {@link org.qi4j.api.entity.EntityComposite}. The Configuration implementation
+ * will either locate an instance of the given Configuration type in the
+ * persistent store using the identity of the Service, or create a new such instance
+ * if one doesn't already exist.
+ * </p>
+ * <p>
+ * If a new Configuration instance is created then it will be populated with properties
+ * from the properties file whose filesystem name is the same as the identity (e.g. "MyService.properties").
+ * If a service is not given a name via the {@code org.qi4j.bootstrap.ServiceDeclaration#identifiedBy(String)}, the
+ * name will default to the FQCN of the ServiceComposite type.
+ * </p>
+ * <p>
+ * The Configuration instance can be modified externally just like any other EntityComposite, but
+ * its values will not be updated in the Service until {@link #refresh()} is called. This allows
+ * safe reloads of Configuration state to ensure that it is not reloaded while the Service is handling
+ * a request.
+ * </p>
+ * <p>
+ * The Configuration will be automatically refreshed when the Service is activated by the Zest runtime.
+ * Any refreshes at other points will have to be done manually or triggered through some other
+ * mechanism.
+ * </p>
+ * <p>
+ * The user configuration entity is part of a long running {@link UnitOfWork}, and to persist changes to it the
+ * {@link #save()} method must be called. No other actions are required. Example;
+ * </p>
+ * <pre><code>
+ *
+ * public interface MyConfiguration extends ConfigurationComposite
+ * {
+ *     Property&lt;Long&gt; timeout();
+ * }
+ *
+ * :
+ *
+ * &#64;This Configuration&lt;MyConfiguration&gt; config;
+ * :
+ * private void setTimeoutConfiguration( long timeout )
+ * {
+ *     config.get().timeout().set( timeout );
+ *     config.save();
+ * }
+ * </code></pre>
+ * <p>
+ * And even if a separate thread is using the {@code timeout()} configuration when this is happening, the
+ * {@link UnitOfWork} isolation will ensure that the other thread is not affected. That thread, on the other hand
+ * will need to do a {@link #refresh()} at an appropriate time to pick up the timeout change. For instance;
+ * </p>
+ * <pre><code>
+ *
+ * &#64;Service InventoryService remoteInventoryService;
+ *
+ * public void restockInventoryItem( InventoryItemId id, int itemCount )
+ * {
+ *     config.refresh();
+ *     long timeout = config.get().timeout().get();
+ *
+ *     remoteInventoryService.restock( id, itemCount, timeout );
+ *
+ *     :
+ *     :
+ * }
+ * </code></pre>
+ */
+@SuppressWarnings( "JavadocReference" )
+@Mixins( Configuration.ConfigurationMixin.class )
+public interface Configuration<T>
+{
+    /**
+     * Retrieves the user configuration instance managed by this Configuration.
+     * <p>
+     * Even if the user configuration is initialized from properties file, the consistency rules of Zest composites
+     * still applies. If the the properties file is missing a value, then the initialization will fail with a
+     * RuntimeException. If Constraints has been defined, those will need to be satisfied as well. The user
+     * configuration instance returned will fulfill the constraints and consistency normal to all composites, and
+     * can therefor safely be used with additional checks.
+     * </p>
+     *
+     * @return The fully initialized and ready-to-use user configuration instance.
+     */
+    T get();
+
+    /**
+     * Updates the values of the managed user ConfigurationComposite instance from the underlying
+     * {@code org.qi4j.spi.entitystore.EntityStore}.  Any modified values in the current user configuration that
+     * has not been saved, via {@link #save()} method, will be lost.
+     */
+    void refresh();
+
+    /**
+     * Persists the modified values in the user configuration instance to the underlying store.
+     */
+    void save();
+
+    /**
+     * Implementation of Configuration.
+     * <p>
+     * This is effectively an internal class in Zest and should never be used directly by user code.
+     * </p>
+     *
+     * @param <T>
+     */
+    public class ConfigurationMixin<T>
+        implements Configuration<T>
+    {
+        private T configuration;
+        private UnitOfWork uow;
+
+        @Structure
+        private Qi4j api;
+
+        @This
+        private ServiceComposite me;
+
+        @Structure
+        private Module module;
+
+        @Service
+        private Iterable<ServiceReference<ValueSerialization>> valueSerialization;
+
+        public ConfigurationMixin()
+        {
+        }
+
+        @Override
+        public synchronized T get()
+        {
+            if( configuration == null )
+            {
+                Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
+                uow = module.newUnitOfWork( usecase );
+                try
+                {
+                    configuration = this.findConfigurationInstanceFor( me, uow );
+                }
+                catch( InstantiationException e )
+                {
+                    throw new IllegalStateException( e );
+                }
+            }
+
+            return configuration;
+        }
+
+        @Override
+        public synchronized void refresh()
+        {
+            if( configuration != null )
+            {
+                configuration = null;
+                uow.discard();
+                uow = null;
+            }
+        }
+
+        @Override
+        public void save()
+        {
+            if( uow != null )
+            {
+                try
+                {
+                    uow.complete();
+                    uow = null;
+                }
+                catch( UnitOfWorkCompletionException e )
+                {
+                    // Should be impossible
+                    e.printStackTrace();
+                }
+
+                configuration = null; // Force refresh
+            }
+        }
+
+        @SuppressWarnings( "unchecked" )
+        public <V> V findConfigurationInstanceFor( ServiceComposite serviceComposite, UnitOfWork uow )
+            throws InstantiationException
+        {
+            ServiceDescriptor serviceModel = api.serviceDescriptorFor( serviceComposite );
+
+            String identity = serviceComposite.identity().get();
+            V configuration;
+            try
+            {
+                configuration = uow.get( serviceModel.<V>configurationType(), identity );
+                uow.pause();
+            }
+            catch( NoSuchEntityException | EntityTypeNotFoundException e )
+            {
+                return (V) initializeConfigurationInstance( serviceComposite, uow, serviceModel, identity );
+            }
+            return configuration;
+        }
+
+        @SuppressWarnings( "unchecked" )
+        private <V extends Identity> V initializeConfigurationInstance( ServiceComposite serviceComposite,
+                                                                        UnitOfWork uow,
+                                                                        ServiceDescriptor serviceModel,
+                                                                        String identity
+        )
+            throws InstantiationException
+        {
+            Module module = api.moduleOf( serviceComposite );
+            Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
+            UnitOfWork buildUow = module.newUnitOfWork( usecase );
+
+            Class<?> type = first( api.serviceDescriptorFor( serviceComposite ).types() );
+            Class<V> configType = serviceModel.configurationType();
+
+            // Check for defaults
+            V config = tryLoadPropertiesFile( buildUow, type, configType, identity );
+            if( config == null )
+            {
+                config = tryLoadJsonFile( buildUow, type, configType, identity );
+                if( config == null )
+                {
+                    config = tryLoadYamlFile( buildUow, type, configType, identity );
+                    if( config == null )
+                    {
+                        config = tryLoadXmlFile( buildUow, type, configType, identity );
+                        if( config == null )
+                        {
+                            try
+                            {
+                                EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( serviceModel.<V>configurationType(), identity );
+                                configBuilder.newInstance();
+                            }
+                            catch( ConstraintViolationException e )
+                            {
+                                throw new NoSuchConfigurationException( configType, identity, e );
+                            }
+                        }
+                    }
+                }
+            }
+
+            try
+            {
+                buildUow.complete();
+
+                // Try again
+                return (V) findConfigurationInstanceFor( serviceComposite, uow );
+            }
+            catch( Exception e1 )
+            {
+                InstantiationException ex = new InstantiationException(
+                    "Could not instantiate configuration, and no configuration initialization file was found (" + identity + ")" );
+                ex.initCause( e1 );
+                throw ex;
+            }
+        }
+
+        private <C, V> V tryLoadPropertiesFile( UnitOfWork buildUow,
+                                                Class<C> compositeType,
+                                                Class<V> configType,
+                                                String identity
+        )
+            throws InstantiationException
+        {
+            EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( configType, identity );
+            String resourceName = identity + ".properties";
+            InputStream asStream = getResource( compositeType, resourceName );
+            if( asStream != null )
+            {
+                try
+                {
+                    PropertyMapper.map( asStream, (Composite) configBuilder.instance() );
+                    return configBuilder.newInstance();
+                }
+                catch( IOException e1 )
+                {
+                    InstantiationException exception = new InstantiationException(
+                        "Could not read underlying Properties file." );
+                    exception.initCause( e1 );
+                    throw exception;
+                }
+            }
+            return null;
+        }
+
+        private InputStream getResource( Class<?> type, String resourceName )
+        {
+            // Load defaults from classpath root if available
+            if( type.getResource( resourceName ) == null && type.getResource( "/" + resourceName ) != null )
+            {
+                resourceName = "/" + resourceName;
+            }
+            return type.getResourceAsStream( resourceName );
+        }
+
+        private <C, V extends Identity> V tryLoadJsonFile( UnitOfWork uow,
+                                                           Class<C> compositeType,
+                                                           Class<V> configType,
+                                                           String identity
+        )
+        {
+            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.JSON, ".json" );
+        }
+
+        private <C, V extends Identity> V tryLoadYamlFile( UnitOfWork uow,
+                                                           Class<C> compositeType,
+                                                           Class<V> configType,
+                                                           String identity
+        )
+        {
+            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.YAML, ".yaml" );
+        }
+
+        private <C, V extends Identity> V tryLoadXmlFile( UnitOfWork uow,
+                                                          Class<C> compositeType,
+                                                          Class<V> configType,
+                                                          String identity
+        )
+        {
+            return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.XML, ".xml" );
+        }
+
+        private <C, V extends Identity> V readConfig( UnitOfWork uow,
+                                                      Class<C> compositeType,
+                                                      Class<V> configType,
+                                                      String identity,
+                                                      String format,
+                                                      String extension
+        )
+        {
+            for( ServiceReference<ValueSerialization> serializerRef : valueSerialization )
+            {
+                ServiceTags serviceTags = serializerRef.metaInfo( ServiceTags.class );
+                if( serviceTags.hasTag( format ) )
+                {
+                    String resourceName = identity + extension;
+                    InputStream asStream = getResource( compositeType, resourceName );
+                    if( asStream != null )
+                    {
+                        V configObject = serializerRef.get().deserialize( configType, asStream );
+                        return uow.toEntity( configType, configObject );
+                    }
+                }
+            }
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/configuration/ConfigurationComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/configuration/ConfigurationComposite.java b/core/api/src/main/java/org/qi4j/api/configuration/ConfigurationComposite.java
new file mode 100644
index 0000000..39fb149
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/configuration/ConfigurationComposite.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.configuration;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.entity.Queryable;
+
+/**
+ * Services that want to be configurable should have a ConfigurationComposite that contains all the settings.
+ * They are treated as EntityComposites, and are therefore stored in an EntityStore. There will be one instance
+ * per service instance that uses each ConfigurationComposite, and the identity of the entity is the same as that
+ * of the service.
+ */
+@Queryable( false )
+public interface ConfigurationComposite
+    extends Identity, Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/configuration/Enabled.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/configuration/Enabled.java b/core/api/src/main/java/org/qi4j/api/configuration/Enabled.java
new file mode 100644
index 0000000..19a2c29
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/configuration/Enabled.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.api.configuration;
+
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.property.Property;
+
+/**
+ * Common configuration for setting whether a service is enabled or not. A disabled service
+ * is not considered to be available. Let your own ConfigurationComposite extend this interface to use.
+ */
+public interface Enabled
+{
+    @UseDefaults
+    Property<Boolean> enabled();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/configuration/NoSuchConfigurationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/configuration/NoSuchConfigurationException.java b/core/api/src/main/java/org/qi4j/api/configuration/NoSuchConfigurationException.java
new file mode 100644
index 0000000..b3d3ed1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/configuration/NoSuchConfigurationException.java
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.qi4j.api.configuration;
+
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.Identity;
+
+public class NoSuchConfigurationException extends RuntimeException
+{
+    private final Class<? extends Identity> configType;
+    private final String identity;
+
+    public NoSuchConfigurationException( Class<? extends Identity> configType,
+                                         String identity,
+                                         ConstraintViolationException cause
+    )
+    {
+        super( "No configuration found for '" + identity + "' and configuration " + configType.getName() + " has one or more non-Optional properties.", cause );
+        this.configType = configType;
+        this.identity = identity;
+    }
+
+    public Class<? extends Identity> configType()
+    {
+        return configType;
+    }
+
+    public String identity()
+    {
+        return identity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/configuration/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/configuration/package.html b/core/api/src/main/java/org/qi4j/api/configuration/package.html
new file mode 100644
index 0000000..7f8a892
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/configuration/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Configuration API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/Constraint.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/Constraint.java b/core/api/src/main/java/org/qi4j/api/constraint/Constraint.java
new file mode 100644
index 0000000..8e53e0e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/Constraint.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.constraint;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/**
+ * All Constraints must implement this interface, which is used for each
+ * value validation.
+ */
+public interface Constraint<ANNOTATION extends Annotation, TYPE>
+    extends Serializable
+{
+    /**
+     * For each value or parameter which should be checked this method will be invoked.
+     * If the method returns true the value is valid. If it returns false the value
+     * is considered invalid. When all constraints have been checked a ConstraintViolationException
+     * will be thrown with all the constraint violations that were found.
+     *
+     * @param annotation the annotation to match
+     * @param value      the value to be checked
+     *
+     * @return true if valid, false if invalid
+     */
+    boolean isValid( ANNOTATION annotation, TYPE value );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDeclaration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDeclaration.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDeclaration.java
new file mode 100644
index 0000000..7ca9249
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDeclaration.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.constraint;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * All annotations that are used to trigger Constraints must have this annotation.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.ANNOTATION_TYPE )
+@Documented
+public @interface ConstraintDeclaration
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDescriptor.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDescriptor.java
new file mode 100644
index 0000000..ff5e5a6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.constraint;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Constraint Descriptor.
+ */
+public interface ConstraintDescriptor
+{
+    Annotation annotation();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintImplementationNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintImplementationNotFoundException.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintImplementationNotFoundException.java
new file mode 100644
index 0000000..e27ef94
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintImplementationNotFoundException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.constraint;
+
+import org.qi4j.api.common.InvalidApplicationException;
+
+/**
+ * This exception is thrown if a Constraint implementation can not be found.
+ */
+public class ConstraintImplementationNotFoundException
+    extends InvalidApplicationException
+{
+    public ConstraintImplementationNotFoundException( String message )
+    {
+        super( message );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolation.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolation.java
new file mode 100644
index 0000000..09c4be0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolation.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.constraint;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/**
+ * When a constraint violation has occurred (ie Constraint.isValid has returned false) it
+ * is put in a collection of all violations that have occurred for this value check.
+ */
+public final class ConstraintViolation
+    implements Serializable
+{
+    private String name;
+    private final Annotation constraint;
+    private final Object value;
+
+    public ConstraintViolation( String name, Annotation constraint, Object value )
+    {
+        this.name = name;
+        this.constraint = constraint;
+        this.value = value;
+    }
+
+    public String name()
+    {
+        return name;
+    }
+
+    public Annotation constraint()
+    {
+        return constraint;
+    }
+
+    public Object value()
+    {
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolationException.java
new file mode 100644
index 0000000..28e41b3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintViolationException.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.constraint;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+
+/**
+ * This Exception is thrown when there is one or more Constraint Violations in a method
+ * call.
+ * <p>
+ * The Constraint Violations are aggregated per method, and this exception will contain those
+ * violations, together with the Composite instance it happened on as well as the Method that
+ * was invoked. The Exception also has support for localized messages of these violations.
+ * </p>
+ */
+public class ConstraintViolationException
+    extends IllegalArgumentException
+{
+    private static final long serialVersionUID = 1L;
+
+    private final Collection<ConstraintViolation> constraintViolations;
+    private String methodName;
+    private String mixinTypeName;
+    private String instanceToString;
+    private Iterable<Class<?>> instanceTypes;
+
+    public ConstraintViolationException( Composite instance, Member method,
+                                         Collection<ConstraintViolation> constraintViolations
+    )
+    {
+        this( instance.toString(), Qi4j.FUNCTION_DESCRIPTOR_FOR.map( instance ).types(), method, constraintViolations );
+    }
+
+    public ConstraintViolationException( String instanceToString,
+                                         Iterable<Class<?>> instanceTypes,
+                                         Member method,
+                                         Collection<ConstraintViolation> violations
+    )
+    {
+        this.instanceToString = instanceToString;
+        this.instanceTypes = instanceTypes;
+        mixinTypeName = method.getDeclaringClass().getName();
+        methodName = method.getName();
+        this.constraintViolations = violations;
+    }
+
+    public ConstraintViolationException( String instanceToString,
+                                         Iterable<Class<?>> instanceTypes,
+                                         String mixinTypeName,
+                                         String methodName,
+                                         Collection<ConstraintViolation> violations
+    )
+    {
+        this.instanceToString = instanceToString;
+        this.instanceTypes = instanceTypes;
+        this.mixinTypeName = mixinTypeName;
+        this.methodName = methodName;
+        this.constraintViolations = violations;
+    }
+
+    public Collection<ConstraintViolation> constraintViolations()
+    {
+        return constraintViolations;
+    }
+
+    /**
+     * Creates localized messages of all the constraint violations that has occured.
+     * <p>
+     * The key "<code>Qi4j_ConstraintViolation_<i><strong>CompositeType</strong></i></code>" will be used to lookup the text formatting
+     * pattern from the ResourceBundle, where <strong><code><i>CompositeType</i></code></strong> is the
+     * class name of the Composite where the constraint was violated. If such key does not exist, then the
+     * key &nbsp;"<code>Qi4j_ConstraintViolation</code>" will be used, and if that one also doesn't exist, or
+     * the resourceBundle argument is null, then the default patterns will be used;
+     * </p>
+     * <table summary="Localization of constraint vioations.">
+     * <tr><th>Type of Composite</th><th>Pattern used</th></tr>
+     * <tr><td>Composite</td>
+     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1}</code></td>
+     * </tr>
+     * <tr><td>EntityComposite</td>
+     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}]</code></td>
+     * </tr>
+     * <tr><td>ServiceComposite</td>
+     * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in service {0}</code></td>
+     * </tr>
+     * </table>
+     * Then format each ConstraintViolation according to such pattern, where the following argument are passed;
+     * <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr>
+     * <tr>
+     * <td>{0}</td>
+     * <td>Composite instance toString()</td>
+     * </tr>
+     * <tr>
+     * <td>{1}</td>
+     * <td>CompositeType class name</td>
+     * </tr>
+     * <tr>
+     * <td>{2}</td>
+     * <td>MixinType class name</td>
+     * </tr>
+     * <tr>
+     * <td>{3}</td>
+     * <td>MixinType method name</td>
+     * </tr>
+     * <tr>
+     * <td>{4}</td>
+     * <td>Annotation toString()</td>
+     * </tr>
+     * <tr>
+     * <td>{5}</td>
+     * <td>toString() of value passed as the argument, or "null" text if argument was null.</td>
+     * </tr>
+     * </table>
+     * <p>
+     * <b>NOTE!!!</b> This class is still under construction and will be modified further.
+     * </p>
+     *
+     * @param bundle The ResourceBundle for Localization, or null if default formatting and locale to be used.
+     *
+     * @return An array of localized messages of the violations incurred.
+     */
+    public String[] localizedMessagesFrom( ResourceBundle bundle )
+    {
+        String pattern = "Constraint violation in {0}.{1} for method ''{3}'' with constraint \"{4}({6})\", for value ''{5}''";
+
+        ArrayList<String> list = new ArrayList<String>();
+        for( ConstraintViolation violation : constraintViolations )
+        {
+            Locale locale;
+            if( bundle != null )
+            {
+                try
+                {
+                    pattern = bundle.getString( "qi4j.constraint." + mixinTypeName + "." + methodName );
+                }
+                catch( MissingResourceException e1 )
+                {
+                    try
+                    {
+                        pattern = bundle.getString( "qi4j.constraint" );
+                    }
+                    catch( MissingResourceException e2 )
+                    {
+                        // ignore. The default pattern will be used.
+                    }
+                }
+                locale = bundle.getLocale();
+            }
+            else
+            {
+                locale = Locale.getDefault();
+            }
+            MessageFormat format = new MessageFormat( pattern, locale );
+
+            Annotation annotation = violation.constraint();
+            String name = violation.name();
+            Object value = violation.value();
+            String classes;
+            if( Iterables.count( instanceTypes ) == 1 )
+            {
+                classes = Iterables.first( instanceTypes ).getSimpleName();
+            }
+            else
+            {
+                classes = "[" + Iterables.<Class<?>>toString( instanceTypes, new Function<Class<?>, String>()
+                {
+                    @Override
+                    public String map( Class<?> from )
+                    {
+                        return from.getSimpleName();
+                    }
+                }, "," ) + "]";
+            }
+            Object[] args = new Object[]
+                {
+                    instanceToString,
+                    classes,
+                    mixinTypeName,
+                    methodName,
+                    annotation.toString(),
+                    "" + value,
+                    name
+                };
+            StringBuffer text = new StringBuffer();
+            format.format( args, text, null );
+            list.add( text.toString() );
+        }
+        String[] result = new String[ list.size() ];
+        list.toArray( result );
+        return result;
+    }
+
+    public String localizedMessage()
+    {
+        String[] messages = localizedMessagesFrom( null );
+        StringBuilder result = new StringBuilder();
+        boolean first = true;
+        for( String message : messages )
+        {
+            if( !first )
+            {
+                result.append( ',' );
+            }
+            first = false;
+            result.append( message );
+        }
+        return result.toString();
+    }
+
+    @Override
+    public String getLocalizedMessage()
+    {
+        return localizedMessage();
+    }
+
+    @Override
+    public String getMessage()
+    {
+        return localizedMessage();
+    }
+
+    public String methodName()
+    {
+        return methodName;
+    }
+
+    public String mixinTypeName()
+    {
+        return mixinTypeName;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/Constraints.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/Constraints.java b/core/api/src/main/java/org/qi4j/api/constraint/Constraints.java
new file mode 100644
index 0000000..b42701c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/Constraints.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.constraint;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used by composites and mixins to declare what Constraints
+ * can be applied in the Composite.
+ * <p>
+ * Constraints implement the {@link Constraint} interface
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE } )
+@Documented
+public @interface Constraints
+{
+    Class<? extends Constraint<?, ?>>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/ConstraintsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/ConstraintsDescriptor.java b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintsDescriptor.java
new file mode 100644
index 0000000..bea1115
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/ConstraintsDescriptor.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.constraint;
+
+/**
+ * Constraints Descriptor.
+ */
+public interface ConstraintsDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/Name.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/Name.java b/core/api/src/main/java/org/qi4j/api/constraint/Name.java
new file mode 100644
index 0000000..fc4c79e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/Name.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.constraint;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation for parameter names. This is used to add extra information for constraint exception.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.PARAMETER } )
+@Documented
+public @interface Name
+{
+    String value();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/constraint/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/constraint/package.html b/core/api/src/main/java/org/qi4j/api/constraint/package.html
new file mode 100644
index 0000000..2e4d340
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/constraint/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Constraint API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/DataSet.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/DataSet.java b/core/api/src/main/java/org/qi4j/api/dataset/DataSet.java
new file mode 100644
index 0000000..2e4bdc3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/DataSet.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.api.dataset;
+
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Specification;
+
+/**
+ * definition.constrain(entity(Person.class))
+ * builder.from(path(Person.class,Movie.))
+ * TODO
+ */
+public interface DataSet<T>
+{
+    DataSet<T> constrain( Specification<T> selection );
+
+    <U> DataSet<U> project( Function<T, U> conversion );
+
+    Query<T> newQuery();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/DataSetSource.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/DataSetSource.java b/core/api/src/main/java/org/qi4j/api/dataset/DataSetSource.java
new file mode 100644
index 0000000..4cf68f1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/DataSetSource.java
@@ -0,0 +1,27 @@
+/*
+ * 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.qi4j.api.dataset;
+
+/**
+ * TODO
+ */
+public interface DataSetSource
+{
+    <T> DataSet<T> newDataSet( Class<T> type );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/Query.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/Query.java b/core/api/src/main/java/org/qi4j/api/dataset/Query.java
new file mode 100644
index 0000000..61edd73
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/Query.java
@@ -0,0 +1,64 @@
+/*
+ * 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.qi4j.api.dataset;
+
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.QueryException;
+import org.qi4j.api.query.QueryExecutionException;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Visitor;
+
+/**
+ * TODO
+ */
+public interface Query<T>
+{
+    public enum Order
+    {
+        ASCENDING, DESCENDING
+    }
+
+    Query filter( Specification<T> filter );
+
+    Query orderBy( final Property<?> property, final Order order );
+
+    Query skip( int skipNrOfResults );
+
+    Query limit( int maxNrOfResults );
+
+    // Variables
+    Query<T> setVariable( String name, Object value );
+
+    Object getVariable( String name );
+
+    long count()
+        throws QueryExecutionException;
+
+    T first()
+        throws QueryExecutionException;
+
+    T single()
+        throws QueryException;
+
+    <ThrowableType extends Throwable> boolean execute( Visitor<T, ThrowableType> resultVisitor )
+        throws ThrowableType, QueryExecutionException;
+
+    Iterable<T> toIterable()
+        throws QueryExecutionException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableDataSet.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableDataSet.java b/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableDataSet.java
new file mode 100644
index 0000000..3300ea4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableDataSet.java
@@ -0,0 +1,57 @@
+/*
+ * 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.qi4j.api.dataset.iterable;
+
+import org.qi4j.api.dataset.DataSet;
+import org.qi4j.api.dataset.Query;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+/**
+ * TODO
+ */
+public class IterableDataSet<T>
+    implements DataSet<T>
+{
+    private Iterable<T> iterable;
+
+    public IterableDataSet( Iterable<T> iterable )
+    {
+        this.iterable = iterable;
+    }
+
+    @Override
+    public DataSet<T> constrain( Specification<T> selection )
+    {
+        return new IterableDataSet<T>( Iterables.filter( selection, iterable ) );
+    }
+
+    @Override
+    public <U> DataSet<U> project( Function<T, U> conversion )
+    {
+        return new IterableDataSet<U>( Iterables.map( conversion, iterable ) );
+    }
+
+    @Override
+    public Query<T> newQuery()
+    {
+        return new IterableQuery<T>( iterable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableQuery.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableQuery.java b/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableQuery.java
new file mode 100644
index 0000000..b816a25
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/iterable/IterableQuery.java
@@ -0,0 +1,127 @@
+/*
+ * 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.qi4j.api.dataset.iterable;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.qi4j.api.dataset.Query;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.QueryException;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Visitor;
+
+/**
+ * TODO
+ */
+public class IterableQuery<T> implements Query<T>
+{
+    private Iterable<T> iterable;
+    private int skip;
+    private int limit;
+    private Map<String, Object> variables = new HashMap<String, Object>();
+
+    public IterableQuery( Iterable<T> iterable )
+    {
+        this.iterable = iterable;
+    }
+
+    @Override
+    public Query filter( Specification<T> filter )
+    {
+        iterable = Iterables.filter( filter, iterable );
+
+        return this;
+    }
+
+    @Override
+    public Query orderBy( Property<?> property, Order order )
+    {
+        return this;
+    }
+
+    @Override
+    public Query skip( int skipNrOfResults )
+    {
+        this.skip = skipNrOfResults;
+
+        return this;
+    }
+
+    @Override
+    public Query limit( int maxNrOfResults )
+    {
+        this.limit = maxNrOfResults;
+        return this;
+    }
+
+    @Override
+    public Query<T> setVariable( String name, Object value )
+    {
+        variables.put( name, value );
+        return this;
+    }
+
+    @Override
+    public Object getVariable( String name )
+    {
+        return variables.get( name );
+    }
+
+    @Override
+    public long count()
+    {
+        return Iterables.count( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
+    }
+
+    @Override
+    public T first()
+    {
+        return Iterables.first( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
+    }
+
+    @Override
+    public T single()
+        throws QueryException
+    {
+        return Iterables.single( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean execute( Visitor<T, ThrowableType> resultVisitor )
+        throws ThrowableType
+    {
+        for( T t : toIterable() )
+        {
+            if( !resultVisitor.visit( t ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    public Iterable<T> toIterable()
+        throws QueryException
+    {
+        return Iterables.limit( limit, Iterables.skip( skip, iterable ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/iterable/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/iterable/package.html b/core/api/src/main/java/org/qi4j/api/dataset/iterable/package.html
new file mode 100644
index 0000000..9874cb5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/iterable/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Iterable DataSets.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/dataset/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/dataset/package.html b/core/api/src/main/java/org/qi4j/api/dataset/package.html
new file mode 100644
index 0000000..f324682
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/dataset/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>DataSet API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/Aggregated.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/Aggregated.java b/core/api/src/main/java/org/qi4j/api/entity/Aggregated.java
new file mode 100644
index 0000000..11e4ba5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/Aggregated.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.entity;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks an association as aggregating the referenced Entities
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.METHOD } )
+@Documented
+public @interface Aggregated
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/EntityBuilder.java b/core/api/src/main/java/org/qi4j/api/entity/EntityBuilder.java
new file mode 100644
index 0000000..7020253
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/EntityBuilder.java
@@ -0,0 +1,60 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.entity;
+
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * EntityBuilders are used to instantiate EntityComposites. They can be acquired from
+ * {@link org.qi4j.api.unitofwork.UnitOfWork#newEntityBuilder(Class)} and allows the client
+ * to provide additional settings before instantiating the Composite.
+ *
+ * After calling newInstance() the builder becomes invalid, and may not be called again.
+ */
+public interface EntityBuilder<T>
+{
+    /**
+     * Get a representation of the state for the new Composite.
+     * It is possible to access and update properties and associations,
+     * even immutable ones since the builder represents the initial state.
+     *
+     * @return a proxy implementing the Composite type
+     */
+    T instance();
+
+    /**
+     * Get a representation of the state of the given type for the new Composite.
+     * This is primarily used if you want to provide state for a private mixin type.
+     *
+     * @param mixinType the mixin which you want to provide state for
+     *
+     * @return a proxy implementing the given mixin type
+     */
+    <K> K instanceFor( Class<K> mixinType );
+
+    /**
+     * Create a new Entity instance.
+     *
+     * @return a new Entity instance
+     *
+     * @throws org.qi4j.api.common.ConstructionException
+     *                            thrown if it was not possible to instantiate the Composite
+     * @throws LifecycleException if the entity could not be created
+     */
+    T newInstance()
+        throws ConstructionException, LifecycleException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/EntityBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/EntityBuilderTemplate.java b/core/api/src/main/java/org/qi4j/api/entity/EntityBuilderTemplate.java
new file mode 100644
index 0000000..4473844
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/EntityBuilderTemplate.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.entity;
+
+import org.qi4j.api.structure.Module;
+
+/**
+ * EntityBuilderTemplate.
+ */
+public abstract class EntityBuilderTemplate<T>
+{
+    Class<T> type;
+
+    protected EntityBuilderTemplate( Class<T> type )
+    {
+        this.type = type;
+    }
+
+    protected abstract void build( T prototype );
+
+    public T newInstance( Module module )
+    {
+        EntityBuilder<T> builder = module.currentUnitOfWork().newEntityBuilder( type );
+        build( builder.instance() );
+        return builder.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/EntityComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/EntityComposite.java b/core/api/src/main/java/org/qi4j/api/entity/EntityComposite.java
new file mode 100644
index 0000000..93089b8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/EntityComposite.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.entity;
+
+import org.qi4j.api.association.AssociationMixin;
+import org.qi4j.api.association.ManyAssociationMixin;
+import org.qi4j.api.association.NamedAssociationMixin;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.mixin.Mixins;
+
+/**
+ * EntityComposites are Composites that has mutable state persisted in EntityStores and equality defined from its
+ * identity.
+ */
+@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } )
+public interface EntityComposite
+    extends Identity, Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/EntityDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/EntityDescriptor.java b/core/api/src/main/java/org/qi4j/api/entity/EntityDescriptor.java
new file mode 100644
index 0000000..6ce2500
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/EntityDescriptor.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.entity;
+
+import org.qi4j.api.association.AssociationStateDescriptor;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.StatefulCompositeDescriptor;
+
+/**
+ * Entity Descriptor.
+ */
+public interface EntityDescriptor
+    extends CompositeDescriptor, StatefulCompositeDescriptor
+{
+    @Override
+    AssociationStateDescriptor state();
+
+    boolean queryable();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/EntityReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/EntityReference.java b/core/api/src/main/java/org/qi4j/api/entity/EntityReference.java
new file mode 100644
index 0000000..967647c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/EntityReference.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.entity;
+
+import java.io.Serializable;
+import org.qi4j.api.util.NullArgumentException;
+
+/**
+ * An EntityReference is identity of a specific Entity instance.
+ * <p>When stringified, the identity is used as-is. Example:</p>
+ * <pre>123456-abcde</pre>
+ */
+public final class EntityReference
+    implements Serializable
+{
+    /**
+     * Parse an URI to an EntityReference.
+     * @param uri the URI to parse
+     * @return the EntityReference represented by the given URI
+     */
+    public static EntityReference parseURI( String uri )
+    {
+        String identity = uri.substring( "urn:qi4j:entity:".length() );
+        return new EntityReference( identity );
+    }
+
+    /**
+     * Parse an Entity identity to an EntityReference.
+     * @param identity the EntityReference identity
+     * @return the EntityReference represented by the given identity
+     */
+    public static EntityReference parseEntityReference( String identity )
+    {
+        return new EntityReference( identity );
+    }
+
+    /**
+     * @param object an EntityComposite
+     * @return the EntityReference for the given EntityComposite
+     */
+    public static EntityReference entityReferenceFor( Object object )
+    {
+        return new EntityReference( (EntityComposite) object );
+    }
+
+    public static EntityReference create( Identity identity )
+    {
+        if( identity == null )
+            return null;
+        return new EntityReference( identity.identity().get() );
+    }
+
+    private static final long serialVersionUID = 1L;
+
+    private String identity;
+
+    /**
+     * @param entityComposite a non-null EntityComposite
+     * @throws NullPointerException if entityComposite is null
+     */
+    public EntityReference( EntityComposite entityComposite )
+    {
+        this( entityComposite.identity().get() );
+    }
+
+    /**
+     * @param identity reference identity
+     * @throws NullArgumentException if identity is null or empty
+     */
+    public EntityReference( String identity )
+    {
+        NullArgumentException.validateNotEmpty( "identity", identity );
+        this.identity = identity;
+    }
+
+    /**
+     * @return This EntityReference identity.
+     */
+    public final String identity()
+    {
+        return identity;
+    }
+
+    /**
+     * @return An URI representation of this EntityReference.
+     */
+    public String toURI()
+    {
+        return "urn:qi4j:entity:" + identity;
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        EntityReference that = (EntityReference) o;
+        return identity.equals( that.identity );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return identity.hashCode();
+    }
+
+    /**
+     * @return This EntityReference identity.
+     */
+    @Override
+    public String toString()
+    {
+        return identity;
+    }
+}


[06/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/NamedAssociationValueState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/NamedAssociationValueState.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/NamedAssociationValueState.java
deleted file mode 100644
index b252d33..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/NamedAssociationValueState.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.value;
-
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.spi.entity.NamedAssociationState;
-
-public class NamedAssociationValueState
-    implements NamedAssociationState
-{
-    private final Map<String, EntityReference> references;
-
-    public NamedAssociationValueState( Map<String, EntityReference> references )
-    {
-        this.references = references;
-    }
-
-    @Override
-    public int count()
-    {
-        return references.size();
-    }
-
-    @Override
-    public boolean containsName( String name )
-    {
-        return references.containsKey( name );
-    }
-
-    @Override
-    public boolean put( String name, EntityReference entityReference )
-    {
-        return references.put( name, entityReference ) != null;
-    }
-
-    @Override
-    public boolean remove( String name )
-    {
-        return references.remove( name ) != null;
-    }
-
-    @Override
-    public EntityReference get( String name )
-    {
-        return references.get( name );
-    }
-
-    @Override
-    public String nameOf( EntityReference entityReference )
-    {
-        for( Map.Entry<String, EntityReference> entry : references.entrySet() )
-        {
-            if( entry.getValue().equals( entityReference ) )
-            {
-                return entry.getKey();
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public Iterator<String> iterator()
-    {
-        return references.keySet().iterator();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ReferenceProperty.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ReferenceProperty.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ReferenceProperty.java
deleted file mode 100644
index 1bda2e9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ReferenceProperty.java
+++ /dev/null
@@ -1,53 +0,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.
- */
-package org.apache.zest.runtime.value;
-
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.Property;
-
-/**
- * The reference for an Association
- */
-public class ReferenceProperty
-    implements Property<EntityReference>
-{
-    EntityReference reference;
-
-    public ReferenceProperty()
-    {
-    }
-
-    public ReferenceProperty( EntityReference reference )
-    {
-        this.reference = reference;
-    }
-
-    @Override
-    public EntityReference get()
-    {
-        return reference;
-    }
-
-    @Override
-    public void set( EntityReference newValue )
-        throws IllegalArgumentException, IllegalStateException
-    {
-        reference = newValue;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
deleted file mode 100644
index ceeeb10..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.value;
-
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.value.NoSuchValueException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Implementation of ValueBuilder
- */
-public final class ValueBuilderInstance<T>
-    implements ValueBuilder<T>
-{
-
-    private final ModuleInstance currentModule;
-    private final ValueInstance prototypeInstance;
-
-    public ValueBuilderInstance( ModelModule<ValueModel> compositeModelModule, ModuleInstance currentModule, StateResolver stateResolver )
-    {
-        ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, stateResolver );
-        prototypeInstance = compositeModelModule.model().newValueInstance( compositeModelModule.module(), state );
-        prototypeInstance.prepareToBuild();
-        this.currentModule = currentModule;
-    }
-
-    @Override
-    public T prototype()
-    {
-        return prototypeInstance.<T>proxy();
-    }
-
-    @Override
-    public AssociationStateHolder state()
-    {
-        return prototypeInstance.state();
-    }
-
-    @Override
-    public <K> K prototypeFor( Class<K> mixinType )
-    {
-        return prototypeInstance.newProxy( mixinType );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public T newInstance()
-        throws ConstructionException
-    {
-        Class<Composite> valueType = (Class<Composite>) first( prototypeInstance.types() );
-
-        ModelModule<ValueModel> valueModel = currentModule.typeLookup().lookupValueModel( valueType );
-
-        if( valueModel == null )
-        {
-            throw new NoSuchValueException( valueType.getName(), currentModule.name() );
-        }
-        return new ValueBuilderWithPrototype<>( valueModel, currentModule, prototype() ).newInstance();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
deleted file mode 100644
index f6a40ae..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2007, Rickard Öberg.
- * Copyright 2009, Niclas Hedhman.
- * Copyright 2012, Kent Sølvsten.
- * Copyright 2013, Paul Merlin.
- *
- * 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.zest.runtime.value;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.functional.Function;
-import org.apache.zest.runtime.composite.FunctionStateResolver;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * Implementation of ValueBuilder with a prototype supplied
- */
-public class ValueBuilderWithPrototype<T>
-    implements ValueBuilder<T>
-{
-    private ValueInstance prototypeInstance;
-    private final ValueModel valueModel;
-
-    public ValueBuilderWithPrototype( ModelModule<ValueModel> compositeModelModule,
-                                      ModuleInstance currentModule,
-                                      T prototype
-    )
-    {
-        valueModel = compositeModelModule.model();
-        // Only shallow clone, as all generic types of the ValueComposites are expected to be Immutable.
-
-        MixinsModel mixinsModel = valueModel.mixinsModel();
-        Object[] mixins = mixinsModel.newMixinHolder();
-        final ValueStateInstance prototypeState = ValueInstance.valueInstanceOf( (ValueComposite) prototype ).state();
-        StateResolver resolver = new FunctionStateResolver(
-            new PropertyDescriptorFunction( prototypeState ),
-            new AssociationDescriptorEntityReferenceFunction( prototypeState ),
-            new AssociationDescriptorIterableFunction( prototypeState ),
-            new AssociationDescriptorMapFunction( prototypeState )
-        );
-        ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, resolver );
-        ValueInstance valueInstance = new ValueInstance(
-            valueModel,
-            currentModule,
-            mixins,
-            state
-        );
-
-        int i = 0;
-        InjectionContext injectionContext = new InjectionContext( valueInstance, UsesInstance.EMPTY_USES, state );
-        for( MixinModel mixinModel : mixinsModel.mixinModels() )
-        {
-            mixins[ i++ ] = mixinModel.newInstance( injectionContext );
-        }
-
-//        // Use serialization-deserialization to make a copy of the prototype
-//        final Object value;
-//        try
-//        {
-//            // @TODO there is probably a more efficient way to do this
-//            ValueSerialization valueSerialization = currentModule.valueSerialization();
-//            String serialized = valueSerialization.serialize( prototype );
-//            value = valueSerialization.deserialize( valueModel.valueType(), serialized);
-//        }
-//        catch( ValueSerializationException e )
-//        {
-//            throw new IllegalStateException( "Could not serialize-copy Value", e );
-//        }
-
-//        ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) value );
-        valueInstance.prepareToBuild();
-        this.prototypeInstance = valueInstance;
-    }
-
-    @Override
-    public T prototype()
-    {
-        verifyUnderConstruction();
-        return prototypeInstance.<T>proxy();
-    }
-
-    @Override
-    public AssociationStateHolder state()
-    {
-        verifyUnderConstruction();
-        return prototypeInstance.state();
-    }
-
-    @Override
-    public <K> K prototypeFor( Class<K> mixinType )
-    {
-        verifyUnderConstruction();
-        return prototypeInstance.newProxy( mixinType );
-    }
-
-    @Override
-    public T newInstance()
-        throws ConstructionException
-    {
-        verifyUnderConstruction();
-
-        // Set correct info's (immutable) on the state
-        prototypeInstance.prepareBuilderState();
-
-        // Check that it is valid
-        valueModel.checkConstraints( prototypeInstance.state() );
-
-        try
-        {
-            return prototypeInstance.<T>proxy();
-        }
-        finally
-        {
-            // Invalidate builder
-            prototypeInstance = null;
-        }
-    }
-
-    private void verifyUnderConstruction()
-    {
-        if( prototypeInstance == null )
-        {
-            throw new IllegalStateException( "ValueBuilder instances cannot be reused" );
-        }
-    }
-
-    private static class PropertyDescriptorFunction
-        implements Function<PropertyDescriptor, Object>
-    {
-        private final ValueStateInstance prototypeState;
-
-        public PropertyDescriptorFunction( ValueStateInstance prototypeState )
-        {
-            this.prototypeState = prototypeState;
-        }
-
-        @Override
-        public Object map( PropertyDescriptor descriptor )
-        {
-            return prototypeState.propertyFor( descriptor.accessor() ).get();
-        }
-    }
-
-    private static class AssociationDescriptorEntityReferenceFunction
-        implements Function<AssociationDescriptor, EntityReference>
-    {
-        private final ValueStateInstance prototypeState;
-
-        public AssociationDescriptorEntityReferenceFunction( ValueStateInstance prototypeState )
-        {
-            this.prototypeState = prototypeState;
-        }
-
-        @Override
-        public EntityReference map( AssociationDescriptor descriptor )
-        {
-            return prototypeState.associationFor( descriptor.accessor() ).reference();
-        }
-    }
-
-    private static class AssociationDescriptorIterableFunction
-        implements Function<AssociationDescriptor, Iterable<EntityReference>>
-    {
-        private final ValueStateInstance prototypeState;
-
-        public AssociationDescriptorIterableFunction( ValueStateInstance prototypeState )
-        {
-            this.prototypeState = prototypeState;
-        }
-
-        @Override
-        public Iterable<EntityReference> map( AssociationDescriptor descriptor )
-        {
-            return prototypeState.manyAssociationFor( descriptor.accessor() ).references();
-        }
-    }
-
-    private static class AssociationDescriptorMapFunction
-        implements Function<AssociationDescriptor, Map<String, EntityReference>>
-    {
-        private final ValueStateInstance prototypeState;
-
-        public AssociationDescriptorMapFunction( ValueStateInstance prototypeState )
-        {
-            this.prototypeState = prototypeState;
-        }
-
-        @Override
-        public Map<String, EntityReference> map( AssociationDescriptor descriptor )
-        {
-            Map<String, EntityReference> result = new HashMap<>();
-            NamedAssociation<?> namedAssociation = prototypeState.namedAssociationFor( descriptor.accessor() );
-            for( String name : namedAssociation )
-            {
-                result.put( name, namedAssociation.referenceOf( name ) );
-            }
-            return result;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
deleted file mode 100644
index 57413b5..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012, Kent Sølvsten. 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.zest.runtime.value;
-
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-public class ValueBuilderWithState<T> implements ValueBuilder<T>
-{
-    private final ModelModule<ValueModel> model;
-    private ValueInstance prototypeInstance;
-
-    public ValueBuilderWithState( ModelModule<ValueModel> compositeModelModule,
-                                  ModuleInstance currentModule,
-                                  StateResolver stateResolver )
-    {
-        ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, stateResolver );
-        ValueInstance instance = compositeModelModule.model().newValueInstance( compositeModelModule.module(), state );
-        instance.prepareToBuild();
-        this.model = compositeModelModule;
-        this.prototypeInstance = instance;
-    }
-
-    @Override
-    public T prototype()
-    {
-        verifyUnderConstruction();
-        return prototypeInstance.<T>proxy();
-    }
-
-    @Override
-    public AssociationStateHolder state()
-    {
-        verifyUnderConstruction();
-        return prototypeInstance.state();
-    }
-
-    @Override
-    public <K> K prototypeFor( Class<K> mixinType )
-    {
-        verifyUnderConstruction();
-
-        return prototypeInstance.newProxy( mixinType );
-    }
-
-    @Override
-    public T newInstance()
-        throws ConstructionException
-    {
-        verifyUnderConstruction();
-
-        // Set correct info's (immutable) on the state
-        prototypeInstance.prepareBuilderState();
-
-        // Check that it is valid
-        model.model().checkConstraints( prototypeInstance.state() );
-
-        try
-        {
-            return prototypeInstance.<T>proxy();
-        }
-        finally
-        {
-            // Invalidate builder
-            prototypeInstance = null;
-        }
-    }
-
-    private void verifyUnderConstruction()
-    {
-        if( prototypeInstance == null )
-        {
-            throw new IllegalStateException( "ValueBuilder instances cannot be reused" );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
deleted file mode 100644
index 3141ac1..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2007, Alin Dreghiciu. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin. 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.zest.runtime.value;
-
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.composite.MixinsInstance;
-import org.apache.zest.runtime.composite.TransientInstance;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * ValueComposite instance
- */
-public final class ValueInstance
-    extends TransientInstance
-    implements CompositeInstance, MixinsInstance
-{
-    public static ValueInstance valueInstanceOf( ValueComposite composite )
-    {
-        return (ValueInstance) Proxy.getInvocationHandler( composite );
-    }
-
-    public ValueInstance( ValueModel compositeModel,
-                          ModuleSpi moduleInstance,
-                          Object[] mixins,
-                          ValueStateInstance state
-    )
-    {
-        super( compositeModel, moduleInstance, mixins, state );
-    }
-
-    /**
-     * Perform equals with {@code o} argument.
-     * <p>
-     * The definition of equals() for the Value is that if both the state and descriptor are equal,
-     * then the values are equal.
-     * </p>
-     *
-     * @param o The other object to compare.
-     *
-     * @return Returns a {@code boolean} indicator whether this object is equals the other.
-     */
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || !Proxy.isProxyClass( o.getClass() ) )
-        {
-            return false;
-        }
-
-        try
-        {
-            ValueInstance that = (ValueInstance) Proxy.getInvocationHandler( o );
-            // Descriptor equality
-            if( !descriptor().equals( that.descriptor() ) )
-            {
-                return false;
-            }
-            // State equality
-            return state.equals( that.state );
-        }
-        catch( ClassCastException e )
-        {
-            return false;
-        }
-    }
-
-    @Override
-    public ValueStateInstance state()
-    {
-        return (ValueStateInstance) state;
-    }
-
-    @Override
-    public ValueModel descriptor()
-    {
-        return (ValueModel) compositeModel;
-    }
-
-    /**
-     * When a ValueBuilder is about to start, ensure that all state has builder infos, i.e. they are mutable.
-     */
-    public void prepareToBuild()
-    {
-        for( PropertyModel propertyDescriptor : descriptor().state().properties() )
-        {
-            PropertyInstance<Object> propertyInstance =
-                (PropertyInstance<Object>) state.propertyFor( propertyDescriptor.accessor() );
-
-            propertyInstance.prepareToBuild( propertyDescriptor );
-        }
-
-        for( AssociationModel associationDescriptor : descriptor().state().associations() )
-        {
-            state().associationFor( associationDescriptor.accessor() )
-                .setAssociationInfo( associationDescriptor.getBuilderInfo() );
-        }
-
-        for( ManyAssociationModel associationDescriptor : descriptor().state().manyAssociations() )
-        {
-            state().manyAssociationFor( associationDescriptor.accessor() )
-                .setAssociationInfo( associationDescriptor.getBuilderInfo() );
-        }
-
-        for( NamedAssociationModel associationDescriptor : descriptor().state().namedAssociations() )
-        {
-            state().namedAssociationFor( associationDescriptor.accessor() )
-                .setAssociationInfo( associationDescriptor.getBuilderInfo() );
-        }
-    }
-
-    /**
-     * When a ValueBuilder is finished and is about to instantiate a Value, call this to ensure that the state has correct
-     * settings, i.e. is immutable.
-     */
-    public void prepareBuilderState()
-    {
-        for( PropertyModel propertyDescriptor : descriptor().state().properties() )
-        {
-            PropertyInstance<Object> propertyInstance =
-                (PropertyInstance<Object>) state.propertyFor( propertyDescriptor.accessor() );
-            propertyInstance.prepareBuilderState( propertyDescriptor );
-        }
-
-        for( AssociationModel associationDescriptor : descriptor().state().associations() )
-        {
-            state().associationFor( associationDescriptor.accessor() ).setAssociationInfo( associationDescriptor );
-        }
-
-        for( ManyAssociationModel associationDescriptor : descriptor().state().manyAssociations() )
-        {
-            state().manyAssociationFor( associationDescriptor.accessor() ).setAssociationInfo( associationDescriptor );
-        }
-
-        for( NamedAssociationModel associationDescriptor : descriptor().state().namedAssociations() )
-        {
-            state().namedAssociationFor( associationDescriptor.accessor() ).setAssociationInfo( associationDescriptor );
-        }
-    }
-
-    /**
-     * Calculate hash code.
-     *
-     * @return the hashcode of this instance.
-     */
-    @Override
-    public int hashCode()
-    {
-        int hash = compositeModel.hashCode() * 23; // Descriptor
-        return hash + state.hashCode() * 5; // State
-    }
-
-    @Override
-    public String toString()
-    {
-        return ( (ModuleSpi) module() ).valueSerialization().serialize( this.<ValueComposite>proxy() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
deleted file mode 100644
index aa8c9b4..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.value;
-
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.type.ValueCompositeType;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.CompositeModel;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * Model for ValueComposites
- */
-public final class ValueModel
-    extends CompositeModel
-    implements ValueDescriptor
-{
-    private ValueCompositeType valueType;
-
-    public ValueModel( final Iterable<Class<?>> types,
-                       final Visibility visibility,
-                       final MetaInfo metaInfo,
-                       final MixinsModel mixinsModel,
-                       final ValueStateModel stateModel,
-                       final CompositeMethodsModel compositeMethodsModel
-    )
-    {
-        super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-
-        valueType = new ValueCompositeType( this );
-    }
-
-    @Override
-    public ValueCompositeType valueType()
-    {
-        return valueType;
-    }
-
-    @Override
-    public ValueStateModel state()
-    {
-        return (ValueStateModel) super.state();
-    }
-
-    // This method is ONLY called by ValueBuilders
-    void checkConstraints( ValueStateInstance state )
-        throws ConstraintViolationException
-    {
-        for( PropertyModel propertyModel : stateModel.properties() )
-        {
-            propertyModel.checkConstraints( state.propertyFor( propertyModel.accessor() ).get() );
-        }
-
-        // IF no UnitOfWork is active, then the Association checks shouldn't be done.
-        if( UnitOfWorkInstance.getCurrent().empty() )
-        {
-            return;
-        }
-        for( AssociationModel associationModel : ( (ValueStateModel) stateModel ).associations() )
-        {
-            associationModel.checkConstraints( state.associationFor( associationModel.accessor() ).get() );
-        }
-
-        for( ManyAssociationModel associationModel : ( (ValueStateModel) stateModel ).manyAssociations() )
-        {
-            associationModel.checkAssociationConstraints( state.manyAssociationFor( associationModel.accessor() ) );
-        }
-    }
-
-    public ValueInstance newValueInstance( ModuleSpi moduleInstance,
-                                           ValueStateInstance state
-    )
-    {
-        Object[] mixins = mixinsModel.newMixinHolder();
-
-        ValueInstance instance = new ValueInstance( this, moduleInstance, mixins, state );
-
-        // Instantiate all mixins
-        int i = 0;
-        InjectionContext injectionContext = new InjectionContext( instance, UsesInstance.EMPTY_USES, state );
-        for( MixinModel mixinModel : mixinsModel.mixinModels() )
-        {
-            mixins[ i++ ] = mixinModel.newInstance( injectionContext );
-        }
-
-        // Return
-        return instance;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
deleted file mode 100644
index 84a2719..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012, Kent Sølvsten. 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.zest.runtime.value;
-
-import java.lang.reflect.AccessibleObject;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.runtime.association.AssociationInfo;
-import org.apache.zest.runtime.association.AssociationInstance;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationInstance;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationInstance;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.runtime.property.PropertyInfo;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * TODO
- */
-public final class ValueStateInstance
-    implements AssociationStateHolder
-{
-    private final Map<AccessibleObject, PropertyInstance<?>> properties;
-    private final Map<AccessibleObject, AssociationInstance<?>> associations;
-    private final Map<AccessibleObject, ManyAssociationInstance<?>> manyAssociations;
-    private final Map<AccessibleObject, NamedAssociationInstance<?>> namedAssociations;
-
-    public ValueStateInstance( Map<AccessibleObject, PropertyInstance<?>> properties,
-                               Map<AccessibleObject, AssociationInstance<?>> associations,
-                               Map<AccessibleObject, ManyAssociationInstance<?>> manyAssociations,
-                               Map<AccessibleObject, NamedAssociationInstance<?>> namedAssociations
-    )
-    {
-        this.properties = properties;
-        this.associations = associations;
-        this.manyAssociations = manyAssociations;
-        this.namedAssociations = namedAssociations;
-    }
-
-    public ValueStateInstance( ModelModule<ValueModel> compositeModelModule,
-                               ModuleInstance currentModule,
-                               StateResolver stateResolver )
-    {
-        ValueModel valueModel = compositeModelModule.model();
-        this.properties = new LinkedHashMap<>();
-        for( PropertyDescriptor propertyDescriptor : valueModel.state().properties() )
-        {
-            PropertyInfo builderInfo = ( (PropertyModel) propertyDescriptor ).getBuilderInfo();
-            Object value = stateResolver.getPropertyState( propertyDescriptor );
-            PropertyInstance<Object> propertyInstance = new PropertyInstance<>( builderInfo, value );
-            properties.put( propertyDescriptor.accessor(), propertyInstance );
-        }
-
-        this.associations = new LinkedHashMap<>();
-        for( AssociationDescriptor associationDescriptor : valueModel.state().associations() )
-        {
-            AssociationInfo builderInfo = ( (AssociationModel) associationDescriptor ).getBuilderInfo();
-            EntityReference value = stateResolver.getAssociationState( associationDescriptor );
-            AssociationInstance<Object> associationInstance1 = new AssociationInstance<>(
-                builderInfo,
-                currentModule.getEntityFunction(),
-                new ReferenceProperty( value ) );
-            associations.put( associationDescriptor.accessor(), associationInstance1 );
-        }
-
-        this.manyAssociations = new LinkedHashMap<>();
-        for( AssociationDescriptor associationDescriptor : valueModel.state().manyAssociations() )
-        {
-            AssociationInfo builderInfo = ( (ManyAssociationModel) associationDescriptor ).getBuilderInfo();
-            List<EntityReference> value = stateResolver.getManyAssociationState( associationDescriptor );
-            ManyAssociationValueState manyAssociationState = new ManyAssociationValueState( value );
-            ManyAssociationInstance<Object> associationInstance = new ManyAssociationInstance<>(
-                builderInfo,
-                currentModule.getEntityFunction(),
-                manyAssociationState );
-            manyAssociations.put( associationDescriptor.accessor(), associationInstance );
-        }
-
-        this.namedAssociations = new LinkedHashMap<>();
-        for( AssociationDescriptor associationDescriptor : valueModel.state().namedAssociations() )
-        {
-            AssociationInfo builderInfo = ( (NamedAssociationModel) associationDescriptor ).getBuilderInfo();
-            Map<String, EntityReference> value = stateResolver.getNamedAssociationState( associationDescriptor );
-            NamedAssociationValueState namedAssociationState = new NamedAssociationValueState( value );
-            NamedAssociationInstance<Object> associationInstance = new NamedAssociationInstance<>(
-                builderInfo,
-                currentModule.getEntityFunction(),
-                namedAssociationState );
-            namedAssociations.put( associationDescriptor.accessor(), associationInstance );
-        }
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> PropertyInstance<T> propertyFor( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        PropertyInstance<T> property = (PropertyInstance<T>) properties.get( accessor );
-
-        if( property == null )
-        {
-            throw new IllegalArgumentException( "No such property:" + accessor );
-        }
-
-        return property;
-    }
-
-    @Override
-    public Iterable<PropertyInstance<?>> properties()
-    {
-        return properties.values();
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> AssociationInstance<T> associationFor( AccessibleObject accessor )
-    {
-        AssociationInstance<T> association = (AssociationInstance<T>) associations.get( accessor );
-
-        if( association == null )
-        {
-            throw new IllegalArgumentException( "No such association:" + accessor );
-        }
-
-        return association;
-    }
-
-    @Override
-    public Iterable<AssociationInstance<?>> allAssociations()
-    {
-        return associations.values();
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> ManyAssociationInstance<T> manyAssociationFor( AccessibleObject accessor )
-    {
-        ManyAssociationInstance<T> manyAssociation = (ManyAssociationInstance<T>) manyAssociations.get( accessor );
-
-        if( manyAssociation == null )
-        {
-            throw new IllegalArgumentException( "No such many-association:" + accessor );
-        }
-
-        return manyAssociation;
-    }
-
-    @Override
-    public Iterable<ManyAssociationInstance<?>> allManyAssociations()
-    {
-        return manyAssociations.values();
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> NamedAssociationInstance<T> namedAssociationFor( AccessibleObject accessor )
-    {
-        NamedAssociationInstance<T> namedAssociation = (NamedAssociationInstance<T>) namedAssociations.get( accessor );
-
-        if( namedAssociation == null )
-        {
-            throw new IllegalArgumentException( "No such named-association:" + accessor );
-        }
-
-        return namedAssociation;
-    }
-
-    @Override
-    public Iterable<? extends NamedAssociationInstance<?>> allNamedAssociations()
-    {
-        return namedAssociations.values();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if( !( obj instanceof ValueStateInstance ) )
-        {
-            return false;
-        }
-        ValueStateInstance state = (ValueStateInstance) obj;
-        if( !properties.equals( state.properties ) )
-        {
-            return false;
-        }
-        if( !associations.equals( state.associations ) )
-        {
-            return false;
-        }
-        if( !manyAssociations.equals( state.manyAssociations ) )
-        {
-            return false;
-        }
-        return namedAssociations.equals( state.namedAssociations );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int result = properties.hashCode();
-        result = 31 * result + associations.hashCode();
-        result = 31 * result + manyAssociations.hashCode();
-        result = 31 * result + namedAssociations.hashCode();
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateModel.java
deleted file mode 100644
index e34398f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateModel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg.
- * Copyright (c) 2012, Kent Sølvsten.
- * Copyright (c) 2014-2015, Paul Merlin.
- *
- * 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.zest.runtime.value;
-
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.property.PropertiesModel;
-
-/**
- * Model for ValueComposite state.
- */
-public final class ValueStateModel
-    extends StateModel
-    implements AssociationStateDescriptor
-{
-    private final AssociationsModel associationsModel;
-    private final ManyAssociationsModel manyAssociationsModel;
-    private final NamedAssociationsModel namedAssociationsModel;
-
-    public ValueStateModel( PropertiesModel propertiesModel,
-                            AssociationsModel associationsModel,
-                            ManyAssociationsModel manyAssociationsModel,
-                            NamedAssociationsModel namedAssociationsModel
-    )
-    {
-        super( propertiesModel );
-        this.associationsModel = associationsModel;
-        this.manyAssociationsModel = manyAssociationsModel;
-        this.namedAssociationsModel = namedAssociationsModel;
-    }
-
-    @Override
-    public AssociationDescriptor getAssociationByName( String name )
-    {
-        return associationsModel.getAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
-    {
-        return associationsModel.getAssociationByQualifiedName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getManyAssociationByName( String name )
-    {
-        return manyAssociationsModel.getManyAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
-    {
-        return manyAssociationsModel.getManyAssociationByQualifiedName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getNamedAssociationByName( String name )
-    {
-        return namedAssociationsModel.getNamedAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
-    {
-        return namedAssociationsModel.getNamedAssociationByQualifiedName( name );
-    }
-
-    @Override
-    public Iterable<AssociationModel> associations()
-    {
-        return associationsModel.associations();
-    }
-
-    @Override
-    public Iterable<ManyAssociationModel> manyAssociations()
-    {
-        return manyAssociationsModel.manyAssociations();
-    }
-
-    @Override
-    public Iterable<NamedAssociationModel> namedAssociations()
-    {
-        return namedAssociationsModel.namedAssociations();
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( ( (VisitableHierarchy<Object, Object>) propertiesModel ).accept( visitor ) )
-            {
-                if( ( (VisitableHierarchy<AssociationsModel, AssociationModel>) associationsModel ).accept( visitor ) )
-                {
-                    if( ( (VisitableHierarchy<ManyAssociationsModel, ManyAssociationModel>) manyAssociationsModel ).accept( visitor ) )
-                    {
-                        ( (VisitableHierarchy<NamedAssociationsModel, NamedAssociationModel>) namedAssociationsModel ).accept( visitor );
-                    }
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/value/ValuesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValuesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValuesModel.java
deleted file mode 100644
index 08f91e1..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValuesModel.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.value;
-
-import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class ValuesModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final List<ValueModel> valueModels;
-
-    public ValuesModel( List<ValueModel> valueModels )
-    {
-        this.valueModels = valueModels;
-    }
-
-    public Iterable<ValueModel> models()
-    {
-        return valueModels;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ValueModel valueModel : valueModels )
-            {
-                if( !valueModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/Qi4jRuntimeImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/Qi4jRuntimeImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/Qi4jRuntimeImpl.java
new file mode 100644
index 0000000..232ad6f
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/Qi4jRuntimeImpl.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime;
+
+import java.lang.reflect.InvocationHandler;
+import java.util.Arrays;
+import java.util.Map;
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.association.AbstractAssociation;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.association.AssociationWrapper;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.ManyAssociationWrapper;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.association.NamedAssociationWrapper;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.api.composite.ModelDescriptor;
+import org.qi4j.api.composite.TransientComposite;
+import org.qi4j.api.composite.TransientDescriptor;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.entity.EntityDescriptor;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.property.PropertyDescriptor;
+import org.qi4j.api.property.PropertyWrapper;
+import org.qi4j.api.property.StateHolder;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.api.service.ServiceDescriptor;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.api.value.ValueDescriptor;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.ApplicationModelFactory;
+import org.qi4j.bootstrap.Qi4jRuntime;
+import org.qi4j.runtime.association.AbstractAssociationInstance;
+import org.qi4j.runtime.association.AssociationInstance;
+import org.qi4j.runtime.association.ManyAssociationInstance;
+import org.qi4j.runtime.association.NamedAssociationInstance;
+import org.qi4j.runtime.bootstrap.ApplicationAssemblyFactoryImpl;
+import org.qi4j.runtime.bootstrap.ApplicationModelFactoryImpl;
+import org.qi4j.runtime.composite.ProxyReferenceInvocationHandler;
+import org.qi4j.runtime.composite.TransientInstance;
+import org.qi4j.runtime.entity.EntityInstance;
+import org.qi4j.runtime.property.PropertyInstance;
+import org.qi4j.runtime.service.ImportedServiceReferenceInstance;
+import org.qi4j.runtime.service.ServiceInstance;
+import org.qi4j.runtime.service.ServiceReferenceInstance;
+import org.qi4j.runtime.structure.ModuleUnitOfWork;
+import org.qi4j.runtime.value.ValueInstance;
+import org.qi4j.spi.Qi4jSPI;
+import org.qi4j.spi.entity.EntityState;
+
+import static java.lang.reflect.Proxy.getInvocationHandler;
+import static org.qi4j.runtime.composite.TransientInstance.compositeInstanceOf;
+
+/**
+ * Incarnation of Zest.
+ */
+public final class Qi4jRuntimeImpl
+    implements Qi4jSPI, Qi4jRuntime
+{
+    private final ApplicationAssemblyFactory applicationAssemblyFactory;
+    private final ApplicationModelFactory applicationModelFactory;
+
+    public Qi4jRuntimeImpl()
+    {
+        applicationAssemblyFactory = new ApplicationAssemblyFactoryImpl();
+        applicationModelFactory = new ApplicationModelFactoryImpl();
+    }
+
+    @Override
+    public ApplicationAssemblyFactory applicationAssemblyFactory()
+    {
+        return applicationAssemblyFactory;
+    }
+
+    @Override
+    public ApplicationModelFactory applicationModelFactory()
+    {
+        return applicationModelFactory;
+    }
+
+    @Override
+    public Qi4j api()
+    {
+        return this;
+    }
+
+    @Override
+    public Qi4jSPI spi()
+    {
+        return this;
+    }
+
+    // API
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public <T> T dereference( T composite )
+    {
+        InvocationHandler handler = getInvocationHandler( composite );
+        if( handler instanceof ProxyReferenceInvocationHandler )
+        {
+            return (T) ( (ProxyReferenceInvocationHandler) handler ).proxy();
+        }
+        if( handler instanceof CompositeInstance )
+        {
+            return composite;
+        }
+        return null;
+    }
+
+    @Override
+    public Module moduleOf( Object compositeOrServiceReferenceOrUow )
+    {
+        if( compositeOrServiceReferenceOrUow instanceof TransientComposite )
+        {
+            TransientComposite composite = (TransientComposite) compositeOrServiceReferenceOrUow;
+            return TransientInstance.compositeInstanceOf( composite ).module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof EntityComposite )
+        {
+            EntityComposite composite = (EntityComposite) compositeOrServiceReferenceOrUow;
+            return EntityInstance.entityInstanceOf( composite ).module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof ValueComposite )
+        {
+            ValueComposite composite = (ValueComposite) compositeOrServiceReferenceOrUow;
+            return ValueInstance.valueInstanceOf( composite ).module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof ServiceComposite )
+        {
+            ServiceComposite composite = (ServiceComposite) compositeOrServiceReferenceOrUow;
+            InvocationHandler handler = getInvocationHandler( composite );
+            if( handler instanceof ServiceInstance )
+            {
+                return ( (ServiceInstance) handler ).module();
+            }
+            return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof UnitOfWork )
+        {
+            ModuleUnitOfWork unitOfWork = (ModuleUnitOfWork) compositeOrServiceReferenceOrUow;
+            return unitOfWork.module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof ServiceReferenceInstance )
+        {
+            ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow;
+            return reference.module();
+        }
+        else if( compositeOrServiceReferenceOrUow instanceof ImportedServiceReferenceInstance )
+        {
+            ImportedServiceReferenceInstance<?> importedServiceReference
+                = (ImportedServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow;
+            return importedServiceReference.module();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be one of "
+                                            + Arrays.asList( TransientComposite.class, ValueComposite.class,
+                                                             ServiceComposite.class, ServiceReference.class,
+                                                             UnitOfWork.class ) );
+    }
+
+    @Override
+    public ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference )
+    {
+        if( compositeOrServiceReference instanceof TransientComposite )
+        {
+            TransientComposite composite = (TransientComposite) compositeOrServiceReference;
+            return TransientInstance.compositeInstanceOf( composite ).descriptor();
+        }
+        else if( compositeOrServiceReference instanceof EntityComposite )
+        {
+            EntityComposite composite = (EntityComposite) compositeOrServiceReference;
+            return EntityInstance.entityInstanceOf( composite ).descriptor();
+        }
+        else if( compositeOrServiceReference instanceof ValueComposite )
+        {
+            ValueComposite composite = (ValueComposite) compositeOrServiceReference;
+            return ValueInstance.valueInstanceOf( composite ).descriptor();
+        }
+        else if( compositeOrServiceReference instanceof ServiceComposite )
+        {
+            ServiceComposite composite = (ServiceComposite) compositeOrServiceReference;
+            InvocationHandler handler = getInvocationHandler( composite );
+            if( handler instanceof ServiceInstance )
+            {
+                return ( (ServiceInstance) handler ).descriptor();
+            }
+            return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).descriptor();
+        }
+        else if( compositeOrServiceReference instanceof ServiceReferenceInstance )
+        {
+            ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReference;
+            return reference.serviceDescriptor();
+        }
+        else if( compositeOrServiceReference instanceof ImportedServiceReferenceInstance )
+        {
+            ImportedServiceReferenceInstance<?> importedServiceReference
+                = (ImportedServiceReferenceInstance<?>) compositeOrServiceReference;
+            return importedServiceReference.serviceDescriptor();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be one of "
+                                            + Arrays.asList( TransientComposite.class, ValueComposite.class,
+                                                             ServiceComposite.class, ServiceReference.class ) );
+    }
+
+    @Override
+    public CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference )
+    {
+        return (CompositeDescriptor) modelDescriptorFor( compositeOrServiceReference );
+    }
+
+    // Descriptors
+
+    @Override
+    public TransientDescriptor transientDescriptorFor( Object transsient )
+    {
+        if( transsient instanceof TransientComposite )
+        {
+            TransientInstance transientInstance = compositeInstanceOf( (Composite) transsient );
+            return (TransientDescriptor) transientInstance.descriptor();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + TransientComposite.class );
+    }
+
+    @Override
+    public StateHolder stateOf( TransientComposite composite )
+    {
+        return TransientInstance.compositeInstanceOf( composite ).state();
+    }
+
+    @Override
+    public EntityDescriptor entityDescriptorFor( Object entity )
+    {
+        if( entity instanceof EntityComposite )
+        {
+            EntityInstance entityInstance = (EntityInstance) getInvocationHandler( entity );
+            return entityInstance.entityModel();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + EntityComposite.class );
+    }
+
+    @Override
+    public AssociationStateHolder stateOf( EntityComposite composite )
+    {
+        return EntityInstance.entityInstanceOf( composite ).state();
+    }
+
+    @Override
+    public ValueDescriptor valueDescriptorFor( Object value )
+    {
+        if( value instanceof ValueComposite )
+        {
+            ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) value );
+            return valueInstance.descriptor();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + ValueComposite.class );
+    }
+
+    @Override
+    public AssociationStateHolder stateOf( ValueComposite composite )
+    {
+        return ValueInstance.valueInstanceOf( composite ).state();
+    }
+
+    @Override
+    public ServiceDescriptor serviceDescriptorFor( Object service )
+    {
+        if( service instanceof ServiceReferenceInstance )
+        {
+            ServiceReferenceInstance<?> ref = (ServiceReferenceInstance<?>) service;
+            return ref.serviceDescriptor();
+        }
+        if( service instanceof ServiceComposite )
+        {
+            ServiceComposite composite = (ServiceComposite) service;
+            return (ServiceDescriptor) ServiceInstance.serviceInstanceOf( composite ).descriptor();
+        }
+        throw new IllegalArgumentException( "Wrong type. Must be subtype of "
+                                            + ServiceComposite.class + " or " + ServiceReference.class );
+    }
+
+    @Override
+    public PropertyDescriptor propertyDescriptorFor( Property<?> property )
+    {
+        while( property instanceof PropertyWrapper )
+        {
+            property = ( (PropertyWrapper) property ).next();
+        }
+
+        return (PropertyDescriptor) ( (PropertyInstance<?>) property ).propertyInfo();
+    }
+
+    @Override
+    public AssociationDescriptor associationDescriptorFor( AbstractAssociation association )
+    {
+        while( association instanceof AssociationWrapper )
+        {
+            association = ( (AssociationWrapper) association ).next();
+        }
+
+        while( association instanceof ManyAssociationWrapper )
+        {
+            association = ( (ManyAssociationWrapper) association ).next();
+        }
+
+        while( association instanceof NamedAssociationWrapper )
+        {
+            association = ( (NamedAssociationWrapper) association ).next();
+        }
+
+        return (AssociationDescriptor) ( (AbstractAssociationInstance) association ).associationInfo();
+    }
+
+    // SPI
+    @Override
+    public EntityState entityStateOf( EntityComposite composite )
+    {
+        return EntityInstance.entityInstanceOf( composite ).entityState();
+    }
+
+    @Override
+    public EntityReference entityReferenceOf( Association assoc )
+    {
+        @SuppressWarnings( "unchecked" )
+        Property<EntityReference> associationState = ( (AssociationInstance) assoc ).getAssociationState();
+        return associationState.get();
+    }
+
+    @Override
+    public Iterable<EntityReference> entityReferenceOf( ManyAssociation assoc )
+    {
+        return ( (ManyAssociationInstance) assoc ).getManyAssociationState();
+    }
+
+    @Override
+    public Iterable<Map.Entry<String, EntityReference>> entityReferenceOf( NamedAssociation assoc )
+    {
+        return ( (NamedAssociationInstance) assoc ).getEntityReferences();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationDelegate.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationDelegate.java b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationDelegate.java
new file mode 100644
index 0000000..86b1d2c
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationDelegate.java
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.activation;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import org.qi4j.api.activation.Activation;
+import org.qi4j.api.activation.ActivationEvent;
+import org.qi4j.api.activation.ActivationEventListener;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.activation.PassivationException;
+import org.qi4j.api.service.ServiceReference;
+
+import static org.qi4j.api.activation.ActivationEvent.EventType.ACTIVATED;
+import static org.qi4j.api.activation.ActivationEvent.EventType.ACTIVATING;
+import static org.qi4j.api.activation.ActivationEvent.EventType.PASSIVATED;
+import static org.qi4j.api.activation.ActivationEvent.EventType.PASSIVATING;
+
+/**
+ * This class manage Activation of a target and propagates to children.
+ */
+@SuppressWarnings( "raw" )
+public final class ActivationDelegate
+    extends ActivationEventListenerSupport
+{
+    private final Object target;
+    private final boolean fireEvents;
+    private ActivatorsInstance targetActivators = null;
+    private final LinkedList<Activation> activeChildren = new LinkedList<>();
+
+    /**
+     * Create a new ActivationDelegate that will fire events.
+     * @param target target of Activation
+     */
+    public ActivationDelegate( Object target )
+    {
+        this( target, true );
+    }
+
+    /**
+     * Create a new ActivationDelegate.
+     * @param target target of Activation
+     * @param fireEvents if {@link ActivationEvent}s should be fired
+     */
+    public ActivationDelegate( Object target, boolean fireEvents )
+    {
+        super();
+        this.target = target;
+        this.fireEvents = fireEvents;
+    }
+
+    public void activate( ActivatorsInstance targetActivators, Activation child )
+        throws Exception
+    {
+        activate( targetActivators, Collections.singleton( child ), null );
+    }
+
+    public void activate( ActivatorsInstance targetActivators, Activation child, Runnable callback )
+        throws Exception
+    {
+        activate( targetActivators, Collections.singleton( child ), callback );
+    }
+
+    public void activate( ActivatorsInstance targetActivators, Iterable<? extends Activation> children )
+        throws ActivationException
+    {
+        activate( targetActivators, children, null );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void activate( ActivatorsInstance targetActivators, Iterable<? extends Activation> children, Runnable callback )
+        throws ActivationException
+    {
+        if( this.targetActivators != null )
+        {
+            throw new IllegalStateException( "Activation.activate() called multiple times "
+                                             + "or without calling passivate() first!" );
+        }
+
+        try
+        {
+            // Before Activation Events
+            if( fireEvents )
+            {
+                fireEvent( new ActivationEvent( target, ACTIVATING ) );
+            }
+
+            // Before Activation for Activators
+            targetActivators.beforeActivation( target instanceof ServiceReference
+                                               ? new PassiveServiceReference( (ServiceReference) target )
+                                               : target );
+
+            // Activation
+            for( Activation child : children )
+            {
+                if( !activeChildren.contains( child ) )
+                {
+                    child.activate();
+                }
+                activeChildren.addFirst( child );
+            }
+
+            // Internal Activation Callback
+            if( callback != null )
+            {
+                callback.run();
+            }
+
+            // After Activation
+            targetActivators.afterActivation( target );
+
+            // After Activation Events
+            if( fireEvents )
+            {
+                fireEvent( new ActivationEvent( target, ACTIVATED ) );
+            }
+
+            // Activated
+            this.targetActivators = targetActivators;
+        }
+        catch( Exception e )
+        {
+            // Passivate actives
+            try
+            {
+                passivate();
+            }
+            catch( PassivationException e1 )
+            {
+                ActivationException activationEx = new ActivationException( "Unable to Activate application.", e );
+                activationEx.addSuppressed( e1 );
+                throw activationEx;
+            }
+            if( e instanceof ActivationException )
+            {
+                throw ( (ActivationException) e );
+            }
+            throw new ActivationException( "Unable to Activate application.", e );
+        }
+    }
+
+    public void passivate()
+        throws PassivationException
+    {
+        passivate( (Runnable) null );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void passivate( Runnable callback )
+        throws PassivationException
+    {
+        Set<Exception> exceptions = new LinkedHashSet<>();
+
+        // Before Passivation Events
+        if( fireEvents )
+        {
+            ActivationEvent event = new ActivationEvent( target, PASSIVATING );
+            for( ActivationEventListener listener : listeners )
+            {
+                try
+                {
+                    listener.onEvent( event );
+                }
+                catch( Exception ex )
+                {
+                    if( ex instanceof PassivationException )
+                    {
+                        exceptions.addAll( ( (PassivationException) ex ).causes() );
+                    }
+                    else
+                    {
+                        exceptions.add( ex );
+                    }
+                }
+            }
+        }
+
+        // Before Passivation for Activators
+        if( targetActivators != null )
+        {
+            try
+            {
+                targetActivators.beforePassivation( target );
+            }
+            catch( PassivationException ex )
+            {
+                exceptions.addAll( ex.causes() );
+            }
+            catch( Exception ex )
+            {
+                exceptions.add( ex );
+            }
+        }
+
+        // Passivation
+        while( !activeChildren.isEmpty() )
+        {
+            passivateOneChild( exceptions );
+        }
+
+        // Internal Passivation Callback
+        if( callback != null )
+        {
+            try
+            {
+                callback.run();
+            }
+            catch( Exception ex )
+            {
+                if( ex instanceof PassivationException )
+                {
+                    exceptions.addAll( ( (PassivationException) ex ).causes() );
+                }
+                else
+                {
+                    exceptions.add( ex );
+                }
+            }
+        }
+
+        // After Passivation for Activators
+        if( targetActivators != null )
+        {
+            try
+            {
+                targetActivators.afterPassivation( target instanceof ServiceReference
+                                                   ? new PassiveServiceReference( (ServiceReference) target )
+                                                   : target );
+            }
+            catch( PassivationException ex )
+            {
+                exceptions.addAll( ex.causes() );
+            }
+            catch( Exception ex )
+            {
+                exceptions.add( ex );
+            }
+        }
+        targetActivators = null;
+
+        // After Passivation Events
+        if( fireEvents )
+        {
+            ActivationEvent event = new ActivationEvent( target, PASSIVATED );
+            for( ActivationEventListener listener : listeners )
+            {
+                try
+                {
+                    listener.onEvent( event );
+                }
+                catch( Exception ex )
+                {
+                    if( ex instanceof PassivationException )
+                    {
+                        exceptions.addAll( ( (PassivationException) ex ).causes() );
+                    }
+                    else
+                    {
+                        exceptions.add( ex );
+                    }
+                }
+            }
+        }
+
+        // Error handling
+        if( exceptions.isEmpty() )
+        {
+            return;
+        }
+        throw new PassivationException( exceptions );
+    }
+
+    @SuppressWarnings( "TooBroadCatch" )
+    private void passivateOneChild( Set<Exception> exceptions )
+    {
+        Activation activeChild = activeChildren.removeFirst();
+        try
+        {
+            activeChild.passivate();
+        }
+        catch( PassivationException ex )
+        {
+            exceptions.addAll( ex.causes() );
+        }
+        catch( Exception ex )
+        {
+            exceptions.add( ex );
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    private static class PassiveServiceReference
+        implements ServiceReference
+    {
+
+        private final ServiceReference reference;
+
+        private PassiveServiceReference( ServiceReference reference )
+        {
+            this.reference = reference;
+        }
+
+        @Override
+        public String identity()
+        {
+            return reference.identity();
+        }
+
+        @Override
+        public Object get()
+        {
+            throw new IllegalStateException( "Service is passive, either activating and"
+                                             + " cannot be used yet or passivating and cannot be used anymore." );
+        }
+
+        @Override
+        public boolean isActive()
+        {
+            return false;
+        }
+
+        @Override
+        public boolean isAvailable()
+        {
+            return false;
+        }
+
+        @Override
+        public Iterable<Class<?>> types()
+        {
+            return reference.types();
+        }
+
+        @Override
+        public <T> T metaInfo( Class<T> infoType )
+        {
+            return reference.metaInfo( infoType );
+        }
+
+        @Override
+        public void registerActivationEventListener( ActivationEventListener listener )
+        {
+            reference.registerActivationEventListener( listener );
+        }
+
+        @Override
+        public void deregisterActivationEventListener( ActivationEventListener listener )
+        {
+            reference.deregisterActivationEventListener( listener );
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return identity().hashCode();
+        }
+
+        @Override
+        public boolean equals( Object obj )
+        {
+            if( obj == null )
+            {
+                return false;
+            }
+            if( getClass() != obj.getClass() )
+            {
+                return false;
+            }
+            final ServiceReference other = (ServiceReference) obj;
+            return identity().equals( other.identity() );
+        }
+
+        @Override
+        public String toString()
+        {
+            return reference.toString();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationEventListenerSupport.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationEventListenerSupport.java b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationEventListenerSupport.java
new file mode 100644
index 0000000..41c883d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivationEventListenerSupport.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ *
+ * 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.qi4j.runtime.activation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.activation.ActivationEvent;
+import org.qi4j.api.activation.ActivationEventListener;
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+
+/**
+ * Internal helper for managing registrations and firing events
+ */
+/* package */ class ActivationEventListenerSupport
+    implements ActivationEventListenerRegistration, ActivationEventListener
+{
+    protected List<ActivationEventListener> listeners = new ArrayList<>();
+
+    @Override
+    public void registerActivationEventListener( ActivationEventListener listener )
+    {
+        List<ActivationEventListener> newListeners = new ArrayList<>();
+        newListeners.addAll( listeners );
+        newListeners.add( listener );
+        listeners = newListeners;
+    }
+
+    @Override
+    public void deregisterActivationEventListener( ActivationEventListener listener )
+    {
+        List<ActivationEventListener> newListeners = new ArrayList<>();
+        newListeners.addAll( listeners );
+        newListeners.remove( listener );
+        listeners = newListeners;
+    }
+
+    /* package */ void fireEvent( ActivationEvent event )
+        throws Exception
+    {
+        for( ActivationEventListener listener : listeners )
+        {
+            listener.onEvent( event );
+        }
+    }
+
+    @Override
+    public void onEvent( ActivationEvent event )
+        throws Exception
+    {
+        fireEvent( event );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorModel.java b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorModel.java
new file mode 100644
index 0000000..823aace
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorModel.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.activation;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.activation.ActivatorDescriptor;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.composite.ConstructorsModel;
+import org.qi4j.runtime.injection.InjectedFieldsModel;
+import org.qi4j.runtime.injection.InjectedMethodsModel;
+import org.qi4j.runtime.injection.InjectionContext;
+
+/**
+ * Model for a single Activator.
+ *
+ * @param <ActivateeType> Type of the activation target
+ */
+public class ActivatorModel<ActivateeType>
+    implements ActivatorDescriptor, VisitableHierarchy<Object, Object>
+{
+    private final Class<? extends Activator<ActivateeType>> activatorType;
+    private final ConstructorsModel constructorsModel;
+    private final InjectedFieldsModel injectedFieldsModel;
+    private final InjectedMethodsModel injectedMethodsModel;
+
+    public ActivatorModel( Class<? extends Activator<ActivateeType>> activatorType )
+    {
+        this.activatorType = activatorType;
+        this.constructorsModel = new ConstructorsModel( activatorType );
+        this.injectedFieldsModel = new InjectedFieldsModel( activatorType );
+        this.injectedMethodsModel = new InjectedMethodsModel( activatorType );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            if( constructorsModel.accept( visitor ) )
+            {
+                if( injectedFieldsModel.accept( visitor ) )
+                {
+                    injectedMethodsModel.accept( visitor );
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    public Activator<ActivateeType> newInstance()
+    {
+        try
+        {
+            return activatorType.newInstance();
+        }
+        catch( InstantiationException | IllegalAccessException ex )
+        {
+            throw new ConstructionException( "Could not instantiate " + activatorType.getName(), ex );
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Activator<ActivateeType> newInstance( InjectionContext injectionContext )
+    {
+        try
+        {
+            Activator<ActivateeType> instance = (Activator<ActivateeType>) constructorsModel.newInstance( injectionContext );
+            injectionContext = new InjectionContext( injectionContext.module(), injectionContext.uses(), instance );
+            inject( injectionContext, instance );
+            return instance;
+        }
+        catch( Exception ex )
+        {
+            throw new ConstructionException( "Could not instantiate " + activatorType.getName(), ex );
+        }
+    }
+
+    public void inject( InjectionContext injectionContext, Activator<ActivateeType> instance )
+    {
+        injectedFieldsModel.inject( injectionContext, instance );
+        injectedMethodsModel.inject( injectionContext, instance );
+    }
+
+    @Override
+    public String toString()
+    {
+        return activatorType.getName();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsInstance.java
new file mode 100644
index 0000000..2059e1e
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsInstance.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.activation;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.activation.PassivationException;
+import org.qi4j.functional.Iterables;
+
+/**
+ * Instance of a Zest Activators of one Activation target. Contains ordered
+ * Activators and roll the Activation on the target.
+ *
+ * @param <ActivateeType> Type of the activation target
+ */
+public class ActivatorsInstance<ActivateeType>
+    implements Activator<ActivateeType>
+{
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static final ActivatorsInstance EMPTY = new ActivatorsInstance( Collections.emptyList() );
+
+    private final Iterable<Activator<ActivateeType>> activators;
+
+    public ActivatorsInstance( Iterable<Activator<ActivateeType>> activators )
+    {
+        this.activators = activators;
+    }
+
+    @Override
+    public void beforeActivation( ActivateeType activating )
+        throws Exception
+    {
+        for( Activator<ActivateeType> activator : activators )
+        {
+            activator.beforeActivation( activating );
+        }
+    }
+
+    @Override
+    public void afterActivation( ActivateeType activated )
+        throws Exception
+    {
+        for( Activator<ActivateeType> activator : activators )
+        {
+            activator.afterActivation( activated );
+        }
+    }
+
+    @Override
+    public void beforePassivation( ActivateeType passivating )
+        throws Exception
+    {
+        Set<Exception> exceptions = new LinkedHashSet<>();
+        for( Activator<ActivateeType> activator : Iterables.reverse( activators ) )
+        {
+            try
+            {
+                activator.beforePassivation( passivating );
+            }
+            catch( Exception ex )
+            {
+                exceptions.add( ex );
+            }
+        }
+        if( !exceptions.isEmpty() )
+        {
+            throw new PassivationException( exceptions );
+        }
+    }
+
+    @Override
+    public void afterPassivation( ActivateeType passivated )
+        throws Exception
+    {
+        Set<Exception> exceptions = new LinkedHashSet<>();
+        for( Activator<ActivateeType> activator : Iterables.reverse( activators ) )
+        {
+            try
+            {
+                activator.afterPassivation( passivated );
+            }
+            catch( Exception ex )
+            {
+                exceptions.add( ex );
+            }
+        }
+        if( !exceptions.isEmpty() )
+        {
+            throw new PassivationException( exceptions );
+        }
+    }
+
+}


[17/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
deleted file mode 100644
index fe35926..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.List;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.constraint.ConstraintViolation;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.Aggregated;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.runtime.unitofwork.BuilderEntityState;
-import org.apache.zest.spi.entity.EntityState;
-
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Model for a ManyAssociation.
- *
- * <p>Equality is based on the ManyAssociation accessor object (associated type and name), not on the QualifiedName.</p>
- */
-public final class ManyAssociationModel
-    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<ManyAssociationModel>
-{
-    private final ValueConstraintsInstance associationConstraints;
-    private final MetaInfo metaInfo;
-    private Type type;
-    private final AccessibleObject accessor;
-    private QualifiedName qualifiedName;
-    private final ValueConstraintsInstance constraints;
-    private boolean queryable;
-    private boolean immutable;
-    private boolean aggregated;
-    private AssociationInfo builderInfo;
-
-    public ManyAssociationModel( AccessibleObject accessor,
-                                 ValueConstraintsInstance valueConstraintsInstance,
-                                 ValueConstraintsInstance associationConstraintsInstance,
-                                 MetaInfo metaInfo
-    )
-    {
-        this.metaInfo = metaInfo;
-        this.constraints = valueConstraintsInstance;
-        this.associationConstraints = associationConstraintsInstance;
-        this.accessor = accessor;
-        initialize();
-    }
-
-    private void initialize()
-    {
-        this.type = GenericAssociationInfo.associationTypeOf( accessor );
-        this.qualifiedName = QualifiedName.fromAccessor( accessor );
-        this.immutable = metaInfo.get( Immutable.class ) != null;
-        this.aggregated = metaInfo.get( Aggregated.class ) != null;
-
-        final Queryable queryable = accessor.getAnnotation( Queryable.class );
-        this.queryable = queryable == null || queryable.value();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public QualifiedName qualifiedName()
-    {
-        return qualifiedName;
-    }
-
-    @Override
-    public Type type()
-    {
-        return type;
-    }
-
-    @Override
-    public boolean isImmutable()
-    {
-        return immutable;
-    }
-
-    @Override
-    public boolean isAggregated()
-    {
-        return aggregated;
-    }
-
-    @Override
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public boolean queryable()
-    {
-        return queryable;
-    }
-
-    public AssociationInfo getBuilderInfo()
-    {
-        return builderInfo;
-    }
-
-    public <T> ManyAssociation<T> newInstance( final ModuleUnitOfWork uow, EntityState state )
-    {
-        return new ManyAssociationInstance<>( state instanceof BuilderEntityState ? builderInfo : this, new Function2<EntityReference, Type, Object>()
-        {
-            @Override
-            public Object map( EntityReference entityReference, Type type )
-            {
-                return uow.get( Classes.RAW_CLASS.map( type ), entityReference.identity() );
-            }
-        }, state.manyAssociationValueOf( qualifiedName ) );
-    }
-
-    @Override
-    public void checkConstraints( Object composite )
-        throws ConstraintViolationException
-    {
-        if( constraints != null )
-        {
-            List<ConstraintViolation> violations = constraints.checkConstraints( composite );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
-            }
-        }
-    }
-
-    public void checkAssociationConstraints( ManyAssociation manyAssociation )
-        throws ConstraintViolationException
-    {
-        if( associationConstraints != null )
-        {
-            List<ConstraintViolation> violations = associationConstraints.checkConstraints( manyAssociation );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
-            }
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super ManyAssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        return visitor.visit( this );
-    }
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        builderInfo = new AssociationInfo()
-        {
-            @Override
-            public boolean isImmutable()
-            {
-                return false;
-            }
-
-            @Override
-            public QualifiedName qualifiedName()
-            {
-                return qualifiedName;
-            }
-
-            @Override
-            public Type type()
-            {
-                return type;
-            }
-
-            @Override
-            public void checkConstraints( Object value )
-                throws ConstraintViolationException
-            {
-                ManyAssociationModel.this.checkConstraints( value );
-            }
-        };
-
-        if( type instanceof TypeVariable )
-        {
-            Class mainType = first( resolution.model().types() );
-            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
-        }
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        ManyAssociationModel that = (ManyAssociationModel) o;
-
-        return accessor.equals( that.accessor );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return accessor.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        if( accessor instanceof Field )
-        {
-            return ( (Field) accessor ).toGenericString();
-        }
-        else
-        {
-            return ( (Method) accessor ).toGenericString();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
deleted file mode 100644
index 220d3ec..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.runtime.value.ValueStateInstance;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * Model for ManyAssociations.
- */
-public final class ManyAssociationsModel
-    implements VisitableHierarchy<ManyAssociationsModel, ManyAssociationModel>
-{
-    private final Map<AccessibleObject, ManyAssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
-
-    public ManyAssociationsModel()
-    {
-    }
-
-    public Iterable<ManyAssociationModel> manyAssociations()
-    {
-        return mapAccessorAssociationModel.values();
-    }
-
-    public void addManyAssociation( ManyAssociationModel model )
-    {
-        mapAccessorAssociationModel.put( model.accessor(), model );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super ManyAssociationsModel, ? super ManyAssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
-            {
-                if( !associationModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public <T> ManyAssociation<T> newInstance( AccessibleObject accessor,
-                                               EntityState entityState,
-                                               ModuleUnitOfWork uow )
-    {
-        return mapAccessorAssociationModel.get( accessor ).newInstance( uow, entityState );
-    }
-
-    public ManyAssociationModel getManyAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        ManyAssociationModel manyAssociationModel = mapAccessorAssociationModel.get( accessor );
-        if( manyAssociationModel == null )
-        {
-            throw new IllegalArgumentException( "No many-association found with name:" + ( (Member) accessor ).getName() );
-        }
-        return manyAssociationModel;
-    }
-
-    public AssociationDescriptor getManyAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().name().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No many-association found with name:" + name );
-    }
-
-    public AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No many-association found with qualified name:" + name );
-    }
-
-    public void checkConstraints( ValueStateInstance state )
-    {
-        for( ManyAssociationModel manyAssociationModel : mapAccessorAssociationModel.values() )
-        {
-            manyAssociationModel.checkAssociationConstraints( state.manyAssociationFor( manyAssociationModel.accessor() ) );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationInstance.java
deleted file mode 100644
index 46e8b87..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationInstance.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.association;
-
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.association.NamedAssociationWrapper;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.spi.entity.NamedAssociationState;
-
-import static org.apache.zest.functional.Iterables.map;
-
-public class NamedAssociationInstance<T>
-    extends AbstractAssociationInstance<T>
-    implements NamedAssociation<T>
-{
-
-    private final NamedAssociationState namedAssociationState;
-
-    public NamedAssociationInstance( AssociationInfo associationInfo,
-                                     Function2<EntityReference, Type, Object> associationFunction,
-                                     NamedAssociationState namedAssociationState
-    )
-    {
-        super( associationInfo, associationFunction );
-        this.namedAssociationState = namedAssociationState;
-    }
-
-    @Override
-    public Iterator<String> iterator()
-    {
-        return namedAssociationState.iterator();
-    }
-
-    @Override
-    public int count()
-    {
-        return namedAssociationState.count();
-    }
-
-    @Override
-    public boolean containsName( String name )
-    {
-        return namedAssociationState.containsName( name );
-    }
-
-    @Override
-    public boolean put( String name, T entity )
-    {
-        NullArgumentException.validateNotNull( "entity", entity );
-        checkImmutable();
-        checkType( entity );
-        associationInfo.checkConstraints( entity );
-        return namedAssociationState.put( name, new EntityReference( ( (Identity) entity ).identity().get() ) );
-    }
-
-    @Override
-    public boolean remove( String name )
-    {
-        checkImmutable();
-        return namedAssociationState.remove( name );
-    }
-
-    @Override
-    public T get( String name )
-    {
-        return getEntity( namedAssociationState.get( name ) );
-    }
-
-    @Override
-    public String nameOf( T entity )
-    {
-        return namedAssociationState.nameOf( getEntityReference( entity ) );
-    }
-
-    @Override
-    public Map<String, T> toMap()
-    {
-        Map<String, T> map = new HashMap<>();
-        for( String name : namedAssociationState )
-        {
-            map.put( name, getEntity( namedAssociationState.get( name ) ) );
-        }
-        return map;
-    }
-
-    @Override
-    public Iterable<EntityReference> references()
-    {
-        return map( new Function<String, EntityReference>()
-        {
-            @Override
-            public EntityReference map( String name )
-            {
-                return namedAssociationState.get( name );
-            }
-        }, namedAssociationState );
-    }
-
-    @Override
-    public EntityReference referenceOf( String name )
-    {
-        return namedAssociationState.get( name );
-    }
-
-    public Iterable<Map.Entry<String, EntityReference>> getEntityReferences()
-    {
-        return map( new Function<String, Map.Entry<String, EntityReference>>()
-        {
-            @Override
-            public Map.Entry<String, EntityReference> map( final String key )
-            {
-                final EntityReference value = namedAssociationState.get( key );
-                return new Map.Entry<String, EntityReference>()
-                {
-                    @Override
-                    public String getKey()
-                    {
-                        return key;
-                    }
-
-                    @Override
-                    public EntityReference getValue()
-                    {
-                        return value;
-                    }
-
-                    @Override
-                    public EntityReference setValue( EntityReference value )
-                    {
-                        throw new UnsupportedOperationException( "Immutable Map" );
-                    }
-
-                    @Override
-                    public boolean equals( Object o )
-                    {
-                        if( o instanceof Map.Entry )
-                        {
-                            Map.Entry other = (Map.Entry) o;
-                            return key.equals( other.getKey() );
-                        }
-                        return false;
-                    }
-
-                    @Override
-                    public int hashCode()
-                    {
-                        return 997 * key.hashCode() + 981813497;
-                    }
-                };
-            }
-        }, namedAssociationState );
-    }
-
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        NamedAssociation<?> that = (NamedAssociation) o;
-        // Unwrap if needed
-        while( that instanceof NamedAssociationWrapper )
-        {
-            that = ( (NamedAssociationWrapper) that ).next();
-        }
-        // Descriptor equality
-        NamedAssociationInstance<?> thatInstance = (NamedAssociationInstance) that;
-        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
-        if( !associationInfo.equals( thatDescriptor ) )
-        {
-            return false;
-        }
-        // State equality
-        if( namedAssociationState.count() != thatInstance.namedAssociationState.count() )
-        {
-            return false;
-        }
-        for( String name : namedAssociationState )
-        {
-            if( !thatInstance.namedAssociationState.containsName( name ) )
-            {
-                return false;
-            }
-            EntityReference thisReference = namedAssociationState.get( name );
-            EntityReference thatReference = thatInstance.namedAssociationState.get( name );
-            if( !thisReference.equals( thatReference ) )
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = associationInfo.hashCode() * 31; // Descriptor
-        for( String name : namedAssociationState )
-        {
-            hash += name.hashCode();
-            hash += namedAssociationState.get( name ).hashCode() * 7; // State
-        }
-        return hash;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
deleted file mode 100644
index d4dd6a6..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.List;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.constraint.ConstraintViolation;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.Aggregated;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.runtime.unitofwork.BuilderEntityState;
-import org.apache.zest.spi.entity.EntityState;
-
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Model for a NamedAssociation.
- *
- * <p>Equality is based on the NamedAssociation accessor object (associated type and name), not on the QualifiedName.</p>
- */
-public final class NamedAssociationModel
-    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<NamedAssociationModel>
-{
-    private final ValueConstraintsInstance associationConstraints;
-    private final MetaInfo metaInfo;
-    private Type type;
-    private final AccessibleObject accessor;
-    private QualifiedName qualifiedName;
-    private final ValueConstraintsInstance constraints;
-    private boolean queryable;
-    private boolean immutable;
-    private boolean aggregated;
-    private AssociationInfo builderInfo;
-
-    public NamedAssociationModel( AccessibleObject accessor,
-                                  ValueConstraintsInstance valueConstraintsInstance,
-                                  ValueConstraintsInstance associationConstraintsInstance,
-                                  MetaInfo metaInfo
-    )
-    {
-        this.metaInfo = metaInfo;
-        this.constraints = valueConstraintsInstance;
-        this.associationConstraints = associationConstraintsInstance;
-        this.accessor = accessor;
-        initialize();
-    }
-
-    private void initialize()
-    {
-        this.type = GenericAssociationInfo.associationTypeOf( accessor );
-        this.qualifiedName = QualifiedName.fromAccessor( accessor );
-        this.immutable = metaInfo.get( Immutable.class ) != null;
-        this.aggregated = metaInfo.get( Aggregated.class ) != null;
-
-        final Queryable queryable = accessor.getAnnotation( Queryable.class );
-        this.queryable = queryable == null || queryable.value();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public QualifiedName qualifiedName()
-    {
-        return qualifiedName;
-    }
-
-    @Override
-    public Type type()
-    {
-        return type;
-    }
-
-    @Override
-    public boolean isImmutable()
-    {
-        return immutable;
-    }
-
-    @Override
-    public boolean isAggregated()
-    {
-        return aggregated;
-    }
-
-    @Override
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public boolean queryable()
-    {
-        return queryable;
-    }
-
-    public AssociationInfo getBuilderInfo()
-    {
-        return builderInfo;
-    }
-
-    public <T> NamedAssociation<T> newInstance( final ModuleUnitOfWork uow, EntityState state )
-    {
-        return new NamedAssociationInstance<>( state instanceof BuilderEntityState ? builderInfo : this, new Function2<EntityReference, Type, Object>()
-        {
-            @Override
-            public Object map( EntityReference entityReference, Type type )
-            {
-                return uow.get( Classes.RAW_CLASS.map( type ), entityReference.identity() );
-            }
-        }, state.namedAssociationValueOf( qualifiedName ) );
-    }
-
-    @Override
-    public void checkConstraints( Object composite )
-        throws ConstraintViolationException
-    {
-        if( constraints != null )
-        {
-            List<ConstraintViolation> violations = constraints.checkConstraints( composite );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
-            }
-        }
-    }
-
-    public void checkAssociationConstraints( NamedAssociation association )
-        throws ConstraintViolationException
-    {
-        if( associationConstraints != null )
-        {
-            List<ConstraintViolation> violations = associationConstraints.checkConstraints( association );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
-            }
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super NamedAssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        return visitor.visit( this );
-    }
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        builderInfo = new AssociationInfo()
-        {
-            @Override
-            public boolean isImmutable()
-            {
-                return false;
-            }
-
-            @Override
-            public QualifiedName qualifiedName()
-            {
-                return qualifiedName;
-            }
-
-            @Override
-            public Type type()
-            {
-                return type;
-            }
-
-            @Override
-            public void checkConstraints( Object value )
-                throws ConstraintViolationException
-            {
-                NamedAssociationModel.this.checkConstraints( value );
-            }
-        };
-
-        if( type instanceof TypeVariable )
-        {
-            Class mainType = first( resolution.model().types() );
-            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
-        }
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        NamedAssociationModel that = (NamedAssociationModel) o;
-
-        return accessor.equals( that.accessor );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return accessor.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        if( accessor instanceof Field )
-        {
-            return ( (Field) accessor ).toGenericString();
-        }
-        else
-        {
-            return ( (Method) accessor ).toGenericString();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
deleted file mode 100644
index 87722b0..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.runtime.value.ValueStateInstance;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * Model for NamedAssociations.
- */
-public final class NamedAssociationsModel
-    implements VisitableHierarchy<NamedAssociationsModel, NamedAssociationModel>
-{
-    private final Map<AccessibleObject, NamedAssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
-
-    public NamedAssociationsModel()
-    {
-    }
-
-    public Iterable<NamedAssociationModel> namedAssociations()
-    {
-        return mapAccessorAssociationModel.values();
-    }
-
-    public void addNamedAssociation( NamedAssociationModel model )
-    {
-        mapAccessorAssociationModel.put( model.accessor(), model );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super NamedAssociationsModel, ? super NamedAssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
-            {
-                if( !associationModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public <T> NamedAssociation<T> newInstance( AccessibleObject accessor,
-                                                EntityState entityState,
-                                                ModuleUnitOfWork uow )
-    {
-        return mapAccessorAssociationModel.get( accessor ).newInstance( uow, entityState );
-    }
-
-    public NamedAssociationModel getNamedAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        if( false )
-        {
-            return (NamedAssociationModel) getNamedAssociationByName( QualifiedName.fromAccessor( accessor ).name() );
-        }
-        NamedAssociationModel namedAssociationModel = mapAccessorAssociationModel.get( accessor );
-        if( namedAssociationModel == null )
-        {
-            throw new IllegalArgumentException( "No named-association found with name:" + ( (Member) accessor ).getName() );
-        }
-        return namedAssociationModel;
-    }
-
-    public AssociationDescriptor getNamedAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().name().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No named-association found with name:" + name );
-    }
-
-    public AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No named-association found with qualified name:" + name );
-    }
-
-    public void checkConstraints( ValueStateInstance state )
-    {
-        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            associationModel.checkAssociationConstraints( state.namedAssociationFor( associationModel.accessor() ) );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
deleted file mode 100644
index 76c6207..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class AndAppliesToFilter
-    implements AppliesToFilter
-{
-    private final AppliesToFilter left;
-    private final AppliesToFilter right;
-
-    AndAppliesToFilter( AppliesToFilter left, AppliesToFilter right )
-    {
-        this.left = left;
-        this.right = right;
-    }
-
-    @Override
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        return left.appliesTo( method, mixin, compositeType, fragmentClass ) &&
-               right.appliesTo( method, mixin, compositeType, fragmentClass );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
deleted file mode 100644
index 622eecb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class AnnotationAppliesToFilter
-    implements AppliesToFilter
-{
-    @SuppressWarnings( "raw" )
-    private final Class annotationType;
-
-    @SuppressWarnings( "raw" )
-    AnnotationAppliesToFilter( Class type )
-    {
-        this.annotationType = type;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        return method.getAnnotation( annotationType ) != null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
deleted file mode 100644
index 7b1c7a4..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-/**
- * Factory for ApplicationAssembly.
- */
-public final class ApplicationAssemblyFactoryImpl
-    implements ApplicationAssemblyFactory
-{
-    @Override
-    public ApplicationAssembly newApplicationAssembly( Assembler assembler )
-        throws AssemblyException
-    {
-        return newApplicationAssembly( new Assembler[][][]{ { { assembler } } } );
-    }
-
-    @Override
-    public ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers )
-        throws AssemblyException
-    {
-        ApplicationAssembly applicationAssembly = newApplicationAssembly();
-
-        // Build all layers bottom-up
-        LayerAssembly below = null;
-        for( int layer = assemblers.length - 1; layer >= 0; layer-- )
-        {
-            // Create Layer
-            LayerAssembly layerAssembly = applicationAssembly.layer( "Layer " + ( layer + 1 ) );
-            for( int module = 0; module < assemblers[ layer ].length; module++ )
-            {
-                // Create Module
-                ModuleAssembly moduleAssembly = layerAssembly.module( "Module " + ( module + 1 ) );
-                for( Assembler assembler : assemblers[ layer ][ module ] )
-                {
-                    // Register Assembler
-                    assembler.assemble( moduleAssembly );
-                }
-            }
-            if( below != null )
-            {
-                layerAssembly.uses( below ); // Link layers
-            }
-            below = layerAssembly;
-        }
-        return applicationAssembly;
-    }
-
-    @Override
-    public ApplicationAssembly newApplicationAssembly()
-    {
-        return new ApplicationAssemblyImpl();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
deleted file mode 100644
index 8fe7f7d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyVisitor;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-/**
- * The representation of an entire application. From
- * this you can set information about the application
- * and create LayerAssemblies.
- */
-public final class ApplicationAssemblyImpl
-    implements ApplicationAssembly
-{
-    private final Map<String, LayerAssemblyImpl> layerAssemblies = new LinkedHashMap<>();
-    private String name = "Application";
-    private String version = "1.0"; // Default version
-    private Application.Mode mode;
-    private final MetaInfo metaInfo = new MetaInfo();
-    private final List<Class<? extends Activator<Application>>> activators = new ArrayList<>();
-
-    public ApplicationAssemblyImpl()
-    {
-        mode = Application.Mode.valueOf( System.getProperty( "mode", "production" ) );
-    }
-
-    @Override
-    public LayerAssembly layer( String name )
-    {
-        if( name != null )
-        {
-            LayerAssemblyImpl existing = layerAssemblies.get( name );
-            if( existing != null )
-            {
-                return existing;
-            }
-        }
-        LayerAssemblyImpl layerAssembly = new LayerAssemblyImpl( this, name );
-        layerAssemblies.put( name, layerAssembly );
-        return layerAssembly;
-    }
-
-    @Override
-    public ModuleAssembly module( String layerName, String moduleName )
-    {
-        return layer( layerName ).module( moduleName );
-    }
-
-    @Override
-    public ApplicationAssembly setName( String name )
-    {
-        this.name = name;
-        return this;
-    }
-
-    @Override
-    public ApplicationAssembly setVersion( String version )
-    {
-        this.version = version;
-        return this;
-    }
-
-    @Override
-    public ApplicationAssembly setMode( Application.Mode mode )
-    {
-        this.mode = mode;
-        return this;
-    }
-
-    @Override
-    public ApplicationAssembly setMetaInfo( Object info )
-    {
-        metaInfo.set( info );
-        return this;
-    }
-
-    @Override
-    @SafeVarargs
-    public final ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators )
-    {
-        this.activators.addAll( Arrays.asList( activators ) );
-        return this;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType
-    {
-        visitor.visitApplication( this );
-        for( LayerAssemblyImpl layerAssembly : layerAssemblies.values() )
-        {
-            layerAssembly.visit( visitor );
-        }
-    }
-
-    public Collection<LayerAssemblyImpl> layerAssemblies()
-    {
-        return layerAssemblies.values();
-    }
-
-    public List<Class<? extends Activator<Application>>> activators()
-    {
-        return activators;
-    }
-
-    public MetaInfo metaInfo()
-    {
-        return metaInfo;
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public String version()
-    {
-        return version;
-    }
-
-    @Override
-    public Application.Mode mode()
-    {
-        return mode;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
deleted file mode 100644
index d1eb738..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationModelFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.injection.InjectedFieldModel;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ApplicationModel;
-import org.apache.zest.runtime.structure.LayerModel;
-import org.apache.zest.runtime.structure.ModuleModel;
-import org.apache.zest.runtime.structure.UsedLayersModel;
-
-/**
- * Factory for Applications.
- */
-public final class ApplicationModelFactoryImpl
-    implements ApplicationModelFactory
-{
-    @Override
-    public ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly )
-        throws AssemblyException
-    {
-        AssemblyHelper helper = new AssemblyHelper();
-
-        ApplicationAssemblyImpl applicationAssembly = (ApplicationAssemblyImpl) assembly;
-        ActivatorsModel<Application> applicationActivators = new ActivatorsModel<>( applicationAssembly.activators() );
-        List<LayerModel> layerModels = new ArrayList<>();
-        final ApplicationModel applicationModel = new ApplicationModel( applicationAssembly.name(),
-                                                                        applicationAssembly.version(),
-                                                                        applicationAssembly.mode(),
-                                                                        applicationAssembly.metaInfo(),
-                                                                        applicationActivators,
-                                                                        layerModels );
-        Map<LayerAssembly, LayerModel> mapAssemblyModel = new HashMap<>();
-        Map<LayerAssembly, List<LayerModel>> mapUsedLayers = new HashMap<>();
-
-        // Build all layers
-        List<LayerAssemblyImpl> layerAssemblies = new ArrayList<>( applicationAssembly.layerAssemblies() );
-        for( LayerAssemblyImpl layerAssembly : layerAssemblies )
-        {
-            List<LayerModel> usedLayers = new ArrayList<>();
-            mapUsedLayers.put( layerAssembly, usedLayers );
-
-            UsedLayersModel usedLayersModel = new UsedLayersModel( usedLayers );
-            List<ModuleModel> moduleModels = new ArrayList<>();
-            String name = layerAssembly.name();
-            if( name == null )
-            {
-                throw new AssemblyException( "Layer must have name set" );
-            }
-            ActivatorsModel<Layer> layerActivators = new ActivatorsModel<>( layerAssembly.activators() );
-            LayerModel layerModel = new LayerModel( name, layerAssembly.metaInfo(), usedLayersModel, layerActivators, moduleModels );
-
-            for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() )
-            {
-                moduleModels.add( moduleAssembly.assembleModule( helper ) );
-            }
-            mapAssemblyModel.put( layerAssembly, layerModel );
-            layerModels.add( layerModel );
-        }
-
-        // Populate used layer lists
-        for( LayerAssemblyImpl layerAssembly : layerAssemblies )
-        {
-            Set<LayerAssembly> usesLayers = layerAssembly.uses();
-            List<LayerModel> usedLayers = mapUsedLayers.get( layerAssembly );
-            for( LayerAssembly usesLayer : usesLayers )
-            {
-                LayerModel layerModel = mapAssemblyModel.get( usesLayer );
-                usedLayers.add( layerModel );
-            }
-        }
-
-        // Bind model
-        // This will resolve all dependencies
-        try
-        {
-//            applicationModel.bind();
-            applicationModel.accept( new BindingVisitor( applicationModel ) );
-        }
-        catch( BindingException e )
-        {
-            throw new AssemblyException( "Unable to bind: " + applicationModel, e );
-        }
-
-        return applicationModel;
-    }
-
-    private static class BindingVisitor
-        implements HierarchicalVisitor<Object, Object, BindingException>
-    {
-        private LayerModel layer;
-        private ModuleModel module;
-        private ModelDescriptor objectDescriptor;
-        private CompositeMethodModel compositeMethodModel;
-
-        private Resolution resolution;
-        private final ApplicationModel applicationModel;
-
-        private BindingVisitor( ApplicationModel applicationModel )
-        {
-            this.applicationModel = applicationModel;
-        }
-
-        @Override
-        public boolean visitEnter( Object visited )
-            throws BindingException
-        {
-            if( visited instanceof Binder )
-            {
-                Binder binder = (Binder) visited;
-                binder.bind( resolution );
-
-                return false;
-            }
-            else if( visited instanceof CompositeMethodModel )
-            {
-                compositeMethodModel = (CompositeMethodModel) visited;
-                resolution = new Resolution( applicationModel, layer, module, objectDescriptor, compositeMethodModel, null );
-            }
-            else if( visited instanceof ModelDescriptor )
-            {
-                objectDescriptor = (ModelDescriptor) visited;
-                resolution = new Resolution( applicationModel, layer, module, objectDescriptor, null, null );
-            }
-            else if( visited instanceof InjectedFieldModel )
-            {
-                InjectedFieldModel fieldModel = (InjectedFieldModel) visited;
-                fieldModel.bind( new Resolution( applicationModel, layer, module,
-                                                 objectDescriptor, compositeMethodModel, fieldModel.field() ) );
-            }
-            else if( visited instanceof ModuleModel )
-            {
-                module = (ModuleModel) visited;
-            }
-            else if( visited instanceof LayerModel )
-            {
-                layer = (LayerModel) visited;
-            }
-
-            return true;
-        }
-
-        @Override
-        public boolean visitLeave( Object visited )
-            throws BindingException
-        {
-            return true;
-        }
-
-        @Override
-        public boolean visit( Object visited )
-            throws BindingException
-        {
-            if( visited instanceof Binder )
-            {
-                ( (Binder) visited ).bind( resolution );
-            }
-            return true;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
deleted file mode 100644
index 374ac66..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.runtime.composite.ConcernModel;
-import org.apache.zest.runtime.composite.ConstraintDeclaration;
-import org.apache.zest.runtime.composite.FragmentClassLoader;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.SideEffectModel;
-
-/**
- * This helper is used when building the application model. It keeps track
- * of already created classloaders and various models
- */
-public class AssemblyHelper
-{
-    Map<Class, Class> instantiationClasses = new HashMap<>();
-    Map<Class, ConstraintDeclaration> constraintDeclarations = new HashMap<>();
-    Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>();
-    Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>();
-
-    public MixinModel getMixinModel( Class mixinClass )
-    {
-        return new MixinModel( mixinClass, instantiationClass( mixinClass ) );
-    }
-
-    public ConcernModel getConcernModel( Class concernClass )
-    {
-        return new ConcernModel( concernClass, instantiationClass( concernClass ) );
-    }
-
-    public SideEffectModel getSideEffectModel( Class sideEffectClass )
-    {
-        return new SideEffectModel( sideEffectClass, instantiationClass( sideEffectClass ) );
-    }
-
-    private Class instantiationClass( Class fragmentClass )
-    {
-        Class instantiationClass = fragmentClass;
-        if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
-        {
-            instantiationClass = instantiationClasses.get( fragmentClass );
-
-            if( instantiationClass == null )
-            {
-                try
-                {
-                    FragmentClassLoader fragmentLoader = getModifierClassLoader( fragmentClass.getClassLoader() );
-                    instantiationClass = fragmentLoader.loadFragmentClass( fragmentClass );
-                    instantiationClasses.put( fragmentClass, instantiationClass );
-                }
-                catch( ClassNotFoundException | VerifyError e )
-                {
-                    throw new ConstructionException( "Could not generate mixin subclass " + fragmentClass.getName(), e );
-                }
-            }
-        }
-        return instantiationClass;
-    }
-
-    private FragmentClassLoader getModifierClassLoader( ClassLoader classLoader )
-    {
-        FragmentClassLoader cl = modifierClassLoaders.get( classLoader );
-        if( cl == null )
-        {
-            cl = new FragmentClassLoader( classLoader );
-            modifierClassLoaders.put( classLoader, cl );
-        }
-        return cl;
-    }
-
-    public boolean appliesTo( Class<?> fragmentClass, Method method, Iterable<Class<?>> types, Class<?> mixinClass )
-    {
-        AppliesToFilter appliesToFilter = appliesToInstances.get( fragmentClass );
-        if( appliesToFilter == null )
-        {
-            appliesToFilter = createAppliesToFilter( fragmentClass );
-            appliesToInstances.put( fragmentClass, appliesToFilter );
-        }
-        for( Class<?> compositeType : types )
-        {
-            if( appliesToFilter.appliesTo( method, mixinClass, compositeType, fragmentClass ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public AppliesToFilter createAppliesToFilter( Class<?> fragmentClass )
-    {
-        AppliesToFilter result = null;
-        if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
-        {
-            result = new TypedFragmentAppliesToFilter();
-            if( Modifier.isAbstract( fragmentClass.getModifiers() ) )
-            {
-                result = new AndAppliesToFilter( result, new ImplementsMethodAppliesToFilter() );
-            }
-        }
-        result = applyAppliesTo( result, fragmentClass );
-        if( result == null )
-        {
-            return AppliesToFilter.ALWAYS;
-        }
-        return result;
-    }
-
-    private AppliesToFilter applyAppliesTo( AppliesToFilter existing, Class<?> modifierClass )
-    {
-        AppliesTo appliesTo = modifierClass.getAnnotation( AppliesTo.class );
-        if( appliesTo != null )
-        {
-            // Use "or" for all filters specified in the annotation
-            AppliesToFilter appliesToAnnotation = null;
-            for( Class<?> appliesToClass : appliesTo.value() )
-            {
-                AppliesToFilter filter;
-                if( AppliesToFilter.class.isAssignableFrom( appliesToClass ) )
-                {
-                    try
-                    {
-                        filter = (AppliesToFilter) appliesToClass.newInstance();
-                    }
-                    catch( Exception e )
-                    {
-                        throw new ConstructionException( e );
-                    }
-                }
-                else if( Annotation.class.isAssignableFrom( appliesToClass ) )
-                {
-                    filter = new AnnotationAppliesToFilter( appliesToClass );
-                }
-                else // Type check
-                {
-                    filter = new TypeCheckAppliesToFilter( appliesToClass );
-                }
-
-                if( appliesToAnnotation == null )
-                {
-                    appliesToAnnotation = filter;
-                }
-                else
-                {
-                    appliesToAnnotation = new OrAppliesToFilter( appliesToAnnotation, filter );
-                }
-            }
-            // Add to the rest of the rules using "and"
-            if( existing == null )
-            {
-                return appliesToAnnotation;
-            }
-            else
-            {
-                return new AndAppliesToFilter( existing, appliesToAnnotation );
-            }
-        }
-        return existing;
-    }
-
-    public boolean appliesTo( Class<? extends Constraint<?, ?>> constraint,
-                              Class<? extends Annotation> annotationType,
-                              Type valueType
-    )
-    {
-        ConstraintDeclaration constraintDeclaration = constraintDeclarations.get( constraint );
-        if( constraintDeclaration == null )
-        {
-            constraintDeclaration = new ConstraintDeclaration( constraint );
-            constraintDeclarations.put( constraint, constraintDeclaration );
-        }
-
-        return constraintDeclaration.appliesTo( annotationType, valueType );
-    }
-}


[16/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
deleted file mode 100644
index 458ff79..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. 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.zest.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.constraint.ConstraintDeclaration;
-import org.apache.zest.api.constraint.Constraints;
-import org.apache.zest.api.constraint.Name;
-import org.apache.zest.api.entity.Lifecycle;
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.sideeffect.SideEffects;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Fields;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.functional.ForEach;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.composite.AbstractConstraintModel;
-import org.apache.zest.runtime.composite.CompositeConstraintModel;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.ConcernModel;
-import org.apache.zest.runtime.composite.ConcernsModel;
-import org.apache.zest.runtime.composite.ConstraintModel;
-import org.apache.zest.runtime.composite.ConstraintsModel;
-import org.apache.zest.runtime.composite.GenericSpecification;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.SideEffectModel;
-import org.apache.zest.runtime.composite.SideEffectsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.composite.ValueConstraintsModel;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.property.PropertiesModel;
-import org.apache.zest.runtime.property.PropertyModel;
-
-import static java.util.Arrays.asList;
-import static org.apache.zest.api.util.Annotations.hasAnnotation;
-import static org.apache.zest.api.util.Annotations.isType;
-import static org.apache.zest.api.util.Annotations.type;
-import static org.apache.zest.api.util.Classes.classHierarchy;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.api.util.Classes.isAssignableFrom;
-import static org.apache.zest.api.util.Classes.typeOf;
-import static org.apache.zest.api.util.Classes.typesOf;
-import static org.apache.zest.api.util.Classes.wrapperClass;
-import static org.apache.zest.functional.Iterables.addAll;
-import static org.apache.zest.functional.Iterables.cast;
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Iterables.matchesAny;
-import static org.apache.zest.functional.Iterables.toList;
-import static org.apache.zest.functional.Specifications.and;
-import static org.apache.zest.functional.Specifications.in;
-import static org.apache.zest.functional.Specifications.not;
-import static org.apache.zest.functional.Specifications.or;
-import static org.apache.zest.functional.Specifications.translate;
-
-/**
- * Declaration of a Composite.
- */
-public abstract class CompositeAssemblyImpl
-    implements HasTypes
-{
-    protected List<Class<?>> concerns = new ArrayList<>();
-    protected List<Class<?>> sideEffects = new ArrayList<>();
-    protected List<Class<?>> mixins = new ArrayList<>();
-    protected List<Class<?>> types = new ArrayList<>();
-    protected MetaInfo metaInfo = new MetaInfo();
-    protected Visibility visibility = Visibility.module;
-
-    protected boolean immutable;
-    protected PropertiesModel propertiesModel;
-    protected StateModel stateModel;
-    protected MixinsModel mixinsModel;
-    protected CompositeMethodsModel compositeMethodsModel;
-    private AssemblyHelper helper;
-    protected StateDeclarations stateDeclarations;
-
-    protected Set<String> registeredStateNames = new HashSet<>();
-
-    public CompositeAssemblyImpl( Class<?> mainType )
-    {
-        types.add( mainType );
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return types;
-    }
-
-    protected StateModel createStateModel()
-    {
-        return new StateModel( propertiesModel );
-    }
-
-    protected MixinsModel createMixinsModel()
-    {
-        return new MixinsModel();
-    }
-
-    protected void buildComposite( AssemblyHelper helper,
-                                   StateDeclarations stateDeclarations
-    )
-    {
-        this.stateDeclarations = stateDeclarations;
-        this.helper = helper;
-        for( Class<?> compositeType : types )
-        {
-            metaInfo = new MetaInfo( metaInfo ).withAnnotations( compositeType );
-            addAnnotationsMetaInfo( compositeType, metaInfo );
-        }
-
-        immutable = metaInfo.get( Immutable.class ) != null;
-        propertiesModel = new PropertiesModel();
-        stateModel = createStateModel();
-        mixinsModel = createMixinsModel();
-        compositeMethodsModel = new CompositeMethodsModel( mixinsModel );
-
-        // Implement composite methods
-        ArrayList<Type> allTypes = getTypes( this.types );
-        Iterable<Class<? extends Constraint<?, ?>>> constraintClasses = constraintDeclarations( getTypes( this.types ) );
-        Iterable<Class<?>> concernClasses = flatten( concerns, concernDeclarations( allTypes ) );
-        Iterable<Class<?>> sideEffectClasses = flatten( sideEffects, sideEffectDeclarations( allTypes ) );
-        Iterable<Class<?>> mixinClasses = flatten( mixins, mixinDeclarations( this.types ) );
-        implementMixinType( types, constraintClasses, concernClasses, sideEffectClasses, mixinClasses );
-
-        // Add state from methods and fields
-        addState( constraintClasses );
-    }
-
-    protected void addAnnotationsMetaInfo( Class<?> type, MetaInfo compositeMetaInfo )
-    {
-        Class[] declaredInterfaces = type.getInterfaces();
-        for( int i = declaredInterfaces.length - 1; i >= 0; i-- )
-        {
-            addAnnotationsMetaInfo( declaredInterfaces[ i], compositeMetaInfo );
-        }
-        compositeMetaInfo.withAnnotations( type );
-    }
-
-    protected void implementMixinType( Iterable<? extends Class<?>> types,
-                                       Iterable<Class<? extends Constraint<?, ?>>> constraintClasses,
-                                       Iterable<Class<?>> concernClasses,
-                                       Iterable<Class<?>> sideEffectClasses,
-                                       Iterable<Class<?>> mixinClasses
-    )
-    {
-        Set<Class<?>> thisDependencies = new HashSet<>();
-        for( Class<?> mixinType : types )
-        {
-            for( Method method : mixinType.getMethods() )
-            {
-                if( !compositeMethodsModel.isImplemented( method )
-                    && !Proxy.class.equals( method.getDeclaringClass().getSuperclass() )
-                    && !Proxy.class.equals( method.getDeclaringClass() )
-                    && !Modifier.isStatic( method.getModifiers() ) )
-                {
-                    MixinModel mixinModel = implementMethod( method, mixinClasses );
-                    ConcernsModel concernsModel = concernsFor(
-                        method,
-                        mixinModel.mixinClass(),
-                        Iterables.<Class<?>>flatten( concernDeclarations( mixinModel.mixinClass() ),
-                                                     concernClasses )
-                    );
-                    SideEffectsModel sideEffectsModel = sideEffectsFor(
-                        method,
-                        mixinModel.mixinClass(),
-                        Iterables.<Class<?>>flatten( sideEffectDeclarations( mixinModel.mixinClass() ),
-                                                     sideEffectClasses )
-                    );
-                    method.setAccessible( true );
-                    ConstraintsModel constraints = constraintsFor(
-                        method,
-                        Iterables.<Class<? extends Constraint<?, ?>>>flatten( constraintDeclarations( mixinModel.mixinClass() ),
-                                                                              constraintClasses )
-                    );
-                    CompositeMethodModel methodComposite = new CompositeMethodModel(
-                        method,
-                        constraints,
-                        concernsModel,
-                        sideEffectsModel,
-                        mixinsModel
-                    );
-
-                    // Implement @This references
-                    Iterable<Class<?>> map = map( new DependencyModel.InjectionTypeFunction(),
-                                                  filter( new DependencyModel.ScopeSpecification( This.class ),
-                                                          methodComposite.dependencies() ) );
-                    Iterable<Class<?>> map1 = map( new DependencyModel.InjectionTypeFunction(),
-                                                   filter( new DependencyModel.ScopeSpecification( This.class ),
-                                                           mixinModel.dependencies() ) );
-                    @SuppressWarnings( "unchecked" )
-                    Iterable<Class<?>> filter = filter(
-                        not( in( Initializable.class, Lifecycle.class, InvocationHandler.class ) ),
-                        map( Classes.RAW_CLASS, interfacesOf( mixinModel.mixinClass() ) )
-                    );
-                    Iterable<? extends Class<?>> flatten = flatten( map, map1, filter );
-                    addAll( thisDependencies, flatten );
-
-                    compositeMethodsModel.addMethod( methodComposite );
-                }
-            }
-            // Add type to set of mixin types
-            mixinsModel.addMixinType( mixinType );
-        }
-
-        // Implement all @This dependencies that were found
-        for( Class<?> thisDependency : thisDependencies )
-        {
-            // Add additional declarations from the @This type
-            Iterable<Class<? extends Constraint<?, ?>>> typeConstraintClasses = flatten(
-                constraintClasses,
-                constraintDeclarations( thisDependency ) );
-            Iterable<Class<?>> typeConcernClasses = flatten(
-                concernClasses,
-                concernDeclarations( thisDependency ) );
-            Iterable<Class<?>> typeSideEffectClasses = flatten(
-                sideEffectClasses,
-                sideEffectDeclarations( thisDependency ) );
-            Iterable<Class<?>> typeMixinClasses = flatten(
-                mixinClasses,
-                mixinDeclarations( thisDependency ) );
-
-            @SuppressWarnings( "unchecked" )
-            Iterable<? extends Class<?>> singleton = iterable( thisDependency );
-            implementMixinType( singleton, typeConstraintClasses, typeConcernClasses, typeSideEffectClasses, typeMixinClasses );
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    protected MixinModel implementMethod( Method method, Iterable<Class<?>> mixinDeclarations )
-    {
-        MixinModel implementationModel = mixinsModel.mixinFor( method );
-        if( implementationModel != null )
-        {
-            return implementationModel;
-        }
-        Class mixinClass = findTypedImplementation( method, mixinDeclarations );
-        if( mixinClass != null )
-        {
-            return implementMethodWithClass( method, mixinClass );
-        }
-
-        // Check generic implementations
-        mixinClass = findGenericImplementation( method, mixinDeclarations );
-        if( mixinClass != null )
-        {
-            return implementMethodWithClass( method, mixinClass );
-        }
-
-        throw new InvalidCompositeException( "No implementation found for method \n    " + method.toGenericString()
-                                             + "\nin\n    " + types );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    private Class findTypedImplementation( final Method method, Iterable<Class<?>> mixins )
-    {
-        // Check if mixinClass implements the method. If so, check if the mixinClass is generic or if the filter passes.
-        // If a mixinClass is both generic AND non-generic at the same time, then the filter applies to the non-generic
-        // side only.
-        Specification<Class<?>> appliesToSpec = new Specification<Class<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( Class<?> item )
-            {
-                return helper.appliesTo( item, method, types, item );
-            }
-        };
-        return first( filter( and( isAssignableFrom( method.getDeclaringClass() ),
-                                   or( GenericSpecification.INSTANCE, appliesToSpec ) ),
-                              mixins ) );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Class<?> findGenericImplementation( final Method method, Iterable<Class<?>> mixins )
-    {
-        // Check if mixinClass is generic and the applies-to filter passes
-        return first( filter( and( GenericSpecification.INSTANCE, new Specification<Class<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( Class<?> item )
-            {
-                return helper.appliesTo( item, method, types, item );
-            }
-        } ), mixins ) );
-    }
-
-    private MixinModel implementMethodWithClass( Method method, Class mixinClass )
-    {
-        MixinModel mixinModel = mixinsModel.getMixinModel( mixinClass );
-        if( mixinModel == null )
-        {
-            mixinModel = helper.getMixinModel( mixinClass );
-            mixinsModel.addMixinModel( mixinModel );
-        }
-
-        mixinsModel.addMethodMixin( method, mixinModel );
-
-        return mixinModel;
-    }
-
-    protected void addState( final Iterable<Class<? extends Constraint<?, ?>>> constraintClasses )
-    {
-        // Add method state
-        compositeMethodsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
-        {
-            @Override
-            public boolean visitEnter( Object visited )
-                throws RuntimeException
-            {
-                if( visited instanceof CompositeMethodModel )
-                {
-                    CompositeMethodModel methodModel = (CompositeMethodModel) visited;
-                    if( methodModel.method().getParameterTypes().length == 0 )
-                    {
-                        addStateFor( methodModel.method(), constraintClasses );
-                    }
-
-                    return false;
-                }
-
-                return super.visitEnter( visited );
-            }
-        } );
-
-        // Add field state
-        mixinsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
-        {
-            @Override
-            public boolean visitEnter( Object visited )
-                throws RuntimeException
-            {
-                if( visited instanceof MixinModel )
-                {
-                    MixinModel model = (MixinModel) visited;
-                    Visitor<Field, RuntimeException> addState = new Visitor<Field, RuntimeException>()
-                    {
-                        @Override
-                        public boolean visit( Field visited )
-                            throws RuntimeException
-                        {
-                            addStateFor( visited, constraintClasses );
-                            return true;
-                        }
-                    };
-                    ForEach.forEach( Fields.FIELDS_OF.map( model.mixinClass() ) ).
-                        filter( Annotations.hasAnnotation( State.class ) ).
-                        visit( addState );
-                    return false;
-                }
-                return super.visitEnter( visited );
-            }
-        } );
-    }
-
-    protected void addStateFor( AccessibleObject accessor,
-                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        String stateName = QualifiedName.fromAccessor( accessor ).name();
-
-        if( registeredStateNames.contains( stateName ) )
-        {
-            return; // Skip already registered names
-        }
-
-        if( Property.class.isAssignableFrom( Classes.RAW_CLASS.map( typeOf( accessor ) ) ) )
-        {
-            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-    }
-
-    protected PropertyModel newPropertyModel( AccessibleObject accessor,
-                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-        ValueConstraintsModel valueConstraintsModel = constraintsFor(
-            annotations,
-            GenericPropertyInfo.propertyTypeOf( accessor ),
-            ( (Member) accessor ).getName(),
-            optional,
-            constraintClasses,
-            accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        Object initialValue = stateDeclarations.initialValueOf( accessor );
-        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
-        boolean immutable = this.immutable || metaInfo.get( Immutable.class ) != null;
-        PropertyModel propertyModel = new PropertyModel(
-            accessor,
-            immutable,
-            useDefaults,
-            valueConstraintsInstance,
-            metaInfo,
-            initialValue );
-        return propertyModel;
-    }
-
-    // Model
-    private ConstraintsModel constraintsFor( Method method,
-                                             Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        List<ValueConstraintsModel> parameterConstraintModels = Collections.emptyList();
-        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
-        Type[] parameterTypes = method.getGenericParameterTypes();
-        boolean constrained = false;
-        for( int i = 0; i < parameterAnnotations.length; i++ )
-        {
-            Annotation[] parameterAnnotation = parameterAnnotations[i];
-
-            Name nameAnnotation = (Name) first( filter( isType( Name.class ), iterable( parameterAnnotation ) ) );
-            String name = nameAnnotation == null ? "param" + ( i + 1 ) : nameAnnotation.value();
-
-            boolean optional = first( filter( isType( Optional.class ), iterable( parameterAnnotation ) ) ) != null;
-            ValueConstraintsModel parameterConstraintsModel = constraintsFor(
-                asList( parameterAnnotation ),
-                parameterTypes[i],
-                name,
-                optional,
-                constraintClasses,
-                method );
-            if( parameterConstraintsModel.isConstrained() )
-            {
-                constrained = true;
-            }
-
-            if( parameterConstraintModels.isEmpty() )
-            {
-                parameterConstraintModels = new ArrayList<>();
-            }
-            parameterConstraintModels.add( parameterConstraintsModel );
-        }
-
-        if( !constrained )
-        {
-            return new ConstraintsModel( Collections.<ValueConstraintsModel>emptyList() );
-        }
-        else
-        {
-            return new ConstraintsModel( parameterConstraintModels );
-        }
-    }
-
-    protected ValueConstraintsModel constraintsFor(
-        Iterable<Annotation> constraintAnnotations,
-        Type valueType,
-        String name,
-        boolean optional,
-        Iterable<Class<? extends Constraint<?, ?>>> constraintClasses,
-        AccessibleObject accessor
-    )
-    {
-        valueType = wrapperClass( valueType );
-
-        List<AbstractConstraintModel> constraintModels = new ArrayList<>();
-        nextConstraint:
-        for( Annotation constraintAnnotation : filter( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ),
-                                                       constraintAnnotations ) )
-        {
-            // Check composite declarations first
-            Class<? extends Annotation> annotationType = constraintAnnotation.annotationType();
-            for( Class<? extends Constraint<?, ?>> constraint : constraintClasses )
-            {
-                if( helper.appliesTo( constraint, annotationType, valueType ) )
-                {
-                    constraintModels.add( new ConstraintModel( constraintAnnotation, constraint ) );
-                    continue nextConstraint;
-                }
-            }
-
-            // Check the annotation itself
-            Constraints constraints = annotationType.getAnnotation( Constraints.class );
-            if( constraints != null )
-            {
-                for( Class<? extends Constraint<?, ?>> constraintClass : constraints.value() )
-                {
-                    if( helper.appliesTo( constraintClass, annotationType, valueType ) )
-                    {
-                        constraintModels.add( new ConstraintModel( constraintAnnotation, constraintClass ) );
-                        continue nextConstraint;
-                    }
-                }
-            }
-
-            // No implementation found!
-            // Check if if it's a composite constraints
-            Iterable<Annotation> annotations = iterable( annotationType.getAnnotations() );
-            if( matchesAny( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ), annotations ) )
-            {
-                ValueConstraintsModel valueConstraintsModel = constraintsFor(
-                    annotations,
-                    valueType,
-                    name,
-                    optional,
-                    constraintClasses,
-                    accessor );
-                CompositeConstraintModel compositeConstraintModel = new CompositeConstraintModel(
-                    constraintAnnotation,
-                    valueConstraintsModel );
-                constraintModels.add( compositeConstraintModel );
-                continue nextConstraint;
-            }
-
-            throw new InvalidCompositeException(
-                "Cannot find implementation of constraint @"
-                + annotationType.getSimpleName()
-                + " for "
-                + valueType
-                + " in method "
-                + ( (Member) accessor ).getName()
-                + " of composite " + types );
-        }
-
-        return new ValueConstraintsModel( constraintModels, name, optional );
-    }
-
-    private ConcernsModel concernsFor( Method method,
-                                       Class<?> mixinClass,
-                                       Iterable<Class<?>> concernClasses
-    )
-    {
-        List<ConcernModel> concernsFor = new ArrayList<>();
-        for( Class<?> concern : concernClasses )
-        {
-            if( helper.appliesTo( concern, method, types, mixinClass ) )
-            {
-                concernsFor.add( helper.getConcernModel( concern ) );
-            }
-            else
-            {
-                // Lookup method in mixin
-                if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
-                {
-                    try
-                    {
-                        Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
-                        if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
-                        {
-                            concernsFor.add( helper.getConcernModel( concern ) );
-                        }
-                    }
-                    catch( NoSuchMethodException e )
-                    {
-                        // Ignore
-                    }
-                }
-            }
-        }
-
-        // Check annotations on method that have @Concerns annotations themselves
-        for( Annotation annotation : method.getAnnotations() )
-        {
-            @SuppressWarnings( "raw" )
-            Concerns concerns = annotation.annotationType().getAnnotation( Concerns.class );
-            if( concerns != null )
-            {
-                for( Class<?> concern : concerns.value() )
-                {
-                    if( helper.appliesTo( concern, method, types, mixinClass ) )
-                    {
-                        concernsFor.add( helper.getConcernModel( concern ) );
-                    }
-                }
-            }
-        }
-
-        if( concernsFor.isEmpty() )
-        {
-            return ConcernsModel.EMPTY_CONCERNS;
-        }
-        else
-        {
-            return new ConcernsModel( concernsFor );
-        }
-    }
-
-    private SideEffectsModel sideEffectsFor( Method method,
-                                             Class<?> mixinClass,
-                                             Iterable<Class<?>> sideEffectClasses
-    )
-    {
-        List<SideEffectModel> sideEffectsFor = new ArrayList<>();
-        for( Class<?> sideEffect : sideEffectClasses )
-        {
-            if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
-            {
-                sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
-            }
-            else
-            {
-                // Lookup method in mixin
-                if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
-                {
-                    try
-                    {
-                        Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
-                        if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass ) )
-                        {
-                            sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
-                        }
-                    }
-                    catch( NoSuchMethodException e )
-                    {
-                        // Ignore
-                    }
-                }
-            }
-        }
-
-        if( sideEffectsFor.isEmpty() )
-        {
-            return SideEffectsModel.EMPTY_SIDEEFFECTS;
-        }
-        else
-        {
-            return new SideEffectsModel( sideEffectsFor );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Iterable<Class<? extends Constraint<?, ?>>> constraintDeclarations( Class<?> type )
-    {
-        ArrayList<Type> allTypes = getTypes( type );
-        return constraintDeclarations( allTypes );
-    }
-
-    private Iterable<Class<? extends Constraint<?, ?>>> constraintDeclarations( ArrayList<Type> allTypes )
-    {
-        // Find all constraints and flatten them into an iterable
-        Function<Type, Iterable<Class<? extends Constraint<?, ?>>>> function = new Function<Type, Iterable<Class<? extends Constraint<?, ?>>>>()
-        {
-            @Override
-            public Iterable<Class<? extends Constraint<?, ?>>> map( Type type )
-            {
-                Constraints constraints = Annotations.annotationOn( type, Constraints.class );
-                if( constraints == null )
-                {
-                    return empty();
-                }
-                else
-                {
-                    return iterable( constraints.value() );
-                }
-            }
-        };
-        Iterable<Class<? extends Constraint<?, ?>>> flatten = flattenIterables( map( function, allTypes ) );
-        return toList( flatten );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Iterable<Class<?>> concernDeclarations( Class<?> type )
-    {
-        Iterable<? extends Class<?>> iterable = iterable( type );
-        return concernDeclarations( getTypes( iterable ) );
-    }
-
-    private Iterable<Class<?>> concernDeclarations( ArrayList<Type> allTypes )
-    {
-        // Find all concerns and flattern them into an iterable
-        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
-        {
-            @Override
-            public Iterable<Class<?>> map( Type type )
-            {
-                Concerns concerns = Annotations.annotationOn( type, Concerns.class );
-                if( concerns == null )
-                {
-                    return empty();
-                }
-                else
-                {
-                    return iterable( concerns.value() );
-                }
-            }
-        };
-        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
-        return toList( flatten );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected Iterable<Class<?>> sideEffectDeclarations( Class<?> type )
-    {
-        Iterable<? extends Class<?>> iterable = iterable( type );
-        return sideEffectDeclarations( getTypes( iterable ) );
-    }
-
-    protected Iterable<Class<?>> sideEffectDeclarations( ArrayList<Type> allTypes )
-    {
-        // Find all side-effects and flattern them into an iterable
-        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
-        {
-            @Override
-            public Iterable<Class<?>> map( Type type )
-            {
-                SideEffects sideEffects = Annotations.annotationOn( type, SideEffects.class );
-                if( sideEffects == null )
-                {
-                    return empty();
-                }
-                else
-                {
-                    return iterable( sideEffects.value() );
-                }
-            }
-        };
-        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
-        return toList( flatten );
-    }
-
-    private ArrayList<Type> getTypes( Class<?> type )
-    {
-        Iterable<? extends Class<?>> iterable = iterable( type );
-        return getTypes( iterable );
-    }
-
-    private ArrayList<Type> getTypes( Iterable<? extends Class<?>> typess )
-    {
-        // Find side-effect declarations
-        ArrayList<Type> allTypes = new ArrayList<>();
-        for( Class<?> type : typess )
-        {
-            Iterable<Type> types;
-            if( type.isInterface() )
-            {
-                types = typesOf( type );
-            }
-            else
-            {
-                types = cast( classHierarchy( type ) );
-            }
-            addAll( allTypes, types );
-        }
-        return allTypes;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected Iterable<Class<?>> mixinDeclarations( Class<?> type )
-    {
-        Iterable<? extends Class<?>> iterable = iterable( type );
-        return mixinDeclarations( iterable );
-    }
-
-    protected Iterable<Class<?>> mixinDeclarations( Iterable<? extends Class<?>> typess )
-    {
-        // Find mixin declarations
-        ArrayList<Type> allTypes = new ArrayList<>();
-        for( Class<?> type : typess )
-        {
-            Iterable<Type> types = typesOf( type );
-            addAll( allTypes, types );
-        }
-
-        // Find all mixins and flattern them into an iterable
-        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
-        {
-            @Override
-            public Iterable<Class<?>> map( Type type )
-            {
-                Mixins mixins = Annotations.annotationOn( type, Mixins.class );
-                if( mixins == null )
-                {
-                    return empty();
-                }
-                else
-                {
-                    return iterable( mixins.value() );
-                }
-            }
-        };
-        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
-        return toList( flatten );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
deleted file mode 100644
index f755d85..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
+++ /dev/null
@@ -1,42 +0,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.
- *
- */
-package org.apache.zest.runtime.bootstrap;
-
-import org.apache.zest.bootstrap.ConfigurationAssembly;
-
-/**
- * Declaration of a EntityComposite.
- */
-public final class ConfigurationAssemblyImpl
-    implements ConfigurationAssembly
-{
-    private ValueAssemblyImpl value;
-    private EntityAssemblyImpl entity;
-
-    public ConfigurationAssemblyImpl( Class<?> mainType )
-    {
-        value = new ValueAssemblyImpl( mainType );
-        entity = new EntityAssemblyImpl( mainType );
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return value.types();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
deleted file mode 100644
index 1076390..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
+++ /dev/null
@@ -1,124 +0,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.
- *
- */
-
-package org.apache.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.ConfigurationDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a Composite. Created by {@link org.apache.zest.bootstrap.ModuleAssembly#configurations(Class[])}.
- */
-public final class ConfigurationDeclarationImpl
-    implements ConfigurationDeclaration
-{
-    private final Iterable<EntityAssemblyImpl> entities;
-    private final Iterable<ValueAssemblyImpl> values;
-
-    public ConfigurationDeclarationImpl( Iterable<EntityAssemblyImpl> entities, Iterable<ValueAssemblyImpl> values  )
-    {
-        this.entities = entities;
-        this.values = values;
-    }
-
-    @Override
-    public ConfigurationDeclaration setMetaInfo( Object info )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.metaInfo.set( info );
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.metaInfo.set( info );
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationDeclaration visibleIn( Visibility visibility )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.visibility = visibility;
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationDeclaration withConcerns( Class<?>... concerns )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.concerns.addAll( asList( concerns ) );
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.concerns.addAll( asList( concerns ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationDeclaration withSideEffects( Class<?>... sideEffects )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.sideEffects.addAll( asList( sideEffects ) );
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.sideEffects.addAll( asList( sideEffects ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationDeclaration withMixins( Class<?>... mixins )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.mixins.addAll( asList( mixins ) );
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.mixins.addAll( asList( mixins ) );
-        }
-        return this;
-    }
-
-    @Override
-    public ConfigurationDeclaration withTypes( Class<?>... types )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.types.addAll( asList( types ) );
-        }
-        for( ValueAssemblyImpl value : values )
-        {
-            value.types.addAll( asList( types ) );
-        }
-        return this;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
deleted file mode 100644
index 6daba43..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.AssociationDeclarations;
-import org.apache.zest.bootstrap.EntityAssembly;
-import org.apache.zest.bootstrap.ManyAssociationDeclarations;
-import org.apache.zest.bootstrap.NamedAssociationDeclarations;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.composite.ValueConstraintsModel;
-import org.apache.zest.runtime.entity.EntityMixinsModel;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.entity.EntityStateModel;
-import org.apache.zest.runtime.property.PropertyModel;
-
-import static org.apache.zest.api.util.Annotations.isType;
-import static org.apache.zest.api.util.Classes.typeOf;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Declaration of a EntityComposite.
- */
-public final class EntityAssemblyImpl
-    extends CompositeAssemblyImpl
-    implements EntityAssembly
-{
-    private AssociationDeclarations associationDeclarations;
-    private ManyAssociationDeclarations manyAssociationDeclarations;
-    private NamedAssociationDeclarations namedAssociationDeclarations;
-    private AssociationsModel associationsModel;
-    private ManyAssociationsModel manyAssociationsModel;
-    private NamedAssociationsModel namedAssociationsModel;
-
-    public EntityAssemblyImpl( Class<?> entityType )
-    {
-        super( entityType );
-        // The composite must always implement EntityComposite, as a marker interface
-        if( !EntityComposite.class.isAssignableFrom( entityType ) )
-        {
-            types.add( EntityComposite.class );
-        }
-    }
-
-    @Override
-    protected MixinsModel createMixinsModel()
-    {
-        return new EntityMixinsModel();
-    }
-
-    @Override
-    protected StateModel createStateModel()
-    {
-        return new EntityStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
-    }
-
-    EntityModel newEntityModel(
-        StateDeclarations stateDeclarations,
-        AssociationDeclarations associationDecs,
-        ManyAssociationDeclarations manyAssociationDecs,
-        NamedAssociationDeclarations namedAssociationDecs,
-        AssemblyHelper helper
-    )
-    {
-        this.associationDeclarations = associationDecs;
-        this.manyAssociationDeclarations = manyAssociationDecs;
-        this.namedAssociationDeclarations = namedAssociationDecs;
-        try
-        {
-            associationsModel = new AssociationsModel();
-            manyAssociationsModel = new ManyAssociationsModel();
-            namedAssociationsModel = new NamedAssociationsModel();
-            buildComposite( helper, stateDeclarations );
-
-            EntityModel entityModel = new EntityModel(
-                types, visibility, metaInfo, (EntityMixinsModel) mixinsModel, (EntityStateModel) stateModel, compositeMethodsModel );
-
-            return entityModel;
-        }
-        catch( Exception e )
-        {
-            throw new InvalidApplicationException( "Could not register " + types, e );
-        }
-    }
-
-    @Override
-    protected void addStateFor( AccessibleObject accessor,
-                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        String stateName = QualifiedName.fromAccessor( accessor ).name();
-
-        if( registeredStateNames.contains( stateName ) )
-        {
-            return; // Skip already registered names
-        }
-
-        Class<?> accessorType = Classes.RAW_CLASS.map( typeOf( accessor ) );
-        if( Property.class.isAssignableFrom( accessorType ) )
-        {
-            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( Association.class.isAssignableFrom( accessorType ) )
-        {
-            associationsModel.addAssociation( newAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( ManyAssociation.class.isAssignableFrom( accessorType ) )
-        {
-            manyAssociationsModel.addManyAssociation( newManyAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-        else if( NamedAssociation.class.isAssignableFrom( accessorType ) )
-        {
-            namedAssociationsModel.addNamedAssociation( newNamedAssociationModel( accessor, constraintClasses ) );
-            registeredStateNames.add( stateName );
-        }
-    }
-
-    @Override
-    protected PropertyModel newPropertyModel( AccessibleObject accessor,
-                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member) accessor )
-            .getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
-        Object defaultValue = stateDeclarations.initialValueOf( accessor );
-        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
-        boolean immutable = this.immutable || metaInfo.get( Immutable.class ) != null;
-        PropertyModel propertyModel = new PropertyModel( accessor, immutable, useDefaults, valueConstraintsInstance, metaInfo, defaultValue );
-        return propertyModel;
-    }
-
-    public AssociationModel newAssociationModel( AccessibleObject accessor,
-                                                 Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for Association references
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the Association itself
-        valueConstraintsModel = constraintsFor( annotations, Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance associationValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            associationValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        MetaInfo metaInfo = associationDeclarations.metaInfoFor( accessor );
-        AssociationModel associationModel = new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-
-    public ManyAssociationModel newManyAssociationModel( AccessibleObject accessor,
-                                                         Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for entities in ManyAssociation
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the ManyAssociation itself
-        valueConstraintsModel = constraintsFor( annotations, ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance manyValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            manyValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = manyAssociationDeclarations.metaInfoFor( accessor );
-        ManyAssociationModel associationModel = new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-
-    public NamedAssociationModel newNamedAssociationModel( AccessibleObject accessor,
-                                                           Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
-    )
-    {
-        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
-        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
-
-        // Constraints for entities in NamedAssociation
-        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
-            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance valueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            valueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-
-        // Constraints for the NamedAssociation itself
-        valueConstraintsModel = constraintsFor( annotations, NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
-        ValueConstraintsInstance namedValueConstraintsInstance = null;
-        if( valueConstraintsModel.isConstrained() )
-        {
-            namedValueConstraintsInstance = valueConstraintsModel.newInstance();
-        }
-        MetaInfo metaInfo = namedAssociationDeclarations.metaInfoFor( accessor );
-        NamedAssociationModel associationModel = new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
-        return associationModel;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityDeclarationImpl.java
deleted file mode 100644
index ada560e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityDeclarationImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.EntityDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a Composite. Created by {@link org.apache.zest.bootstrap.ModuleAssembly#transients(Class[])}.
- */
-public final class EntityDeclarationImpl
-    implements EntityDeclaration
-{
-    private final Iterable<EntityAssemblyImpl> entities;
-
-    public EntityDeclarationImpl( Iterable<EntityAssemblyImpl> entities )
-    {
-        this.entities = entities;
-    }
-
-    @Override
-    public EntityDeclaration setMetaInfo( Object info )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.metaInfo.set( info );
-        }
-        return this;
-    }
-
-    @Override
-    public EntityDeclaration visibleIn( Visibility visibility )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    public EntityDeclaration withConcerns( Class<?>... concerns )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.concerns.addAll( asList( concerns ) );
-        }
-        return this;
-    }
-
-    @Override
-    public EntityDeclaration withSideEffects( Class<?>... sideEffects )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.sideEffects.addAll( asList( sideEffects ) );
-        }
-        return this;
-    }
-
-    @Override
-    public EntityDeclaration withMixins( Class<?>... mixins )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.mixins.addAll( asList( mixins ) );
-        }
-        return this;
-    }
-
-    @Override
-    public EntityDeclaration withTypes( Class<?>... types )
-    {
-        for( EntityAssemblyImpl entity : entities )
-        {
-            entity.types.addAll( asList( types ) );
-        }
-        return this;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImplementsMethodAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
deleted file mode 100644
index f7ec1ec..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class ImplementsMethodAppliesToFilter
-    implements AppliesToFilter
-{
-    @Override
-    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-    {
-        try
-        {
-            return !Modifier.isAbstract( fragmentClass.getMethod( method.getName(), method.getParameterTypes() )
-                                             .getModifiers() );
-        }
-        catch( NoSuchMethodException e )
-        {
-            return false;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
deleted file mode 100644
index a07b4f8..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.importer.InstanceImporter;
-import org.apache.zest.bootstrap.ImportedServiceAssembly;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.service.ImportedServiceModel;
-
-/**
- * Declaration of an imported Service.
- *
- * Created by {@link org.apache.zest.runtime.bootstrap.ModuleAssemblyImpl#importedServices(Class[])}.
- */
-public final class ImportedServiceAssemblyImpl
-    implements ImportedServiceAssembly
-{
-    private final Class<?> serviceType;
-    private final ModuleAssemblyImpl moduleAssembly;
-    @SuppressWarnings( "raw" )
-    Class<? extends ServiceImporter> serviceProvider = InstanceImporter.class;
-    String identity;
-    boolean importOnStartup = false;
-    MetaInfo metaInfo = new MetaInfo();
-    Visibility visibility = Visibility.module;
-    List<Class<? extends Activator<?>>> activators = new ArrayList<>();
-
-    public ImportedServiceAssemblyImpl( Class<?> serviceType, ModuleAssemblyImpl moduleAssembly )
-    {
-        this.serviceType = serviceType;
-        this.moduleAssembly = moduleAssembly;
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return Iterables.<Class<?>>iterable( serviceType );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    void addImportedServiceModel( List<ImportedServiceModel> serviceModels )
-    {
-        try
-        {
-            String id = identity;
-            if( id == null )
-            {
-                id = generateId( serviceModels, serviceType );
-            }
-
-            ImportedServiceModel serviceModel = new ImportedServiceModel( serviceType,
-                                                                          visibility,
-                                                                          serviceProvider,
-                                                                          id,
-                                                                          importOnStartup,
-                                                                          new MetaInfo( metaInfo ).withAnnotations( serviceType ),
-                                                                          new ActivatorsModel( activators ),
-                                                                          moduleAssembly.name() );
-            serviceModels.add( serviceModel );
-        }
-        catch( Exception e )
-        {
-            throw new InvalidApplicationException( "Could not register " + serviceType.getName(), e );
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    private String generateId( List<ImportedServiceModel> serviceModels, Class serviceType )
-    {
-        // Find identity that is not yet used
-        int idx = 0;
-        String id = serviceType.getSimpleName();
-        boolean invalid;
-        do
-        {
-            invalid = false;
-            for( ImportedServiceModel serviceModel : serviceModels )
-            {
-                if( serviceModel.identity().equals( id ) )
-                {
-                    idx++;
-                    id = serviceType.getSimpleName() + "_" + idx;
-                    invalid = true;
-                    break;
-                }
-            }
-        }
-        while( invalid );
-        return id;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceDeclarationImpl.java
deleted file mode 100644
index d1263e1..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceDeclarationImpl.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.qualifier.ServiceTags;
-import org.apache.zest.bootstrap.ImportedServiceDeclaration;
-
-/**
- * Declaration of an imported Service.
- */
-public final class ImportedServiceDeclarationImpl
-    implements ImportedServiceDeclaration
-{
-    private final Iterable<ImportedServiceAssemblyImpl> assemblies;
-
-    public ImportedServiceDeclarationImpl( Iterable<ImportedServiceAssemblyImpl> assemblies )
-    {
-        this.assemblies = assemblies;
-    }
-
-    @Override
-    public ImportedServiceDeclaration importOnStartup()
-    {
-        for( ImportedServiceAssemblyImpl assembly : assemblies )
-        {
-            assembly.importOnStartup = true;
-        }
-        return this;
-    }
-
-    @Override
-    public ImportedServiceDeclaration visibleIn( Visibility visibility )
-    {
-        for( ImportedServiceAssemblyImpl assembly : assemblies )
-        {
-            assembly.visibility = visibility;
-        }
-        return this;
-    }
-
-    @Override
-    @SuppressWarnings( "raw" )
-    public ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> sip )
-    {
-        for( ImportedServiceAssemblyImpl assembly : assemblies )
-        {
-            assembly.serviceProvider = sip;
-        }
-        return this;
-    }
-
-    @Override
-    public ImportedServiceDeclaration identifiedBy( String identity )
-    {
-        for( ImportedServiceAssemblyImpl assembly : assemblies )
-        {
-            assembly.identity = identity;
-        }
-        return this;
-    }
-
-    @Override
-    public ImportedServiceDeclaration taggedWith( String... tags )
-    {
-        for( ImportedServiceAssemblyImpl serviceAssembly : assemblies )
-        {
-            ServiceTags previousTags = serviceAssembly.metaInfo.get( ServiceTags.class );
-            if( previousTags != null )
-            {
-                List<String> tagList = new ArrayList<>();
-                Collections.addAll( tagList, previousTags.tags() );
-                Collections.addAll( tagList, tags );
-                serviceAssembly.metaInfo.set( new ServiceTags( tagList.toArray( new String[ tagList.size() ] ) ) );
-            }
-            else
-            {
-                serviceAssembly.metaInfo.set( new ServiceTags( tags ) );
-            }
-        }
-
-        return this;
-    }
-
-    @Override
-    public ImportedServiceDeclaration setMetaInfo( Object serviceAttribute )
-    {
-        for( ImportedServiceAssemblyImpl assembly : assemblies )
-        {
-            assembly.metaInfo.set( serviceAttribute );
-        }
-        return this;
-    }
-
-    @Override
-    @SafeVarargs
-    public final ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
-    {
-        for ( ImportedServiceAssemblyImpl serviceAssembly : assemblies ) {
-            serviceAssembly.activators.addAll( Arrays.asList( activators ) );
-        }
-        return this;
-    }
-}
\ No newline at end of file


[14/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractConstraintModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractConstraintModel.java
deleted file mode 100644
index d8c9ff6..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractConstraintModel.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import org.apache.zest.api.constraint.ConstraintDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-
-/**
- * JAVADOC
- */
-public abstract class AbstractConstraintModel
-    implements ConstraintDescriptor, Visitable<ConstraintDescriptor>
-{
-    protected final Annotation annotation;
-
-    public AbstractConstraintModel( Annotation annotation )
-    {
-        this.annotation = annotation;
-    }
-
-    @Override
-    public Annotation annotation()
-    {
-        return annotation;
-    }
-
-    public abstract ConstraintInstance<?, ?> newInstance();
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super ConstraintDescriptor, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        return modelVisitor.visit( this );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
deleted file mode 100644
index a2478ce..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectedFieldsModel;
-import org.apache.zest.runtime.injection.InjectedMethodsModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Iterables.toArray;
-import static org.apache.zest.functional.Iterables.unique;
-
-/**
- * JAVADOC
- */
-public abstract class AbstractModifierModel
-    implements Dependencies, VisitableHierarchy<Object, Object>
-{
-    private final Class<?> modifierClass;
-
-    private final ConstructorsModel constructorsModel;
-    private final InjectedFieldsModel injectedFieldsModel;
-    private final InjectedMethodsModel injectedMethodsModel;
-
-    private final Class<?>[] nextInterfaces;
-
-    @SuppressWarnings( "unchecked" )
-    public AbstractModifierModel( Class<?> declaredModifierClass, Class<?> instantiationClass )
-    {
-        this.modifierClass = instantiationClass;
-        constructorsModel = new ConstructorsModel( modifierClass );
-        injectedFieldsModel = new InjectedFieldsModel( declaredModifierClass );
-        injectedMethodsModel = new InjectedMethodsModel( declaredModifierClass );
-        Class<Class<?>> componentType = (Class<Class<?>>) Class.class.cast( Class.class );
-        nextInterfaces = toArray( componentType, unique( map( RAW_CLASS, interfacesOf( declaredModifierClass ) ) ) );
-    }
-
-    public Class<?> modifierClass()
-    {
-        return modifierClass;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Iterable<DependencyModel> dependencies()
-    {
-        return flattenIterables( map( DEPENDENCIES_FUNCTION, iterable( constructorsModel, injectedFieldsModel, injectedMethodsModel ) ) );
-    }
-
-    public boolean isGeneric()
-    {
-        return InvocationHandler.class.isAssignableFrom( modifierClass );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( constructorsModel.accept( visitor ) )
-            {
-                if( injectedFieldsModel.accept( visitor ) )
-                {
-                    injectedMethodsModel.accept( visitor );
-                }
-            }
-        }
-
-        return visitor.visitLeave( this );
-    }
-
-    // Context
-    public InvocationHandler newInstance( ModuleSpi moduleInstance,
-                                          InvocationHandler next,
-                                          ProxyReferenceInvocationHandler proxyHandler,
-                                          Method method
-    )
-    {
-        InjectionContext injectionContext = new InjectionContext( moduleInstance, wrapNext( next ), proxyHandler );
-
-        Object modifier = constructorsModel.newInstance( injectionContext );
-
-        try
-        {
-            if( FragmentClassLoader.isGenerated( modifier ) )
-            {
-                modifier.getClass().getField( "_instance" ).set( modifier, proxyHandler );
-            }
-        }
-        catch( IllegalAccessException | NoSuchFieldException e )
-        {
-            e.printStackTrace();
-        }
-
-        injectedFieldsModel.inject( injectionContext, modifier );
-        injectedMethodsModel.inject( injectionContext, modifier );
-
-        if( isGeneric() )
-        {
-            return (InvocationHandler) modifier;
-        }
-        else
-        {
-            try
-            {
-                Method invocationMethod = modifierClass.getMethod( "_" + method.getName(), method.getParameterTypes() );
-                TypedModifierInvocationHandler handler = new TypedModifierInvocationHandler();
-                handler.setFragment( modifier );
-                handler.setMethod( invocationMethod );
-                return handler;
-            }
-            catch( NoSuchMethodException e )
-            {
-                throw new ConstructionException( "Could not find modifier method", e );
-            }
-        }
-    }
-
-    private Object wrapNext( InvocationHandler next )
-    {
-        if( isGeneric() )
-        {
-            return next;
-        }
-        else
-        {
-            return Proxy.newProxyInstance( modifierClass.getClassLoader(), nextInterfaces, next );
-        }
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        AbstractModifierModel that = (AbstractModifierModel) o;
-        return modifierClass.equals( that.modifierClass );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return modifierClass.hashCode();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/AtomicInstancePool.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AtomicInstancePool.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AtomicInstancePool.java
deleted file mode 100644
index 4929297..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AtomicInstancePool.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * Method instance pool that keeps a linked list. Uses atomic reference
- * to ensure that instances are acquired and returned in a thread-safe
- * manner.
- */
-public final class AtomicInstancePool
-    implements InstancePool<CompositeMethodInstance>
-{
-    private final AtomicReference<CompositeMethodInstance> first = new AtomicReference<CompositeMethodInstance>();
-
-    @Override
-    public CompositeMethodInstance obtainInstance()
-    {
-        CompositeMethodInstance firstInstance;
-        do
-        {
-            firstInstance = first.get();
-        }
-        while( firstInstance != null && !first.compareAndSet( firstInstance, firstInstance.getNext() ) );
-
-        return firstInstance;
-    }
-
-    @Override
-    public void releaseInstance( CompositeMethodInstance compositeMethodInstance )
-    {
-        CompositeMethodInstance firstInstance;
-        do
-        {
-            firstInstance = first.get();
-            compositeMethodInstance.setNext( firstInstance );
-        }
-        while( !first.compareAndSet( firstInstance, compositeMethodInstance ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompactLevel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompactLevel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompactLevel.java
deleted file mode 100644
index 42a0dee..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompactLevel.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.runtime.composite;
-
-/**
- * Compaction Level of the StackTrace clenaup operation.
- *
- * <pre>
- * <b>off</b>       = Do not modify the stack trace.
- * <b>proxy</b>     = Remove all Zest internal classes and all JDK internal classes from
- *             the originating method call.
- * <b>semi</b>      = Remove all JDK internal classes on the entire stack.
- * <b>extensive</b> = Remove all Zest internal and JDK internal classes from the entire stack.
- * </pre>
- *
- * <p>
- * The Compaction is set through the System Property "<code><b>qi4j.compacttrace</b></code>" to
- * any of the above values.
- * </p>
- */
-enum CompactLevel
-{
-    off, proxy, semi, extensive
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeConstraintModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeConstraintModel.java
deleted file mode 100644
index bcf068c..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeConstraintModel.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.constraint.Constraint;
-
-/**
- * JAVADOC
- */
-public final class CompositeConstraintModel
-    extends AbstractConstraintModel
-{
-    private final ValueConstraintsModel constraintsModel;
-
-    public CompositeConstraintModel( Annotation annotation, ValueConstraintsModel constraintsModel )
-    {
-        super( annotation );
-        this.constraintsModel = constraintsModel;
-    }
-
-    @Override
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public ConstraintInstance<?, ?> newInstance()
-    {
-        try
-        {
-            ValueConstraintsInstance compositeConstraintsInstance = constraintsModel.newInstance();
-            Constraint<?, ?> constraint = new CompositeConstraintInstance( compositeConstraintsInstance );
-            return new ConstraintInstance( constraint, annotation );
-        }
-        catch( Exception e )
-        {
-            throw new ConstructionException( "Could not instantiate constraint implementation", e );
-        }
-    }
-
-    private static class CompositeConstraintInstance
-        implements Constraint<Annotation, Object>
-    {
-        private final ValueConstraintsInstance valueConstraintsInstance;
-
-        private CompositeConstraintInstance( ValueConstraintsInstance valueConstraintsInstance )
-        {
-            this.valueConstraintsInstance = valueConstraintsInstance;
-        }
-
-        @Override
-        public boolean isValid( Annotation annotation, Object value )
-            throws NullPointerException
-        {
-            return valueConstraintsInstance.checkConstraints( value ).isEmpty();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodInstance.java
deleted file mode 100644
index ae3f706..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodInstance.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-public final class CompositeMethodInstance
-{
-    private final InvocationHandler invoker;
-    private final FragmentInvocationHandler mixinInvoker;
-    private final Method method;
-    private final int methodIdx;
-
-    private CompositeMethodInstance next;
-
-    public CompositeMethodInstance( InvocationHandler invoker,
-                                    FragmentInvocationHandler mixinInvoker,
-                                    Method method, int methodIdx
-    )
-    {
-        this.invoker = invoker;
-        this.method = method;
-        this.mixinInvoker = mixinInvoker;
-        this.methodIdx = methodIdx;
-    }
-
-    public Method method()
-    {
-        return method;
-    }
-
-    public Object getMixinFrom( Object[] mixins )
-    {
-        return mixins[ methodIdx ];
-    }
-
-    public Object invoke( Object composite, Object[] params, Object mixin )
-        throws Throwable
-    {
-        mixinInvoker.setFragment( mixin );
-
-        try
-        {
-            return invoker.invoke( composite, method, params );
-        }
-        finally
-        {
-            mixinInvoker.setFragment( null );
-        }
-    }
-
-    public CompositeMethodInstance getNext()
-    {
-        return next;
-    }
-
-    public void setNext( CompositeMethodInstance next )
-    {
-        this.next = next;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
deleted file mode 100644
index 9258dbc..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.MethodDescriptor;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Specifications.notNull;
-
-/**
- * JAVADOC
- */
-public final class CompositeMethodModel
-    implements MethodDescriptor, Dependencies, VisitableHierarchy<Object, Object>
-{
-    // Model
-    private final Method method;
-    private Method invocationMethod; // This will be the _ prefixed method on typed mixins
-    private final ConstraintsModel constraints;
-    private final ConcernsModel concerns;
-    private final SideEffectsModel sideEffects;
-    private final MixinsModel mixins;
-    private AnnotatedElement annotations;
-
-    // Context
-//    private final SynchronizedCompositeMethodInstancePool instancePool = new SynchronizedCompositeMethodInstancePool();
-    private final AtomicInstancePool instancePool = new AtomicInstancePool();
-    private final ConstraintsInstance constraintsInstance;
-
-    public CompositeMethodModel( Method method,
-                                 ConstraintsModel constraintsModel,
-                                 ConcernsModel concernsModel,
-                                 SideEffectsModel sideEffectsModel,
-                                 MixinsModel mixinsModel
-    )
-    {
-        this.method = method;
-        mixins = mixinsModel;
-        concerns = concernsModel;
-        sideEffects = sideEffectsModel;
-        constraints = constraintsModel;
-        constraintsInstance = constraints.newInstance();
-        initialize();
-    }
-
-    private void initialize()
-    {
-        annotations = new CompositeMethodAnnotatedElement();
-        this.method.setAccessible( true );
-//        instancePool = new SynchronizedCompositeMethodInstancePool();
-    }
-
-    // Model
-
-    @Override
-    public Method method()
-    {
-        return method;
-    }
-
-    public MixinModel mixin()
-    {
-        return mixins.mixinFor( method );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Iterable<DependencyModel> dependencies()
-    {
-        return flattenIterables( filter( notNull(), iterable( concerns != null ? concerns.dependencies() : null,
-                                                              sideEffects != null ? sideEffects.dependencies() : null ) ) );
-    }
-
-    // Context
-    public Object invoke( Object composite, Object[] params, MixinsInstance mixins, ModuleSpi moduleInstance )
-        throws Throwable
-    {
-        constraintsInstance.checkValid( composite, method, params );
-
-        CompositeMethodInstance methodInstance = getInstance( moduleInstance );
-        try
-        {
-            return mixins.invoke( composite, params, methodInstance );
-        }
-        finally
-        {
-            instancePool.releaseInstance( methodInstance );
-        }
-    }
-
-    private CompositeMethodInstance getInstance( ModuleSpi moduleInstance )
-    {
-        CompositeMethodInstance methodInstance = instancePool.obtainInstance();
-        if( methodInstance == null )
-        {
-            methodInstance = newCompositeMethodInstance( moduleInstance );
-        }
-
-        return methodInstance;
-    }
-
-    private CompositeMethodInstance newCompositeMethodInstance( ModuleSpi moduleInstance )
-        throws ConstructionException
-    {
-        FragmentInvocationHandler mixinInvocationHandler = mixins.newInvocationHandler( method );
-        InvocationHandler invoker = mixinInvocationHandler;
-        if( concerns != ConcernsModel.EMPTY_CONCERNS )
-        {
-            ConcernsInstance concernsInstance = concerns.newInstance( method, moduleInstance, mixinInvocationHandler );
-            invoker = concernsInstance;
-        }
-        if( sideEffects != SideEffectsModel.EMPTY_SIDEEFFECTS )
-        {
-            SideEffectsInstance sideEffectsInstance = sideEffects.newInstance( method, moduleInstance, invoker );
-            invoker = sideEffectsInstance;
-        }
-
-        if( invocationMethod == null )
-        {
-            MixinModel model = mixins.mixinFor( method );
-            if( !InvocationHandler.class.isAssignableFrom( model.mixinClass() ) )
-            {
-                try
-                {
-                    invocationMethod = model.instantiationClass()
-                        .getMethod( "_" + method.getName(), method.getParameterTypes() );
-                }
-                catch( NoSuchMethodException e )
-                {
-                    invocationMethod = method;
-//                    throw new ConstructionException( "Could not find the subclass method", e );
-                }
-            }
-            else
-            {
-                invocationMethod = method;
-            }
-        }
-
-        mixinInvocationHandler.setMethod( invocationMethod );
-
-        return new CompositeMethodInstance( invoker, mixinInvocationHandler, method, mixins.methodIndex.get( method ) );
-    }
-
-    public AnnotatedElement annotatedElement()
-    {
-        return annotations;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            constraints.accept( modelVisitor );
-            concerns.accept( modelVisitor );
-            sideEffects.accept( modelVisitor );
-        }
-        return modelVisitor.visitLeave( this );
-    }
-
-    @Override
-    public String toString()
-    {
-        return method.toGenericString();
-    }
-
-    public Iterable<Method> invocationsFor( Class<?> mixinClass )
-    {
-        return mixins.invocationsFor( mixinClass );
-    }
-
-    public class CompositeMethodAnnotatedElement
-        implements AnnotatedElement
-    {
-        @Override
-        public boolean isAnnotationPresent( Class<? extends Annotation> annotationClass )
-        {
-            // Check method
-            if( method.isAnnotationPresent( annotationClass ) )
-            {
-                return true;
-            }
-
-            // Check mixin
-            try
-            {
-                MixinModel model = mixins.mixinFor( method );
-                if( GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
-                {
-                    return false;
-                }
-                return ( model.mixinClass()
-                             .getMethod( method.getName(), method.getParameterTypes() )
-                             .isAnnotationPresent( annotationClass ) );
-            }
-            catch( NoSuchMethodException e )
-            {
-                return false;
-            }
-        }
-
-        @Override
-        public <T extends Annotation> T getAnnotation( Class<T> annotationClass )
-        {
-            // Check mixin
-            try
-            {
-                MixinModel model = mixins.mixinFor( method );
-                if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
-                {
-                    T annotation = annotationClass.cast( model.mixinClass()
-                                                             .getMethod( method.getName(), method.getParameterTypes() )
-                                                             .getAnnotation( annotationClass ) );
-                    if( annotation != null )
-                    {
-                        return annotation;
-                    }
-                }
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Ignore
-            }
-
-            // Check method
-            return method.getAnnotation( annotationClass );
-        }
-
-        @Override
-        public Annotation[] getAnnotations()
-        {
-            // Add mixin annotations
-            List<Annotation> annotations = new ArrayList<Annotation>();
-            MixinModel model = mixins.mixinFor( method );
-            Annotation[] mixinAnnotations = new Annotation[ 0 ];
-            if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
-            {
-                mixinAnnotations = model.mixinClass().getAnnotations();
-                annotations.addAll( Arrays.asList( mixinAnnotations ) );
-            }
-
-            // Add method annotations, but don't include duplicates
-            Annotation[] methodAnnotations = method.getAnnotations();
-            next:
-            for( Annotation methodAnnotation : methodAnnotations )
-            {
-                for( int i = 0; i < mixinAnnotations.length; i++ )
-                {
-                    if( annotations.get( i ).annotationType().equals( methodAnnotation.annotationType() ) )
-                    {
-                        continue next;
-                    }
-                }
-
-                annotations.add( methodAnnotation );
-            }
-
-            return annotations.toArray( new Annotation[ annotations.size() ] );
-        }
-
-        @Override
-        public Annotation[] getDeclaredAnnotations()
-        {
-            return new Annotation[ 0 ];
-        }
-
-        // @Override (Since JDK 8)
-        @SuppressWarnings( "unchecked" )
-        public <T extends Annotation> T[] getAnnotationsByType( Class<T> annotationClass )
-        {
-            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
-            return (T[]) Array.newInstance( annotationClass, 0 );
-        }
-
-        // @Override (Since JDK 8)
-        public <T extends Annotation> T getDeclaredAnnotation( Class<T> annotationClass )
-        {
-            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
-            return null;
-        }
-
-        // @Override (Since JDK 8)
-        @SuppressWarnings( "unchecked" )
-        public <T extends Annotation> T[] getDeclaredAnnotationsByType( Class<T> annotationClass )
-        {
-            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
-            return (T[]) Array.newInstance( annotationClass, 0 );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
deleted file mode 100644
index 62d44c2..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Method;
-import java.util.LinkedHashMap;
-import org.apache.zest.api.composite.MissingMethodException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * Model for Composite methods. This includes both private and public methods.
- */
-public final class CompositeMethodsModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final LinkedHashMap<Method, CompositeMethodModel> methods;
-    private final MixinsModel mixinsModel;
-
-    public CompositeMethodsModel( MixinsModel mixinsModel )
-    {
-        methods = new LinkedHashMap<>();
-        this.mixinsModel = mixinsModel;
-    }
-
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.flattenIterables( map( Dependencies.DEPENDENCIES_FUNCTION, methods.values() ) );
-    }
-
-    // Context
-    public Object invoke( MixinsInstance mixins,
-                          Object proxy,
-                          Method method,
-                          Object[] args,
-                          ModuleSpi moduleInstance
-    )
-        throws Throwable
-    {
-        CompositeMethodModel compositeMethod = methods.get( method );
-
-        if( compositeMethod == null )
-        {
-            if( method.getDeclaringClass().equals( Object.class ) )
-            {
-                return mixins.invokeObject( proxy, args, method );
-            }
-
-            if( !method.getDeclaringClass().isInterface() )
-            {
-                Iterable<Class<?>> types = mixinsModel.mixinTypes();
-                for( Class<?> aClass : types )
-                {
-                    try
-                    {
-                        Method realMethod = aClass.getMethod( method.getName(), method.getParameterTypes() );
-                        compositeMethod = methods.get( realMethod );
-                        break;
-                    }
-                    catch( NoSuchMethodException e )
-                    {
-                    }
-                    catch( SecurityException e )
-                    {
-                    }
-                }
-            }
-//            return mixins.invokeObject( proxy, args, method );
-            throw new MissingMethodException( "Method '" + method + "' is not implemented" );
-        }
-        else
-        {
-            return compositeMethod.invoke( proxy, args, mixins, moduleInstance );
-        }
-    }
-
-    public void addMethod( CompositeMethodModel methodModel )
-    {
-        methods.put( methodModel.method(), methodModel );
-    }
-
-    public boolean isImplemented( Method method )
-    {
-        return methods.containsKey( method );
-    }
-
-    public Iterable<Method> methods()
-    {
-        return methods.keySet();
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( CompositeMethodModel compositeMethodModel : methods.values() )
-            {
-                if( !compositeMethodModel.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-
-    @Override
-    public String toString()
-    {
-        return methods().toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
deleted file mode 100644
index a9554f3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static java.lang.reflect.Proxy.newProxyInstance;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.toList;
-
-/**
- * JAVADOC
- */
-public abstract class CompositeModel
-    implements VisitableHierarchy<Object, Object>, Dependencies, CompositeDescriptor
-{
-    protected final MixinsModel mixinsModel;
-    protected final CompositeMethodsModel compositeMethodsModel;
-    private final Set<Class<?>> types;
-    private final Visibility visibility;
-    private final MetaInfo metaInfo;
-    protected final StateModel stateModel;
-    protected Class<? extends Composite> proxyClass;
-    protected Constructor<? extends Composite> proxyConstructor;
-
-    protected CompositeModel( final Iterable<Class<?>> types,
-                              final Visibility visibility,
-                              final MetaInfo metaInfo,
-                              final MixinsModel mixinsModel,
-                              final StateModel stateModel,
-                              final CompositeMethodsModel compositeMethodsModel
-    )
-    {
-        this.types = Iterables.addAll( new LinkedHashSet<Class<?>>(), types );
-        this.visibility = visibility;
-        this.metaInfo = metaInfo;
-        this.stateModel = stateModel;
-        this.compositeMethodsModel = compositeMethodsModel;
-        this.mixinsModel = mixinsModel;
-
-        // Create proxy class
-        createProxyClass();
-    }
-
-    // Model
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return types;
-    }
-
-    public StateModel state()
-    {
-        return stateModel;
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public Visibility visibility()
-    {
-        return visibility;
-    }
-
-    @Override
-    public boolean isAssignableTo( Class<?> type )
-    {
-        for( Class<?> aClass : types )
-        {
-            if( type.isAssignableFrom( aClass ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public MixinsModel mixinsModel()
-    {
-        return mixinsModel;
-    }
-
-    @Override
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public Class<?> primaryType()
-    {
-        Class primaryType = null;
-        for( Class type : mixinTypes() )
-        {
-            if( type.getName().equals( "scala.ScalaObject" ) )
-            {
-                continue;
-            }
-            if( primaryType == null )
-            {
-                primaryType = type;
-            }
-            else if( primaryType.isAssignableFrom( type ) )
-            {
-                primaryType = type;
-            }
-        }
-        return primaryType;
-    }
-
-    @Override
-    public Iterable<Class<?>> mixinTypes()
-    {
-        return mixinsModel.mixinTypes();
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.flatten( mixinsModel.dependencies(), compositeMethodsModel.dependencies() );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( compositeMethodsModel.accept( visitor ) )
-            {
-                if( stateModel.accept( visitor ) )
-                {
-                    mixinsModel.accept( visitor );
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    private void createProxyClass()
-    {
-        Class<?> mainType = first( types );
-        if( mainType.isInterface() )
-        {
-            ClassLoader proxyClassloader = mainType.getClassLoader();
-
-            Class<?>[] interfaces = Iterables.toArray( Class.class, Iterables.<Class>cast( types ) );
-            proxyClass = (Class<? extends Composite>) ProxyGenerator.createProxyClass( proxyClassloader, interfaces );
-
-            try
-            {
-                proxyConstructor = proxyClass.getConstructor( InvocationHandler.class );
-            }
-            catch( NoSuchMethodException e )
-            {
-                throw (InvalidCompositeException) new InvalidCompositeException( "Could not get proxy constructor" ).initCause( e );
-            }
-            proxyConstructor.setAccessible( true );
-        }
-        else
-        {
-            try
-            {
-                proxyClass = new TransientClassLoader( getClass().getClassLoader() ).loadFragmentClass( mainType );
-                proxyConstructor = (Constructor<? extends Composite>) proxyClass.getConstructors()[ 0 ];
-            }
-            catch( ClassNotFoundException e )
-            {
-                throw (InvalidCompositeException) new InvalidCompositeException( "Could not get proxy constructor" ).initCause( e );
-            }
-        }
-    }
-
-    // Context
-    public final Object invoke( MixinsInstance mixins,
-                                Object proxy,
-                                Method method,
-                                Object[] args,
-                                ModuleSpi moduleInstance
-    )
-        throws Throwable
-    {
-        return compositeMethodsModel.invoke( mixins, proxy, method, args, moduleInstance );
-    }
-
-    public Composite newProxy( InvocationHandler invocationHandler )
-        throws ConstructionException
-    {
-        Class<?> mainType = first( types() );
-        if( mainType.isInterface() )
-        {
-
-            try
-            {
-                return Composite.class.cast( proxyConstructor.newInstance( invocationHandler ) );
-            }
-            catch( Exception e )
-            {
-                throw new ConstructionException( e );
-            }
-        }
-        else
-        {
-            try
-            {
-                Object[] args = new Object[ proxyConstructor.getParameterTypes().length ];
-                Composite composite = Composite.class.cast( proxyConstructor.newInstance( args ) );
-                proxyClass.getField( "_instance" ).set( composite, invocationHandler );
-                return composite;
-            }
-            catch( Exception e )
-            {
-                throw new ConstructionException( e );
-            }
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    public <T> T newProxy( InvocationHandler invocationHandler, Class<T> mixinType )
-        throws IllegalArgumentException
-    {
-
-//        if (!matchesAny( isAssignableFrom( mixinType ), types ))
-        if( !mixinsModel.isImplemented( mixinType ) )
-        {
-            String message = "Composite " + primaryType().getName() + " does not implement type " + mixinType.getName();
-            throw new IllegalArgumentException( message );
-        }
-
-        // Instantiate proxy for given mixin interface
-        return mixinType.cast( newProxyInstance( mixinType.getClassLoader(), new Class[]{ mixinType }, invocationHandler ) );
-    }
-
-    @Override
-    public String toString()
-    {
-        return toList( types ).toString();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernModel.java
deleted file mode 100644
index 4de8f64..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernModel.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import org.apache.zest.api.concern.ConcernDescriptor;
-
-/**
- * JAVADOC
- */
-public final class ConcernModel extends AbstractModifierModel
-    implements ConcernDescriptor
-{
-    public ConcernModel( Class concernClass, Class instantiationClass )
-    {
-        super( concernClass, instantiationClass );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsInstance.java
deleted file mode 100644
index eeecc8f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsInstance.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-public final class ConcernsInstance
-    implements InvocationHandler
-{
-    private final InvocationHandler firstConcern;
-    private final FragmentInvocationHandler mixinInvocationHandler;
-    private final ProxyReferenceInvocationHandler proxyHandler;
-
-    public ConcernsInstance( InvocationHandler firstConcern,
-                             FragmentInvocationHandler mixinInvocationHandler,
-                             ProxyReferenceInvocationHandler proxyHandler
-    )
-    {
-        this.firstConcern = firstConcern;
-        this.mixinInvocationHandler = mixinInvocationHandler;
-        this.proxyHandler = proxyHandler;
-    }
-
-    public boolean isEmpty()
-    {
-        return firstConcern == mixinInvocationHandler;
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] params )
-        throws Throwable
-    {
-        proxyHandler.setProxy( proxy );
-        try
-        {
-            return firstConcern.invoke( proxy, method, params );
-        }
-        catch( InvocationTargetException e )
-        {
-            throw e.getTargetException();
-        }
-        finally
-        {
-            proxyHandler.clearProxy();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
deleted file mode 100644
index 22092fc..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.concern.ConcernsDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * JAVADOC
- */
-public final class ConcernsModel
-    implements ConcernsDescriptor, Dependencies, VisitableHierarchy<Object, Object>
-{
-    public static final ConcernsModel EMPTY_CONCERNS = new ConcernsModel( Collections.<ConcernModel>emptyList() );
-
-    private List<ConcernModel> concernsFor;
-
-    public ConcernsModel( List<ConcernModel> concernsFor )
-    {
-        this.concernsFor = concernsFor;
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.flattenIterables( Iterables.map( Dependencies.DEPENDENCIES_FUNCTION, concernsFor ) );
-    }
-
-    // Context
-    public ConcernsInstance newInstance( Method method, ModuleSpi moduleInstance,
-                                         FragmentInvocationHandler mixinInvocationHandler
-    )
-    {
-        ProxyReferenceInvocationHandler proxyHandler = new ProxyReferenceInvocationHandler();
-        InvocationHandler nextConcern = mixinInvocationHandler;
-        for( int i = concernsFor.size() - 1; i >= 0; i-- )
-        {
-            ConcernModel concernModel = concernsFor.get( i );
-
-            nextConcern = concernModel.newInstance( moduleInstance, nextConcern, proxyHandler, method );
-        }
-
-        return new ConcernsInstance( nextConcern, mixinInvocationHandler, proxyHandler );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( ConcernModel concernModel : concernsFor )
-            {
-                if( !concernModel.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintDeclaration.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintDeclaration.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintDeclaration.java
deleted file mode 100644
index 18184cc..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintDeclaration.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.util.Classes;
-
-/**
- * JAVADOC
- */
-public final class ConstraintDeclaration
-{
-    private final Class<? extends Constraint<?, ?>> constraintClass;
-    @SuppressWarnings( "raw" )
-    private final Class constraintAnnotationType;
-    private final Type constraintValueType;
-
-    @SuppressWarnings( "unchecked" )
-    public ConstraintDeclaration( Class<? extends Constraint<?, ?>> constraintClass )
-    {
-        this.constraintClass = constraintClass;
-
-        constraintAnnotationType = (Class<? extends Annotation>) ( (ParameterizedType) constraintClass.getGenericInterfaces()[ 0 ] )
-            .getActualTypeArguments()[ 0 ];
-        constraintValueType = ( (ParameterizedType) constraintClass.getGenericInterfaces()[ 0 ] ).getActualTypeArguments()[ 1 ];
-    }
-
-    public Class<? extends Constraint<?, ?>> constraintClass()
-    {
-        return constraintClass;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public boolean appliesTo( Class annotationType, Type valueType )
-    {
-        if( constraintValueType instanceof Class )
-        {
-            Class constraintValueClass = (Class) constraintValueType;
-            Class valueClass = Classes.RAW_CLASS.map( valueType );
-            return constraintAnnotationType.equals( annotationType ) && constraintValueClass.isAssignableFrom( valueClass );
-        }
-        else if( constraintValueType instanceof ParameterizedType )
-        {
-            // TODO Handle nested generics
-            Class constraintValueClass = Classes.RAW_CLASS.map( constraintValueType );
-            Class valueClass = Classes.RAW_CLASS.map( valueType );
-            return constraintAnnotationType.equals( annotationType ) && constraintValueClass.isAssignableFrom( valueClass );
-        }
-        else
-        {
-            return false; // TODO Handles more cases. What are they?
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintInstance.java
deleted file mode 100644
index 3f855be..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintInstance.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import org.apache.zest.api.constraint.Constraint;
-
-/**
- * JAVADOC
- */
-public final class ConstraintInstance<A extends Annotation, T>
-{
-    private final Constraint<A, T> constraint;
-    private final A annotation;
-
-    public ConstraintInstance( Constraint<A, T> constraint, A annotation )
-    {
-        this.constraint = constraint;
-        this.annotation = annotation;
-    }
-
-    public A annotation()
-    {
-        return annotation;
-    }
-
-    public boolean isValid( T value )
-    {
-        return constraint.isValid( annotation, value );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintModel.java
deleted file mode 100644
index f73f8d7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintModel.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.constraint.Constraint;
-
-/**
- * JAVADOC
- */
-public final class ConstraintModel
-    extends AbstractConstraintModel
-{
-    private final Class<? extends Constraint<?, ?>> constraintClass;
-
-    public ConstraintModel( Annotation annotation, Class<? extends Constraint<?, ?>> constraintClass )
-    {
-        super( annotation );
-        this.constraintClass = constraintClass;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public ConstraintInstance<?, ?> newInstance()
-    {
-        try
-        {
-            Constraint<?, ?> constraint = constraintClass.newInstance();
-            return new ConstraintInstance( constraint, annotation );
-        }
-        catch( Exception e )
-        {
-            throw new ConstructionException( "Could not instantiate constraint implementation", e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsCheck.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsCheck.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsCheck.java
deleted file mode 100644
index 096c8cd..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsCheck.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import org.apache.zest.api.constraint.ConstraintViolationException;
-
-/**
- * Call this to perform a value constraint check
- */
-public interface ConstraintsCheck
-{
-    public void checkConstraints( Object value )
-        throws ConstraintViolationException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsInstance.java
deleted file mode 100644
index 4e3b313..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsInstance.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2009, Niclas Hedhman. 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.zest.runtime.composite;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.constraint.ConstraintViolation;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- */
-public final class ConstraintsInstance
-{
-    private final List<ValueConstraintsInstance> valueConstraintsInstances;
-
-    public ConstraintsInstance( List<ValueConstraintsInstance> parameterConstraints )
-    {
-        valueConstraintsInstances = parameterConstraints;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void checkValid( Object instance, Method method, Object[] params )
-        throws ConstraintViolationException
-    {
-        if( valueConstraintsInstances.isEmpty() )
-        {
-            return; // No constraints to check
-        }
-
-        // Check constraints
-        List<ConstraintViolation> violations = null;
-        for( int i = 0; i < params.length; i++ )
-        {
-            Object param = params[ i ];
-            List<ConstraintViolation> paramViolations = valueConstraintsInstances.get( i ).checkConstraints( param );
-            if( !paramViolations.isEmpty() )
-            {
-                if( violations == null )
-                {
-                    violations = new ArrayList<>();
-                }
-                violations.addAll( paramViolations );
-            }
-        }
-
-        // Check if any constraint failed
-        if( violations != null )
-        {
-            if( instance instanceof Composite )
-            {
-                throw new ConstraintViolationException( (Composite) instance, method, violations );
-            }
-            if( instance instanceof CompositeInstance )
-            {
-                throw new ConstraintViolationException( (Composite) ( (CompositeInstance) instance ).proxy(), method, violations );
-            }
-            Iterable<? extends Class<?>> types = iterable( instance.getClass() );
-            throw new ConstraintViolationException( instance.toString(), (Iterable<Class<?>>) types, method, violations );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsModel.java
deleted file mode 100644
index 0ea5139..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstraintsModel.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.constraint.ConstraintsDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class ConstraintsModel
-    implements ConstraintsDescriptor, VisitableHierarchy<Object, Object>
-{
-    private List<ValueConstraintsModel> parameterConstraintModels;
-
-    private static ConstraintsInstance EMPTY_CONSTRAINTS = new ConstraintsInstance( Collections.<ValueConstraintsInstance>emptyList() );
-
-    public ConstraintsModel( List<ValueConstraintsModel> parameterConstraintModels )
-    {
-        this.parameterConstraintModels = parameterConstraintModels;
-    }
-
-    public ConstraintsInstance newInstance()
-    {
-        if( parameterConstraintModels.isEmpty() )
-        {
-            return EMPTY_CONSTRAINTS;
-        }
-        else
-        {
-            List<ValueConstraintsInstance> parameterConstraintsInstances = new ArrayList<ValueConstraintsInstance>( parameterConstraintModels
-                                                                                                                        .size() );
-            for( ValueConstraintsModel parameterConstraintModel : parameterConstraintModels )
-            {
-                parameterConstraintsInstances.add( parameterConstraintModel.newInstance() );
-            }
-            return new ConstraintsInstance( parameterConstraintsInstances );
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            if( parameterConstraintModels != null )
-            {
-                for( ValueConstraintsModel parameterConstraintModel : parameterConstraintModels )
-                {
-                    if( !parameterConstraintModel.accept( modelVisitor ) )
-                    {
-                        break;
-                    }
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorModel.java
deleted file mode 100644
index e78481f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorModel.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.ConstructorDescriptor;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectedParametersModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-
-/**
- * JAVADOC
- */
-public final class ConstructorModel
-    implements ConstructorDescriptor, VisitableHierarchy<Object, Object>
-{
-    private Constructor<?> constructor;
-
-    private InjectedParametersModel parameters;
-
-    public ConstructorModel( Constructor<?> constructor, InjectedParametersModel parameters )
-    {
-        this.constructor = constructor;
-        this.parameters = parameters;
-        this.constructor.setAccessible( true );
-    }
-
-    @Override
-    public Constructor<?> constructor()
-    {
-        return constructor;
-    }
-
-    public Iterable<DependencyModel> dependencies()
-    {
-        return parameters.dependencies();
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            parameters.accept( modelVisitor );
-        }
-
-        return modelVisitor.visitLeave( this );
-    }
-
-    // Context
-
-    public Object newInstance( InjectionContext context )
-        throws ConstructionException
-    {
-        // Create parameters
-        Object[] parametersInstance = parameters.newParametersInstance( context );
-        // Invoke constructor
-        try
-        {
-            return constructor.newInstance( parametersInstance );
-        }
-        catch( InvocationTargetException e )
-        {
-            Throwable targetException = e.getTargetException();
-            if( targetException instanceof InvalidCompositeException )
-            {
-                throw (InvalidCompositeException) targetException;
-            }
-            String message = "Could not instantiate \n    " + constructor.getDeclaringClass() + "\nusing constructor:\n    " + constructor
-                .toGenericString();
-            throw new ConstructionException( message, targetException );
-        }
-        catch( Throwable e )
-        {
-            System.err.println( constructor.toGenericString() );
-            System.err.println( Arrays.asList( parametersInstance ) );
-            throw new ConstructionException( "Could not instantiate " + constructor.getDeclaringClass(), e );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return constructor.toGenericString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorsModel.java
deleted file mode 100644
index 4b14cc3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConstructorsModel.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.api.injection.InjectionScope;
-import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectedParametersModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.ParameterizedTypeInstance;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- */
-public final class ConstructorsModel
-    implements Binder, Dependencies, VisitableHierarchy<Object, Object>
-{
-    @SuppressWarnings( "raw" )
-    private final Class fragmentClass;
-    private final List<ConstructorModel> constructorModels;
-    private List<ConstructorModel> boundConstructors;
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public ConstructorsModel( Class fragmentClass )
-    {
-        this.fragmentClass = fragmentClass;
-        validate( fragmentClass );
-        constructorModels = new ArrayList<>();
-        Constructor[] realConstructors = this.fragmentClass.getDeclaredConstructors();
-        Class injectionClass = FragmentClassLoader.getSourceClass( fragmentClass );
-        for( Constructor constructor : realConstructors )
-        {
-            constructor.setAccessible( true );
-            try
-            {
-                Constructor injectionConstructor = injectionClass.getDeclaredConstructor( constructor.getParameterTypes() );
-                injectionConstructor.setAccessible( true );
-                ConstructorModel constructorModel = newConstructorModel( this.fragmentClass, constructor,
-                                                                         injectionConstructor );
-                if( constructorModel != null )
-                {
-                    constructorModels.add( constructorModel );
-                }
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Ignore and continue
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    private void validate( Class fragmentClass )
-    {
-        // Ensure that the fragment class is not an inner class, in which case we should give a reasonable exception
-        if( fragmentClass.getDeclaringClass() == null )
-        {
-            return;
-        }
-        if( Modifier.isStatic( fragmentClass.getModifiers() ) )
-        {
-            return;
-        }
-        throw new InvalidCompositeException( "Inner classes can not be used. Use static nested classes instead: " + fragmentClass );
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        Function<ConstructorModel, Iterable<DependencyModel>> constructorDependencies = new Function<ConstructorModel, Iterable<DependencyModel>>()
-        {
-            @Override
-            public Iterable<DependencyModel> map( ConstructorModel constructorModel )
-            {
-                return constructorModel.dependencies();
-            }
-        };
-
-        return Iterables.flattenIterables( Iterables.map( constructorDependencies, boundConstructors == null ? constructorModels : boundConstructors ) );
-    }
-
-    @SuppressWarnings( "raw" )
-    private ConstructorModel newConstructorModel( Class fragmentClass,
-                                                  Constructor realConstructor,
-                                                  Constructor injectedConstructor
-    )
-    {
-        int idx = 0;
-        InjectedParametersModel parameters = new InjectedParametersModel();
-        Annotation[][] parameterAnnotations = injectedConstructor.getParameterAnnotations();
-        for( Type type : injectedConstructor.getGenericParameterTypes() )
-        {
-            Annotation injectionAnnotation = first(
-                filter( Specifications.translate( Annotations.type(), Annotations.hasAnnotation( InjectionScope.class ) ), iterable( parameterAnnotations[ idx ] ) ) );
-
-            if( injectionAnnotation == null )
-            {
-                if( fragmentClass.getSuperclass().isMemberClass() )
-                {
-                    injectionAnnotation = new Uses()
-                    {
-                        @Override
-                        public Class<? extends Annotation> annotationType()
-                        {
-                            return Uses.class;
-                        }
-                    };
-                }
-                else
-                {
-                    return null; // invalid constructor parameter
-                }
-            }
-
-            boolean optional = DependencyModel.isOptional( injectionAnnotation, parameterAnnotations[ idx ] );
-
-            Type genericType = type;
-            if( genericType instanceof ParameterizedType )
-            {
-                genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
-                    .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );
-
-                for( int i = 0; i < ( (ParameterizedType) genericType ).getActualTypeArguments().length; i++ )
-                {
-                    Type typeArg = ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ];
-                    if( typeArg instanceof TypeVariable )
-                    {
-                        typeArg = Classes.resolveTypeVariable( (TypeVariable) typeArg, realConstructor.getDeclaringClass(), fragmentClass );
-                        ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ] = typeArg;
-                    }
-                }
-            }
-
-            DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional,
-                                                                   parameterAnnotations[ idx ] );
-            parameters.addDependency( dependencyModel );
-            idx++;
-        }
-        return new ConstructorModel( realConstructor, parameters );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( boundConstructors != null )
-            {
-                for( ConstructorModel constructorModel : boundConstructors )
-                {
-                    if( !constructorModel.accept( visitor ) )
-                    {
-                        break;
-                    }
-                }
-            }
-            else
-            {
-                for( ConstructorModel constructorModel : constructorModels )
-                {
-                    if( !constructorModel.accept( visitor ) )
-                    {
-                        break;
-                    }
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    // Binding
-    @Override
-    public void bind( final Resolution resolution )
-        throws BindingException
-    {
-        boundConstructors = new ArrayList<>();
-        for( ConstructorModel constructorModel : constructorModels )
-        {
-            try
-            {
-                constructorModel.accept( new HierarchicalVisitorAdapter<Object, Object, BindingException>()
-                {
-                    @Override
-                    public boolean visit( Object visitor )
-                        throws BindingException
-                    {
-                        if( visitor instanceof Binder )
-                        {
-                            ( (Binder) visitor ).bind( resolution );
-                        }
-                        return true;
-                    }
-                } );
-                boundConstructors.add( constructorModel );
-            }
-            catch( Exception e )
-            {
-                // Ignore
-                e.printStackTrace();
-            }
-        }
-
-        if( boundConstructors.isEmpty() )
-        {
-            StringBuilder messageBuilder = new StringBuilder( "Found no constructor that could be bound: " );
-            if( resolution.model() instanceof CompositeDescriptor )
-            {
-                messageBuilder.append( fragmentClass.getName() )
-                    .append( " in " )
-                    .append( resolution.model().toString() );
-            }
-            else
-            {
-                messageBuilder.append( resolution.model().toString() );
-            }
-
-            if( messageBuilder.indexOf( "$" ) >= 0 )
-            {
-                // This could be ok if instance is created manually
-                return;
-//                messageBuilder.append( "\nInner classes can not be used." );
-            }
-            String message = messageBuilder.toString();
-            throw new BindingException( message );
-        }
-
-        // Sort based on parameter count
-        Collections.sort( boundConstructors, new Comparator<ConstructorModel>()
-        {
-            @Override
-            public int compare( ConstructorModel o1, ConstructorModel o2 )
-            {
-                Integer model2ParametersCount = o2.constructor().getParameterTypes().length;
-                int model1ParametersCount = o1.constructor().getParameterTypes().length;
-                return model2ParametersCount.compareTo( model1ParametersCount );
-            }
-        } );
-    }
-
-    public Object newInstance( InjectionContext injectionContext )
-    {
-        // Try all bound constructors, in order
-        ConstructionException exception = null;
-        for( ConstructorModel constructorModel : boundConstructors )
-        {
-            try
-            {
-                return constructorModel.newInstance( injectionContext );
-            }
-            catch( ConstructionException e )
-            {
-                exception = e;
-            }
-        }
-
-        throw exception;
-    }
-}


[41/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Classes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Classes.java b/core/api/src/main/java/org/apache/zest/api/util/Classes.java
deleted file mode 100644
index 79f1d32..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Classes.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.functional.Iterables.cast;
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Iterables.matchesAny;
-import static org.apache.zest.functional.Iterables.prepend;
-
-/**
- * Useful methods for handling Classes.
- */
-public final class Classes
-{
-    private final static Map<Type, Type> wrapperClasses = new HashMap<>();
-
-    static
-    {
-        wrapperClasses.put( boolean.class, Boolean.class );
-        wrapperClasses.put( byte.class, Byte.class );
-        wrapperClasses.put( short.class, Short.class );
-        wrapperClasses.put( char.class, Character.class );
-        wrapperClasses.put( int.class, Integer.class );
-        wrapperClasses.put( long.class, Long.class );
-        wrapperClasses.put( float.class, Float.class );
-        wrapperClasses.put( double.class, Double.class );
-    }
-
-    private final static Map<Type, Type> primitiveClasses = new HashMap<>();
-
-    static
-    {
-        primitiveClasses.put( boolean.class, Boolean.class );
-        primitiveClasses.put( byte.class, Byte.class );
-        primitiveClasses.put( short.class, Short.class );
-        primitiveClasses.put( char.class, Character.class );
-        primitiveClasses.put( int.class, Integer.class );
-        primitiveClasses.put( long.class, Long.class );
-        primitiveClasses.put( float.class, Float.class );
-        primitiveClasses.put( double.class, Double.class );
-    }
-
-    /**
-     * Convert from primitive class (int, short, double, etc.) to wrapper class (Integer, Short, Double, etc.).
-     * Return the same class if it's not a primitive class. This can therefore safely be used on all types
-     * to ensure that they are not primitives.
-     */
-    private static final Function<Type, Type> WRAPPER_CLASS = new Function<Type, Type>()
-    {
-        @Override
-        public Type map( Type aClass )
-        {
-            Type wrapperClass = wrapperClasses.get( aClass );
-            return wrapperClass == null ? aClass : wrapperClass;
-        }
-    };
-
-    /**
-     * Convert from wrapper class (Integer, Short, Double, etc.) to primitive class (int, short, double, etc.).
-     * Return the same class if it's not a wrapper class. This can therefore safely be used on all types
-     * to ensure that they are primitives if possible.
-     */
-    @SuppressWarnings( "UnusedDeclaration" )
-    private static final Function<Type, Type> PRIMITIVE_CLASS = new Function<Type, Type>()
-    {
-        @Override
-        public Type map( Type aClass )
-        {
-            Type primitiveClass = primitiveClasses.get( aClass );
-            return primitiveClass == null ? aClass : primitiveClass;
-        }
-    };
-
-    /**
-     * Function that extract the raw class of a type.
-     */
-    public static final Function<Type, Class<?>> RAW_CLASS = new Function<Type, Class<?>>()
-    {
-        @Override
-        public Class<?> map( Type genericType )
-        {
-            // Calculate raw type
-            if( genericType instanceof Class )
-            {
-                return (Class<?>) genericType;
-            }
-            else if( genericType instanceof ParameterizedType )
-            {
-                return (Class<?>) ( (ParameterizedType) genericType ).getRawType();
-            }
-            else if( genericType instanceof TypeVariable )
-            {
-                return (Class<?>) ( (TypeVariable) genericType ).getGenericDeclaration();
-            }
-            else if( genericType instanceof WildcardType )
-            {
-                return (Class<?>) ( (WildcardType) genericType ).getUpperBounds()[ 0];
-            }
-            else if( genericType instanceof GenericArrayType )
-            {
-                Object temp = Array.newInstance( (Class<?>) ( (GenericArrayType) genericType ).getGenericComponentType(), 0 );
-                return temp.getClass();
-            }
-            throw new IllegalArgumentException( "Could not extract the raw class of " + genericType );
-        }
-    };
-
-    private static final Function<AccessibleObject, Type> TYPE_OF = new Function<AccessibleObject, Type>()
-    {
-        @Override
-        public Type map( AccessibleObject accessor )
-        {
-            return accessor instanceof Method ? ( (Method) accessor ).getGenericReturnType() : ( (Field) accessor ).getGenericType();
-        }
-    };
-
-    private static final Function<Type, Iterable<Class<?>>> CLASS_HIERARCHY = new Function<Type, Iterable<Class<?>>>()
-    {
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Iterable<Class<?>> map( Type type )
-        {
-            if( type == null )
-            {
-                return empty();
-            }
-            if( type.equals( Object.class ) )
-            {
-                Class<?> aClass = (Class<?>) type;
-                return cast( iterable( aClass ) );
-            }
-            else
-            {
-                type = RAW_CLASS.map( type );
-                Class superclass = ( (Class) type ).getSuperclass();
-                return prepend( (Class<?>) type, map( superclass ) );
-            }
-        }
-    };
-
-    @SuppressWarnings( "raw" )
-    private static final Function<Type, Iterable<Type>> INTERFACES_OF = new Function<Type, Iterable<Type>>()
-    {
-        @Override
-        public Iterable<Type> map( Type type )
-        {
-            Class clazz = RAW_CLASS.map( type );
-
-            if( clazz.isInterface() )
-            {
-                Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() );
-                Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) );
-                return prepend( type, flattenIterables );
-            }
-            else
-            {
-                if( type.equals( Object.class ) )
-                {
-                    return iterable( clazz.getGenericInterfaces() );
-                }
-                else
-                {
-                    return flatten( flattenIterables( Iterables.map( INTERFACES_OF,
-                                                                     iterable( clazz.getGenericInterfaces() ) ) ),
-                                    INTERFACES_OF.map( RAW_CLASS.map( type ).getSuperclass() ) );
-                }
-            }
-        }
-    };
-
-    @SuppressWarnings( "raw" )
-    private static final Function<Type, Iterable<Type>> TYPES_OF = new Function<Type, Iterable<Type>>()
-    {
-        @Override
-        public Iterable<Type> map( Type type )
-        {
-            Class clazz = RAW_CLASS.map( type );
-
-            if( clazz.isInterface() )
-            {
-                Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() );
-                Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) );
-                return prepend( clazz, flattenIterables );
-            }
-            else
-            {
-                return flatten( CLASS_HIERARCHY.map( type ),
-                                flattenIterables( Iterables.map( INTERFACES_OF, CLASS_HIERARCHY.map( type ) ) ) );
-            }
-        }
-    };
-
-    public static Type typeOf( AccessibleObject from )
-    {
-        return TYPE_OF.map( from );
-    }
-
-    public static Iterable<Type> typesOf( Iterable<Type> types )
-    {
-        Iterable<Type> result = empty();
-        for( Type type : types )
-        {
-            result = flatten( result, typesOf( type ) );
-        }
-        return result;
-    }
-
-    public static Iterable<Type> typesOf( Type type )
-    {
-        return TYPES_OF.map( type );
-    }
-
-    public static Iterable<? extends Type> interfacesOf( Iterable<? extends Type> types )
-    {
-        Iterable<Type> result = empty();
-        for( Type type : types )
-        {
-            result = flatten( result, interfacesOf( type ) );
-        }
-        return result;
-    }
-
-    public static Iterable<Type> interfacesOf( Type type )
-    {
-        return INTERFACES_OF.map( type );
-    }
-
-    public static Iterable<Class<?>> classHierarchy( Class<?> type )
-    {
-        return CLASS_HIERARCHY.map( type );
-    }
-
-    public static Type wrapperClass( Type type )
-    {
-        return WRAPPER_CLASS.map( type );
-    }
-
-    public static Specification<Class<?>> isAssignableFrom( final Class clazz )
-    {
-        return new Specification<Class<?>>()
-        {
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public boolean satisfiedBy( Class<?> item )
-            {
-                return clazz.isAssignableFrom( item );
-            }
-        };
-    }
-
-    @SuppressWarnings( "raw" )
-    public static Specification<Object> instanceOf( final Class clazz )
-    {
-        return new Specification<Object>()
-        {
-            @Override
-            public boolean satisfiedBy( Object item )
-            {
-                return clazz.isInstance( item );
-            }
-        };
-    }
-
-    public static Specification<Class<?>> hasModifier( final int classModifier )
-    {
-        return new Specification<Class<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( Class<?> item )
-            {
-                return ( item.getModifiers() & classModifier ) != 0;
-            }
-        };
-    }
-
-    public static <T> Function<Type, Iterable<T>> forClassHierarchy( final Function<Class<?>, Iterable<T>> function )
-    {
-        return new Function<Type, Iterable<T>>()
-        {
-            @Override
-            public Iterable<T> map( Type type )
-            {
-                return flattenIterables( Iterables.map( function, CLASS_HIERARCHY.map( type ) ) );
-            }
-        };
-    }
-
-    public static <T> Function<Type, Iterable<T>> forTypes( final Function<Type, Iterable<T>> function )
-    {
-        return new Function<Type, Iterable<T>>()
-        {
-            @Override
-            public Iterable<T> map( Type type )
-            {
-                return flattenIterables( Iterables.map( function, TYPES_OF.map( type ) ) );
-            }
-        };
-    }
-
-    @SuppressWarnings( "raw" )
-    public static Set<Class<?>> interfacesWithMethods( Set<Class<?>> interfaces )
-    {
-        Set<Class<?>> newSet = new LinkedHashSet<>();
-        for( Class type : interfaces )
-        {
-            if( type.isInterface() && type.getDeclaredMethods().length > 0 )
-            {
-                newSet.add( type );
-            }
-        }
-
-        return newSet;
-    }
-
-    public static String simpleGenericNameOf( Type type )
-    {
-        StringBuilder sb = new StringBuilder();
-        simpleGenericNameOf( sb, type );
-        return sb.toString();
-    }
-
-    @SuppressWarnings( "raw" )
-    private static void simpleGenericNameOf( StringBuilder sb, Type type )
-    {
-        if( type instanceof Class )
-        {
-            sb.append( ( (Class) type ).getSimpleName() );
-        }
-        else if( type instanceof ParameterizedType )
-        {
-            ParameterizedType pt = (ParameterizedType) type;
-            simpleGenericNameOf( sb, pt.getRawType() );
-            sb.append( "<" );
-            boolean atLeastOne = false;
-            for( Type typeArgument : pt.getActualTypeArguments() )
-            {
-                if( atLeastOne )
-                {
-                    sb.append( ", " );
-                }
-                simpleGenericNameOf( sb, typeArgument );
-                atLeastOne = true;
-            }
-            sb.append( ">" );
-        }
-        else if( type instanceof GenericArrayType )
-        {
-            GenericArrayType gat = (GenericArrayType) type;
-            simpleGenericNameOf( sb, gat.getGenericComponentType() );
-            sb.append( "[]" );
-        }
-        else if( type instanceof TypeVariable )
-        {
-            TypeVariable tv = (TypeVariable) type;
-            sb.append( tv.getName() );
-        }
-        else if( type instanceof WildcardType )
-        {
-            WildcardType wt = (WildcardType) type;
-            sb.append( "? extends " );
-            boolean atLeastOne = false;
-            for( Type typeArgument : wt.getUpperBounds() )
-            {
-                if( atLeastOne )
-                {
-                    sb.append( ", " );
-                }
-                simpleGenericNameOf( sb, typeArgument );
-                atLeastOne = true;
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException( "Don't know how to deal with type:" + type );
-        }
-    }
-
-    @SuppressWarnings( "UnusedDeclaration" )
-    public static <AnnotationType extends Annotation>
-        AnnotationType findAnnotationOfTypeOrAnyOfSuperTypes( Class<?> type, Class<AnnotationType> annotationClass )
-    {
-        AnnotationType result = null;
-        for( Type clazz : Classes.TYPES_OF.map( type ) )
-        {
-            result = Classes.RAW_CLASS.map( clazz ).getAnnotation( annotationClass );
-            if( result != null )
-            {
-                break;
-            }
-        }
-
-        return result;
-    }
-
-    public static Specification<Member> memberNamed( final String name )
-    {
-        return new Specification<Member>()
-        {
-            @Override
-            public boolean satisfiedBy( Member item )
-            {
-                return item.getName().equals( name );
-            }
-        };
-    }
-
-    /**
-     * Given a type variable, find what it resolves to given the declaring class where type
-     * variable was found and a top class that extends the declaring class.
-     *
-     * @param name The TypeVariable name.
-     * @param declaringClass The class where the TypeVariable is declared.
-     * @param topClass The top class that extends the declaringClass
-     *
-     * @return The Type instance of the given TypeVariable
-     */
-    @SuppressWarnings( "raw" )
-    public static Type resolveTypeVariable( TypeVariable name, Class declaringClass, Class topClass )
-    {
-        Type type = resolveTypeVariable( name, declaringClass, new HashMap<TypeVariable, Type>(), topClass );
-        if( type == null )
-        {
-            type = Object.class;
-        }
-        return type;
-    }
-
-    @SuppressWarnings( "raw" )
-    private static Type resolveTypeVariable( TypeVariable name,
-                                             Class declaringClass,
-                                             Map<TypeVariable, Type> mappings,
-                                             Class current
-    )
-    {
-        if( current.equals( declaringClass ) )
-        {
-            Type resolvedType = name;
-            while( resolvedType instanceof TypeVariable )
-            {
-                resolvedType = mappings.get( resolvedType );
-            }
-            return resolvedType;
-        }
-
-        List<Type> types = new ArrayList<>();
-        for( Type type : current.getGenericInterfaces() )
-        {
-            Iterable<Type> interfaces = Classes.INTERFACES_OF.map( type );
-            for( Type anInterface : interfaces )
-            {
-                if( !types.contains( anInterface ) )
-                {
-                    types.add( anInterface );
-                }
-            }
-            types.add( type );
-        }
-
-        if( current.getGenericSuperclass() != null )
-        {
-            types.add( current.getGenericSuperclass() );
-        }
-
-        for( Type type : types )
-        {
-            Class subClass;
-            if( type instanceof ParameterizedType )
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                Type[] args = pt.getActualTypeArguments();
-                Class clazz = (Class) pt.getRawType();
-                TypeVariable[] vars = clazz.getTypeParameters();
-                for( int i = 0; i < vars.length; i++ )
-                {
-                    TypeVariable var = vars[ i];
-                    Type mappedType = args[ i];
-                    mappings.put( var, mappedType );
-                }
-                subClass = (Class) pt.getRawType();
-            }
-            else
-            {
-                subClass = (Class) type;
-            }
-
-            Type resolvedType = resolveTypeVariable( name, declaringClass, mappings, subClass );
-            if( resolvedType != null )
-            {
-                return resolvedType;
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Get URI for a class.
-     *
-     * @param clazz class
-     *
-     * @return URI
-     *
-     * @throws NullPointerException if clazz is null
-     */
-    @SuppressWarnings( "raw" )
-    public static String toURI( final Class clazz )
-        throws NullPointerException
-    {
-        return toURI( clazz.getName() );
-    }
-
-    /**
-     * Get URI for a class name.
-     * <p>
-     * Example:
-     * </p>
-     * <p>
-     * Class name com.example.Foo$Bar is converted to URI urn:qi4j:com.example.Foo-Bar
-     * </p>
-     *
-     * @param className class name
-     *
-     * @return URI
-     *
-     * @throws NullPointerException if className is null
-     */
-    public static String toURI( String className )
-        throws NullPointerException
-    {
-        className = normalizeClassToURI( className );
-        return "urn:qi4j:type:" + className;
-    }
-
-    /**
-     * Get class name from a URI
-     *
-     * @param uri URI
-     *
-     * @return class name
-     *
-     * @throws NullPointerException if uri is null
-     */
-    public static String toClassName( String uri )
-        throws NullPointerException
-    {
-        uri = uri.substring( "urn:qi4j:type:".length() );
-        uri = denormalizeURIToClass( uri );
-        return uri;
-    }
-
-    public static String normalizeClassToURI( String className )
-    {
-        return className.replace( '$', '-' );
-    }
-
-    public static String denormalizeURIToClass( String uriPart )
-    {
-        return uriPart.replace( '-', '$' );
-    }
-
-    public static Specification<ModelDescriptor> modelTypeSpecification( final String className )
-    {
-        return new Specification<ModelDescriptor>()
-        {
-            @Override
-            public boolean satisfiedBy( ModelDescriptor item )
-            {
-                return matchesAny( new Specification<String>()
-                {
-                    @Override
-                    public boolean satisfiedBy( String item )
-                    {
-                        return item.equals( className );
-                    }
-                }, map( new Function<Class<?>, String>()
-                {
-                    @Override
-                    public String map( Class<?> item )
-                    {
-                        return item.getName();
-                    }
-                }, item.types() ) );
-            }
-        };
-    }
-
-    @SuppressWarnings( "raw" )
-    public static Specification<ModelDescriptor> exactTypeSpecification( final Class type )
-    {
-        return new Specification<ModelDescriptor>()
-        {
-            @Override
-            public boolean satisfiedBy( ModelDescriptor item )
-            {
-                return matchesAny( new Specification<Class<?>>()
-                {
-                    @Override
-                    public boolean satisfiedBy( Class<?> item )
-                    {
-                        return item.equals( type );
-                    }
-                }, item.types() );
-            }
-        };
-    }
-
-    @SuppressWarnings( "raw" )
-    public static Specification<ModelDescriptor> assignableTypeSpecification( final Class type )
-    {
-        return new Specification<ModelDescriptor>()
-        {
-            @Override
-            public boolean satisfiedBy( ModelDescriptor item )
-            {
-                return matchesAny( new Specification<Class<?>>()
-                {
-                    @Override
-                    @SuppressWarnings( "unchecked" )
-                    public boolean satisfiedBy( Class<?> itemType )
-                    {
-                        return !type.equals( itemType ) && type.isAssignableFrom( itemType );
-                    }
-                }, item.types() );
-            }
-        };
-    }
-
-    @SuppressWarnings( "raw" )
-    public static String toString( Iterable<? extends Class> type )
-    {
-        StringBuilder builder = new StringBuilder();
-        builder.append( "[" );
-        boolean first = true;
-        for( Class c : type )
-        {
-            if( !first )
-            {
-                builder.append( "," );
-            }
-            first = false;
-            builder.append( c.getSimpleName() );
-        }
-        builder.append( "]" );
-        return builder.toString();
-    }
-
-    public static Function<Type, String> toClassName()
-    {
-        return new Function<Type, String>()
-        {
-            @Override
-            public String map( Type type )
-            {
-                return RAW_CLASS.map( type ).getName();
-            }
-        };
-    }
-
-    private Classes()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Constructors.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Constructors.java b/core/api/src/main/java/org/apache/zest/api/util/Constructors.java
deleted file mode 100644
index 440c6fb..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Constructors.java
+++ /dev/null
@@ -1,40 +0,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.
- */
-package org.apache.zest.api.util;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Type;
-import org.apache.zest.functional.Function;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * Useful methods for handling Constructors.
- */
-public final class Constructors
-{
-    public static final Function<Type, Iterable<Constructor<?>>> CONSTRUCTORS_OF = Classes.forClassHierarchy( new Function<Class<?>, Iterable<Constructor<?>>>()
-    {
-        @Override
-        public Iterable<Constructor<?>> map( Class<?> type )
-        {
-            return iterable( type.getDeclaredConstructors() );
-        }
-    } );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Dates.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Dates.java b/core/api/src/main/java/org/apache/zest/api/util/Dates.java
deleted file mode 100644
index 126c169..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Dates.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.util;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Useful methods for handling Dates.
- */
-public final class Dates
-{
-    // Formatters are not thread-safe. Create one per thread
-    private static final ThreadLocal<DateFormat> ISO8601 = new ThreadLocal<DateFormat>()
-    {
-        @Override
-        protected DateFormat initialValue()
-        {
-            return new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
-        }
-    };
-
-    private static final ThreadLocal<DateFormat> ISO8601_UTC = new ThreadLocal<DateFormat>()
-    {
-        @Override
-        protected DateFormat initialValue()
-        {
-            SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
-            dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
-            return dateFormat;
-        }
-    };
-
-    /**
-     * @param stringDate a string representing a date as either ISO8601, @millis@ or /Date() formats
-     * @return a Date
-     */
-    public static Date fromString( String stringDate )
-    {
-        try
-        {
-            Date date = ISO8601_UTC.get().parse( stringDate );
-            return date;
-        }
-        catch( ParseException e )
-        {
-            try
-            {
-                Date date = ISO8601.get().parse( stringDate );
-                return date;
-            }
-            catch( ParseException e1 )
-            {
-                // @millis@ format
-                if( stringDate.startsWith( "@" ) && stringDate.endsWith( "@" ) )
-                {
-                    long time = Long.parseLong( stringDate.substring( 1, stringDate.length() - 1 ) );
-                    Date date = new Date( time );
-                    return date;
-                }
-                else if( stringDate.startsWith( "/Date(" ) && stringDate.endsWith( ")/" ) ) // Microsoft format
-                {
-                    long time = Long.parseLong( stringDate.substring( 6, stringDate.length() - 2 ) );
-                    Date date = new Date( time );
-                    return date;
-                }
-                throw new IllegalStateException( "Illegal date:" + stringDate );
-            }
-        }
-    }
-
-    /**
-     * @param date a Date
-     * @return String representation in ISO8601 UTC
-     */
-    public static String toUtcString( Date date )
-    {
-        return ISO8601_UTC.get().format( date );
-    }
-
-    private Dates()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Fields.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Fields.java b/core/api/src/main/java/org/apache/zest/api/util/Fields.java
deleted file mode 100644
index e6ecced..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Fields.java
+++ /dev/null
@@ -1,51 +0,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.
- */
-package org.apache.zest.api.util;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Iterables;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * Useful methods for handling Fields.
- */
-public final class Fields
-{
-    public static final Function2<Class<?>, String, Field> FIELD_NAMED = new Function2<Class<?>, String, Field>()
-    {
-        @Override
-        public Field map( Class<?> aClass, String name )
-        {
-            return Iterables.first( Iterables.filter( Classes.memberNamed( name ), FIELDS_OF.map( aClass ) ) );
-        }
-    };
-
-    public static final Function<Type, Iterable<Field>> FIELDS_OF = Classes.forClassHierarchy( new Function<Class<?>, Iterable<Field>>()
-    {
-        @Override
-        public Iterable<Field> map( Class<?> type )
-        {
-            return iterable( type.getDeclaredFields() );
-        }
-    } );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/ListMap.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/ListMap.java b/core/api/src/main/java/org/apache/zest/api/util/ListMap.java
deleted file mode 100644
index 57f0623..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/ListMap.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Map whose values are Lists of things. Create
- * one ArrayList for each key that is added. The list does not allow
- * duplicates.
- */
-public final class ListMap<K, V>
-    extends HashMap<K, List<V>>
-{
-    public void add( K key, V value )
-    {
-        List<V> list = get( key );
-        if( list == null )
-        {
-            list = new ArrayList<V>();
-            put( key, list );
-        }
-        if( !list.contains( value ) )
-        {
-            list.add( value );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Methods.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Methods.java b/core/api/src/main/java/org/apache/zest/api/util/Methods.java
deleted file mode 100644
index f87d58f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Methods.java
+++ /dev/null
@@ -1,50 +0,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.
- */
-package org.apache.zest.api.util;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * Useful methods for handling Methods.
- */
-public class Methods
-{
-    public static final Specification<Type> HAS_METHODS = new Specification<Type>()
-    {
-        @Override
-        public boolean satisfiedBy( Type item )
-        {
-            return Classes.RAW_CLASS.map( item ).getDeclaredMethods().length > 0;
-        }
-    };
-
-    public static final Function<Type, Iterable<Method>> METHODS_OF = Classes.forTypes( new Function<Type, Iterable<Method>>()
-    {
-        @Override
-        public Iterable<Method> map( Type type )
-        {
-            return iterable( Classes.RAW_CLASS.map( type ).getDeclaredMethods() );
-        }
-    } );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/NullArgumentException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/NullArgumentException.java b/core/api/src/main/java/org/apache/zest/api/util/NullArgumentException.java
deleted file mode 100644
index 2807ca3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/NullArgumentException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.util;
-
-/**
- * Thrown if an argument to a method was null, and the method required
- * it to be non-null.
- */
-public class NullArgumentException
-    extends IllegalArgumentException
-{
-    private static final long serialVersionUID = 4815431779868729780L;
-
-    private NullArgumentException( String message )
-    {
-        super( message );
-    }
-
-    public static void validateNotNull( String parameterName, Object value )
-    {
-        if( value != null )
-        {
-            return;
-        }
-        String message = parameterName + " was null.";
-        throw new NullArgumentException( message );
-    }
-
-    public static void validateNotEmpty( String parameterName, String value )
-    {
-        if( value == null )
-        {
-            String message = parameterName + " was null.";
-            throw new NullArgumentException( message );
-        }
-        if( value.length() == 0 )
-        {
-            String message = parameterName + " was empty.";
-            throw new NullArgumentException( message );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/package.html b/core/api/src/main/java/org/apache/zest/api/util/package.html
deleted file mode 100644
index ea75db3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>API Utilities.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/NoSuchValueException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/NoSuchValueException.java b/core/api/src/main/java/org/apache/zest/api/value/NoSuchValueException.java
deleted file mode 100644
index 754768a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/NoSuchValueException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.value;
-
-import org.apache.zest.api.composite.NoSuchCompositeException;
-
-/**
- * Thrown when no visible value of the requested type is found.
- */
-public class NoSuchValueException
-    extends NoSuchCompositeException
-{
-    public NoSuchValueException( String valueType, String moduleName )
-    {
-        super( "ValueComposite", valueType, moduleName );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilder.java b/core/api/src/main/java/org/apache/zest/api/value/ValueBuilder.java
deleted file mode 100644
index c544ef0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.value;
-
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * Builder for Values.
- */
-public interface ValueBuilder<T>
-{
-    AssociationStateHolder state();
-
-    /**
-     * Get a representation of the state for the new Value.
-     * It is possible to access and update properties and associations,
-     * even immutable ones since the builder represents the initial state.
-     *
-     * @return a mutable instance of the Value type
-     */
-    T prototype();
-
-    /**
-     * Get a representation of the state of the given type for the new ValueComposite.
-     * This is primarily used if you want to provide state for a private mixin type.
-     *
-     * @param mixinType the mixin which you want to provide state for
-     *
-     * @return a proxy implementing the given mixin type
-     */
-    <K> K prototypeFor( Class<K> mixinType );
-
-    /**
-     * Create a new Composite instance.
-     *
-     * @return a new Composite instance
-     *
-     * @throws org.apache.zest.api.common.ConstructionException
-     *          thrown if it was not possible to instantiate the Composite
-     */
-    T newInstance()
-        throws ConstructionException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderFactory.java b/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderFactory.java
deleted file mode 100644
index 062c3fd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderFactory.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.value;
-
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.functional.Function;
-
-/**
- * Factory for Values and ValueBuilders.
- */
-public interface ValueBuilderFactory
-{
-
-    /**
-     * Instantiate a Value of the given type.
-     *
-     * @param valueType the Value type to instantiate
-     *
-     * @return a new Value instance
-     *
-     * @throws NoSuchValueException if no value extending the mixinType has been registered
-     * @throws ConstructionException if the value could not be instantiated
-     */
-    <T> T newValue( Class<T> valueType )
-        throws NoSuchValueException, ConstructionException;
-
-    /**
-     * Create a builder for creating new Values that implements the given Value type.
-     * <p>The returned ValueBuilder can be reused to create several Values instances.</p>
-     *
-     * @param valueType an interface that describes the Composite to be instantiated
-     *
-     * @return a ValueBuilder for creation of ValueComposites implementing the interface
-     *
-     * @throws NoSuchValueException if no value extending the mixinType has been registered
-     */
-    <T> ValueBuilder<T> newValueBuilder( Class<T> valueType )
-        throws NoSuchValueException;
-
-    /**
-     * Create a builder for creating a new Value starting with the given prototype.
-     * <p>The returned ValueBuilder can only be used ONCE.</p>
-     *
-     * @param prototype a prototype the builder will use
-     *
-     * @return a ValueBuilder for creation of ValueComposites implementing the interface of the prototype
-     *
-     * @throws NoSuchValueException if no value extending the mixinType has been registered
-     */
-    <T> ValueBuilder<T> newValueBuilderWithPrototype( T prototype );
-
-    /**
-     * Create a builder for creating a new Value starting with the given state.
-     * <p>The returned ValueBuilder can only be used ONCE.</p>
-     *
-     * @param mixinType an interface that describes the Composite to be instantiated
-     * @param propertyFunction a function providing the state of properties
-     * @param associationFunction a function providing the state of associations
-     * @param manyAssociationFunction a function providing the state of many associations
-     * @param namedAssociationFunction a function providing the state of named associations
-     *
-     * @return a ValueBuilder for creation of ValueComposites implementing the interface
-     *
-     * @throws NoSuchValueException if no value extending the mixinType has been registered
-     */
-    <T> ValueBuilder<T> newValueBuilderWithState( Class<T> mixinType,
-                                                  Function<PropertyDescriptor, Object> propertyFunction,
-                                                  Function<AssociationDescriptor, EntityReference> associationFunction,
-                                                  Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-                                                  Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction );
-
-    /**
-     * Instantiate a Value of the given type using the serialized state given as String.
-     *
-     * @param valueType the Value type to instantiate
-     * @param serializedState  the state of the Value
-     *
-     * @return a new Value instance
-     *
-     * @throws NoSuchValueException if no value extending the mixinType has been registered
-     * @throws ConstructionException if the value could not be instantiated
-     */
-    <T> T newValueFromSerializedState( Class<T> valueType, String serializedState );
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java b/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
deleted file mode 100644
index 5860f4b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.value;
-
-import org.apache.zest.api.structure.Module;
-
-/**
- * Builder template for Values.
- */
-public abstract class ValueBuilderTemplate<T>
-{
-    Class<T> type;
-
-    protected ValueBuilderTemplate( Class<T> type )
-    {
-        this.type = type;
-    }
-
-    protected abstract void build( T prototype );
-
-    public T newInstance( Module module )
-    {
-        ValueBuilder<T> builder = module.newValueBuilder( type );
-        build( builder.prototype() );
-        return builder.newInstance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueComposite.java b/core/api/src/main/java/org/apache/zest/api/value/ValueComposite.java
deleted file mode 100644
index dff6264..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueComposite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.value;
-
-import org.apache.zest.api.association.AssociationMixin;
-import org.apache.zest.api.association.ManyAssociationMixin;
-import org.apache.zest.api.association.NamedAssociationMixin;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Immutable;
-
-/**
- * ValueComposites are Composites that has state, and equality is defined from its values and not any identity nor
- * instance references.
- *
- * <ul>
- * <li>No Identity</li>
- * <li>No Lifecycle</li>
- * <li>Immutable</li>
- * <li>equals()/hashCode() operates on the Properties</li>
- * <li>Can have property and associations methods.</li>
- * <li>Can not reference Services</li>
- * <li>Can not have @Uses</li>
- * </ul>
- */
-@Immutable
-@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } )
-public interface ValueComposite
-    extends Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueDescriptor.java b/core/api/src/main/java/org/apache/zest/api/value/ValueDescriptor.java
deleted file mode 100644
index dbd424c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueDescriptor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.value;
-
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.StatefulCompositeDescriptor;
-import org.apache.zest.api.type.ValueCompositeType;
-
-/**
- * Descriptor for ValueComposites.
- */
-public interface ValueDescriptor
-    extends CompositeDescriptor, StatefulCompositeDescriptor
-{
-    ValueCompositeType valueType();
-
-    @Override
-    AssociationStateDescriptor state();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java b/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
deleted file mode 100644
index abdd7d1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin. 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.zest.api.value;
-
-import java.io.InputStream;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Function2;
-
-/**
- * Use a ValueDeserializer to create new values instances from serialized state.
- *
- * <p>
- *     Serialized state must be one of:
- * </p>
- * <ul>
- *     <li>a ValueComposite,</li>
- *     <li>an EntityReference,</li>
- *     <li>a Collection,</li>
- *     <li>a Map,</li>
- *     <li>a Plain Value.</li>
- * </ul>
- * <p>
- *     Nested plain values, EntityReferences, Collections, Maps, ValueComposites are supported.
- *     EntityReferences are deserialized as their identity string.
- * </p>
- * <p>
- *     Plain values can be one of:
- * </p>
- * <ul>
- *     <li>String,</li>
- *     <li>Character or char,</li>
- *     <li>Boolean or boolean,</li>
- *     <li>Integer or int,</li>
- *     <li>Long or long,</li>
- *     <li>Short or short,</li>
- *     <li>Byte or byte,</li>
- *     <li>Float or float,</li>
- *     <li>Double or double,</li>
- *     <li>BigInteger,</li>
- *     <li>BigDecimal,</li>
- *     <li>Date,</li>
- *     <li>DateTime (JodaTime),</li>
- *     <li>LocalDateTime (JodaTime),</li>
- *     <li>LocalDate (JodaTime).</li>
- * </ul>
- * <p>
- *     Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are deserialized
- *     from base64 encoded bytes using pure Java serialization. If it happens that the input is invalid, a
- *     ValueSerializationException is thrown.
- * </p>
- * <p>
- *     Having type information in the serialized payload allows to keep actual ValueComposite types and by so
- *     circumvent {@link org.apache.zest.api.composite.AmbiguousTypeException} when deserializing.
- * </p>
- */
-public interface ValueDeserializer
-{
-
-    /**
-     * Factory method for a typed deserialize function.
-     *
-     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
-     *
-     * @param type the value type
-     * @param <T> the parametrized function return type
-     * @return a deserialization function
-     */
-    <T> Function<String, T> deserialize( Class<T> type );
-
-    /**
-     * Factory method for a typed deserialize function.
-     *
-     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
-     *
-     * @param valueType the value type
-     * @param <T> the parametrized function return type
-     * @return a deserialization function
-     */
-    <T> Function<String, T> deserialize( ValueType valueType );
-
-    /**
-     * Factory method for an untyped deserialize function.
-     *
-     * <p>The returned Function may throw {@link ValueSerializationException}.</p>
-     *
-     * @param <T> the parametrized function return type
-     * @return a deserialization function
-     */
-    <T> Function2<ValueType, String, T> deserialize();
-
-    /**
-     * Deserialize a value from a state.
-     *
-     * @param <T> the parametrized returned type
-     * @param type the value type
-     * @param input the state
-     * @return the value
-     * @throws ValueSerializationException if the deserialization failed
-     */
-    <T> T deserialize( Class<?> type, String input )
-        throws ValueSerializationException;
-
-    /**
-     * Deserialize a value from a state.
-     *
-     * @param <T> the parametrized returned type
-     * @param valueType the value type
-     * @param input the state
-     * @return the value
-     * @throws ValueSerializationException if the deserialization failed
-     */
-    <T> T deserialize( ValueType valueType, String input )
-        throws ValueSerializationException;
-
-    /**
-     * Deserialize a value from a state.
-     *
-     * @param <T> the parametrized returned type
-     * @param type the value type
-     * @param input the state stream
-     * @return the value
-     * @throws ValueSerializationException if the deserialization failed
-     */
-    <T> T deserialize( Class<?> type, InputStream input )
-        throws ValueSerializationException;
-
-    /**
-     * Deserialize a value from a state.
-     *
-     * @param <T> the parametrized returned type
-     * @param valueType the value type
-     * @param input the state stream
-     * @return the value
-     * @throws ValueSerializationException if the deserialization failed
-     */
-    <T> T deserialize( ValueType valueType, InputStream input )
-        throws ValueSerializationException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueSerialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueSerialization.java b/core/api/src/main/java/org/apache/zest/api/value/ValueSerialization.java
deleted file mode 100644
index 6a6809e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueSerialization.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin. 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.zest.api.value;
-
-/**
- * ValueSerialization API.
- *
- * See {@link ValueSerializer} and {@link ValueDeserializer}.
- */
-public interface ValueSerialization
-    extends ValueSerializer, ValueDeserializer
-{
-
-    /**
-     * Serialization format @Service tags.
-     *
-     * <p>
-     *     ValueSerialization implementations should be tagged with theses at assembly time so that consumers can
-     *     specify which format they need.
-     * </p>
-     */
-    interface Formats
-    {
-
-        /**
-         * Tag a ValueSerialization service that support the JSON format.
-         */
-        String JSON = "json";
-        /**
-         * Tag a ValueSerialization service that support the XML format.
-         */
-        String XML = "xml";
-        /**
-         * Tag a ValueSerialization service that support the YAML format.
-         */
-        String YAML = "yaml";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueSerializationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializationException.java b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializationException.java
deleted file mode 100644
index 39d1576..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializationException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin. 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.zest.api.value;
-
-/**
- * Thrown when an error occur during value state (de)serialization.
- */
-public class ValueSerializationException
-    extends RuntimeException
-{
-
-    private static final long serialVersionUID = 1L;
-
-    public ValueSerializationException()
-    {
-        super();
-    }
-
-    public ValueSerializationException( String message )
-    {
-        super( message );
-    }
-
-    public ValueSerializationException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    public ValueSerializationException( Throwable cause )
-    {
-        super( cause.getClass().getName() + ": " + cause.getMessage(), cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
deleted file mode 100644
index 26db5e2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.api.value;
-
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.composite.AmbiguousTypeException;
-import org.apache.zest.functional.Function;
-
-/**
- * Use a ValueSerializer to serialize values state.
- *
- * <p>
- *     Serialized object must be one of:
- * </p>
- * <ul>
- *     <li>a ValueComposite,</li>
- *     <li>an EntityComposite or EntityReference,</li>
- *     <li>an Iterable,</li>
- *     <li>a Map,</li>
- *     <li>a Plain Value.</li>
- * </ul>
- * <p>
- *     Nested plain values, EntityReferences, Iterables, Maps, ValueComposites and EntityComposites are supported.
- *     EntityComposites and EntityReferences are serialized as their identity string.
- * </p>
- * <p>
- *     Plain values can be one of:
- * </p>
- * <ul>
- *     <li>String,</li>
- *     <li>Character or char,</li>
- *     <li>Boolean or boolean,</li>
- *     <li>Integer or int,</li>
- *     <li>Long or long,</li>
- *     <li>Short or short,</li>
- *     <li>Byte or byte,</li>
- *     <li>Float or float,</li>
- *     <li>Double or double,</li>
- *     <li>BigInteger,</li>
- *     <li>BigDecimal,</li>
- *     <li>Date,</li>
- *     <li>DateTime (JodaTime),</li>
- *     <li>LocalDateTime (JodaTime),</li>
- *     <li>LocalDate (JodaTime).</li>
- * </ul>
- * <p>
- *     Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are serialized to
- *     base64 encoded bytes using pure Java serialization. If it happens that the value is not Serializable, a
- *     ValueSerializationException is thrown.
- * </p>
- * <p>
- *     Having type information in the serialized payload allows to keep actual ValueComposite types and by so
- *     circumvent {@link AmbiguousTypeException} when deserializing.
- * </p>
- */
-public interface ValueSerializer
-{
-
-    /**
-     * Factory method for a serialize function.
-     *
-     * @param <T> the parametrized function input type
-     * @return a serialization function.
-     */
-    <T> Function<T, String> serialize();
-
-    /**
-     * Factory method for a serialize function.
-     *
-     * @param <T> the parametrized function input type
-     * @param options ValueSerializer Options
-     * @return a serialization function.
-     */
-    <T> Function<T, String> serialize( Options options );
-
-    /**
-     * Factory method for a serialize function.
-     *
-     * @param <T> the parametrized function input type
-     * @param includeTypeInfo if type information should be included in the output
-     * @return a serialization function.
-     */
-    @Deprecated
-    <T> Function<T, String> serialize( boolean includeTypeInfo );
-
-    /**
-     * Serialize the state of a value with type information.
-     *
-     * @param object an Object to serialize
-     * @return the state
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    String serialize( Object object )
-        throws ValueSerializationException;
-
-    /**
-     * Serialize the state of a value.
-     *
-     * @param options ValueSerializer Options
-     * @param object an Object to serialize
-     * @return the state
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    String serialize( Options options, Object object )
-        throws ValueSerializationException;
-
-    /**
-     * Serialize the state of a value.
-     *
-     * @param object an Object to serialize
-     * @param includeTypeInfo if type information should be included in the output
-     * @return the state
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    @Deprecated
-    String serialize( Object object, boolean includeTypeInfo )
-        throws ValueSerializationException;
-
-    /**
-     * Serialize the state of a value with type information.
-     *
-     * @param object an Object to serialize
-     * @param output that will be used as output
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    void serialize( Object object, OutputStream output )
-        throws ValueSerializationException;
-
-    /**
-     * Serialize the state of a value.
-     *
-     * @param options ValueSerializer Options
-     * @param object an Object to serialize
-     * @param output that will be used as output
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    void serialize( Options options, Object object, OutputStream output )
-        throws ValueSerializationException;
-
-    /**
-     * Serialize the state of a value.
-     *
-     * @param object an Object to serialize
-     * @param output that will be used as output
-     * @param includeTypeInfo if type information should be included in the output
-     * @throws ValueSerializationException if the Value serialization failed
-     */
-    @Deprecated
-    void serialize( Object object, OutputStream output, boolean includeTypeInfo )
-        throws ValueSerializationException;
-
-    /**
-     * Serialization options.
-     */
-    final class Options
-    {
-        /**
-         * Boolean flag to include type information.
-         * Default to TRUE.
-         */
-        public static final String INCLUDE_TYPE_INFO = "includeTypeInfo";
-        public static final String MAP_ENTRIES_AS_OBJECTS = "mapentriesasobjects";
-        private final Map<String, String> options = new HashMap<>();
-
-        /**
-         * Create new default ValueSerializer Options.
-         */
-        public Options()
-        {
-            this.options.put( INCLUDE_TYPE_INFO, "true" );
-            this.options.put( MAP_ENTRIES_AS_OBJECTS, "false" );
-        }
-
-        /**
-         * Set {@link #INCLUDE_TYPE_INFO} option to TRUE.
-         * @return This
-         */
-        public Options withTypeInfo()
-        {
-            return put( INCLUDE_TYPE_INFO, true );
-        }
-
-        /**
-         * Set {@link #INCLUDE_TYPE_INFO} option to FALSE.
-         * @return This
-         */
-        public Options withoutTypeInfo()
-        {
-            return put( INCLUDE_TYPE_INFO, false );
-        }
-
-        public Options withMapEntriesAsObjects()
-        {
-            return put( MAP_ENTRIES_AS_OBJECTS, true );
-        }
-
-        public Options withMapEntriesAsKeyValuePairs()
-        {
-            return put( MAP_ENTRIES_AS_OBJECTS, false );
-        }
-
-        /**
-         * Get Boolean option value.
-         * @param option The option
-         * @return The boolean value of the option, or null if absent
-         */
-        public Boolean getBoolean( String option )
-        {
-            if( !options.containsKey( option ) )
-            {
-                return null;
-            }
-            return Boolean.valueOf( options.get( option ) );
-        }
-
-        /**
-         * Get Integer option value.
-         * @param option The option
-         * @return The integer value of the option, or null if absent
-         */
-        public Integer getInteger( String option )
-        {
-            if( !options.containsKey( option ) )
-            {
-                return null;
-            }
-            return Integer.valueOf( options.get( option ) );
-        }
-
-        /**
-         * Get String option value.
-         * @param option The option
-         * @return The string value of the option, or null if absent
-         */
-        public String getString( String option )
-        {
-            return options.get( option );
-        }
-
-        /**
-         * Put an option String value.
-         * @param option The option
-         * @param value The value
-         * @return This Options instance
-         */
-        public Options put( String option, String value )
-        {
-            if( value == null )
-            {
-                return remove( option );
-            }
-            options.put( option, value );
-            return this;
-        }
-
-        /**
-         * Put an option boolean value.
-         * @param option The option
-         * @param value The value
-         * @return This Options instance
-         */
-        public Options put( String option, Boolean value )
-        {
-            if( value == null )
-            {
-                return remove( option );
-            }
-            options.put( option, Boolean.toString( value ) );
-            return this;
-        }
-
-        /**
-         * Put an option Integer value.
-         * @param option The option
-         * @param value The value
-         * @return This Options instance
-         */
-        public Options put( String option, Integer value )
-        {
-            if( value == null )
-            {
-                return remove( option );
-            }
-            options.put( option, value.toString() );
-            return this;
-        }
-
-        /**
-         * Remove an option value.
-         * @param option The option
-         * @return This Options instance
-         */
-        public Options remove( String option )
-        {
-            options.remove( option );
-            return this;
-        }
-
-        /**
-         * Get all defined options as a Map.
-         * @return All defined options in a new Map
-         */
-        public Map<String, String> toMap()
-        {
-            return new HashMap<>( options );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/value/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/package.html b/core/api/src/main/java/org/apache/zest/api/value/package.html
deleted file mode 100644
index 540b3f6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/value/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Value API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/Qi4j.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/Qi4j.java b/core/api/src/main/java/org/qi4j/api/Qi4j.java
new file mode 100644
index 0000000..cfd8a89
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/Qi4j.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.association.AbstractAssociation;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.api.composite.InvalidCompositeException;
+import org.qi4j.api.composite.ModelDescriptor;
+import org.qi4j.api.composite.TransientDescriptor;
+import org.qi4j.api.entity.EntityDescriptor;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.property.PropertyDescriptor;
+import org.qi4j.api.service.ServiceDescriptor;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.value.ValueDescriptor;
+import org.qi4j.functional.Function;
+
+/**
+ * Encapsulation of the Zest API.
+ */
+public interface Qi4j
+{
+    /**
+     * If a Modifier gets a reference to the Composite using @This,
+     * then that reference must be dereferenced using this method
+     * before handing it out for others to use.
+     *
+     * @param <T>       Parameterized type of the Composite
+     * @param composite instance reference injected in Modified using @This
+     *
+     * @return the dereferenced Composite
+     */
+    <T> T dereference( T composite );
+
+    /**
+     * Returns the Module or UnitOfWork where the Composite belongs.
+     *
+     * @param compositeOrUow The Composite (Service, Value, Entity or Transient) or UnitOfWork to lookup the Module it
+     *                       belongs to.
+     *
+     * @return The Module instance where the Composite or UnitOfWork belongs to.
+     */
+    Module moduleOf( Object compositeOrUow );
+
+    /**
+     * Returns the ModelDescriptor of the Composite.
+     *
+     * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the
+     *                                    ModelDescriptor
+     *
+     * @return The ModelDescriptor of the Composite
+     */
+    ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference );
+
+    /**
+     * Returns the CompositeDescriptor of the Composite.
+     *
+     * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the
+     *                                    CompositeDescriptor
+     *
+     * @return The CompositeDescriptor of the Composite
+     */
+    CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference );
+
+    /**
+     * Returns the TransientDescriptor of the TransientComposite.
+     *
+     * @param transsient The TransientComposite for which to lookup the TransientDescriptor
+     *
+     * @return The TransientDescriptor of the TransientComposite
+     */
+    TransientDescriptor transientDescriptorFor( Object transsient );
+
+    /**
+     * Returns the EntityDescriptor of the EntityComposite.
+     *
+     * @param entity The EntityComposite for which to lookup the EntityDescriptor
+     *
+     * @return The EntityDescriptor of the EntityComposite
+     */
+    EntityDescriptor entityDescriptorFor( Object entity );
+
+    /**
+     * Returns the ValueDescriptor of the ValueComposite.
+     *
+     * @param value The ValueComposite for which to lookup the ValueDescriptor
+     *
+     * @return The ValueDescriptor of the ValueComposite
+     */
+    ValueDescriptor valueDescriptorFor( Object value );
+
+    /**
+     * Returns the ServiceDescriptor of the ServiceComposite.
+     *
+     * @param service The ServiceComposite for which to lookup the ServiceDescriptor
+     *
+     * @return The ServiceDescriptor of the ServiceComposite
+     */
+    ServiceDescriptor serviceDescriptorFor( Object service );
+
+    /**
+     * Returns the PropertyDescriptor of the Property.
+     *
+     * @param property The Property for which to lookup the PropertyDescriptor
+     *
+     * @return The PropertyDescriptor of the Property
+     */
+    PropertyDescriptor propertyDescriptorFor( Property<?> property );
+
+    /**
+     * Returns the AssociationDescriptor of the Association.
+     *
+     * @param association The Association for which to lookup the AssociationDescriptor
+     *
+     * @return The AssociationDescriptor of the Association
+     */
+    AssociationDescriptor associationDescriptorFor( AbstractAssociation association );
+
+    /**
+     * Function that returns the CompositeDescriptor of a Composite.
+     */
+    Function<Composite, CompositeDescriptor> FUNCTION_DESCRIPTOR_FOR = new Function<Composite, CompositeDescriptor>()
+    {
+        @Override
+        public CompositeDescriptor map( Composite composite )
+        {
+            if( composite instanceof Proxy )
+            {
+                InvocationHandler invocationHandler = Proxy.getInvocationHandler( composite );
+                return ( (CompositeInstance) invocationHandler ).descriptor();
+            }
+            try
+            {
+                Class<? extends Composite> compositeClass = composite.getClass();
+                Field instanceField = compositeClass.getField( "_instance" );
+                Object instance = instanceField.get( composite );
+                return ( (CompositeInstance) instance ).descriptor();
+            }
+            catch( Exception e )
+            {
+                InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" );
+                exception.initCause( e );
+                throw exception;
+            }
+        }
+    };
+
+    /**
+     * Function that returns the CompositeInstance of a Composite.
+     */
+    Function<Composite, CompositeInstance> FUNCTION_COMPOSITE_INSTANCE_OF = new Function<Composite, CompositeInstance>()
+    {
+        @Override
+        public CompositeInstance map( Composite composite )
+        {
+            if( composite instanceof Proxy )
+            {
+                return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) );
+            }
+            try
+            {
+                Class<? extends Composite> compositeClass = composite.getClass();
+                Field instanceField = compositeClass.getField( "_instance" );
+                Object instance = instanceField.get( composite );
+                return (CompositeInstance) instance;
+            }
+            catch( Exception e )
+            {
+                InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" );
+                exception.initCause( e );
+                throw exception;
+            }
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/Activation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/Activation.java b/core/api/src/main/java/org/qi4j/api/activation/Activation.java
new file mode 100644
index 0000000..32f26e4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/Activation.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Interface used by Structure elements and Services that can be activated and passivated.
+ * <p>Application and Layer expose this interface so you can activate and passivate them.</p>
+ * <p>Module and ServiceComposite activation/passivation is handled by the Zest runtime.</p>
+ */
+public interface Activation
+{
+    /**
+     * Activate.
+     * <p>Fail fast execution order is:</p>
+     * <ul>
+     *   <li>Fire {@link ActivationEvent.EventType#ACTIVATING}</li>
+     *   <li>Call {@link Activator#beforeActivation(java.lang.Object)} on each Activator</li>
+     *   <li>Call {@link #activate()} children</li>
+     *   <li>Call {@link Activator#afterActivation(java.lang.Object)} on each Activator</li>
+     *   <li>Fire {@link ActivationEvent.EventType#ACTIVATED}</li>
+     * </ul>
+     * <p>If an Exception is thrown, already activated nodes are passivated.</p>
+     * @throws ActivationException with first Exception of activation plus the PassivationException if any
+     */
+    void activate()
+        throws ActivationException;
+
+    /**
+     * Passivate.
+     * <p>Fail safe execution order is:</p>
+     * <ul>
+     *   <li>Fire {@link ActivationEvent.EventType#PASSIVATING}</li>
+     *   <li>Call {@link Activator#beforePassivation(java.lang.Object)} on each Activator</li>
+     *   <li>Call {@link #passivate()} children</li>
+     *   <li>Call {@link Activator#afterPassivation(java.lang.Object)} on each Activator</li>
+     *   <li>Fire {@link ActivationEvent.EventType#PASSIVATED}</li>
+     * </ul>
+     * @throws PassivationException after passivation with all Exceptions of passivation if any
+     */
+    void passivate()
+        throws PassivationException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivationEvent.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivationEvent.java b/core/api/src/main/java/org/qi4j/api/activation/ActivationEvent.java
new file mode 100644
index 0000000..1852251
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivationEvent.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * ActivationEvents are fired during activation and passivation of instances in Zest.
+ */
+public final class ActivationEvent
+{
+    public enum EventType
+    {
+        ACTIVATING, ACTIVATED, PASSIVATING, PASSIVATED
+    }
+
+    private final long timestamp;
+    private final Object source;
+    private final EventType type;
+
+    public ActivationEvent( Object source, EventType type )
+    {
+        this.timestamp = System.currentTimeMillis();
+        this.source = source;
+        this.type = type;
+    }
+
+    /**
+     * @return the source of the Activation event
+     */
+    public Object source()
+    {
+        return source;
+    }
+
+    /**
+     * @return the type of the Activation event
+     */
+    public EventType type()
+    {
+        return type;
+    }
+
+    /**
+     * @return an informative message describing the event
+     */
+    public String message()
+    {
+        switch( type )
+        {
+        case ACTIVATING:
+            return "Activating " + source;
+        case ACTIVATED:
+            return "Activated " + source;
+        case PASSIVATING:
+            return "Passivating " + source;
+        case PASSIVATED:
+            return "Passivated " + source;
+        }
+        return "";
+    }
+
+    /**
+     * @see #message()
+     */
+    @Override
+    public String toString()
+    {
+        return message();
+    }
+}
\ No newline at end of file


[33/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/MatchTypeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/MatchTypeSpecification.java b/core/api/src/main/java/org/qi4j/api/type/MatchTypeSpecification.java
new file mode 100644
index 0000000..ff7e8e5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/MatchTypeSpecification.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.type;
+
+import org.qi4j.functional.Specification;
+
+/**
+ * Match Type Specification for HasTypes.
+ */
+public class MatchTypeSpecification
+    implements Specification<HasTypes>
+{
+    private final Class<?> matchType;
+
+    public MatchTypeSpecification( Class<?> matchType )
+    {
+        this.matchType = matchType;
+    }
+
+    @Override
+    public boolean satisfiedBy( HasTypes item )
+    {
+        for( Class<?> type : item.types() )
+        {
+            if( matchType.isAssignableFrom( type ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/Serialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/Serialization.java b/core/api/src/main/java/org/qi4j/api/type/Serialization.java
new file mode 100644
index 0000000..57184a0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/Serialization.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.type;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Serialization options for Property intstances.
+ * <p>
+ * The {@code entry} type represents the explicit key=keyValue, value=valueValue. For JSON serialization;
+ * </p>
+ * <pre>
+ *     [
+ *         { "key1" : "value1" },
+ *         { "key2" : "value2" }
+ *     ]
+ * </pre>
+ * <p>
+ * For XML serialization;
+ * </p>
+ * <pre>
+ *     &lt;object&gt;
+ *         &lt;
+ *     &lt;/object&gt;
+ * </pre>
+ * <p>
+ * The {@code object} type represents the explicit keyValue=valueValue.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Serialization
+{
+    Variant value();
+
+    enum Variant
+    {
+        entry, object
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java b/core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java
new file mode 100644
index 0000000..c546625
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.type;
+
+import java.lang.reflect.Type;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.property.PropertyDescriptor;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.api.value.ValueDescriptor;
+
+/**
+ * ValueComposite ValueType.
+ */
+public final class ValueCompositeType
+    extends ValueType
+{
+    private final ValueDescriptor model;
+
+    public static boolean isValueComposite( Type type )
+    {
+        return ValueComposite.class.isAssignableFrom( Classes.RAW_CLASS.map( type ) );
+    }
+
+    public ValueCompositeType( ValueDescriptor model )
+    {
+        super( model.types() );
+        this.model = model;
+    }
+
+    public Iterable<? extends PropertyDescriptor> properties()
+    {
+        return model.state().properties();
+    }
+
+    public Iterable<? extends AssociationDescriptor> associations()
+    {
+        return model.state().associations();
+    }
+
+    public Iterable<? extends AssociationDescriptor> manyAssociations()
+    {
+        return model.state().manyAssociations();
+    }
+
+    public Iterable<? extends AssociationDescriptor> namedAssociations()
+    {
+        return model.state().namedAssociations();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/ValueType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/ValueType.java b/core/api/src/main/java/org/qi4j/api/type/ValueType.java
new file mode 100644
index 0000000..ede914c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/ValueType.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2013, Paul Merlin. 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.qi4j.api.type;
+
+import java.util.Collections;
+import org.qi4j.api.util.NullArgumentException;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Base class for types of values in ValueComposites and Properties.
+ */
+public class ValueType
+    implements HasTypes
+{
+
+    public static ValueType of( Class<?> type )
+    {
+        return new ValueType( type );
+    }
+
+    /**
+     * Check if a non-null object is of any of the Primitive Value Types or an array of them.
+     * <p>
+     *     String, Boolean, Integer, Double, Float, Long, Byte, Short and Character and their Java primitive types
+     *     counterparts are considered as Primitive Value Types.
+     * </p>
+     * <p>
+     *     Date, BigInteger, BigDecimal and JodaTime types are not considered as Primitive Value Types.
+     * </p>
+     *
+     * @return true if object is a primitive value or an array of primitive values
+     * @throws IllegalArgumentException if object is null
+     */
+    public static boolean isPrimitiveValue( Object object )
+    {
+        NullArgumentException.validateNotNull( "object", object );
+        if( object instanceof String
+            || object instanceof Character
+            || object instanceof Boolean
+            || object instanceof Integer
+            || object instanceof Double
+            || object instanceof Float
+            || object instanceof Long
+            || object instanceof Byte
+            || object instanceof Short )
+        {
+            return true;
+        }
+        if( object.getClass().isArray() )
+        {
+            return isArrayOfPrimitiveValues( object );
+        }
+        return false;
+    }
+
+    private static boolean isArrayOfPrimitiveValues( Object array )
+    {
+        if( array instanceof String[]
+            || array instanceof char[] || array instanceof Character[]
+            || array instanceof boolean[] || array instanceof Boolean[]
+            || array instanceof int[] || array instanceof Integer[]
+            || array instanceof double[] || array instanceof Double[]
+            || array instanceof float[] || array instanceof Float[]
+            || array instanceof long[] || array instanceof Long[]
+            || array instanceof byte[] || array instanceof Byte[]
+            || array instanceof short[] || array instanceof Short[] )
+        {
+            return true;
+        }
+        return false;
+    }
+
+    public static boolean isPrimitiveValueType( ValueType valueType )
+    {
+        return isPrimitiveValueType( valueType.mainType() );
+    }
+
+    /**
+     * @see ValueType#isPrimitiveValue(java.lang.Object) 
+     */
+    public static boolean isPrimitiveValueType( Class<?> type )
+    {
+        NullArgumentException.validateNotNull( "type", type );
+        if( String.class.isAssignableFrom( type ) )
+        {
+            return true;
+        }
+        if( type.isArray() )
+        {
+            return isPrimitiveValueType( type.getComponentType() );
+        }
+        return false;
+    }
+    protected final Iterable<Class<?>> types;
+
+    public ValueType( Class<?> type )
+    {
+        this( Collections.singleton( type ) );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public ValueType( Iterable<? extends Class<?>> types )
+    {
+        this.types = (Iterable<Class<?>>) types;
+    }
+
+    public Class<?> mainType()
+    {
+        return first( types );
+    }
+
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return types;
+    }
+
+    @Override
+    public String toString()
+    {
+        String name = Iterables.toString(
+            types,
+            new Function<Class<?>, String>()
+            {
+                @Override
+                public String map( Class<?> item )
+                {
+                    return item.getName();
+                }
+            },
+            "," );
+        if( name.contains( "," ) )
+        {
+            name = "{" + name + "}";
+        }
+        return name;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/package.html b/core/api/src/main/java/org/qi4j/api/type/package.html
new file mode 100644
index 0000000..d42baa3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Type API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/ConcurrentEntityModificationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/ConcurrentEntityModificationException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/ConcurrentEntityModificationException.java
new file mode 100644
index 0000000..7745b5a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/ConcurrentEntityModificationException.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.unitofwork;
+
+import org.qi4j.api.entity.EntityComposite;
+
+/**
+ * This exception is thrown by UnitOfWork.complete() if any entities that are being committed
+ * had been changed while the UnitOfWork was being executed.
+ */
+public class ConcurrentEntityModificationException
+    extends UnitOfWorkCompletionException
+{
+    private static final long serialVersionUID = 3872723845064767689L;
+
+    private final Iterable<EntityComposite> concurrentlyModifiedEntities;
+
+    public ConcurrentEntityModificationException( Iterable<EntityComposite> concurrentlyModifiedEntities )
+    {
+        super("Entities changed concurrently :" + concurrentlyModifiedEntities);
+        this.concurrentlyModifiedEntities = concurrentlyModifiedEntities;
+    }
+
+    public Iterable<EntityComposite> concurrentlyModifiedEntities()
+    {
+        return concurrentlyModifiedEntities;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/EntityCompositeAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/EntityCompositeAlreadyExistsException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/EntityCompositeAlreadyExistsException.java
new file mode 100644
index 0000000..66e388d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/EntityCompositeAlreadyExistsException.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2008 Niclas Hedhman.
+ *
+ * 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.qi4j.api.unitofwork;
+
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * If you try to create an EntityComposite whose identity already exists,
+ * then this exception will be thrown.
+ */
+public class EntityCompositeAlreadyExistsException
+    extends UnitOfWorkException
+{
+    private static final long serialVersionUID = -7297710939536508481L;
+
+    private final EntityReference identity;
+
+    public EntityCompositeAlreadyExistsException( EntityReference identity )
+    {
+        super( "EntityComposite (" + identity + ") already exists." );
+        this.identity = identity;
+    }
+
+    public EntityReference identity()
+    {
+        return identity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/EntityTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/EntityTypeNotFoundException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/EntityTypeNotFoundException.java
new file mode 100644
index 0000000..39765fd
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/EntityTypeNotFoundException.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007-2008, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2007, Alin Dreghiciu. 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.qi4j.api.unitofwork;
+
+import org.qi4j.functional.Function;
+
+import static org.qi4j.functional.Iterables.fold;
+
+/**
+ * Zest exception to be thrown in case that an entity composite
+ * was not found during a lookup call.
+ */
+public class EntityTypeNotFoundException
+    extends UnitOfWorkException
+{
+    private final String compositeType;
+
+    public EntityTypeNotFoundException( String entityType, String moduleName, Iterable<String> visibility )
+    {
+        super( "Could not find an EntityComposite of type " + entityType + " in module [" + moduleName + "].\n" +
+               "\tThe following entity types are visible:\n" + join(visibility) );
+        this.compositeType = entityType;
+    }
+
+    private static String join( Iterable<String> visibility )
+    {
+        return fold( new Function<String, String>()
+        {
+            StringBuilder result;
+            {
+                result = new StringBuilder();
+            }
+
+            @Override
+            public String map( String type )
+            {
+                result.append( type );
+                result.append( "\n" );
+                return result.toString();
+            }
+        }, visibility );
+    }
+
+    public String compositeType()
+    {
+        return compositeType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/NoSuchEntityException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/NoSuchEntityException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/NoSuchEntityException.java
new file mode 100644
index 0000000..cbffe9d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/NoSuchEntityException.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2008-2013, Niclas Hedhman. 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.qi4j.api.unitofwork;
+
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.usecase.Usecase;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+
+/**
+ * This exception indicates that the requested Entity with the given
+ * identity does not exist.
+ */
+public class NoSuchEntityException
+    extends UnitOfWorkException
+{
+    private final EntityReference identity;
+    private final Usecase usecase;
+    private final Class<?>[] mixinTypes;
+
+    public NoSuchEntityException( EntityReference identity, Class<?> mixinType, Usecase usecase )
+    {
+        super( "Could not find entity (" + identity + ") of type " + mixinType.getName() + " in usecase '" + usecase.name() + "'" );
+        this.identity = identity;
+        this.usecase = usecase;
+        this.mixinTypes = new Class<?>[]{ mixinType };
+    }
+
+    public NoSuchEntityException( EntityReference identity, Class<?>[] mixinTypes, Usecase usecase )
+    {
+        super( "Could not find entity (" + identity + ") of type " + toString( mixinTypes ) + " in usecase '" + usecase.name() + "'" );
+        this.identity = identity;
+        this.mixinTypes = mixinTypes;
+        this.usecase = usecase;
+    }
+
+    public NoSuchEntityException( EntityReference identity, Iterable<Class<?>> types, Usecase usecase )
+    {
+        this( identity, castToArray( types ), usecase );
+    }
+
+    public EntityReference identity()
+    {
+        return identity;
+    }
+
+    public Class<?>[] mixinTypes()
+    {
+        return mixinTypes;
+    }
+
+    public Usecase usecase()
+    {
+        return usecase;
+    }
+
+    private static Class<?>[] castToArray( Iterable<Class<?>> iterableClasses )
+    {
+        Iterable<Class> types = Iterables.cast( iterableClasses );
+        return Iterables.toArray( Class.class, types );
+    }
+
+    private static String toString( Class<?>[] mixinTypes )
+    {
+        Iterable<String> map = Iterables.map( new Function<Class<?>, String>()
+        {
+            @Override
+            public String map( Class<?> item )
+            {
+                return item.getName();
+            }
+        }, Iterables.iterable( mixinTypes ) );
+        return Iterables.fold( new Function<String, String>()
+        {
+            StringBuilder result;
+            boolean first = true;
+
+            {
+                result = new StringBuilder();
+                result.append( "[" );
+            }
+
+            @Override
+            public String map( String strings )
+            {
+                if( !first )
+                {
+                    result.append( ',' );
+                }
+                first = false;
+                result.append( strings );
+                return result.toString() + "]";
+            }
+        }, map );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWork.java
new file mode 100644
index 0000000..2ce6855
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWork.java
@@ -0,0 +1,429 @@
+/*
+ * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007-2012, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2013-2015, Paul Merlin. 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.qi4j.api.unitofwork;
+
+import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.composite.AmbiguousTypeException;
+import org.qi4j.api.entity.EntityBuilder;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.entity.LifecycleException;
+import org.qi4j.api.property.PropertyDescriptor;
+import org.qi4j.api.query.Query;
+import org.qi4j.api.query.QueryBuilder;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.usecase.Usecase;
+import org.qi4j.functional.Function;
+
+/**
+ * All operations on entities goes through an UnitOfWork.
+ * <p>
+ * A UnitOfWork allows you to access
+ * Entities and work with them. All modifications to Entities are recorded by the UnitOfWork,
+ * and at the end they may be sent to the underlying EntityStore by calling complete(). If the
+ * UoW was read-only you may instead simply discard() it.
+ * </p>
+ * <p>
+ * A UoW differs from a traditional Transaction in the sense that it is not tied at all to the underlying
+ * storage resource. Because of this there is no timeout on a UoW. It can be very short or very long.
+ * Another difference is that if a call to complete() fails, and the cause is validation errors in the
+ * Entities of the UoW, then these can be corrected and the UoW retried. By contrast, when a Transaction
+ * commit fails, then the whole transaction has to be done from the beginning again.
+ * </p>
+ * <p>
+ * A UoW can be associated with a Usecase. A Usecase describes the metainformation about the process
+ * to be performed by the UoW.
+ * </p>
+ * <p>
+ * If a code block that uses a UoW throws an exception you need to ensure that this is handled properly,
+ * and that the UoW is closed before returning. Because discard() is a no-op if the UoW is closed, we therefore
+ * recommend the following template to be used:
+ * </p>
+ * <pre>
+ *     UnitOfWork uow = module.newUnitOfWork();
+ *     try
+ *     {
+ *         ...
+ *         uow.complete();
+ *     }
+ *     finally
+ *     {
+ *         uow.discard();
+ *     }
+ * </pre>
+ * <p>
+ * This ensures that in the happy case the UoW is completed, and if any exception is thrown the UoW is discarded. After
+ * the UoW has completed the discard() method doesn't do anything, and so has no effect. You can choose to either add
+ * catch blocks for any exceptions, including exceptions from complete(), or skip them.
+ * </p>
+ * <p>
+ * Since 2.1 you can leverage Java 7 Automatic Resource Management (ie. Try With Resources) and use the following
+ * template instead:
+ * </p>
+ * <pre>
+ *     try( UnitOfWork uow = module.newUnitOfWork() )
+ *     {
+ *         ...
+ *         uow.complete();
+ *     }
+ * </pre>
+ * <p>
+ * It has the very same effect than the template above but is shorter.</p>
+ */
+public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
+{
+
+    /**
+     * Get the UnitOfWorkFactory that this UnitOfWork was created from.
+     *
+     * @return The UnitOfWorkFactory instance that was used to create this UnitOfWork.
+     */
+    UnitOfWorkFactory unitOfWorkFactory();
+
+    long currentTime();
+
+    /**
+     * Get the Usecase for this UnitOfWork
+     *
+     * @return the Usecase
+     */
+    Usecase usecase();
+
+    void setMetaInfo( Object metaInfo );
+
+    <T> Query<T> newQuery( QueryBuilder<T> queryBuilder );
+
+//    DataSet newDataSetBuilder(Specification<?>... constraints);
+
+    /**
+     * Create a new Entity which implements the given mixin type.
+     * <p>
+     * An EntityComposite
+     * will be chosen according to what has been registered and the visibility rules
+     * for Modules and Layers will be considered. If several
+     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
+     * </p>
+     * <p>
+     * The identity of the Entity will be generated by the IdentityGenerator of the Module of the EntityComposite.
+     * </p>
+     *
+     * @param type the mixin type that the EntityComposite must implement
+     *
+     * @return a new Entity
+     *
+     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     * @throws LifecycleException          if the entity cannot be created
+     */
+    <T> T newEntity( Class<T> type )
+        throws EntityTypeNotFoundException, AmbiguousTypeException, LifecycleException;
+
+    /**
+     * Create a new Entity which implements the given mixin type. An EntityComposite
+     * will be chosen according to what has been registered and the visibility rules
+     * for Modules and Layers will be considered. If several
+     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
+     *
+     * @param type     the mixin type that the EntityComposite must implement
+     * @param identity the identity of the new Entity
+     *
+     * @return a new Entity
+     *
+     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     * @throws LifecycleException          if the entity cannot be created
+     */
+    <T> T newEntity( Class<T> type, String identity )
+        throws EntityTypeNotFoundException, AmbiguousTypeException, LifecycleException;
+
+    /**
+     * Create a new EntityBuilder for an EntityComposite which implements the given mixin type. An EntityComposite
+     * will be chosen according to what has been registered and the visibility rules
+     * for Modules and Layers will be considered. If several
+     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
+     *
+     * @param type the mixin type that the EntityComposite must implement
+     *
+     * @return a new EntityBuilder
+     *
+     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     */
+    <T> EntityBuilder<T> newEntityBuilder( Class<T> type )
+        throws EntityTypeNotFoundException, AmbiguousTypeException;
+
+    /**
+     * Create a new EntityBuilder for an EntityComposite which implements the given mixin type. An EntityComposite
+     * will be chosen according to what has been registered and the visibility rules
+     * for Modules and Layers will be considered. If several
+     * mixins implement the type then an AmbiguousTypeException will be thrown.
+     *
+     * @param type     the mixin type that the EntityComposite must implement
+     * @param identity the identity of the new Entity
+     *
+     * @return a new EntityBuilder
+     *
+     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     */
+    <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
+        throws EntityTypeNotFoundException, AmbiguousTypeException;
+
+    /**
+     * Create a new EntityBuilder for an EntityComposite wich implements the given mixin type starting with the given
+     * state.
+     * <p>
+     * An EntityComposite will be chosen according to what has been registered and the visibility rules for Modules and
+     * Layers will be considered.
+     *
+     * @param <T>                      Entity type
+     * @param type                     Entity type
+     * @param propertyFunction         a function providing the state of properties
+     * @param associationFunction      a function providing the state of associations
+     * @param manyAssociationFunction  a function providing the state of many associations
+     * @param namedAssociationFunction a function providing the state of named associations
+     *
+     * @return a new EntityBuilder starting with the given state
+     *
+     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     */
+    <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type,
+                                                    Function<PropertyDescriptor, Object> propertyFunction,
+                                                    Function<AssociationDescriptor, EntityReference> associationFunction,
+                                                    Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
+                                                    Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
+        throws EntityTypeNotFoundException, AmbiguousTypeException;
+
+    /**
+     * Create a new EntityBuilder for an EntityComposite wich implements the given mixin type starting with the given
+     * state.
+     * <p>
+     * An EntityComposite will be chosen according to what has been registered and the visibility rules for Modules and
+     * Layers will be considered.
+     *
+     * @param <T>                      Entity type
+     * @param type                     Entity type
+     * @param identity                 the identity of the new Entity
+     * @param propertyFunction         a function providing the state of properties
+     * @param associationFunction      a function providing the state of associations
+     * @param manyAssociationFunction  a function providing the state of many associations
+     * @param namedAssociationFunction a function providing the state of named associations
+     *
+     * @return a new EntityBuilder starting with the given state
+     *
+     * @throws EntityTypeNotFoundException If no mixins implements the given type
+     * @throws AmbiguousTypeException      If several mixins implement the given type
+     */
+    <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type, String identity,
+                                                    Function<PropertyDescriptor, Object> propertyFunction,
+                                                    Function<AssociationDescriptor, EntityReference> associationFunction,
+                                                    Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
+                                                    Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
+        throws EntityTypeNotFoundException, AmbiguousTypeException;
+
+    /**
+     * Find an Entity of the given mixin type with the give identity. This
+     * method verifies that it exists by asking the underlying EntityStore.
+     *
+     * @param type     of the entity
+     * @param identity of the entity
+     *
+     * @return the entity
+     *
+     * @throws EntityTypeNotFoundException if no entity type could be found
+     * @throws NoSuchEntityException       if the entity could not be found
+     */
+    <T> T get( Class<T> type, String identity )
+        throws EntityTypeNotFoundException, NoSuchEntityException;
+
+    /**
+     * If you have a reference to an Entity from another
+     * UnitOfWork and want to create a reference to it in this
+     * UnitOfWork, then call this method.
+     *
+     * @param entity the Entity to be dereferenced
+     *
+     * @return an Entity from this UnitOfWork
+     *
+     * @throws EntityTypeNotFoundException if no entity type could be found
+     */
+    <T> T get( T entity )
+        throws EntityTypeNotFoundException;
+
+    /**
+     * Remove the given Entity.
+     *
+     * @param entity the Entity to be removed.
+     *
+     * @throws LifecycleException if the entity could not be removed
+     */
+    void remove( Object entity )
+        throws LifecycleException;
+
+    /**
+     * Complete this UnitOfWork. This will send all the changes down to the underlying
+     * EntityStore's.
+     *
+     * @throws UnitOfWorkCompletionException         if the UnitOfWork could not be completed
+     * @throws ConcurrentEntityModificationException if entities have been modified by others
+     */
+    void complete()
+        throws UnitOfWorkCompletionException, ConcurrentEntityModificationException;
+
+    /**
+     * Discard this UnitOfWork. Use this if a failure occurs that you cannot handle,
+     * or if the usecase was of a read-only character. This is a no-op of the UnitOfWork
+     * is already closed.
+     */
+    void discard();
+
+    /**
+     * Discard this UnitOfWork. Use this if a failure occurs that you cannot handle,
+     * or if the usecase was of a read-only character. This is a no-op of the UnitOfWork
+     * is already closed. This simply call the {@link #discard()} method and is an
+     * implementation of the {@link AutoCloseable} interface providing Try With Resources
+     * support for UnitOfWork.
+     */
+    @Override
+    public void close();
+
+    /**
+     * Check if the UnitOfWork is open. It is closed after either complete() or discard()
+     * methods have been called successfully.
+     *
+     * @return true if the UnitOfWork is open.
+     */
+    boolean isOpen();
+
+    /**
+     * Check if the UnitOfWork is paused. It is not paused after it has been create through the
+     * UnitOfWorkFactory, and it can be paused by calling {@link #pause()} and then resumed by calling
+     * {@link #resume()}.
+     *
+     * @return true if this UnitOfWork has been paused.
+     */
+    boolean isPaused();
+
+    /**
+     * Pauses this UnitOfWork.
+     * <p>
+     * Calling this method will cause the underlying UnitOfWork to become the current UnitOfWork until the
+     * the resume() method is called. It is the client's responsibility not to drop the reference to this
+     * UnitOfWork while being paused.
+     * </p>
+     */
+    void pause();
+
+    /**
+     * Resumes this UnitOfWork to again become the current UnitOfWork.
+     */
+    void resume();
+
+    /**
+     * Register a callback. Callbacks are invoked when the UnitOfWork
+     * is completed or discarded.
+     *
+     * @param callback a callback to be registered with this UnitOfWork
+     */
+    void addUnitOfWorkCallback( UnitOfWorkCallback callback );
+
+    /**
+     * Unregister a callback. Callbacks are invoked when the UnitOfWork
+     * is completed or discarded.
+     *
+     * @param callback a callback to be unregistered with this UnitOfWork
+     */
+    void removeUnitOfWorkCallback( UnitOfWorkCallback callback );
+
+    /**
+     * Converts the provided Entity to a Value of the same type.
+     * This is a convenience method to convert an EntityComposite to a ValueComposite.
+     * <p>
+     * All Property values are transferred across as-is, and the Association, ManyAssociation
+     * and NamedAssociatino values are kept in the ValueComposite as EntityReferences
+     * until they are dereferenced (get() and other methods), and IF a UnitOfWork is
+     * present at dereferencing the corresponding EntityCompoiste is retrieved from the
+     * EntityStore. If there is not an UnitOfWork present, an exception is thrown.
+     * </p>
+     * <p>
+     * For this to work, the Composites (both Entity and Value) must not declare the
+     * EntityComposite and ValueComposite super types, but rely on the declaration in
+     * the assembly, and also extend the Identity supertype.
+     * </p>
+     * Example;
+     * <pre><code>
+     *     public interface Person extends Identity { ... };
+     *     public class MyAssembler
+     *     {
+     *         public void assemble( ModuleAssembly module )
+     *         {
+     *             module.values( Person.class );
+     *             module.entities( Person.class );
+     *         }
+     *     }
+     * </code></pre>
+     *
+     * @param primaryType The shared type for which the properties and associations will
+     *                    be converted. Properties outside this type will be ignored.
+     * @param entityComposite The entity to be convered.
+     */
+    <T extends Identity> T toValue( Class<T> primaryType, T entityComposite );
+
+    /**
+     * Converts the provided Value to an Entity of the same type.
+     * This is a convenience method to convert a ValueComposite to an EntityComposite.
+     * <p>
+     * All Property values are transferred across as-is (no deep copy in case mutable
+     * types (DISCOURAGED!) are used), and the Association, ManyAssociation
+     * and NamedAssociatino that were in the ValueComposite as EntityReferences are
+     * transferred into the EntityComposite correctly, and can be dereferenced.
+     * </p>
+     * <p>
+     * This method MUST be called within a UnitOfWork.
+     * </p>
+     * <p>
+     * If an Entity with the Identity in the ValueComposite already exists, then that
+     * Entity is updated with the values from the ValueComposite. If an Entity of
+     * that Identity doesn't exist and new one is created.
+     * </p>
+     * <p>
+     * For this to work, the Composites (both Entity and Value) must not declare the
+     * EntityComposite and ValueComposite super types, but rely on the declaration in
+     * the assembly, and also extend the Identity supertype.
+     * </p>
+     * Example;
+     * <pre><code>
+     *     public interface Person extends Identity { ... };
+     *     public class MyAssembler
+     *     {
+     *         public void assemble( ModuleAssembly module )
+     *         {
+     *             module.values( Person.class );
+     *             module.entities( Person.class );
+     *         }
+     *     }
+     * </code></pre>
+     *
+     * @param primaryType The shared type for which the properties and associations will
+     *                    be converted. Properties outside this type will be ignored.
+     * @param valueComposite The Value to be convered into an Entity.
+     */
+    <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite );
+
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCallback.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCallback.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCallback.java
new file mode 100644
index 0000000..77a78e9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCallback.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.unitofwork;
+
+/**
+ * Callback interface for UnitOfWork completion or discard. Implementations
+ * of this interface can be registered through {@link UnitOfWork#addUnitOfWorkCallback(UnitOfWorkCallback)}.
+ *
+ * If Entities implement this interface they will also receive invocations of this callback interface.
+ */
+public interface UnitOfWorkCallback
+{
+    /**
+     * This is called before the completion of the UnitOfWork.
+     * The callback may do any validation checks and throw
+     * UnitOfWorkCompletionException if there is any reason
+     * why the UnitOfWork is not in a valid state to be completed.
+     *
+     * @throws UnitOfWorkCompletionException
+     */
+    void beforeCompletion()
+        throws UnitOfWorkCompletionException;
+
+    /**
+     * This is called after the completion or discarding
+     * of the UnitOfWork. The callback may do any cleanup
+     * necessary related to the UnitOfWork. Note that the
+     * UnitOfWork is no longer active when this method is
+     * called, so no methods on it may be invoked.
+     *
+     * @param status
+     */
+    void afterCompletion( UnitOfWorkStatus status );
+
+    enum UnitOfWorkStatus
+    {
+        COMPLETED, DISCARDED
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCompletionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCompletionException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCompletionException.java
new file mode 100644
index 0000000..54f6c72
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkCompletionException.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.unitofwork;
+
+/**
+ * When an attempt to {@link UnitOfWork#complete()} an UnitOfWork
+ * fails, this exception will be thrown.
+ */
+public class UnitOfWorkCompletionException
+    extends Exception
+{
+    private static final long serialVersionUID = 6531642131384516904L;
+
+    public UnitOfWorkCompletionException()
+    {
+    }
+
+    public UnitOfWorkCompletionException( String string )
+    {
+        super( string );
+    }
+
+    public UnitOfWorkCompletionException( String string, Throwable throwable )
+    {
+        super( string, throwable );
+    }
+
+    public UnitOfWorkCompletionException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java
new file mode 100644
index 0000000..03b15d7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java
@@ -0,0 +1,45 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.unitofwork;
+
+/**
+ * Base Exception for UnitOfWork related concerns.
+ */
+public class UnitOfWorkException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = -8544178439804058558L;
+
+    public UnitOfWorkException()
+    {
+    }
+
+    public UnitOfWorkException( String message )
+    {
+        super( message );
+    }
+
+    public UnitOfWorkException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public UnitOfWorkException( Throwable cause )
+    {
+        super( cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkFactory.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkFactory.java
new file mode 100644
index 0000000..a8755d4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkFactory.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.unitofwork;
+
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.usecase.Usecase;
+
+/**
+ * Factory for UnitOfWork.
+ */
+public interface UnitOfWorkFactory
+{
+    /**
+     * Create a new UnitOfWork and associate it with the current thread.
+     * <p>
+     * The UnitOfWork will use the default Usecase settings.
+     * </p>
+     * <p>
+     * Current time will be set to System.currentTimeMillis();
+     * </p>
+     * @return a new UnitOfWork
+     */
+    UnitOfWork newUnitOfWork();
+
+    /**
+     * Create a new UnitOfWork and associate it with the current thread.
+     * <p>
+     * The UnitOfWork will use the default Usecase settings.
+     * </p>
+     * @return a new UnitOfWork
+     */
+    UnitOfWork newUnitOfWork( long currentTime );
+
+    /**
+     * Create a new UnitOfWork for the given Usecase and associate it with the current thread.
+     * <p>
+     * Current time will be set to System.currentTimeMillis();
+     * </p>
+     * @param usecase the Usecase for this UnitOfWork
+     *
+     * @return a new UnitOfWork
+     */
+    UnitOfWork newUnitOfWork( Usecase usecase );
+
+    /**
+     * Create a new UnitOfWork for the given Usecase and associate it with the current thread.
+     *
+     * @param usecase the Usecase for this UnitOfWork
+     *
+     * @return a new UnitOfWork
+     */
+    UnitOfWork newUnitOfWork( Usecase usecase, long currentTime );
+
+    /**
+     * @return true if there is an active UnitOfWork associated with the executing thread
+     */
+    boolean isUnitOfWorkActive();
+
+    /**
+     * Returns the UnitOfWork that is currently associated with the executing thread.
+     *
+     * @return The current UnitOfWork associated with the executing thread
+     *
+     * @throws IllegalStateException if no current UnitOfWork is active
+     */
+    UnitOfWork currentUnitOfWork()
+        throws IllegalStateException;
+
+    /**
+     * Returns the UnitOfWork that the EntityComposite is bound to.
+     *
+     * @param entity the entity to be checked.
+     *
+     * @return The UnitOfWork instance that the Entity is bound to, or null if the entity is not associated with
+     *         any UnitOfWork.
+     */
+    UnitOfWork getUnitOfWork( EntityComposite entity );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkOptions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkOptions.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkOptions.java
new file mode 100644
index 0000000..33e544d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkOptions.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.unitofwork;
+
+/**
+ * Set instances of this in MetaInfo on UnitOfWork or the associated Usecase.
+ *  <p>
+ * Options:
+ *  </p>
+ * <p>
+ * "pruneOnPause": if true, then clear out all instances that have been loaded in the UoW but not modified
+ * </p>
+ */
+public class UnitOfWorkOptions
+{
+    private boolean pruneOnPause = false;
+
+    public UnitOfWorkOptions( boolean pruneOnPause )
+    {
+        this.pruneOnPause = pruneOnPause;
+    }
+
+    public boolean isPruneOnPause()
+    {
+        return pruneOnPause;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkTemplate.java b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkTemplate.java
new file mode 100644
index 0000000..e8663b4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkTemplate.java
@@ -0,0 +1,93 @@
+/*
+ * 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.qi4j.api.unitofwork;
+
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.usecase.Usecase;
+
+/**
+ * UnitOfWork Template.
+ */
+public abstract class UnitOfWorkTemplate<RESULT, ThrowableType extends Throwable>
+{
+    private Usecase usecase = Usecase.DEFAULT;
+    private int retries = 10;
+    private boolean complete = true;
+
+    protected UnitOfWorkTemplate()
+    {
+    }
+
+    protected UnitOfWorkTemplate( int retries, boolean complete )
+    {
+        this.retries = retries;
+        this.complete = complete;
+    }
+
+    protected UnitOfWorkTemplate( Usecase usecase, int retries, boolean complete )
+    {
+        this.usecase = usecase;
+        this.retries = retries;
+        this.complete = complete;
+    }
+
+    protected abstract RESULT withUnitOfWork( UnitOfWork uow )
+        throws ThrowableType;
+
+    @SuppressWarnings( "unchecked" )
+    public RESULT withModule( Module module )
+        throws ThrowableType, UnitOfWorkCompletionException
+    {
+        int loop = 0;
+        ThrowableType ex = null;
+        do
+        {
+            UnitOfWork uow = module.newUnitOfWork( usecase );
+
+            try
+            {
+                RESULT result = withUnitOfWork( uow );
+                if( complete )
+                {
+                    try
+                    {
+                        uow.complete();
+                        return result;
+                    }
+                    catch( ConcurrentEntityModificationException e )
+                    {
+                        // Retry?
+                        ex = (ThrowableType) e;
+                    }
+                }
+            }
+            catch( Throwable e )
+            {
+                ex = (ThrowableType) e;
+            }
+            finally
+            {
+                uow.discard();
+            }
+        }
+        while( loop++ < retries );
+
+        throw ex;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkConcern.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkConcern.java b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkConcern.java
new file mode 100644
index 0000000..c684385
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkConcern.java
@@ -0,0 +1,182 @@
+/*  Copyright 2008 Edward Yakop.
+ *  Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.unitofwork.concern;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.concern.GenericConcern;
+import org.qi4j.api.injection.scope.Invocation;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.injection.scope.Uses;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.unitofwork.ConcurrentEntityModificationException;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.usecase.Usecase;
+import org.qi4j.api.usecase.UsecaseBuilder;
+
+/**
+ * {@code UnitOfWorkConcern} manages the unit of work complete, discard and retry policy.
+ *
+ * @see UnitOfWorkPropagation
+ * @see UnitOfWorkDiscardOn
+ */
+@AppliesTo( UnitOfWorkPropagation.class )
+public class UnitOfWorkConcern
+    extends GenericConcern
+{
+    private static final Class<?>[] DEFAULT_DISCARD_CLASSES = new Class[]{ Throwable.class };
+
+    @Structure
+    Module module;
+
+    @Invocation
+    UnitOfWorkPropagation propagation;
+
+    /**
+     * Handles method with {@code UnitOfWorkPropagation} annotation.
+     *
+     * @param proxy  The object.
+     * @param method The invoked method.
+     * @param args   The method arguments.
+     *
+     * @return The returned value of method invocation.
+     *
+     * @throws Throwable Thrown if the method invocation throw exception.
+     */
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        UnitOfWorkPropagation.Propagation propagationPolicy = propagation.value();
+        if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRED )
+        {
+            if( module.isUnitOfWorkActive() )
+            {
+                return next.invoke( proxy, method, args );
+            }
+            else
+            {
+                Usecase usecase = usecase();
+                return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
+            }
+        }
+        else if( propagationPolicy == UnitOfWorkPropagation.Propagation.MANDATORY )
+        {
+            if( !module.isUnitOfWorkActive() )
+            {
+                throw new IllegalStateException( "UnitOfWork was required but there is no available unit of work." );
+            }
+        }
+        else if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRES_NEW )
+        {
+            Usecase usecase = usecase();
+            return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
+        }
+        return next.invoke( proxy, method, args );
+    }
+
+    private Usecase usecase()
+    {
+        String usecaseName = propagation.usecase();
+        Usecase usecase;
+        if( usecaseName == null )
+        {
+            usecase = Usecase.DEFAULT;
+        }
+        else
+        {
+            usecase = UsecaseBuilder.newUsecase( usecaseName );
+        }
+        return usecase;
+    }
+
+    protected Object invokeWithCommit( Object proxy, Method method, Object[] args, UnitOfWork currentUnitOfWork )
+        throws Throwable
+    {
+        try
+        {
+            UnitOfWorkRetry retryAnnot = method.getAnnotation( UnitOfWorkRetry.class );
+            int maxTries = 0;
+            long delayFactor = 0;
+            long initialDelay = 0;
+            if( retryAnnot != null )
+            {
+                maxTries = retryAnnot.retries();
+                initialDelay = retryAnnot.initialDelay();
+                delayFactor = retryAnnot.delayFactory();
+            }
+            int retry = 0;
+            while( true )
+            {
+                Object result = next.invoke( proxy, method, args );
+                try
+                {
+                    currentUnitOfWork.complete();
+                    return result;
+                }
+                catch( ConcurrentEntityModificationException e )
+                {
+                    if( retry >= maxTries )
+                    {
+                        throw e;
+                    }
+                    module.currentUnitOfWork().discard();
+                    Thread.sleep( initialDelay + retry * delayFactor );
+                    retry++;
+                    currentUnitOfWork = module.newUnitOfWork( usecase() );
+                }
+            }
+        }
+        catch( Throwable throwable )
+        {
+            // Discard only if this concern create a unit of work
+            discardIfRequired( method, currentUnitOfWork, throwable );
+            throw throwable;
+        }
+    }
+
+    /**
+     * Discard unit of work if the discard policy match.
+     *
+     * @param aMethod     The invoked method. This argument must not be {@code null}.
+     * @param aUnitOfWork The current unit of work. This argument must not be {@code null}.
+     * @param aThrowable  The exception thrown. This argument must not be {@code null}.
+     */
+    protected void discardIfRequired( Method aMethod, UnitOfWork aUnitOfWork, Throwable aThrowable )
+    {
+        UnitOfWorkDiscardOn discardPolicy = aMethod.getAnnotation( UnitOfWorkDiscardOn.class );
+        Class<?>[] discardClasses;
+        if( discardPolicy != null )
+        {
+            discardClasses = discardPolicy.value();
+        }
+        else
+        {
+            discardClasses = DEFAULT_DISCARD_CLASSES;
+        }
+
+        Class<? extends Throwable> aThrowableClass = aThrowable.getClass();
+        for( Class<?> discardClass : discardClasses )
+        {
+            if( discardClass.isAssignableFrom( aThrowableClass ) )
+            {
+                aUnitOfWork.discard();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkDiscardOn.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkDiscardOn.java b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkDiscardOn.java
new file mode 100644
index 0000000..3668736
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkDiscardOn.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2008, Edward Yakop. 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.qi4j.api.unitofwork.concern;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation to denote the unit of work discard policy.
+ * <p>
+ * By default, discard is applied on any method that has {@link UnitOfWorkPropagation} and any exception is thrown.
+ * </p>
+ * <p>
+ * Apply {@code UnitOfWorkDiscardOn} to override the default settings.
+ * </p>
+ * <p>
+ * Usage example:
+ * </p>
+ * <pre>
+ * <code>
+ *
+ * &#64;Concerns( UnitOfWorkConcern.class )
+ * public class MyBusinessServiceMixin implements BusinessService
+ * {
+ *   &#64;Structure UnitOfWorkFactory uowf;
+ *
+ *   &#64;UnitOfWorkDiscardOn( MyBusinessException.class )
+ *   public void myBusinessMethod()
+ *   {
+ *     // Must invoke current unit of work.
+ *     UnitOfWork uow = uowf.currentUnitOfWork();
+ *
+ *     // Perform business logic
+ *   }
+ * }
+ * </code>
+ * </pre>
+ *
+ * <p>
+ * The unit of work will be discarded iff {@code MyBusinessException} exceptions or its subclass is thrown from within
+ * {@code myBusinessMethod} method.
+ * </p>
+ */
+@Retention( RUNTIME )
+@Target( METHOD )
+@Inherited
+@Documented
+public @interface UnitOfWorkDiscardOn
+{
+    Class<? extends Throwable>[] value() default { Throwable.class };
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkPropagation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkPropagation.java b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkPropagation.java
new file mode 100644
index 0000000..4fe78b7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkPropagation.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2008, Edward Yakop. All Rights Reserved.
+ * Copyright (c) 2009, Niclas Hedhman. 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.qi4j.api.unitofwork.concern;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation to denote the unit of work propagation.
+ * <p>
+ * Usage example:
+ * </p>
+ * <pre>
+ * <code>
+ *
+ * &#64;Concerns( UnitOfWorkConcern.class )
+ * public class MyBusinessServiceMixin implements BusinessService
+ * {
+ *   &#64;Structure UnitOfWorkFactory uowf;
+ *
+ *   &#64;UnitOfWorkPropagation
+ *   public void myBusinessMethod()
+ *   {
+ *     // Must invoke current unit of work.
+ *     UnitOfWork uow = uowf.currentUnitOfWork();
+ *
+ *     // Perform business logic
+ *   }
+ * }
+ * </code>
+ * </pre>
+ */
+@Retention( RUNTIME )
+@Target( METHOD )
+@Inherited
+@Documented
+public @interface UnitOfWorkPropagation
+{
+    Propagation value() default Propagation.REQUIRED;
+
+    String usecase() default "";
+
+    /**
+     * Propagation behaviors.
+     */
+    enum Propagation
+    {
+        /**
+         * Default propagation behavior.
+         * Behavior: <br>
+         * If no current transaction: creates a new UnitOfWork <br>
+         * If there is a current UnitOfWork: use the current UnitOfWork.
+         */
+        REQUIRED,
+
+        /**
+         * Behavior: <br>
+         * If no current UnitOfWork: throw an exception <br>
+         * If there is a current UnitOfWork: use the current UnitOfWork.
+         */
+        MANDATORY,
+
+        /**
+         * Behavior: <br>
+         * If no current UnitOfWork: creates a new UnitOfWork <br>
+         * If there is a current UnitOfWork: suspend the current UnitOfWork and create a new UnitOfWork.
+         */
+        REQUIRES_NEW
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkRetry.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkRetry.java b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkRetry.java
new file mode 100644
index 0000000..de386f9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/UnitOfWorkRetry.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.api.unitofwork.concern;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * This annotation describes the retries that should occur in case of {@link org.qi4j.api.unitofwork.ConcurrentEntityModificationException}
+ * occurs.
+ */
+@Retention( RUNTIME )
+@Target( METHOD )
+@Inherited
+@Documented
+public @interface UnitOfWorkRetry
+{
+    int retries() default 1;
+
+    long initialDelay() default 0;
+
+    long delayFactory() default 10;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/concern/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/concern/package.html b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/package.html
new file mode 100644
index 0000000..68cbe0e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/concern/package.html
@@ -0,0 +1,24 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<html>
+    <body>
+        <h2>UnitOfWork Concerns.</h2>
+        <p>
+            UnitOfWork Concerns allow declarative UnitOfWork propagation, discard wrt. exceptions and automatic retry.
+        </p>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/unitofwork/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/unitofwork/package.html b/core/api/src/main/java/org/qi4j/api/unitofwork/package.html
new file mode 100644
index 0000000..1bc08fa
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/unitofwork/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>UnitOfWork API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/usecase/Usecase.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/usecase/Usecase.java b/core/api/src/main/java/org/qi4j/api/usecase/Usecase.java
new file mode 100644
index 0000000..415672a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/usecase/Usecase.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.usecase;
+
+import java.io.Serializable;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.structure.MetaInfoHolder;
+
+/**
+ * A Usecase. A Usecase is used as a model for UnitOfWork, and helps
+ * implementations decide what to do in certain circumstances.
+ */
+public final class Usecase
+    implements Serializable, MetaInfoHolder
+{
+    public static final Usecase DEFAULT = new Usecase( "Default", new MetaInfo() );
+
+    private static final long serialVersionUID = 1L;
+    private final String name;
+    private final MetaInfo metaInfo;
+
+    Usecase( String name, MetaInfo metaInfo )
+    {
+        this.name = name;
+        this.metaInfo = metaInfo;
+    }
+
+    /**
+     * Name of the usecase.
+     *
+     * @return the name
+     */
+    public String name()
+    {
+        return name;
+    }
+
+    /**
+     * Meta-info for the usecase. This can be of any type, and is typically set when creating the usecase
+     * and read during the execution of the usecase.
+     *
+     * @param infoType the MetaInfo type to retrieve.
+     *
+     * @return the previously stored metaInfo of the given type for the usecase.
+     */
+    @Override
+    public <T> T metaInfo( Class<T> infoType )
+    {
+        return metaInfo.get( infoType );
+    }
+
+    @Override
+    public String toString()
+    {
+        return name + ", meta info:" + metaInfo;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/usecase/UsecaseBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/usecase/UsecaseBuilder.java b/core/api/src/main/java/org/qi4j/api/usecase/UsecaseBuilder.java
new file mode 100644
index 0000000..118b72d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/usecase/UsecaseBuilder.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.usecase;
+
+import org.qi4j.api.common.MetaInfo;
+
+/**
+ * Builder for Usecases.
+ */
+public final class UsecaseBuilder
+{
+    public static UsecaseBuilder buildUsecase( String aName )
+    {
+        return new UsecaseBuilder( aName );
+    }
+
+    public static Usecase newUsecase( String aName )
+    {
+        return new UsecaseBuilder( aName ).newUsecase();
+    }
+
+    private MetaInfo metaInfo = new MetaInfo();
+
+    private String name;
+
+    private UsecaseBuilder( String name )
+    {
+        this.name = name;
+    }
+
+    public UsecaseBuilder withMetaInfo( Object metaInfo )
+    {
+        this.metaInfo.set( metaInfo );
+        return this;
+    }
+
+    public Usecase newUsecase()
+    {
+        return new Usecase( name, metaInfo );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/usecase/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/usecase/package.html b/core/api/src/main/java/org/qi4j/api/usecase/package.html
new file mode 100644
index 0000000..71c696a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/usecase/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Usecase API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/util/Annotations.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/util/Annotations.java b/core/api/src/main/java/org/qi4j/api/util/Annotations.java
new file mode 100644
index 0000000..8adc5ff
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/util/Annotations.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Type;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.api.util.Classes.interfacesOf;
+import static org.qi4j.api.util.Classes.typeOf;
+import static org.qi4j.functional.Iterables.flatten;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.map;
+
+/**
+ * Useful methods for handling Annotations.
+ */
+public final class Annotations
+{
+    public static Function<Type, Iterable<Annotation>> ANNOTATIONS_OF = Classes.forTypes( new Function<Type, Iterable<Annotation>>()
+    {
+        @Override
+        public Iterable<Annotation> map( Type type )
+        {
+            return Iterables.iterable( Classes.RAW_CLASS.map( type ).getAnnotations() );
+        }
+    } );
+
+    public static Specification<AnnotatedElement> hasAnnotation( final Class<? extends Annotation> annotationType )
+    {
+        return new Specification<AnnotatedElement>()
+        {
+            @Override
+            public boolean satisfiedBy( AnnotatedElement element )
+            {
+                return element.getAnnotation( annotationType ) != null;
+            }
+        };
+    }
+
+    public static Function<Annotation, Class<? extends Annotation>> type()
+    {
+        return new Function<Annotation, Class<? extends Annotation>>()
+        {
+            @Override
+            public Class<? extends Annotation> map( Annotation annotation )
+            {
+                return annotation.annotationType();
+            }
+        };
+    }
+
+    public static Specification<Annotation> isType( final Class<? extends Annotation> annotationType )
+    {
+        return new Specification<Annotation>()
+        {
+            @Override
+            public boolean satisfiedBy( Annotation annotation )
+            {
+                return annotation.annotationType().equals( annotationType );
+            }
+        };
+    }
+
+    public static <T extends Annotation> T annotationOn( Type type, Class<T> annotationType )
+    {
+        return annotationType.cast( Classes.RAW_CLASS.map( type ).getAnnotation( annotationType ) );
+    }
+
+    public static Iterable<Annotation> findAccessorAndTypeAnnotationsIn( AccessibleObject accessor )
+    {
+        return flatten( iterable( accessor.getAnnotations() ),
+                        flattenIterables( map( Annotations.ANNOTATIONS_OF, interfacesOf( typeOf( accessor ) ) ) ) );
+    }
+}


[10/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InvocationInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InvocationInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InvocationInjectionProviderFactory.java
deleted file mode 100644
index d7348ff..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InvocationInjectionProviderFactory.java
+++ /dev/null
@@ -1,117 +0,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.
- */
-package org.apache.zest.runtime.injection.provider;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public final class InvocationInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    @SuppressWarnings( "raw" )
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        Class injectionClass = Classes.RAW_CLASS.map( dependencyModel.injectionType() );
-        if( injectionClass.equals( Method.class ) ||
-            injectionClass.equals( AnnotatedElement.class ) ||
-            injectionClass.equals( Iterable.class ) ||
-            Annotation.class.isAssignableFrom( injectionClass ) )
-        {
-            return new InvocationDependencyResolution( resolution, dependencyModel );
-        }
-        else
-        {
-            String injectedTo = dependencyModel.injectedClass().getName();
-            throw new InvalidInjectionException( "Invalid injection type " + injectionClass + " in " + injectedTo );
-        }
-    }
-
-    private static class InvocationDependencyResolution
-        implements InjectionProvider
-    {
-        private final Resolution resolution;
-        private final DependencyModel dependencyModel;
-
-        private InvocationDependencyResolution( Resolution resolution, DependencyModel dependencyModel )
-        {
-            this.resolution = resolution;
-            this.dependencyModel = dependencyModel;
-        }
-
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            Class injectionClass = Classes.RAW_CLASS.map( dependencyModel.injectionType() );
-            final CompositeMethodModel methodModel = resolution.method();
-            if( injectionClass.equals( Method.class ) )
-            {
-                return methodModel.method();
-            }
-
-            final AnnotatedElement annotatedElement = methodModel.annotatedElement();
-            if( injectionClass.equals( AnnotatedElement.class ) )
-            {
-                return annotatedElement;
-            }
-            final Annotation annotation = annotatedElement.getAnnotation( injectionClass );
-            if( annotation != null )
-            {
-                return annotation;
-            }
-            if( dependencyModel.injectionType() instanceof Class<?> )
-            {
-                return annotatedElement.getAnnotation( (Class<Annotation>) dependencyModel.injectionType() );
-            }
-            if( dependencyModel.injectionType() instanceof ParameterizedType )
-            {
-                ParameterizedType injectionType = (ParameterizedType) dependencyModel.injectionType();
-                Type rawType = injectionType.getRawType();
-                Type[] actualTypeArguments = injectionType.getActualTypeArguments();
-                boolean isAnIterable = rawType.equals( Iterable.class );
-                boolean haveOneGenericType = actualTypeArguments.length == 1;
-                boolean thatIsOfTypeMethod = actualTypeArguments[ 0 ].equals( Method.class );
-                if( isAnIterable && haveOneGenericType && thatIsOfTypeMethod )
-                {
-                    Class<?> injectedClass = dependencyModel.injectedClass();
-                    Iterable<Method> result = methodModel.invocationsFor( injectedClass );
-                    return result;
-                }
-            }
-            return null;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ModifiesInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ModifiesInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ModifiesInjectionProviderFactory.java
deleted file mode 100644
index fedb010..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ModifiesInjectionProviderFactory.java
+++ /dev/null
@@ -1,70 +0,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.
- */
-package org.apache.zest.runtime.injection.provider;
-
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public final class ModifiesInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution bindingContext, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        if( bindingContext.model() instanceof CompositeDescriptor )
-        {
-            Class<?> type = Classes.RAW_CLASS.map( dependencyModel.injectionType() );
-            if( type.isAssignableFrom( dependencyModel.injectedClass() ) )
-            {
-                return new ModifiedInjectionProvider();
-            }
-            else
-            {
-                throw new InvalidInjectionException( "Composite " + bindingContext.model() + " does not implement @ConcernFor type " + type
-                    .getName() + " in modifier " + dependencyModel.injectedClass().getName() );
-            }
-        }
-        else
-        {
-            throw new InvalidInjectionException( "The class " + dependencyModel.injectedClass()
-                .getName() + " is not a modifier" );
-        }
-    }
-
-    private static class ModifiedInjectionProvider
-        implements InjectionProvider
-    {
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            return context.next();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
deleted file mode 100644
index 4c5bb26..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.injection.provider;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.qualifier.Qualifier;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.api.util.Annotations.hasAnnotation;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.iterable;
-
-public final class ServiceInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        // TODO This could be changed to allow multiple @Qualifier annotations
-        Annotation qualifierAnnotation = first( filter( Specifications.translate( Annotations.type(), hasAnnotation( Qualifier.class ) ), iterable( dependencyModel
-                                                                                                                                                        .annotations() ) ) );
-        Specification<ServiceReference<?>> serviceQualifier = null;
-        if( qualifierAnnotation != null )
-        {
-            Qualifier qualifier = qualifierAnnotation.annotationType().getAnnotation( Qualifier.class );
-            try
-            {
-                serviceQualifier = qualifier.value().newInstance().qualifier( qualifierAnnotation );
-            }
-            catch( Exception e )
-            {
-                throw new InvalidInjectionException( "Could not instantiate qualifier serviceQualifier", e );
-            }
-        }
-
-        if( dependencyModel.rawInjectionType().equals( Iterable.class ) )
-        {
-            Type iterableType = ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ];
-            if( Classes.RAW_CLASS.map( iterableType ).equals( ServiceReference.class ) )
-            {
-                // @Service Iterable<ServiceReference<MyService<Foo>> serviceRefs
-                Type serviceType = ( (ParameterizedType) iterableType ).getActualTypeArguments()[ 0 ];
-
-                return new IterableServiceReferenceProvider( serviceType, serviceQualifier );
-            }
-            else
-            {
-                // @Service Iterable<MyService<Foo>> services
-                return new IterableServiceProvider( iterableType, serviceQualifier );
-            }
-        }
-        else if( dependencyModel.rawInjectionType().equals( ServiceReference.class ) )
-        {
-            // @Service ServiceReference<MyService<Foo>> serviceRef
-            Type referencedType = ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ];
-            return new ServiceReferenceProvider( referencedType, serviceQualifier );
-        }
-        else
-        {
-            // @Service MyService<Foo> service
-            return new ServiceProvider( dependencyModel.injectionType(), serviceQualifier );
-        }
-    }
-
-    private static class IterableServiceReferenceProvider
-        extends ServiceInjectionProvider
-    {
-        private IterableServiceReferenceProvider( Type serviceType,
-                                                  Specification<ServiceReference<?>> serviceQualifier
-        )
-        {
-            super( serviceType, serviceQualifier );
-        }
-
-        @Override
-        public synchronized Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            return getServiceReferences( context );
-        }
-    }
-
-    private static class IterableServiceProvider
-        extends ServiceInjectionProvider
-        implements Function<ServiceReference<?>, Object>
-    {
-        private IterableServiceProvider( Type serviceType,
-                                         Specification<ServiceReference<?>> serviceQualifier
-        )
-        {
-            super( serviceType, serviceQualifier );
-        }
-
-        @Override
-        public synchronized Object provideInjection( final InjectionContext context )
-            throws InjectionProviderException
-        {
-            return Iterables.map( this, getServiceReferences( context ) );
-        }
-
-        @Override
-        public Object map( ServiceReference<?> objectServiceReference )
-        {
-            return objectServiceReference.get();
-        }
-    }
-
-    private static class ServiceReferenceProvider
-        extends ServiceInjectionProvider
-    {
-        ServiceReferenceProvider( Type serviceType, Specification<ServiceReference<?>> qualifier )
-        {
-            super( serviceType, qualifier );
-        }
-
-        @Override
-        public synchronized Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            return getServiceReference( context );
-        }
-    }
-
-    private static class ServiceProvider
-        extends ServiceInjectionProvider
-    {
-        ServiceProvider( Type serviceType, Specification<ServiceReference<?>> qualifier )
-        {
-            super( serviceType, qualifier );
-        }
-
-        @Override
-        public synchronized Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            ServiceReference<?> ref = getServiceReference( context );
-
-            if( ref != null )
-            {
-                return ref.get();
-            }
-            else
-            {
-                return null;
-            }
-        }
-    }
-
-    private abstract static class ServiceInjectionProvider
-        implements InjectionProvider
-    {
-        private final Type serviceType;
-        private final Specification<ServiceReference<?>> serviceQualifier;
-
-        private ServiceInjectionProvider( Type serviceType,
-                                            Specification<ServiceReference<?>> serviceQualifier
-        )
-        {
-            this.serviceType = serviceType;
-            this.serviceQualifier = serviceQualifier;
-        }
-
-        protected ServiceReference<Object> getServiceReference( InjectionContext context )
-        {
-            try
-            {
-                if( serviceQualifier == null )
-                {
-                    return context.module().findService( serviceType );
-                }
-                else
-                {
-                    return Iterables.first( Iterables.filter( serviceQualifier, context.module()
-                        .findServices( serviceType ) ) );
-                }
-            }
-            catch( NoSuchServiceException e )
-            {
-                return null;
-            }
-        }
-
-        protected Iterable<ServiceReference<Object>> getServiceReferences( final InjectionContext context )
-        {
-            if( serviceQualifier == null )
-            {
-                return context.module().findServices( serviceType );
-            }
-            else
-            {
-                return Iterables.filter( serviceQualifier, context.module().findServices( serviceType ) );
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StateInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StateInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StateInjectionProviderFactory.java
deleted file mode 100644
index 8d0bcc7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StateInjectionProviderFactory.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.injection.provider;
-
-import org.apache.zest.api.association.AbstractAssociation;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.StateDescriptor;
-import org.apache.zest.api.composite.StatefulCompositeDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public final class StateInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        if( StateHolder.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            // @State StateHolder properties;
-            return new StateInjectionProvider();
-        }
-        else if( UnitOfWork.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            if( !( resolution.model() instanceof EntityDescriptor ) )
-            {
-                throw new InvalidInjectionException( "Only EntityComposites can be injected with '@State UnitOfWork'" );
-            }
-            return new UnitOfWorkInjectionProvider();
-        }
-        else if( Property.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            // @State Property<String> name;
-            StateDescriptor descriptor;
-            descriptor = ( (StatefulCompositeDescriptor) resolution.model() ).state();
-
-            State annotation = (State) dependencyModel.injectionAnnotation();
-            String name;
-            if( annotation.value().isEmpty() )
-            {
-                name = resolution.field().getName();
-            }
-            else
-            {
-                name = annotation.value();
-            }
-
-            PropertyDescriptor propertyDescriptor = descriptor.findPropertyModelByName( name );
-            return new PropertyInjectionProvider( propertyDescriptor );
-        }
-        else if( Association.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            // @State Association<MyEntity> name;
-            AssociationStateDescriptor descriptor = ( (EntityDescriptor) resolution.model() ).state();
-            State annotation = (State) dependencyModel.injectionAnnotation();
-            String name;
-            if( annotation.value().isEmpty() )
-            {
-                name = resolution.field().getName();
-            }
-            else
-            {
-                name = annotation.value();
-            }
-            AssociationDescriptor model = descriptor.getAssociationByName( name );
-            return new AssociationInjectionProvider( model );
-        }
-        else if( ManyAssociation.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            // @State ManyAssociation<MyEntity> name;
-            AssociationStateDescriptor descriptor = ( (EntityDescriptor) resolution.model() ).state();
-            State annotation = (State) dependencyModel.injectionAnnotation();
-            String name;
-            if( annotation.value().isEmpty() )
-            {
-                name = resolution.field().getName();
-            }
-            else
-            {
-                name = annotation.value();
-            }
-            AssociationDescriptor model = descriptor.getManyAssociationByName( name );
-            return new ManyAssociationInjectionProvider( model );
-        }
-        else if( NamedAssociation.class.isAssignableFrom( dependencyModel.rawInjectionType() ) )
-        {
-            // @State NamedAssociation<MyEntity> name;
-            AssociationStateDescriptor descriptor = ( (EntityDescriptor) resolution.model() ).state();
-            State annotation = (State) dependencyModel.injectionAnnotation();
-            String name;
-            if( annotation.value().isEmpty() )
-            {
-                name = resolution.field().getName();
-            }
-            else
-            {
-                name = annotation.value();
-            }
-            AssociationDescriptor model = descriptor.getNamedAssociationByName( name );
-            return new NamedAssociationInjectionProvider( model );
-        }
-
-        throw new InjectionProviderException( "Injected value has invalid type" );
-    }
-
-    private static class PropertyInjectionProvider
-        implements InjectionProvider
-    {
-        private final PropertyDescriptor propertyDescriptor;
-
-        private PropertyInjectionProvider( PropertyDescriptor propertyDescriptor )
-        {
-            this.propertyDescriptor = propertyDescriptor;
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            Property<?> value = context.state().propertyFor( propertyDescriptor.accessor() );
-            if( value != null )
-            {
-                return value;
-            }
-            else
-            {
-                throw new InjectionProviderException( "Non-optional property " + propertyDescriptor + " had no value" );
-            }
-        }
-    }
-
-    private static class AssociationInjectionProvider
-        implements InjectionProvider
-    {
-        private final AssociationDescriptor associationDescriptor;
-
-        private AssociationInjectionProvider( AssociationDescriptor associationDescriptor )
-        {
-            this.associationDescriptor = associationDescriptor;
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            AbstractAssociation abstractAssociation = ( (AssociationStateHolder) context.state() ).
-                associationFor( associationDescriptor.accessor() );
-            if( abstractAssociation != null )
-            {
-                return abstractAssociation;
-            }
-            else
-            {
-                throw new InjectionProviderException( "Non-optional association " + associationDescriptor.qualifiedName() + " had no association" );
-            }
-        }
-    }
-
-    private static class ManyAssociationInjectionProvider
-        implements InjectionProvider
-    {
-        private final AssociationDescriptor manyAssociationDescriptor;
-
-        private ManyAssociationInjectionProvider( AssociationDescriptor manyAssociationDescriptor )
-        {
-            this.manyAssociationDescriptor = manyAssociationDescriptor;
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            ManyAssociation<?> abstractAssociation = ( (AssociationStateHolder) context.state() ).
-                manyAssociationFor( manyAssociationDescriptor.accessor() );
-            if( abstractAssociation != null )
-            {
-                return abstractAssociation;
-            }
-            else
-            {
-                throw new InjectionProviderException( "Non-optional association " + manyAssociationDescriptor.qualifiedName() + " had no association" );
-            }
-        }
-    }
-
-    private static class NamedAssociationInjectionProvider
-        implements InjectionProvider
-    {
-        private final AssociationDescriptor namedAssociationDescriptor;
-
-        private NamedAssociationInjectionProvider( AssociationDescriptor namedAssociationDescriptor )
-        {
-            this.namedAssociationDescriptor = namedAssociationDescriptor;
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            NamedAssociation<?> abstractAssociation = ( (AssociationStateHolder) context.state() ).
-                namedAssociationFor( namedAssociationDescriptor.accessor() );
-            if( abstractAssociation != null )
-            {
-                return abstractAssociation;
-            }
-            else
-            {
-                throw new InjectionProviderException( "Non-optional association " + namedAssociationDescriptor.qualifiedName() + " had no association" );
-            }
-        }
-    }
-
-    static private class StateInjectionProvider
-        implements InjectionProvider
-    {
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            return context.state();
-        }
-    }
-
-    static private class UnitOfWorkInjectionProvider
-        implements InjectionProvider
-    {
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            return ( (EntityInstance) context.compositeInstance() ).unitOfWork();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
deleted file mode 100644
index 7ee3db0..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2007, 2008 Niclas Hedhman.
- *
- * 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.zest.runtime.injection.provider;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.composite.TransientBuilderFactory;
-import org.apache.zest.api.object.ObjectFactory;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
-
-public final class StructureInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        return new StructureInjectionProvider( dependencyModel );
-    }
-
-    private static class StructureInjectionProvider
-        implements InjectionProvider
-    {
-        private final DependencyModel dependencyModel;
-
-        private StructureInjectionProvider( DependencyModel dependencyModel )
-        {
-            this.dependencyModel = dependencyModel;
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            Type type1 = dependencyModel.injectionType();
-            if( !( type1 instanceof Class ) )
-            {
-                throw new InjectionProviderException( "Type [" + type1 + "] can not be injected from the @Structure injection scope: " + context );
-            }
-            Class clazz = (Class) type1;
-            if( clazz.equals( TransientBuilderFactory.class ) )
-            {
-                return context.module();
-            }
-            else if( clazz.equals( ObjectFactory.class ) )
-            {
-                return context.module();
-            }
-            else if( clazz.equals( ValueBuilderFactory.class ) )
-            {
-                return context.module();
-            }
-            else if( clazz.equals( UnitOfWorkFactory.class ) )
-            {
-                return context.module();
-            }
-            else if( clazz.equals( QueryBuilderFactory.class ) )
-            {
-                return context.module();
-            }
-            else if( clazz.equals( ServiceFinder.class ) )
-            {
-                return context.module();
-            }
-            else if( Module.class.isAssignableFrom( clazz ) )
-            {
-                return context.module();
-            }
-            else if( ModuleSpi.class.isAssignableFrom( clazz ) )
-            {
-                return context.module();
-            }
-            else if( Layer.class.isAssignableFrom( clazz ) )
-            {
-                return (( ModuleInstance) context.module()).layerInstance();
-            }
-            else if( Application.class.isAssignableFrom( clazz ) )
-            {
-                return (( ModuleInstance) context.module()).layerInstance().applicationInstance();
-            }
-            else if( Qi4j.class.isAssignableFrom( clazz ) )
-            {
-                return (( ModuleInstance) context.module()).layerInstance().applicationInstance().runtime();
-            }
-
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
deleted file mode 100644
index a7b53eb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
+++ /dev/null
@@ -1,138 +0,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.
- */
-package org.apache.zest.runtime.injection.provider;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.composite.ProxyGenerator;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- */
-public final class ThisInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public InjectionProvider newInjectionProvider( Resolution bindingContext, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        if( bindingContext.model() instanceof CompositeDescriptor )
-        {
-            // If Composite type then return real type, otherwise use the specified one
-            final Class<?> thisType = dependencyModel.rawInjectionType();
-
-            Iterable<Class<?>> injectionTypes = null;
-            if( Classes.assignableTypeSpecification( thisType ).satisfiedBy( bindingContext.model() ) )
-            {
-                injectionTypes = bindingContext.model().types();
-            }
-            else
-            {
-                CompositeDescriptor acd = ( (CompositeDescriptor) bindingContext.model() );
-                for( Class<?> mixinType : acd.mixinTypes() )
-                {
-                    if( thisType.isAssignableFrom( mixinType ) )
-                    {
-                        Iterable<? extends Class<?>> iterable = iterable( thisType );
-                        injectionTypes = (Iterable<Class<?>>) iterable;
-                        break;
-                    }
-                }
-
-                if( injectionTypes == null )
-                {
-                    throw new InvalidInjectionException( "Composite " + bindingContext.model()
-                                                         + " does not implement @This type " + thisType.getName() + " in fragment "
-                                                         + dependencyModel.injectedClass().getName() );
-                }
-            }
-
-            return new ThisInjectionProvider( injectionTypes );
-        }
-        else
-        {
-            throw new InvalidInjectionException( "Object " + dependencyModel.injectedClass() + " may not use @This" );
-        }
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    private static class ThisInjectionProvider
-        implements InjectionProvider
-    {
-        Constructor proxyConstructor;
-        private Class[] interfaces;
-
-        private ThisInjectionProvider( Iterable<Class<?>> types )
-        {
-            try
-            {
-                Class proxyClass;
-                if( Proxy.class.isAssignableFrom( first( types ) ) )
-                {
-                    proxyClass = first( types );
-                }
-                else
-                {
-                    Class<?> mainType = first( types );
-                    interfaces = Iterables.toArray( Class.class, Iterables.<Class>cast( types ) );
-                    proxyClass = ProxyGenerator.createProxyClass(mainType.getClassLoader(), interfaces);
-                }
-
-                proxyConstructor = proxyClass.getConstructor( InvocationHandler.class );
-            }
-            catch( Exception e )
-            {
-                // Ignore
-                e.printStackTrace();
-            }
-        }
-
-        @Override
-        public Object provideInjection( InjectionContext context )
-        {
-            try
-            {
-                InvocationHandler handler = context.compositeInstance();
-                if( handler == null )
-                {
-                    handler = context.proxyHandler();
-                }
-                return proxyConstructor.newInstance( handler );
-            }
-            catch( Exception e )
-            {
-                throw new InjectionProviderException( "Could not instantiate @This proxy", e );
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
deleted file mode 100644
index 0e5ed5a..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
+++ /dev/null
@@ -1,131 +0,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.
- */
-package org.apache.zest.runtime.injection.provider;
-
-import java.lang.reflect.Constructor;
-import org.apache.zest.api.composite.NoSuchTransientException;
-import org.apache.zest.api.object.NoSuchObjectException;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public final class UsesInjectionProviderFactory
-    implements InjectionProviderFactory
-{
-    public UsesInjectionProviderFactory()
-    {
-    }
-
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        return new UsesInjectionProvider( dependencyModel );
-    }
-
-    private static class UsesInjectionProvider
-        implements InjectionProvider
-    {
-        private final DependencyModel dependency;
-
-        public UsesInjectionProvider( DependencyModel dependency )
-        {
-            this.dependency = dependency;
-        }
-
-        @SuppressWarnings( "unchecked" )
-        @Override
-        public Object provideInjection( InjectionContext context )
-            throws InjectionProviderException
-        {
-            UsesInstance uses = context.uses();
-
-            Class injectionType = dependency.rawInjectionType();
-            Object usesObject = uses.useForType( injectionType );
-
-            if( usesObject == null && !dependency.optional() )
-            {
-                // No @Uses object provided
-                // Try instantiating a Transient or Object for the given type
-                Module moduleInstance = context.module();
-
-                try
-                {
-                    if( context.instance() != null )
-                    {
-                        uses = uses.use( context.instance() );
-                    }
-                    usesObject = moduleInstance.newTransient( injectionType, uses.toArray() );
-                }
-                catch( NoSuchTransientException e )
-                {
-                    try
-                    {
-                        usesObject = moduleInstance.newObject( injectionType, uses.toArray() );
-                    }
-                    catch( NoSuchObjectException e1 )
-                    {
-                        // Could not instantiate an instance - to try instantiate as plain class
-                        try
-                        {
-                            usesObject = injectionType.newInstance();
-                        }
-                        catch( Throwable e2 )
-                        {
-                            // Could not instantiate - try with this as first argument
-                            try
-                            {
-                                Constructor constructor = injectionType.getDeclaredConstructor( context.instance()
-                                                                                                    .getClass() );
-                                if( !constructor.isAccessible() )
-                                {
-                                    constructor.setAccessible( true );
-                                }
-                                usesObject = constructor.newInstance( context.instance() );
-                            }
-                            catch( Throwable e3 )
-                            {
-                                // Really can't instantiate it - ignore
-                            }
-                        }
-                    }
-                }
-
-                if( usesObject != null )
-                {
-                    context.setUses( context.uses().use( usesObject ) ); // Use this for other injections in same graph
-                }
-
-                return usesObject;
-            }
-            else
-            {
-                return usesObject;
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/internal/Activator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/internal/Activator.java b/core/runtime/src/main/java/org/apache/zest/runtime/internal/Activator.java
deleted file mode 100644
index d94a67a..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/internal/Activator.java
+++ /dev/null
@@ -1,57 +0,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.
- */
-package org.apache.zest.runtime.internal;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.apache.zest.bootstrap.Qi4jRuntime;
-import org.apache.zest.bootstrap.RuntimeFactory;
-import org.apache.zest.runtime.Qi4jRuntimeImpl;
-
-/**
- *
- */
-public class Activator
-    implements BundleActivator
-{
-    private ServiceRegistration registration;
-
-    @Override
-    public void start( BundleContext bundleContext )
-        throws Exception
-    {
-        RuntimeFactory factory = new RuntimeFactory()
-        {
-            @Override
-            public Qi4jRuntime createRuntime()
-            {
-                return new Qi4jRuntimeImpl();
-            }
-        };
-        registration = bundleContext.registerService( RuntimeFactory.class.getName(), factory, null );
-    }
-
-    @Override
-    public void stop( BundleContext bundleContext )
-        throws Exception
-    {
-        registration.unregister();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/model/Binder.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/model/Binder.java b/core/runtime/src/main/java/org/apache/zest/runtime/model/Binder.java
deleted file mode 100644
index fdcbd2b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/model/Binder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.model;
-
-import org.apache.zest.bootstrap.BindingException;
-
-/**
- * Interface for models that can understand binding of dependencies
- */
-public interface Binder
-{
-    void bind( Resolution resolution )
-        throws BindingException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/model/Resolution.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/model/Resolution.java b/core/runtime/src/main/java/org/apache/zest/runtime/model/Resolution.java
deleted file mode 100644
index db64211..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/model/Resolution.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.model;
-
-import java.lang.reflect.Field;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.structure.ApplicationModel;
-import org.apache.zest.runtime.structure.LayerModel;
-import org.apache.zest.runtime.structure.ModuleModel;
-
-/**
- * JAVADOC
- */
-public final class Resolution
-{
-    private final ApplicationModel application;
-    private final LayerModel layer;
-    private final ModuleModel module;
-    private final ModelDescriptor modelDescriptor;
-    private final CompositeMethodModel method;
-    private final Field field;
-
-    public Resolution( ApplicationModel application,
-                       LayerModel layer,
-                       ModuleModel module,
-                       ModelDescriptor modelDescriptor,
-                       CompositeMethodModel method,
-                       Field field
-    )
-    {
-        this.application = application;
-        this.layer = layer;
-        this.module = module;
-        this.modelDescriptor = modelDescriptor;
-        this.method = method;
-        this.field = field;
-    }
-
-    public ApplicationModel application()
-    {
-        return application;
-    }
-
-    public LayerModel layer()
-    {
-        return layer;
-    }
-
-    public ModuleModel module()
-    {
-        return module;
-    }
-
-    public ModelDescriptor model()
-    {
-        return modelDescriptor;
-    }
-
-    public CompositeMethodModel method()
-    {
-        return method;
-    }
-
-    public Field field()
-    {
-        return field;
-    }
-
-    public Resolution forField( final Field injectedField )
-    {
-        return new Resolution( application, layer, module, modelDescriptor, method, injectedField );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
deleted file mode 100644
index e4df4e5..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.object;
-
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.mixin.InitializationException;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.composite.ConstructorsModel;
-import org.apache.zest.runtime.injection.InjectedFieldsModel;
-import org.apache.zest.runtime.injection.InjectedMethodsModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- */
-public final class ObjectModel
-    implements ObjectDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final Class<?> objectType;
-    private final Visibility visibility;
-    private final MetaInfo metaInfo;
-    private final ConstructorsModel constructorsModel;
-    private final InjectedFieldsModel injectedFieldsModel;
-    private final InjectedMethodsModel injectedMethodsModel;
-
-    public ObjectModel( Class<?> objectType,
-                        Visibility visibility,
-                        MetaInfo metaInfo
-    )
-    {
-        this.objectType = objectType;
-        this.visibility = visibility;
-        this.metaInfo = metaInfo;
-
-        constructorsModel = new ConstructorsModel( objectType );
-        injectedFieldsModel = new InjectedFieldsModel( objectType );
-        injectedMethodsModel = new InjectedMethodsModel( objectType );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Iterable<Class<?>> types()
-    {
-        Iterable<? extends Class<?>> iterable = iterable( objectType );
-        return (Iterable<Class<?>>) iterable;
-    }
-
-    @Override
-    public Visibility visibility()
-    {
-        return visibility;
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public boolean isAssignableTo( Class<?> type )
-    {
-        return type.isAssignableFrom( objectType );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( constructorsModel.accept( visitor ) )
-            {
-                if( injectedFieldsModel.accept( visitor ) )
-                {
-                    injectedMethodsModel.accept( visitor );
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Object newInstance( InjectionContext injectionContext )
-    {
-        Object instance;
-        try
-        {
-            instance = constructorsModel.newInstance( injectionContext );
-            injectionContext = new InjectionContext( injectionContext.module(), injectionContext.uses(), instance );
-            injectedFieldsModel.inject( injectionContext, instance );
-            injectedMethodsModel.inject( injectionContext, instance );
-        }
-        catch( Exception e )
-        {
-            throw new ConstructionException( "Could not instantiate " + objectType.getName(), e );
-        }
-
-        if( instance instanceof Initializable )
-        {
-            try
-            {
-                ( (Initializable) instance ).initialize();
-            }
-            catch( InitializationException e )
-            {
-                throw new ConstructionException( "Unable to initialize " + objectType, e );
-            }
-        }
-
-        return instance;
-    }
-
-    public void inject( InjectionContext injectionContext, Object instance )
-    {
-        injectedFieldsModel.inject( injectionContext, instance );
-        injectedMethodsModel.inject( injectionContext, instance );
-    }
-
-    @Override
-    public String toString()
-    {
-        return objectType.getName();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
deleted file mode 100644
index 9f05074..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.object;
-
-import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public class ObjectsModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final List<ObjectModel> objectModels;
-
-    public ObjectsModel( List<ObjectModel> objectModels )
-    {
-        this.objectModels = objectModels;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ObjectModel objectModel : objectModels )
-            {
-                if( !objectModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Iterable<ObjectModel> models()
-    {
-        return objectModels;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/package.html
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/package.html b/core/runtime/src/main/java/org/apache/zest/runtime/package.html
deleted file mode 100644
index 612d1ae..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Apache Zest™ Runtime.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertiesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertiesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertiesModel.java
deleted file mode 100644
index 202fc89..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertiesModel.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. 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.zest.runtime.property;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * Base class for properties model
- */
-public class PropertiesModel
-    implements VisitableHierarchy<Object, Object>
-{
-    protected final Map<AccessibleObject, PropertyModel> mapAccessiblePropertyModel = new LinkedHashMap<>();
-
-    public PropertiesModel()
-    {
-    }
-
-    public void addProperty( PropertyModel property )
-    {
-        mapAccessiblePropertyModel.put( property.accessor(), property );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( PropertyModel propertyModel : mapAccessiblePropertyModel.values() )
-            {
-                if( !propertyModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-
-        return visitor.visitLeave( this );
-    }
-
-    public Iterable<PropertyModel> properties()
-    {
-        return mapAccessiblePropertyModel.values();
-    }
-
-    public PropertyModel getProperty( AccessibleObject accessor )
-    {
-        PropertyModel propertyModel = mapAccessiblePropertyModel.get( accessor );
-        if( propertyModel == null )
-        {
-            throw new IllegalArgumentException( "No property found with name: " + ( (Member) accessor ).getName() );
-        }
-
-        return propertyModel;
-    }
-
-    public PropertyModel getPropertyByName( String name )
-        throws IllegalArgumentException
-    {
-        for( PropertyModel propertyModel : mapAccessiblePropertyModel.values() )
-        {
-            if( propertyModel.qualifiedName().name().equals( name ) )
-            {
-                return propertyModel;
-            }
-        }
-        throw new IllegalArgumentException( "No property found with name: " + name );
-    }
-
-    public PropertyModel getPropertyByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        for( PropertyModel propertyModel : mapAccessiblePropertyModel.values() )
-        {
-            if( propertyModel.qualifiedName().equals( name ) )
-            {
-                return propertyModel;
-            }
-        }
-        throw new IllegalArgumentException( "No property found with qualified name: " + name );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInfo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInfo.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInfo.java
deleted file mode 100644
index cb185cf..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInfo.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.runtime.property;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.runtime.composite.ConstraintsCheck;
-
-/**
- * TODO
- */
-public interface PropertyInfo
-    extends ConstraintsCheck
-{
-    boolean isImmutable();
-
-    QualifiedName qualifiedName();
-
-    Type type();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInstance.java
deleted file mode 100644
index 9bd2e9d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyInstance.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Edward Yakop. 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.zest.runtime.property;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.PropertyWrapper;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.api.type.MapType;
-import org.apache.zest.api.type.ValueCompositeType;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.runtime.value.ValueInstance;
-
-/**
- * {@code PropertyInstance} represents a property.
- */
-public class PropertyInstance<T>
-    implements Property<T>
-{
-    protected volatile T value;
-    protected PropertyInfo model;
-
-    /**
-     * Construct an instance of {@code PropertyInstance} with the specified arguments.
-     *
-     * @param model  The property model. This argument must not be {@code null}.
-     * @param aValue The property value.
-     */
-    public PropertyInstance( PropertyInfo model, T aValue )
-    {
-        this.model = model;
-        value = aValue;
-    }
-
-    public PropertyInfo propertyInfo()
-    {
-        return model;
-    }
-
-    /**
-     * @param model The property model. This argument must not be {@code null}.
-     */
-    public void setPropertyInfo( PropertyInfo model )
-    {
-        this.model = model;
-    }
-
-    /**
-     * Returns this property value.
-     *
-     * @return This property value.
-     */
-    @Override
-    public T get()
-    {
-        return value;
-    }
-
-    /**
-     * Sets this property value.
-     *
-     * @param aNewValue The new value.
-     */
-    @Override
-    public void set( T aNewValue )
-    {
-        if( model.isImmutable() )
-        {
-            throw new IllegalStateException( "Property [" + model.qualifiedName() + "] is immutable." );
-        }
-
-        model.checkConstraints( aNewValue );
-
-        value = aNewValue;
-    }
-
-    /**
-     * Perform equals with {@code o} argument.
-     * <p>
-     *     The definition of equals() for the Property is that if both the state and descriptor are equal,
-     *     then the properties are equal.
-     * </p>
-     *
-     * @param o The other object to compare.
-     * @return Returns a {@code boolean} indicator whether this object is equals the other.
-     */
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        Property<?> that = (Property<?>) o;
-        // Unwrap if needed
-        while( that instanceof PropertyWrapper )
-        {
-            that = ( (PropertyWrapper) that ).next();
-        }
-        // Descriptor equality
-        PropertyDescriptor thatDescriptor = (PropertyDescriptor) ( (PropertyInstance) that ).propertyInfo();
-        if( !model.equals( thatDescriptor ) )
-        {
-            return false;
-        }
-        // State equality
-        T value = get();
-        if( value == null )
-        {
-            return that.get() == null;
-        }
-        return value.equals( that.get() );
-    }
-
-    /**
-     * Calculate hash code.
-     *
-     * @return the hashcode of this instance.
-     */
-    @Override
-    public int hashCode()
-    {
-        int hash = model.hashCode() * 19; // Descriptor
-        T value = get();
-        if( value != null )
-        {
-            hash += value.hashCode() * 13; // State
-        }
-        return hash;
-    }
-
-    /**
-     * Returns the value as string.
-     *
-     * @return The value as string.
-     */
-    @Override
-    public String toString()
-    {
-        Object value = get();
-        return value == null ? "" : value.toString();
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public void prepareToBuild( PropertyModel propertyDescriptor )
-    {
-        // Check if state has to be modified
-        model = propertyDescriptor.getBuilderInfo();
-        if( propertyDescriptor.valueType() instanceof ValueCompositeType )
-        {
-            Object value = get();
-            if( value != null )
-            {
-                ValueInstance.valueInstanceOf( (ValueComposite) value ).prepareToBuild();
-            }
-        }
-        else if( propertyDescriptor.valueType() instanceof CollectionType )
-        {
-            Object value = get();
-
-            if( value != null )
-            {
-                if( value instanceof List )
-                {
-                    value = new ArrayList( (Collection) value );
-                }
-                else if( value instanceof Set )
-                {
-                    value = new LinkedHashSet( (Collection) value );
-                }
-
-                // Check if items are Values
-                CollectionType collection = (CollectionType) propertyDescriptor.valueType();
-                if( collection.collectedType() instanceof ValueCompositeType )
-                {
-                    Collection coll = (Collection) value;
-                    for( Object instance : coll )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareToBuild();
-                    }
-                }
-
-                set( (T) value );
-            }
-        }
-        else if( propertyDescriptor.valueType() instanceof MapType )
-        {
-            Object value = get();
-
-            if( value != null )
-            {
-                Map map = new LinkedHashMap( (Map) value );
-
-                // Check if keys/values are Values
-                MapType mapType = (MapType) propertyDescriptor.valueType();
-                if( mapType.keyType() instanceof ValueCompositeType )
-                {
-                    for( Object instance : map.keySet() )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareToBuild();
-                    }
-                }
-                if( mapType.valueType() instanceof ValueCompositeType )
-                {
-                    for( Object instance : map.values() )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareToBuild();
-                    }
-                }
-
-                set( (T) value );
-            }
-        }
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public void prepareBuilderState( PropertyModel propertyDescriptor )
-    {
-        // Check if state has to be modified
-        if( propertyDescriptor.valueType() instanceof ValueCompositeType )
-        {
-            Object value = get();
-            if( value != null )
-            {
-                ValueInstance.valueInstanceOf( (ValueComposite) value ).prepareBuilderState();
-            }
-        }
-        else if( propertyDescriptor.valueType() instanceof CollectionType )
-        {
-            T value = get();
-            if( value != null )
-            {
-                if( propertyDescriptor.isImmutable() )
-                {
-                    if( value instanceof List )
-                    {
-                        value = (T) Collections.unmodifiableList( (List<? extends Object>) value );
-                    }
-                    else if( value instanceof Set )
-                    {
-                        value = (T) Collections.unmodifiableSet( (Set<? extends Object>) value );
-                    }
-                    else
-                    {
-                        value = (T) Collections.unmodifiableCollection( (Collection<? extends Object>) value );
-                    }
-
-                    this.value = value;
-                }
-
-                CollectionType collection = (CollectionType) propertyDescriptor.valueType();
-                if( collection.collectedType() instanceof ValueCompositeType )
-                {
-                    Collection coll = (Collection) value;
-                    for( Object instance : coll )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareBuilderState();
-                    }
-                }
-            }
-        }
-        else if( propertyDescriptor.valueType() instanceof MapType )
-        {
-            T value = get();
-
-            if( value != null )
-            {
-                MapType mapType = (MapType) propertyDescriptor.valueType();
-                if( mapType.keyType() instanceof ValueCompositeType )
-                {
-                    Map map = (Map) value;
-                    for( Object instance : map.keySet() )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareBuilderState();
-                    }
-                }
-                if( mapType.valueType() instanceof ValueCompositeType )
-                {
-                    Map map = (Map) value;
-                    for( Object instance : map.values() )
-                    {
-                        ValueInstance.valueInstanceOf( (ValueComposite) instance ).prepareBuilderState();
-                    }
-                }
-                if( propertyDescriptor.isImmutable() )
-                {
-                    value = (T) Collections.unmodifiableMap( (Map<?, ?>) value );
-                }
-
-                this.value = value;
-            }
-        }
-
-        model = propertyDescriptor;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
deleted file mode 100644
index 9f37373..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.property;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.List;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.constraint.ConstraintViolation;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.DefaultValues;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.InvalidPropertyTypeException;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.Serialization;
-import org.apache.zest.api.type.ValueCompositeType;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.types.ValueTypeFactory;
-
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Model for a Property.
- *
- * <p>Equality is based on the Property accessor object (property type and name), not on the QualifiedName.</p>
- */
-public class PropertyModel
-    implements PropertyDescriptor, PropertyInfo, Binder, Visitable<PropertyModel>
-{
-    private Type type;
-
-    private transient AccessibleObject accessor; // Interface accessor
-
-    private final QualifiedName qualifiedName;
-
-    private final ValueConstraintsInstance constraints; // May be null
-
-    protected final MetaInfo metaInfo;
-
-    private final Object initialValue;
-
-    private final boolean useDefaults;
-
-    private final boolean immutable;
-
-    private ValueType valueType;
-
-    protected PropertyInfo builderInfo;
-
-    private final boolean queryable;
-
-    public PropertyModel( AccessibleObject accessor,
-                          boolean immutable,
-                          boolean useDefaults,
-                          ValueConstraintsInstance constraints,
-                          MetaInfo metaInfo,
-                          Object initialValue
-    )
-    {
-        if( accessor instanceof Method )
-        {
-            Method m = (Method) accessor;
-            if( !m.getReturnType().equals( Property.class ) )
-            {
-                throw new InvalidPropertyTypeException( accessor );
-            }
-        }
-        this.immutable = immutable;
-        this.metaInfo = metaInfo;
-        type = GenericPropertyInfo.propertyTypeOf( accessor );
-        this.accessor = accessor;
-        qualifiedName = QualifiedName.fromAccessor( accessor );
-
-        this.useDefaults = useDefaults;
-
-        this.initialValue = initialValue;
-
-        this.constraints = constraints;
-
-        final Queryable queryable = accessor.getAnnotation( Queryable.class );
-        this.queryable = queryable == null || queryable.value();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    public String name()
-    {
-        return qualifiedName.name();
-    }
-
-    @Override
-    public QualifiedName qualifiedName()
-    {
-        return qualifiedName;
-    }
-
-    @Override
-    public Type type()
-    {
-        return type;
-    }
-
-    @Override
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public ValueType valueType()
-    {
-        return valueType;
-    }
-
-    @Override
-    public boolean isImmutable()
-    {
-        return immutable;
-    }
-
-    public PropertyInfo getBuilderInfo()
-    {
-        return builderInfo;
-    }
-
-    @Override
-    public boolean queryable()
-    {
-        return queryable;
-    }
-
-    @Override
-    public Object initialValue( Module module )
-    {
-        // Use supplied value from assembly
-        Object value = initialValue;
-
-        // Check for @UseDefaults annotation
-        if( value == null && useDefaults )
-        {
-            if( valueType instanceof ValueCompositeType )
-            {
-                return module.newValue( (Class<?>) first( valueType().types() ) );
-            }
-            else
-            {
-                value = DefaultValues.getDefaultValueOf( type );
-            }
-        }
-
-        return value;
-    }
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        ValueTypeFactory factory = ValueTypeFactory.instance();
-        Class<?> declaringClass = ( (Member) accessor() ).getDeclaringClass();
-        Class<?> mainType = first( resolution.model().types() );
-        Serialization.Variant variant = findVariant();
-        valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module(), variant );
-        builderInfo = new BuilderPropertyInfo();
-        if( type instanceof TypeVariable )
-        {
-            type = Classes.resolveTypeVariable( (TypeVariable) type, declaringClass, mainType );
-        }
-    }
-
-    private Serialization.Variant findVariant()
-    {
-        Serialization serialization = metaInfo.get( Serialization.class );
-        Serialization.Variant variant = null;
-        if( serialization != null )
-        {
-            variant = serialization.value();
-        }
-        if( variant == null )
-        {
-            variant = Serialization.Variant.entry;
-        }
-        return variant;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super PropertyModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        return visitor.visit( this );
-    }
-
-    @Override
-    public void checkConstraints( Object value )
-        throws ConstraintViolationException
-    {
-        if( constraints != null )
-        {
-            List<ConstraintViolation> violations = constraints.checkConstraints( value );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "<new instance>", empty, ( (Member) accessor ), violations );
-            }
-        }
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        PropertyModel that = (PropertyModel) o;
-        return accessor.equals( that.accessor );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return accessor.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        if( accessor instanceof Field )
-        {
-            return ( (Field) accessor ).toGenericString();
-        }
-        else
-        {
-            return ( (Method) accessor ).toGenericString();
-        }
-    }
-
-    private class BuilderPropertyInfo implements PropertyInfo
-    {
-        @Override
-        public boolean isImmutable()
-        {
-            return false;
-        }
-
-        @Override
-        public QualifiedName qualifiedName()
-        {
-            return qualifiedName;
-        }
-
-        @Override
-        public Type type()
-        {
-            return type;
-        }
-
-        @Override
-        public void checkConstraints( Object value )
-            throws ConstraintViolationException
-        {
-            if( constraints != null )
-            {
-                List<ConstraintViolation> violations = constraints.checkConstraints( value );
-                if( !violations.isEmpty() )
-                {
-                    Iterable<Class<?>> empty = empty();
-                    throw new ConstraintViolationException( "<new instance>", empty, ( (Member) accessor ), violations );
-                }
-            }
-        }
-    }
-}
\ No newline at end of file


[04/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AssemblyHelper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AssemblyHelper.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AssemblyHelper.java
new file mode 100644
index 0000000..f67025a
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AssemblyHelper.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.runtime.composite.ConcernModel;
+import org.qi4j.runtime.composite.ConstraintDeclaration;
+import org.qi4j.runtime.composite.FragmentClassLoader;
+import org.qi4j.runtime.composite.MixinModel;
+import org.qi4j.runtime.composite.SideEffectModel;
+
+/**
+ * This helper is used when building the application model. It keeps track
+ * of already created classloaders and various models
+ */
+public class AssemblyHelper
+{
+    Map<Class, Class> instantiationClasses = new HashMap<>();
+    Map<Class, ConstraintDeclaration> constraintDeclarations = new HashMap<>();
+    Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>();
+    Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>();
+
+    public MixinModel getMixinModel( Class mixinClass )
+    {
+        return new MixinModel( mixinClass, instantiationClass( mixinClass ) );
+    }
+
+    public ConcernModel getConcernModel( Class concernClass )
+    {
+        return new ConcernModel( concernClass, instantiationClass( concernClass ) );
+    }
+
+    public SideEffectModel getSideEffectModel( Class sideEffectClass )
+    {
+        return new SideEffectModel( sideEffectClass, instantiationClass( sideEffectClass ) );
+    }
+
+    private Class instantiationClass( Class fragmentClass )
+    {
+        Class instantiationClass = fragmentClass;
+        if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
+        {
+            instantiationClass = instantiationClasses.get( fragmentClass );
+
+            if( instantiationClass == null )
+            {
+                try
+                {
+                    FragmentClassLoader fragmentLoader = getModifierClassLoader( fragmentClass.getClassLoader() );
+                    instantiationClass = fragmentLoader.loadFragmentClass( fragmentClass );
+                    instantiationClasses.put( fragmentClass, instantiationClass );
+                }
+                catch( ClassNotFoundException | VerifyError e )
+                {
+                    throw new ConstructionException( "Could not generate mixin subclass " + fragmentClass.getName(), e );
+                }
+            }
+        }
+        return instantiationClass;
+    }
+
+    private FragmentClassLoader getModifierClassLoader( ClassLoader classLoader )
+    {
+        FragmentClassLoader cl = modifierClassLoaders.get( classLoader );
+        if( cl == null )
+        {
+            cl = new FragmentClassLoader( classLoader );
+            modifierClassLoaders.put( classLoader, cl );
+        }
+        return cl;
+    }
+
+    public boolean appliesTo( Class<?> fragmentClass, Method method, Iterable<Class<?>> types, Class<?> mixinClass )
+    {
+        AppliesToFilter appliesToFilter = appliesToInstances.get( fragmentClass );
+        if( appliesToFilter == null )
+        {
+            appliesToFilter = createAppliesToFilter( fragmentClass );
+            appliesToInstances.put( fragmentClass, appliesToFilter );
+        }
+        for( Class<?> compositeType : types )
+        {
+            if( appliesToFilter.appliesTo( method, mixinClass, compositeType, fragmentClass ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public AppliesToFilter createAppliesToFilter( Class<?> fragmentClass )
+    {
+        AppliesToFilter result = null;
+        if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
+        {
+            result = new TypedFragmentAppliesToFilter();
+            if( Modifier.isAbstract( fragmentClass.getModifiers() ) )
+            {
+                result = new AndAppliesToFilter( result, new ImplementsMethodAppliesToFilter() );
+            }
+        }
+        result = applyAppliesTo( result, fragmentClass );
+        if( result == null )
+        {
+            return AppliesToFilter.ALWAYS;
+        }
+        return result;
+    }
+
+    private AppliesToFilter applyAppliesTo( AppliesToFilter existing, Class<?> modifierClass )
+    {
+        AppliesTo appliesTo = modifierClass.getAnnotation( AppliesTo.class );
+        if( appliesTo != null )
+        {
+            // Use "or" for all filters specified in the annotation
+            AppliesToFilter appliesToAnnotation = null;
+            for( Class<?> appliesToClass : appliesTo.value() )
+            {
+                AppliesToFilter filter;
+                if( AppliesToFilter.class.isAssignableFrom( appliesToClass ) )
+                {
+                    try
+                    {
+                        filter = (AppliesToFilter) appliesToClass.newInstance();
+                    }
+                    catch( Exception e )
+                    {
+                        throw new ConstructionException( e );
+                    }
+                }
+                else if( Annotation.class.isAssignableFrom( appliesToClass ) )
+                {
+                    filter = new AnnotationAppliesToFilter( appliesToClass );
+                }
+                else // Type check
+                {
+                    filter = new TypeCheckAppliesToFilter( appliesToClass );
+                }
+
+                if( appliesToAnnotation == null )
+                {
+                    appliesToAnnotation = filter;
+                }
+                else
+                {
+                    appliesToAnnotation = new OrAppliesToFilter( appliesToAnnotation, filter );
+                }
+            }
+            // Add to the rest of the rules using "and"
+            if( existing == null )
+            {
+                return appliesToAnnotation;
+            }
+            else
+            {
+                return new AndAppliesToFilter( existing, appliesToAnnotation );
+            }
+        }
+        return existing;
+    }
+
+    public boolean appliesTo( Class<? extends Constraint<?, ?>> constraint,
+                              Class<? extends Annotation> annotationType,
+                              Type valueType
+    )
+    {
+        ConstraintDeclaration constraintDeclaration = constraintDeclarations.get( constraint );
+        if( constraintDeclaration == null )
+        {
+            constraintDeclaration = new ConstraintDeclaration( constraint );
+            constraintDeclarations.put( constraint, constraintDeclaration );
+        }
+
+        return constraintDeclaration.appliesTo( annotationType, valueType );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/CompositeAssemblyImpl.java
new file mode 100644
index 0000000..7441390
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/CompositeAssemblyImpl.java
@@ -0,0 +1,837 @@
+/*
+ * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2008-2013, Niclas Hedhman. 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.qi4j.runtime.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.composite.InvalidCompositeException;
+import org.qi4j.api.concern.Concerns;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.api.constraint.ConstraintDeclaration;
+import org.qi4j.api.constraint.Constraints;
+import org.qi4j.api.constraint.Name;
+import org.qi4j.api.entity.Lifecycle;
+import org.qi4j.api.injection.scope.State;
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Initializable;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.sideeffect.SideEffects;
+import org.qi4j.api.type.HasTypes;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.util.Fields;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.functional.ForEach;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.HierarchicalVisitorAdapter;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Visitor;
+import org.qi4j.runtime.composite.AbstractConstraintModel;
+import org.qi4j.runtime.composite.CompositeConstraintModel;
+import org.qi4j.runtime.composite.CompositeMethodModel;
+import org.qi4j.runtime.composite.CompositeMethodsModel;
+import org.qi4j.runtime.composite.ConcernModel;
+import org.qi4j.runtime.composite.ConcernsModel;
+import org.qi4j.runtime.composite.ConstraintModel;
+import org.qi4j.runtime.composite.ConstraintsModel;
+import org.qi4j.runtime.composite.GenericSpecification;
+import org.qi4j.runtime.composite.MixinModel;
+import org.qi4j.runtime.composite.MixinsModel;
+import org.qi4j.runtime.composite.SideEffectModel;
+import org.qi4j.runtime.composite.SideEffectsModel;
+import org.qi4j.runtime.composite.StateModel;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.composite.ValueConstraintsModel;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.runtime.property.PropertiesModel;
+import org.qi4j.runtime.property.PropertyModel;
+
+import static java.util.Arrays.asList;
+import static org.qi4j.api.util.Annotations.hasAnnotation;
+import static org.qi4j.api.util.Annotations.isType;
+import static org.qi4j.api.util.Annotations.type;
+import static org.qi4j.api.util.Classes.classHierarchy;
+import static org.qi4j.api.util.Classes.interfacesOf;
+import static org.qi4j.api.util.Classes.isAssignableFrom;
+import static org.qi4j.api.util.Classes.typeOf;
+import static org.qi4j.api.util.Classes.typesOf;
+import static org.qi4j.api.util.Classes.wrapperClass;
+import static org.qi4j.functional.Iterables.addAll;
+import static org.qi4j.functional.Iterables.cast;
+import static org.qi4j.functional.Iterables.empty;
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.flatten;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.map;
+import static org.qi4j.functional.Iterables.matchesAny;
+import static org.qi4j.functional.Iterables.toList;
+import static org.qi4j.functional.Specifications.and;
+import static org.qi4j.functional.Specifications.in;
+import static org.qi4j.functional.Specifications.not;
+import static org.qi4j.functional.Specifications.or;
+import static org.qi4j.functional.Specifications.translate;
+
+/**
+ * Declaration of a Composite.
+ */
+public abstract class CompositeAssemblyImpl
+    implements HasTypes
+{
+    protected List<Class<?>> concerns = new ArrayList<>();
+    protected List<Class<?>> sideEffects = new ArrayList<>();
+    protected List<Class<?>> mixins = new ArrayList<>();
+    protected List<Class<?>> types = new ArrayList<>();
+    protected MetaInfo metaInfo = new MetaInfo();
+    protected Visibility visibility = Visibility.module;
+
+    protected boolean immutable;
+    protected PropertiesModel propertiesModel;
+    protected StateModel stateModel;
+    protected MixinsModel mixinsModel;
+    protected CompositeMethodsModel compositeMethodsModel;
+    private AssemblyHelper helper;
+    protected StateDeclarations stateDeclarations;
+
+    protected Set<String> registeredStateNames = new HashSet<>();
+
+    public CompositeAssemblyImpl( Class<?> mainType )
+    {
+        types.add( mainType );
+    }
+
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return types;
+    }
+
+    protected StateModel createStateModel()
+    {
+        return new StateModel( propertiesModel );
+    }
+
+    protected MixinsModel createMixinsModel()
+    {
+        return new MixinsModel();
+    }
+
+    protected void buildComposite( AssemblyHelper helper,
+                                   StateDeclarations stateDeclarations
+    )
+    {
+        this.stateDeclarations = stateDeclarations;
+        this.helper = helper;
+        for( Class<?> compositeType : types )
+        {
+            metaInfo = new MetaInfo( metaInfo ).withAnnotations( compositeType );
+            addAnnotationsMetaInfo( compositeType, metaInfo );
+        }
+
+        immutable = metaInfo.get( Immutable.class ) != null;
+        propertiesModel = new PropertiesModel();
+        stateModel = createStateModel();
+        mixinsModel = createMixinsModel();
+        compositeMethodsModel = new CompositeMethodsModel( mixinsModel );
+
+        // Implement composite methods
+        ArrayList<Type> allTypes = getTypes( this.types );
+        Iterable<Class<? extends Constraint<?, ?>>> constraintClasses = constraintDeclarations( getTypes( this.types ) );
+        Iterable<Class<?>> concernClasses = flatten( concerns, concernDeclarations( allTypes ) );
+        Iterable<Class<?>> sideEffectClasses = flatten( sideEffects, sideEffectDeclarations( allTypes ) );
+        Iterable<Class<?>> mixinClasses = flatten( mixins, mixinDeclarations( this.types ) );
+        implementMixinType( types, constraintClasses, concernClasses, sideEffectClasses, mixinClasses );
+
+        // Add state from methods and fields
+        addState( constraintClasses );
+    }
+
+    protected void addAnnotationsMetaInfo( Class<?> type, MetaInfo compositeMetaInfo )
+    {
+        Class[] declaredInterfaces = type.getInterfaces();
+        for( int i = declaredInterfaces.length - 1; i >= 0; i-- )
+        {
+            addAnnotationsMetaInfo( declaredInterfaces[ i], compositeMetaInfo );
+        }
+        compositeMetaInfo.withAnnotations( type );
+    }
+
+    protected void implementMixinType( Iterable<? extends Class<?>> types,
+                                       Iterable<Class<? extends Constraint<?, ?>>> constraintClasses,
+                                       Iterable<Class<?>> concernClasses,
+                                       Iterable<Class<?>> sideEffectClasses,
+                                       Iterable<Class<?>> mixinClasses
+    )
+    {
+        Set<Class<?>> thisDependencies = new HashSet<>();
+        for( Class<?> mixinType : types )
+        {
+            for( Method method : mixinType.getMethods() )
+            {
+                if( !compositeMethodsModel.isImplemented( method )
+                    && !Proxy.class.equals( method.getDeclaringClass().getSuperclass() )
+                    && !Proxy.class.equals( method.getDeclaringClass() )
+                    && !Modifier.isStatic( method.getModifiers() ) )
+                {
+                    MixinModel mixinModel = implementMethod( method, mixinClasses );
+                    ConcernsModel concernsModel = concernsFor(
+                        method,
+                        mixinModel.mixinClass(),
+                        Iterables.<Class<?>>flatten( concernDeclarations( mixinModel.mixinClass() ),
+                                                     concernClasses )
+                    );
+                    SideEffectsModel sideEffectsModel = sideEffectsFor(
+                        method,
+                        mixinModel.mixinClass(),
+                        Iterables.<Class<?>>flatten( sideEffectDeclarations( mixinModel.mixinClass() ),
+                                                     sideEffectClasses )
+                    );
+                    method.setAccessible( true );
+                    ConstraintsModel constraints = constraintsFor(
+                        method,
+                        Iterables.<Class<? extends Constraint<?, ?>>>flatten( constraintDeclarations( mixinModel.mixinClass() ),
+                                                                              constraintClasses )
+                    );
+                    CompositeMethodModel methodComposite = new CompositeMethodModel(
+                        method,
+                        constraints,
+                        concernsModel,
+                        sideEffectsModel,
+                        mixinsModel
+                    );
+
+                    // Implement @This references
+                    Iterable<Class<?>> map = map( new DependencyModel.InjectionTypeFunction(),
+                                                  filter( new DependencyModel.ScopeSpecification( This.class ),
+                                                          methodComposite.dependencies() ) );
+                    Iterable<Class<?>> map1 = map( new DependencyModel.InjectionTypeFunction(),
+                                                   filter( new DependencyModel.ScopeSpecification( This.class ),
+                                                           mixinModel.dependencies() ) );
+                    @SuppressWarnings( "unchecked" )
+                    Iterable<Class<?>> filter = filter(
+                        not( in( Initializable.class, Lifecycle.class, InvocationHandler.class ) ),
+                        map( Classes.RAW_CLASS, interfacesOf( mixinModel.mixinClass() ) )
+                    );
+                    Iterable<? extends Class<?>> flatten = flatten( map, map1, filter );
+                    addAll( thisDependencies, flatten );
+
+                    compositeMethodsModel.addMethod( methodComposite );
+                }
+            }
+            // Add type to set of mixin types
+            mixinsModel.addMixinType( mixinType );
+        }
+
+        // Implement all @This dependencies that were found
+        for( Class<?> thisDependency : thisDependencies )
+        {
+            // Add additional declarations from the @This type
+            Iterable<Class<? extends Constraint<?, ?>>> typeConstraintClasses = flatten(
+                constraintClasses,
+                constraintDeclarations( thisDependency ) );
+            Iterable<Class<?>> typeConcernClasses = flatten(
+                concernClasses,
+                concernDeclarations( thisDependency ) );
+            Iterable<Class<?>> typeSideEffectClasses = flatten(
+                sideEffectClasses,
+                sideEffectDeclarations( thisDependency ) );
+            Iterable<Class<?>> typeMixinClasses = flatten(
+                mixinClasses,
+                mixinDeclarations( thisDependency ) );
+
+            @SuppressWarnings( "unchecked" )
+            Iterable<? extends Class<?>> singleton = iterable( thisDependency );
+            implementMixinType( singleton, typeConstraintClasses, typeConcernClasses, typeSideEffectClasses, typeMixinClasses );
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    protected MixinModel implementMethod( Method method, Iterable<Class<?>> mixinDeclarations )
+    {
+        MixinModel implementationModel = mixinsModel.mixinFor( method );
+        if( implementationModel != null )
+        {
+            return implementationModel;
+        }
+        Class mixinClass = findTypedImplementation( method, mixinDeclarations );
+        if( mixinClass != null )
+        {
+            return implementMethodWithClass( method, mixinClass );
+        }
+
+        // Check generic implementations
+        mixinClass = findGenericImplementation( method, mixinDeclarations );
+        if( mixinClass != null )
+        {
+            return implementMethodWithClass( method, mixinClass );
+        }
+
+        throw new InvalidCompositeException( "No implementation found for method \n    " + method.toGenericString()
+                                             + "\nin\n    " + types );
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    private Class findTypedImplementation( final Method method, Iterable<Class<?>> mixins )
+    {
+        // Check if mixinClass implements the method. If so, check if the mixinClass is generic or if the filter passes.
+        // If a mixinClass is both generic AND non-generic at the same time, then the filter applies to the non-generic
+        // side only.
+        Specification<Class<?>> appliesToSpec = new Specification<Class<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( Class<?> item )
+            {
+                return helper.appliesTo( item, method, types, item );
+            }
+        };
+        return first( filter( and( isAssignableFrom( method.getDeclaringClass() ),
+                                   or( GenericSpecification.INSTANCE, appliesToSpec ) ),
+                              mixins ) );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Class<?> findGenericImplementation( final Method method, Iterable<Class<?>> mixins )
+    {
+        // Check if mixinClass is generic and the applies-to filter passes
+        return first( filter( and( GenericSpecification.INSTANCE, new Specification<Class<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( Class<?> item )
+            {
+                return helper.appliesTo( item, method, types, item );
+            }
+        } ), mixins ) );
+    }
+
+    private MixinModel implementMethodWithClass( Method method, Class mixinClass )
+    {
+        MixinModel mixinModel = mixinsModel.getMixinModel( mixinClass );
+        if( mixinModel == null )
+        {
+            mixinModel = helper.getMixinModel( mixinClass );
+            mixinsModel.addMixinModel( mixinModel );
+        }
+
+        mixinsModel.addMethodMixin( method, mixinModel );
+
+        return mixinModel;
+    }
+
+    protected void addState( final Iterable<Class<? extends Constraint<?, ?>>> constraintClasses )
+    {
+        // Add method state
+        compositeMethodsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
+        {
+            @Override
+            public boolean visitEnter( Object visited )
+                throws RuntimeException
+            {
+                if( visited instanceof CompositeMethodModel )
+                {
+                    CompositeMethodModel methodModel = (CompositeMethodModel) visited;
+                    if( methodModel.method().getParameterTypes().length == 0 )
+                    {
+                        addStateFor( methodModel.method(), constraintClasses );
+                    }
+
+                    return false;
+                }
+
+                return super.visitEnter( visited );
+            }
+        } );
+
+        // Add field state
+        mixinsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
+        {
+            @Override
+            public boolean visitEnter( Object visited )
+                throws RuntimeException
+            {
+                if( visited instanceof MixinModel )
+                {
+                    MixinModel model = (MixinModel) visited;
+                    Visitor<Field, RuntimeException> addState = new Visitor<Field, RuntimeException>()
+                    {
+                        @Override
+                        public boolean visit( Field visited )
+                            throws RuntimeException
+                        {
+                            addStateFor( visited, constraintClasses );
+                            return true;
+                        }
+                    };
+                    ForEach.forEach( Fields.FIELDS_OF.map( model.mixinClass() ) ).
+                        filter( Annotations.hasAnnotation( State.class ) ).
+                        visit( addState );
+                    return false;
+                }
+                return super.visitEnter( visited );
+            }
+        } );
+    }
+
+    protected void addStateFor( AccessibleObject accessor,
+                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        String stateName = QualifiedName.fromAccessor( accessor ).name();
+
+        if( registeredStateNames.contains( stateName ) )
+        {
+            return; // Skip already registered names
+        }
+
+        if( Property.class.isAssignableFrom( Classes.RAW_CLASS.map( typeOf( accessor ) ) ) )
+        {
+            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+    }
+
+    protected PropertyModel newPropertyModel( AccessibleObject accessor,
+                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+        ValueConstraintsModel valueConstraintsModel = constraintsFor(
+            annotations,
+            GenericPropertyInfo.propertyTypeOf( accessor ),
+            ( (Member) accessor ).getName(),
+            optional,
+            constraintClasses,
+            accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        Object initialValue = stateDeclarations.initialValueOf( accessor );
+        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
+        boolean immutable = this.immutable || metaInfo.get( Immutable.class ) != null;
+        PropertyModel propertyModel = new PropertyModel(
+            accessor,
+            immutable,
+            useDefaults,
+            valueConstraintsInstance,
+            metaInfo,
+            initialValue );
+        return propertyModel;
+    }
+
+    // Model
+    private ConstraintsModel constraintsFor( Method method,
+                                             Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        List<ValueConstraintsModel> parameterConstraintModels = Collections.emptyList();
+        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+        Type[] parameterTypes = method.getGenericParameterTypes();
+        boolean constrained = false;
+        for( int i = 0; i < parameterAnnotations.length; i++ )
+        {
+            Annotation[] parameterAnnotation = parameterAnnotations[i];
+
+            Name nameAnnotation = (Name) first( filter( isType( Name.class ), iterable( parameterAnnotation ) ) );
+            String name = nameAnnotation == null ? "param" + ( i + 1 ) : nameAnnotation.value();
+
+            boolean optional = first( filter( isType( Optional.class ), iterable( parameterAnnotation ) ) ) != null;
+            ValueConstraintsModel parameterConstraintsModel = constraintsFor(
+                asList( parameterAnnotation ),
+                parameterTypes[i],
+                name,
+                optional,
+                constraintClasses,
+                method );
+            if( parameterConstraintsModel.isConstrained() )
+            {
+                constrained = true;
+            }
+
+            if( parameterConstraintModels.isEmpty() )
+            {
+                parameterConstraintModels = new ArrayList<>();
+            }
+            parameterConstraintModels.add( parameterConstraintsModel );
+        }
+
+        if( !constrained )
+        {
+            return new ConstraintsModel( Collections.<ValueConstraintsModel>emptyList() );
+        }
+        else
+        {
+            return new ConstraintsModel( parameterConstraintModels );
+        }
+    }
+
+    protected ValueConstraintsModel constraintsFor(
+        Iterable<Annotation> constraintAnnotations,
+        Type valueType,
+        String name,
+        boolean optional,
+        Iterable<Class<? extends Constraint<?, ?>>> constraintClasses,
+        AccessibleObject accessor
+    )
+    {
+        valueType = wrapperClass( valueType );
+
+        List<AbstractConstraintModel> constraintModels = new ArrayList<>();
+        nextConstraint:
+        for( Annotation constraintAnnotation : filter( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ),
+                                                       constraintAnnotations ) )
+        {
+            // Check composite declarations first
+            Class<? extends Annotation> annotationType = constraintAnnotation.annotationType();
+            for( Class<? extends Constraint<?, ?>> constraint : constraintClasses )
+            {
+                if( helper.appliesTo( constraint, annotationType, valueType ) )
+                {
+                    constraintModels.add( new ConstraintModel( constraintAnnotation, constraint ) );
+                    continue nextConstraint;
+                }
+            }
+
+            // Check the annotation itself
+            Constraints constraints = annotationType.getAnnotation( Constraints.class );
+            if( constraints != null )
+            {
+                for( Class<? extends Constraint<?, ?>> constraintClass : constraints.value() )
+                {
+                    if( helper.appliesTo( constraintClass, annotationType, valueType ) )
+                    {
+                        constraintModels.add( new ConstraintModel( constraintAnnotation, constraintClass ) );
+                        continue nextConstraint;
+                    }
+                }
+            }
+
+            // No implementation found!
+            // Check if if it's a composite constraints
+            Iterable<Annotation> annotations = iterable( annotationType.getAnnotations() );
+            if( matchesAny( translate( type(), hasAnnotation( ConstraintDeclaration.class ) ), annotations ) )
+            {
+                ValueConstraintsModel valueConstraintsModel = constraintsFor(
+                    annotations,
+                    valueType,
+                    name,
+                    optional,
+                    constraintClasses,
+                    accessor );
+                CompositeConstraintModel compositeConstraintModel = new CompositeConstraintModel(
+                    constraintAnnotation,
+                    valueConstraintsModel );
+                constraintModels.add( compositeConstraintModel );
+                continue nextConstraint;
+            }
+
+            throw new InvalidCompositeException(
+                "Cannot find implementation of constraint @"
+                + annotationType.getSimpleName()
+                + " for "
+                + valueType
+                + " in method "
+                + ( (Member) accessor ).getName()
+                + " of composite " + types );
+        }
+
+        return new ValueConstraintsModel( constraintModels, name, optional );
+    }
+
+    private ConcernsModel concernsFor( Method method,
+                                       Class<?> mixinClass,
+                                       Iterable<Class<?>> concernClasses
+    )
+    {
+        List<ConcernModel> concernsFor = new ArrayList<>();
+        for( Class<?> concern : concernClasses )
+        {
+            if( helper.appliesTo( concern, method, types, mixinClass ) )
+            {
+                concernsFor.add( helper.getConcernModel( concern ) );
+            }
+            else
+            {
+                // Lookup method in mixin
+                if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
+                {
+                    try
+                    {
+                        Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
+                        if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
+                        {
+                            concernsFor.add( helper.getConcernModel( concern ) );
+                        }
+                    }
+                    catch( NoSuchMethodException e )
+                    {
+                        // Ignore
+                    }
+                }
+            }
+        }
+
+        // Check annotations on method that have @Concerns annotations themselves
+        for( Annotation annotation : method.getAnnotations() )
+        {
+            @SuppressWarnings( "raw" )
+            Concerns concerns = annotation.annotationType().getAnnotation( Concerns.class );
+            if( concerns != null )
+            {
+                for( Class<?> concern : concerns.value() )
+                {
+                    if( helper.appliesTo( concern, method, types, mixinClass ) )
+                    {
+                        concernsFor.add( helper.getConcernModel( concern ) );
+                    }
+                }
+            }
+        }
+
+        if( concernsFor.isEmpty() )
+        {
+            return ConcernsModel.EMPTY_CONCERNS;
+        }
+        else
+        {
+            return new ConcernsModel( concernsFor );
+        }
+    }
+
+    private SideEffectsModel sideEffectsFor( Method method,
+                                             Class<?> mixinClass,
+                                             Iterable<Class<?>> sideEffectClasses
+    )
+    {
+        List<SideEffectModel> sideEffectsFor = new ArrayList<>();
+        for( Class<?> sideEffect : sideEffectClasses )
+        {
+            if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
+            {
+                sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
+            }
+            else
+            {
+                // Lookup method in mixin
+                if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
+                {
+                    try
+                    {
+                        Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
+                        if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass ) )
+                        {
+                            sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
+                        }
+                    }
+                    catch( NoSuchMethodException e )
+                    {
+                        // Ignore
+                    }
+                }
+            }
+        }
+
+        if( sideEffectsFor.isEmpty() )
+        {
+            return SideEffectsModel.EMPTY_SIDEEFFECTS;
+        }
+        else
+        {
+            return new SideEffectsModel( sideEffectsFor );
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Iterable<Class<? extends Constraint<?, ?>>> constraintDeclarations( Class<?> type )
+    {
+        ArrayList<Type> allTypes = getTypes( type );
+        return constraintDeclarations( allTypes );
+    }
+
+    private Iterable<Class<? extends Constraint<?, ?>>> constraintDeclarations( ArrayList<Type> allTypes )
+    {
+        // Find all constraints and flatten them into an iterable
+        Function<Type, Iterable<Class<? extends Constraint<?, ?>>>> function = new Function<Type, Iterable<Class<? extends Constraint<?, ?>>>>()
+        {
+            @Override
+            public Iterable<Class<? extends Constraint<?, ?>>> map( Type type )
+            {
+                Constraints constraints = Annotations.annotationOn( type, Constraints.class );
+                if( constraints == null )
+                {
+                    return empty();
+                }
+                else
+                {
+                    return iterable( constraints.value() );
+                }
+            }
+        };
+        Iterable<Class<? extends Constraint<?, ?>>> flatten = flattenIterables( map( function, allTypes ) );
+        return toList( flatten );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Iterable<Class<?>> concernDeclarations( Class<?> type )
+    {
+        Iterable<? extends Class<?>> iterable = iterable( type );
+        return concernDeclarations( getTypes( iterable ) );
+    }
+
+    private Iterable<Class<?>> concernDeclarations( ArrayList<Type> allTypes )
+    {
+        // Find all concerns and flattern them into an iterable
+        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
+        {
+            @Override
+            public Iterable<Class<?>> map( Type type )
+            {
+                Concerns concerns = Annotations.annotationOn( type, Concerns.class );
+                if( concerns == null )
+                {
+                    return empty();
+                }
+                else
+                {
+                    return iterable( concerns.value() );
+                }
+            }
+        };
+        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
+        return toList( flatten );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected Iterable<Class<?>> sideEffectDeclarations( Class<?> type )
+    {
+        Iterable<? extends Class<?>> iterable = iterable( type );
+        return sideEffectDeclarations( getTypes( iterable ) );
+    }
+
+    protected Iterable<Class<?>> sideEffectDeclarations( ArrayList<Type> allTypes )
+    {
+        // Find all side-effects and flattern them into an iterable
+        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
+        {
+            @Override
+            public Iterable<Class<?>> map( Type type )
+            {
+                SideEffects sideEffects = Annotations.annotationOn( type, SideEffects.class );
+                if( sideEffects == null )
+                {
+                    return empty();
+                }
+                else
+                {
+                    return iterable( sideEffects.value() );
+                }
+            }
+        };
+        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
+        return toList( flatten );
+    }
+
+    private ArrayList<Type> getTypes( Class<?> type )
+    {
+        Iterable<? extends Class<?>> iterable = iterable( type );
+        return getTypes( iterable );
+    }
+
+    private ArrayList<Type> getTypes( Iterable<? extends Class<?>> typess )
+    {
+        // Find side-effect declarations
+        ArrayList<Type> allTypes = new ArrayList<>();
+        for( Class<?> type : typess )
+        {
+            Iterable<Type> types;
+            if( type.isInterface() )
+            {
+                types = typesOf( type );
+            }
+            else
+            {
+                types = cast( classHierarchy( type ) );
+            }
+            addAll( allTypes, types );
+        }
+        return allTypes;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected Iterable<Class<?>> mixinDeclarations( Class<?> type )
+    {
+        Iterable<? extends Class<?>> iterable = iterable( type );
+        return mixinDeclarations( iterable );
+    }
+
+    protected Iterable<Class<?>> mixinDeclarations( Iterable<? extends Class<?>> typess )
+    {
+        // Find mixin declarations
+        ArrayList<Type> allTypes = new ArrayList<>();
+        for( Class<?> type : typess )
+        {
+            Iterable<Type> types = typesOf( type );
+            addAll( allTypes, types );
+        }
+
+        // Find all mixins and flattern them into an iterable
+        Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>()
+        {
+            @Override
+            public Iterable<Class<?>> map( Type type )
+            {
+                Mixins mixins = Annotations.annotationOn( type, Mixins.class );
+                if( mixins == null )
+                {
+                    return empty();
+                }
+                else
+                {
+                    return iterable( mixins.value() );
+                }
+            }
+        };
+        Iterable<Class<?>> flatten = flattenIterables( map( function, allTypes ) );
+        return toList( flatten );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationAssemblyImpl.java
new file mode 100644
index 0000000..d8088cc
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationAssemblyImpl.java
@@ -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.qi4j.runtime.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.AssociationDeclarations;
+import org.qi4j.bootstrap.ConfigurationAssembly;
+import org.qi4j.bootstrap.EntityAssembly;
+import org.qi4j.bootstrap.ManyAssociationDeclarations;
+import org.qi4j.bootstrap.NamedAssociationDeclarations;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.runtime.association.AssociationModel;
+import org.qi4j.runtime.association.AssociationsModel;
+import org.qi4j.runtime.association.ManyAssociationModel;
+import org.qi4j.runtime.association.ManyAssociationsModel;
+import org.qi4j.runtime.association.NamedAssociationModel;
+import org.qi4j.runtime.association.NamedAssociationsModel;
+import org.qi4j.runtime.composite.MixinsModel;
+import org.qi4j.runtime.composite.StateModel;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.composite.ValueConstraintsModel;
+import org.qi4j.runtime.entity.EntityMixinsModel;
+import org.qi4j.runtime.entity.EntityModel;
+import org.qi4j.runtime.entity.EntityStateModel;
+import org.qi4j.runtime.property.PropertyModel;
+
+import static org.qi4j.api.util.Annotations.isType;
+import static org.qi4j.api.util.Classes.typeOf;
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Declaration of a EntityComposite.
+ */
+public final class ConfigurationAssemblyImpl
+    implements ConfigurationAssembly
+{
+    private ValueAssemblyImpl value;
+    private EntityAssemblyImpl entity;
+
+    public ConfigurationAssemblyImpl( Class<?> mainType )
+    {
+        value = new ValueAssemblyImpl( mainType );
+        entity = new EntityAssemblyImpl( mainType );
+    }
+
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return value.types();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationDeclarationImpl.java
new file mode 100644
index 0000000..18a14cb
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ConfigurationDeclarationImpl.java
@@ -0,0 +1,125 @@
+/*
+ *  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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.ConfigurationDeclaration;
+import org.qi4j.bootstrap.EntityDeclaration;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Declaration of a Composite. Created by {@link org.qi4j.bootstrap.ModuleAssembly#configurations(Class[])}.
+ */
+public final class ConfigurationDeclarationImpl
+    implements ConfigurationDeclaration
+{
+    private final Iterable<EntityAssemblyImpl> entities;
+    private final Iterable<ValueAssemblyImpl> values;
+
+    public ConfigurationDeclarationImpl( Iterable<EntityAssemblyImpl> entities, Iterable<ValueAssemblyImpl> values  )
+    {
+        this.entities = entities;
+        this.values = values;
+    }
+
+    @Override
+    public ConfigurationDeclaration setMetaInfo( Object info )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.metaInfo.set( info );
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.metaInfo.set( info );
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationDeclaration visibleIn( Visibility visibility )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.visibility = visibility;
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationDeclaration withConcerns( Class<?>... concerns )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.concerns.addAll( asList( concerns ) );
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.concerns.addAll( asList( concerns ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationDeclaration withSideEffects( Class<?>... sideEffects )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.sideEffects.addAll( asList( sideEffects ) );
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.sideEffects.addAll( asList( sideEffects ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationDeclaration withMixins( Class<?>... mixins )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.mixins.addAll( asList( mixins ) );
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.mixins.addAll( asList( mixins ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationDeclaration withTypes( Class<?>... types )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.types.addAll( asList( types ) );
+        }
+        for( ValueAssemblyImpl value : values )
+        {
+            value.types.addAll( asList( types ) );
+        }
+        return this;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityAssemblyImpl.java
new file mode 100644
index 0000000..e74f63c
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityAssemblyImpl.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.AssociationDeclarations;
+import org.qi4j.bootstrap.EntityAssembly;
+import org.qi4j.bootstrap.ManyAssociationDeclarations;
+import org.qi4j.bootstrap.NamedAssociationDeclarations;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.runtime.association.AssociationModel;
+import org.qi4j.runtime.association.AssociationsModel;
+import org.qi4j.runtime.association.ManyAssociationModel;
+import org.qi4j.runtime.association.ManyAssociationsModel;
+import org.qi4j.runtime.association.NamedAssociationModel;
+import org.qi4j.runtime.association.NamedAssociationsModel;
+import org.qi4j.runtime.composite.MixinsModel;
+import org.qi4j.runtime.composite.StateModel;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.composite.ValueConstraintsModel;
+import org.qi4j.runtime.entity.EntityMixinsModel;
+import org.qi4j.runtime.entity.EntityModel;
+import org.qi4j.runtime.entity.EntityStateModel;
+import org.qi4j.runtime.property.PropertyModel;
+
+import static org.qi4j.api.util.Annotations.isType;
+import static org.qi4j.api.util.Classes.typeOf;
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Declaration of a EntityComposite.
+ */
+public final class EntityAssemblyImpl
+    extends CompositeAssemblyImpl
+    implements EntityAssembly
+{
+    private AssociationDeclarations associationDeclarations;
+    private ManyAssociationDeclarations manyAssociationDeclarations;
+    private NamedAssociationDeclarations namedAssociationDeclarations;
+    private AssociationsModel associationsModel;
+    private ManyAssociationsModel manyAssociationsModel;
+    private NamedAssociationsModel namedAssociationsModel;
+
+    public EntityAssemblyImpl( Class<?> entityType )
+    {
+        super( entityType );
+        // The composite must always implement EntityComposite, as a marker interface
+        if( !EntityComposite.class.isAssignableFrom( entityType ) )
+        {
+            types.add( EntityComposite.class );
+        }
+    }
+
+    @Override
+    protected MixinsModel createMixinsModel()
+    {
+        return new EntityMixinsModel();
+    }
+
+    @Override
+    protected StateModel createStateModel()
+    {
+        return new EntityStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
+    }
+
+    EntityModel newEntityModel(
+        StateDeclarations stateDeclarations,
+        AssociationDeclarations associationDecs,
+        ManyAssociationDeclarations manyAssociationDecs,
+        NamedAssociationDeclarations namedAssociationDecs,
+        AssemblyHelper helper
+    )
+    {
+        this.associationDeclarations = associationDecs;
+        this.manyAssociationDeclarations = manyAssociationDecs;
+        this.namedAssociationDeclarations = namedAssociationDecs;
+        try
+        {
+            associationsModel = new AssociationsModel();
+            manyAssociationsModel = new ManyAssociationsModel();
+            namedAssociationsModel = new NamedAssociationsModel();
+            buildComposite( helper, stateDeclarations );
+
+            EntityModel entityModel = new EntityModel(
+                types, visibility, metaInfo, (EntityMixinsModel) mixinsModel, (EntityStateModel) stateModel, compositeMethodsModel );
+
+            return entityModel;
+        }
+        catch( Exception e )
+        {
+            throw new InvalidApplicationException( "Could not register " + types, e );
+        }
+    }
+
+    @Override
+    protected void addStateFor( AccessibleObject accessor,
+                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        String stateName = QualifiedName.fromAccessor( accessor ).name();
+
+        if( registeredStateNames.contains( stateName ) )
+        {
+            return; // Skip already registered names
+        }
+
+        Class<?> accessorType = Classes.RAW_CLASS.map( typeOf( accessor ) );
+        if( Property.class.isAssignableFrom( accessorType ) )
+        {
+            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( Association.class.isAssignableFrom( accessorType ) )
+        {
+            associationsModel.addAssociation( newAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( ManyAssociation.class.isAssignableFrom( accessorType ) )
+        {
+            manyAssociationsModel.addManyAssociation( newManyAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( NamedAssociation.class.isAssignableFrom( accessorType ) )
+        {
+            namedAssociationsModel.addNamedAssociation( newNamedAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+    }
+
+    @Override
+    protected PropertyModel newPropertyModel( AccessibleObject accessor,
+                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member) accessor )
+            .getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        Object defaultValue = stateDeclarations.initialValueOf( accessor );
+        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
+        boolean immutable = this.immutable || metaInfo.get( Immutable.class ) != null;
+        PropertyModel propertyModel = new PropertyModel( accessor, immutable, useDefaults, valueConstraintsInstance, metaInfo, defaultValue );
+        return propertyModel;
+    }
+
+    public AssociationModel newAssociationModel( AccessibleObject accessor,
+                                                 Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for Association references
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the Association itself
+        valueConstraintsModel = constraintsFor( annotations, Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance associationValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            associationValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        MetaInfo metaInfo = associationDeclarations.metaInfoFor( accessor );
+        AssociationModel associationModel = new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+
+    public ManyAssociationModel newManyAssociationModel( AccessibleObject accessor,
+                                                         Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for entities in ManyAssociation
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the ManyAssociation itself
+        valueConstraintsModel = constraintsFor( annotations, ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance manyValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            manyValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = manyAssociationDeclarations.metaInfoFor( accessor );
+        ManyAssociationModel associationModel = new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+
+    public NamedAssociationModel newNamedAssociationModel( AccessibleObject accessor,
+                                                           Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for entities in NamedAssociation
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the NamedAssociation itself
+        valueConstraintsModel = constraintsFor( annotations, NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance namedValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            namedValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = namedAssociationDeclarations.metaInfoFor( accessor );
+        NamedAssociationModel associationModel = new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityDeclarationImpl.java
new file mode 100644
index 0000000..c92af35
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/EntityDeclarationImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.EntityDeclaration;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Declaration of a Composite. Created by {@link org.qi4j.bootstrap.ModuleAssembly#transients(Class[])}.
+ */
+public final class EntityDeclarationImpl
+    implements EntityDeclaration
+{
+    private final Iterable<EntityAssemblyImpl> entities;
+
+    public EntityDeclarationImpl( Iterable<EntityAssemblyImpl> entities )
+    {
+        this.entities = entities;
+    }
+
+    @Override
+    public EntityDeclaration setMetaInfo( Object info )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.metaInfo.set( info );
+        }
+        return this;
+    }
+
+    @Override
+    public EntityDeclaration visibleIn( Visibility visibility )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    public EntityDeclaration withConcerns( Class<?>... concerns )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.concerns.addAll( asList( concerns ) );
+        }
+        return this;
+    }
+
+    @Override
+    public EntityDeclaration withSideEffects( Class<?>... sideEffects )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.sideEffects.addAll( asList( sideEffects ) );
+        }
+        return this;
+    }
+
+    @Override
+    public EntityDeclaration withMixins( Class<?>... mixins )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.mixins.addAll( asList( mixins ) );
+        }
+        return this;
+    }
+
+    @Override
+    public EntityDeclaration withTypes( Class<?>... types )
+    {
+        for( EntityAssemblyImpl entity : entities )
+        {
+            entity.types.addAll( asList( types ) );
+        }
+        return this;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImplementsMethodAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
new file mode 100644
index 0000000..ea580ff
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImplementsMethodAppliesToFilter.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class ImplementsMethodAppliesToFilter
+    implements AppliesToFilter
+{
+    @Override
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        try
+        {
+            return !Modifier.isAbstract( fragmentClass.getMethod( method.getName(), method.getParameterTypes() )
+                                             .getModifiers() );
+        }
+        catch( NoSuchMethodException e )
+        {
+            return false;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceAssemblyImpl.java
new file mode 100644
index 0000000..97b36d5
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceAssemblyImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.importer.InstanceImporter;
+import org.qi4j.bootstrap.ImportedServiceAssembly;
+import org.qi4j.functional.Iterables;
+import org.qi4j.runtime.activation.ActivatorsModel;
+import org.qi4j.runtime.service.ImportedServiceModel;
+
+/**
+ * Declaration of an imported Service.
+ *
+ * Created by {@link org.qi4j.runtime.bootstrap.ModuleAssemblyImpl#importedServices(Class[])}.
+ */
+public final class ImportedServiceAssemblyImpl
+    implements ImportedServiceAssembly
+{
+    private final Class<?> serviceType;
+    private final ModuleAssemblyImpl moduleAssembly;
+    @SuppressWarnings( "raw" )
+    Class<? extends ServiceImporter> serviceProvider = InstanceImporter.class;
+    String identity;
+    boolean importOnStartup = false;
+    MetaInfo metaInfo = new MetaInfo();
+    Visibility visibility = Visibility.module;
+    List<Class<? extends Activator<?>>> activators = new ArrayList<>();
+
+    public ImportedServiceAssemblyImpl( Class<?> serviceType, ModuleAssemblyImpl moduleAssembly )
+    {
+        this.serviceType = serviceType;
+        this.moduleAssembly = moduleAssembly;
+    }
+
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return Iterables.<Class<?>>iterable( serviceType );
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    void addImportedServiceModel( List<ImportedServiceModel> serviceModels )
+    {
+        try
+        {
+            String id = identity;
+            if( id == null )
+            {
+                id = generateId( serviceModels, serviceType );
+            }
+
+            ImportedServiceModel serviceModel = new ImportedServiceModel( serviceType,
+                                                                          visibility,
+                                                                          serviceProvider,
+                                                                          id,
+                                                                          importOnStartup,
+                                                                          new MetaInfo( metaInfo ).withAnnotations( serviceType ),
+                                                                          new ActivatorsModel( activators ),
+                                                                          moduleAssembly.name() );
+            serviceModels.add( serviceModel );
+        }
+        catch( Exception e )
+        {
+            throw new InvalidApplicationException( "Could not register " + serviceType.getName(), e );
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    private String generateId( List<ImportedServiceModel> serviceModels, Class serviceType )
+    {
+        // Find identity that is not yet used
+        int idx = 0;
+        String id = serviceType.getSimpleName();
+        boolean invalid;
+        do
+        {
+            invalid = false;
+            for( ImportedServiceModel serviceModel : serviceModels )
+            {
+                if( serviceModel.identity().equals( id ) )
+                {
+                    idx++;
+                    id = serviceType.getSimpleName() + "_" + idx;
+                    invalid = true;
+                    break;
+                }
+            }
+        }
+        while( invalid );
+        return id;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceDeclarationImpl.java
new file mode 100644
index 0000000..57eaaeb
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ImportedServiceDeclarationImpl.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.qualifier.ServiceTags;
+import org.qi4j.bootstrap.ImportedServiceDeclaration;
+
+/**
+ * Declaration of an imported Service.
+ */
+public final class ImportedServiceDeclarationImpl
+    implements ImportedServiceDeclaration
+{
+    private final Iterable<ImportedServiceAssemblyImpl> assemblies;
+
+    public ImportedServiceDeclarationImpl( Iterable<ImportedServiceAssemblyImpl> assemblies )
+    {
+        this.assemblies = assemblies;
+    }
+
+    @Override
+    public ImportedServiceDeclaration importOnStartup()
+    {
+        for( ImportedServiceAssemblyImpl assembly : assemblies )
+        {
+            assembly.importOnStartup = true;
+        }
+        return this;
+    }
+
+    @Override
+    public ImportedServiceDeclaration visibleIn( Visibility visibility )
+    {
+        for( ImportedServiceAssemblyImpl assembly : assemblies )
+        {
+            assembly.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    @SuppressWarnings( "raw" )
+    public ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> sip )
+    {
+        for( ImportedServiceAssemblyImpl assembly : assemblies )
+        {
+            assembly.serviceProvider = sip;
+        }
+        return this;
+    }
+
+    @Override
+    public ImportedServiceDeclaration identifiedBy( String identity )
+    {
+        for( ImportedServiceAssemblyImpl assembly : assemblies )
+        {
+            assembly.identity = identity;
+        }
+        return this;
+    }
+
+    @Override
+    public ImportedServiceDeclaration taggedWith( String... tags )
+    {
+        for( ImportedServiceAssemblyImpl serviceAssembly : assemblies )
+        {
+            ServiceTags previousTags = serviceAssembly.metaInfo.get( ServiceTags.class );
+            if( previousTags != null )
+            {
+                List<String> tagList = new ArrayList<>();
+                Collections.addAll( tagList, previousTags.tags() );
+                Collections.addAll( tagList, tags );
+                serviceAssembly.metaInfo.set( new ServiceTags( tagList.toArray( new String[ tagList.size() ] ) ) );
+            }
+            else
+            {
+                serviceAssembly.metaInfo.set( new ServiceTags( tags ) );
+            }
+        }
+
+        return this;
+    }
+
+    @Override
+    public ImportedServiceDeclaration setMetaInfo( Object serviceAttribute )
+    {
+        for( ImportedServiceAssemblyImpl assembly : assemblies )
+        {
+            assembly.metaInfo.set( serviceAttribute );
+        }
+        return this;
+    }
+
+    @Override
+    @SafeVarargs
+    public final ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
+    {
+        for ( ImportedServiceAssemblyImpl serviceAssembly : assemblies ) {
+            serviceAssembly.activators.addAll( Arrays.asList( activators ) );
+        }
+        return this;
+    }
+}
\ No newline at end of file


[09/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java
deleted file mode 100644
index 41ec961..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/query/IterableQuerySource.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.query;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.spi.query.QuerySource;
-
-/**
- * JAVADOC
- */
-public class IterableQuerySource
-    implements QuerySource
-{
-    private final Iterable iterable;
-
-    /**
-     * Constructor.
-     *
-     * @param iterable iterable
-     */
-    @SuppressWarnings( "raw" )
-    IterableQuerySource( final Iterable iterable )
-    {
-        this.iterable = iterable;
-    }
-
-    @Override
-    public <T> T find( Class<T> resultType,
-                       Specification<Composite> whereClause,
-                       Iterable<OrderBy> orderBySegments,
-                       Integer firstResult,
-                       Integer maxResults,
-                       Map<String, Object> variables
-    )
-    {
-        final Iterator<T> iterator = iterator( resultType, whereClause, orderBySegments, firstResult, maxResults, variables );
-        if( iterator.hasNext() )
-        {
-            return iterator.next();
-        }
-        return null;
-    }
-
-    @Override
-    public <T> long count( Class<T> resultType,
-                           Specification<Composite> whereClause,
-                           Iterable<OrderBy> orderBySegments,
-                           Integer firstResult,
-                           Integer maxResults,
-                           Map<String, Object> variables
-    )
-    {
-        return list( resultType, whereClause, orderBySegments, firstResult, maxResults, variables ).size();
-    }
-
-    @Override
-    public <T> Iterator<T> iterator( Class<T> resultType,
-                                     Specification<Composite> whereClause,
-                                     Iterable<OrderBy> orderBySegments,
-                                     Integer firstResult,
-                                     Integer maxResults,
-                                     Map<String, Object> variables
-    )
-    {
-        return list( resultType, whereClause, orderBySegments, firstResult, maxResults, variables ).iterator();
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    private <T> List<T> list( Class<T> resultType,
-                              Specification<Composite> whereClause,
-                              Iterable<OrderBy> orderBySegments,
-                              Integer firstResult,
-                              Integer maxResults,
-                              Map<String, Object> variables
-    )
-    {
-        // Ensure it's a list first
-        List<T> list = filter( resultType, whereClause );
-
-        // Order list
-        if( orderBySegments != null )
-        {
-            // Sort it
-            Collections.sort( list, new OrderByComparator( orderBySegments ) );
-        }
-
-        // Cut results
-        if( firstResult != null )
-        {
-            if( firstResult > list.size() )
-            {
-                return Collections.emptyList();
-            }
-
-            int toIdx;
-            if( maxResults != null )
-            {
-                toIdx = Math.min( firstResult + maxResults, list.size() );
-            }
-            else
-            {
-                toIdx = list.size();
-            }
-
-            list = list.subList( firstResult, toIdx );
-        }
-        else
-        {
-            int toIdx;
-            if( maxResults != null )
-            {
-                toIdx = Math.min( maxResults, list.size() );
-            }
-            else
-            {
-                toIdx = list.size();
-            }
-
-            list = list.subList( 0, toIdx );
-        }
-
-        return list;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    private <T> List<T> filter( Class<T> resultType, Specification whereClause )
-    {
-        if( whereClause == null )
-        {
-            return Iterables.toList( Iterables.filter( Classes.instanceOf( resultType ), iterable ) );
-        }
-        else
-        {
-            return Iterables.toList( Iterables.filter( Specifications.and( Classes.instanceOf( resultType ), whereClause ), iterable ) );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return "IterableQuerySource{" + iterable + '}';
-    }
-
-    private static class OrderByComparator<T extends Composite>
-        implements Comparator<T>
-    {
-
-        private final Iterable<OrderBy> orderBySegments;
-
-        private OrderByComparator( Iterable<OrderBy> orderBySegments )
-        {
-            this.orderBySegments = orderBySegments;
-        }
-
-        @Override
-        @SuppressWarnings( {"raw", "unchecked"} )
-        public int compare( T o1, T o2 )
-        {
-            for( OrderBy orderBySegment : orderBySegments )
-            {
-                try
-                {
-                    final Property prop1 = orderBySegment.property().map( o1 );
-                    final Property prop2 = orderBySegment.property().map( o2 );
-                    if( prop1 == null || prop2 == null )
-                    {
-                        if( prop1 == null && prop2 == null )
-                        {
-                            return 0;
-                        }
-                        else if( prop1 != null )
-                        {
-                            return 1;
-                        }
-                        return -1;
-                    }
-                    final Object value1 = prop1.get();
-                    final Object value2 = prop2.get();
-                    if( value1 == null || value2 == null )
-                    {
-                        if( value1 == null && value2 == null )
-                        {
-                            return 0;
-                        }
-                        else if( value1 != null )
-                        {
-                            return 1;
-                        }
-                        return -1;
-                    }
-                    if( value1 instanceof Comparable )
-                    {
-                        int result = ( (Comparable) value1 ).compareTo( value2 );
-                        if( result != 0 )
-                        {
-                            if( orderBySegment.order() == OrderBy.Order.ASCENDING )
-                            {
-                                return result;
-                            }
-                            else
-                            {
-                                return -result;
-                            }
-                        }
-                    }
-                }
-                catch( Exception e )
-                {
-                    return 0;
-                }
-            }
-
-            return 0;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderFactoryImpl.java
deleted file mode 100644
index 8bc93b3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderFactoryImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2007-2009 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.runtime.query;
-
-import org.apache.zest.api.query.NotQueryableException;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.spi.query.EntityFinder;
-
-/**
- * Default implementation of {@link QueryBuilderFactory}
- */
-public final class QueryBuilderFactoryImpl
-    implements QueryBuilderFactory
-{
-    private ServiceFinder finder;
-
-    /**
-     * Constructor.
-     *
-     * @param finder The ServiceFinder of the Module this QueryBuilderFactory belongs to.
-     */
-    public QueryBuilderFactoryImpl( ServiceFinder finder )
-    {
-        NullArgumentException.validateNotNull( "ServiceFinder", finder );
-        this.finder = finder;
-    }
-
-    /**
-     * @see QueryBuilderFactory#newQueryBuilder(Class)
-     */
-    @Override
-    public <T> QueryBuilder<T> newQueryBuilder( final Class<T> resultType )
-    {
-        NotQueryableException.throwIfNotQueryable( resultType );
-
-        final ServiceReference<EntityFinder> serviceReference;
-        try
-        {
-            serviceReference = finder.findService( EntityFinder.class );
-            return new QueryBuilderImpl<T>( serviceReference.get(), resultType, null );
-        }
-        catch( NoSuchServiceException e )
-        {
-            return new QueryBuilderImpl<T>( null, resultType, null );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java
deleted file mode 100644
index 67ab342..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryBuilderImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2007-2009 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.runtime.query;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.spi.query.EntityFinder;
-import org.apache.zest.spi.query.QueryBuilderSPI;
-import org.apache.zest.spi.query.QuerySource;
-
-/**
- * Default implementation of {@link QueryBuilder}
- */
-final class QueryBuilderImpl<T>
-    implements QueryBuilder<T>, QueryBuilderSPI<T>
-{
-
-    /**
-     * Entity finder to be used to locate entities.
-     */
-    private final EntityFinder entityFinder;
-
-    /**
-     * Type of queried entities.
-     */
-    private final Class<T> resultType;
-    /**
-     * Where clause.
-     */
-    private final Specification<Composite> whereClause;
-
-    /**
-     * Constructor.
-     *
-     * @param entityFinder entity finder to be used to locate entities; canot be null
-     * @param resultType   type of queried entities; cannot be null
-     * @param whereClause  current where-clause
-     */
-    QueryBuilderImpl( final EntityFinder entityFinder,
-                      final Class<T> resultType,
-                      final Specification<Composite> whereClause
-    )
-    {
-        this.entityFinder = entityFinder;
-        this.resultType = resultType;
-        this.whereClause = whereClause;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public QueryBuilder<T> where( Specification<Composite> specification )
-    {
-        if( specification == null )
-        {
-            throw new IllegalArgumentException( "Where clause cannot be null" );
-        }
-        if( this.whereClause != null )
-        {
-            specification = QueryExpressions.and( this.whereClause, specification );
-        }
-        return new QueryBuilderImpl<>( entityFinder, resultType, specification );
-    }
-
-    @Override
-    public Query<T> newQuery( Iterable<T> iterable )
-    {
-        return new QueryImpl<>( resultType, whereClause, new IterableQuerySource( iterable ) );
-    }
-
-    // SPI
-    @Override
-    public Query<T> newQuery( QuerySource querySource )
-    {
-        return new QueryImpl<>( resultType, whereClause, querySource );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java
deleted file mode 100644
index 59ebb5d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/query/QueryImpl.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2007 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.runtime.query;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryExecutionException;
-import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.spi.query.QuerySource;
-
-/**
- * Default implementation of {@link org.apache.zest.api.query.Query}.
- */
-/* package */ class QueryImpl<T>
-    implements Query<T>
-{
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Type of queried entities.
-     */
-    private final Class<T> resultType;
-    /**
-     * Where clause.
-     */
-    private final Specification<Composite> whereClause;
-    private QuerySource querySource;
-    /**
-     * Order by clause segments.
-     */
-    private Iterable<OrderBy> orderBySegments;
-    /**
-     * First result to be returned.
-     */
-    private Integer firstResult;
-    /**
-     * Maximum number of results to be returned.
-     */
-    private Integer maxResults;
-    /**
-     * Mapping between variable name and variable values.
-     */
-    private Map<String, Object> variables;
-
-    /**
-     * Constructor.
-     *
-     * @param resultType  type of queried entities; cannot be null
-     * @param whereClause where clause
-     */
-    /* package */ QueryImpl( final Class<T> resultType,
-               final Specification<Composite> whereClause,
-               final QuerySource querySource
-    )
-    {
-        this.resultType = resultType;
-        this.whereClause = whereClause;
-        this.querySource = querySource;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#orderBy(org.apache.zest.api.query.grammar.OrderBy[])
-     */
-    @Override
-    public Query<T> orderBy( final OrderBy... segments )
-    {
-        orderBySegments = Iterables.iterable( segments );
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#orderBy(org.apache.zest.api.property.Property, org.apache.zest.api.query.grammar.OrderBy.Order)
-     */
-    @Override
-    public Query<T> orderBy( Property<?> property, OrderBy.Order order )
-    {
-        if( orderBySegments == null )
-        {
-            orderBySegments = Iterables.iterable( new OrderBy( QueryExpressions.property( property ), order ) );
-        }
-        else
-        {
-            orderBySegments = Iterables.append( new OrderBy( QueryExpressions.property( property ), order ), orderBySegments );
-        }
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#orderBy(org.apache.zest.api.property.Property)
-     */
-    @Override
-    public Query<T> orderBy( Property<?> property )
-    {
-        orderBy( property, OrderBy.Order.ASCENDING );
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#firstResult(int)
-     */
-    @Override
-    public Query<T> firstResult( int firstResult )
-    {
-        this.firstResult = firstResult;
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#maxResults(int)
-     */
-    @Override
-    public Query<T> maxResults( int maxResults )
-    {
-        this.maxResults = maxResults;
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#setVariable(String, Object)
-     */
-    @SuppressWarnings( "unchecked" )
-    @Override
-    public Query<T> setVariable( final String name, final Object value )
-    {
-        if( variables == null )
-        {
-            variables = new HashMap<String, Object>();
-        }
-        variables.put( name, value );
-
-        return this;
-    }
-
-    /**
-     * @see org.apache.zest.api.query.Query#getVariable(String)
-     */
-    @SuppressWarnings( "unchecked" )
-    @Override
-    public <V> V getVariable( final String name )
-    {
-        if( variables == null )
-        {
-            return null;
-        }
-        else
-        {
-            return (V) variables.get( name );
-        }
-    }
-
-    @Override
-    public Class<T> resultType()
-    {
-        return resultType;
-    }
-
-    @Override
-    public T find()
-        throws QueryExecutionException
-    {
-        return querySource.find( resultType, whereClause, orderBySegments, firstResult, maxResults, variables );
-    }
-
-    @Override
-    public long count()
-        throws QueryExecutionException
-    {
-        return querySource.count( resultType, whereClause, orderBySegments, firstResult, maxResults, variables );
-    }
-
-    @Override
-    public Iterator<T> iterator()
-    {
-        return querySource.iterator( resultType, whereClause, orderBySegments, firstResult, maxResults, variables );
-    }
-
-    @Override
-    public String toString()
-    {
-        return "Query{" +
-               " FROM " + querySource +
-               " WHERE " + whereClause +
-               ( orderBySegments != null ? " ORDER BY " + orderBySegments : "" ) +
-               ( firstResult != null ? " FIRST " + firstResult : "" ) +
-               ( maxResults != null ? " MAX " + maxResults : "" ) +
-               " EXPECT " + resultType +
-               ( variables != null ? " WITH VARIABLES " + variables : "" ) +
-               '}';
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceInstance.java
deleted file mode 100644
index b63bf11..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceInstance.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.service;
-
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.service.ServiceImporter;
-
-/**
- * JAVADOC
- */
-public final class ImportedServiceInstance<T>
-    implements Activation
-{
-    private final T instance;
-    private final ServiceImporter<T> importer;
-
-    public ImportedServiceInstance( T instance, ServiceImporter<T> importer )
-    {
-        this.importer = importer;
-        this.instance = instance;
-    }
-
-    public T instance()
-    {
-        return instance;
-    }
-
-    public ServiceImporter importer()
-    {
-        return importer;
-    }
-
-    public boolean isAvailable()
-    {
-        return importer.isAvailable( instance );
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        // NOOP
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        // NOOP
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
deleted file mode 100644
index 669010d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.service;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- */
-public final class ImportedServiceModel
-    implements ImportedServiceDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final Class<?> type;
-    private final Visibility visibility;
-    @SuppressWarnings( "raw" )
-    private final Class<? extends ServiceImporter> serviceImporter;
-    private final String identity;
-    private final boolean importOnStartup;
-    private final MetaInfo metaInfo;
-    private final ActivatorsModel<?> activatorsModel;
-    private final String moduleName;
-
-    @SuppressWarnings( "raw" )
-    public ImportedServiceModel( Class serviceType,
-                                 Visibility visibility,
-                                 Class<? extends ServiceImporter> serviceImporter,
-                                 String identity,
-                                 boolean importOnStartup,
-                                 MetaInfo metaInfo,
-                                 ActivatorsModel<?> activatorsModel,
-                                 String moduleName
-    )
-    {
-        type = serviceType;
-        this.visibility = visibility;
-        this.serviceImporter = serviceImporter;
-        this.identity = identity;
-        this.importOnStartup = importOnStartup;
-        this.metaInfo = metaInfo;
-        this.activatorsModel = activatorsModel;
-        this.moduleName = moduleName;
-    }
-
-    public boolean isImportOnStartup()
-    {
-        return importOnStartup;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Iterable<Class<?>> types()
-    {
-        Iterable<? extends Class<?>> iterable = iterable( type );
-        return (Iterable<Class<?>>) iterable;
-    }
-
-    @Override
-    public Visibility visibility()
-    {
-        return visibility;
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    @SuppressWarnings( "raw" )
-    public Class<? extends ServiceImporter> serviceImporter()
-    {
-        return serviceImporter;
-    }
-
-    @Override
-    public Class<?> type()
-    {
-        return type;
-    }
-
-    @Override
-    public String identity()
-    {
-        return identity;
-    }
-
-    public String moduleName()
-    {
-        return moduleName;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public ActivatorsInstance<?> newActivatorsInstance( Module module )
-        throws Exception
-    {
-        return new ActivatorsInstance( activatorsModel.newInstances( module ) );
-    }
-
-    @Override
-    public boolean isAssignableTo( Class<?> type )
-    {
-        return this.type.isAssignableFrom( type );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            activatorsModel.accept( visitor );
-        }
-        return visitor.visitLeave( this );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public <T> ImportedServiceInstance<T> importInstance( Module module )
-    {
-        ServiceImporter importer = module.newObject( serviceImporter );
-        try
-        {
-            T instance = (T) importer.importService( this );
-            return new ImportedServiceInstance<>( instance, importer );
-        }
-        catch( ServiceImporterException e )
-        {
-            throw e;
-        }
-        catch( Exception e )
-        {
-            throw new ServiceImporterException( "Could not import service " + identity, e );
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    public Object newProxy( InvocationHandler serviceInvocationHandler )
-    {
-        if( type.isInterface() )
-        {
-            return Proxy.newProxyInstance( type.getClassLoader(),
-                                           new Class[]{ type },
-                                           serviceInvocationHandler );
-        }
-        else
-        {
-            Class[] interfaces = type.getInterfaces();
-            return Proxy.newProxyInstance( type.getClassLoader(),
-                                           interfaces,
-                                           serviceInvocationHandler );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return type.getName() + ":" + identity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
deleted file mode 100644
index 750985f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.service;
-
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.ServiceUnavailableException;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-
-/**
- * Implementation of ServiceReference. This manages the reference to the imported service.
- * <p>
- * Whenever the service is requested it is returned directly to the client. That means that
- * to handle service passivation and unavailability correctly, any proxying must be done in the
- * service importer.
- * </p>
- * @param <T> Service Type
- */
-public final class ImportedServiceReferenceInstance<T>
-    implements ServiceReference<T>, Activation
-{
-    private volatile ImportedServiceInstance<T> serviceInstance;
-    private T instance;
-    private final Module module;
-    private final ImportedServiceModel serviceModel;
-    private final ActivationDelegate activation = new ActivationDelegate( this );
-    private boolean active = false;
-
-    public ImportedServiceReferenceInstance( ImportedServiceModel serviceModel, Module module )
-    {
-        this.module = module;
-        this.serviceModel = serviceModel;
-    }
-
-    @Override
-    public String identity()
-    {
-        return serviceModel.identity();
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return serviceModel.types();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return serviceModel.metaInfo( infoType );
-    }
-
-    @Override
-    public synchronized T get()
-    {
-        return getInstance();
-    }
-
-    public ImportedServiceModel serviceDescriptor()
-    {
-        return serviceModel;
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        if( serviceModel.isImportOnStartup() )
-        {
-            getInstance();
-        }
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        if( serviceInstance != null )
-        {
-            try
-            {
-                activation.passivate( new Runnable()
-                {
-                    @Override
-                    public void run()
-                    {
-                        active = false;
-                    }
-                } );
-            }
-            finally
-            {
-                serviceInstance = null;
-                active = false;
-            }
-        }
-    }
-
-    @Override
-    public boolean isActive()
-    {
-        return active;
-    }
-
-    @Override
-    public boolean isAvailable()
-    {
-        try
-        {
-            getInstance();
-            return serviceInstance.isAvailable();
-        }
-        catch( ServiceImporterException ex )
-        {
-            return false;
-        }
-    }
-
-    public Module module()
-    {
-        return module;
-    }
-
-    private T getInstance()
-        throws ServiceImporterException
-    {
-        // DCL that works with Java 1.5 volatile semantics
-        if( serviceInstance == null )
-        {
-            synchronized( this )
-            {
-                if( serviceInstance == null )
-                {
-                    serviceInstance = serviceModel.<T>importInstance( module );
-                    instance = serviceInstance.instance();
-
-                    try
-                    {
-                        activation.activate( serviceModel.newActivatorsInstance( module ), serviceInstance, new Runnable()
-                        {
-                            @Override
-                            public void run()
-                            {
-                                active = true;
-                            }
-                        } );
-                    }
-                    catch( Exception e )
-                    {
-                        serviceInstance = null;
-                        throw new ServiceUnavailableException( "Could not activate service " + serviceModel.identity(), e );
-                    }
-                }
-            }
-        }
-
-        return instance;
-    }
-
-    @Override
-    public String toString()
-    {
-        return serviceModel.identity() + ", active=" + isActive() + ", module='" + serviceModel.moduleName() + "'";
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return identity().hashCode();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if( obj == null )
-        {
-            return false;
-        }
-        if( getClass() != obj.getClass() )
-        {
-            return false;
-        }
-        final ServiceReference other = (ServiceReference) obj;
-        return identity().equals( other.identity() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
deleted file mode 100644
index f957f11..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.service;
-
-import java.util.List;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-
-import static org.apache.zest.api.util.Classes.instanceOf;
-import static org.apache.zest.functional.Iterables.filter;
-
-/**
- * JAVADOC
- */
-public class ImportedServicesInstance
-    implements Activation, ActivationEventListenerRegistration
-{
-    private final ImportedServicesModel servicesModel;
-    private final List<ServiceReference> serviceReferences;
-    private final ActivationDelegate activation = new ActivationDelegate( this, false );
-
-    public ImportedServicesInstance( ImportedServicesModel servicesModel,
-                                     List<ServiceReference> serviceReferences
-    )
-    {
-        this.servicesModel = servicesModel;
-        this.serviceReferences = serviceReferences;
-        for( ServiceReference serviceReference : serviceReferences )
-        {
-            serviceReference.registerActivationEventListener( activation );
-        }
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        Iterable<Activation> activatees = Iterables.<Activation>cast( filter( instanceOf( Activation.class ), serviceReferences ) );
-        activation.activate( ActivatorsInstance.EMPTY, activatees );
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        activation.passivate();
-    }
-
-    public Iterable<ServiceReference> visibleServices( final Visibility visibility )
-    {
-        return Iterables.filter( new Specification<ServiceReference>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference item )
-            {
-                return ( (ImportedServiceReferenceInstance) item ).serviceDescriptor()
-                    .visibility()
-                    .ordinal() >= visibility.ordinal();
-            }
-        }, serviceReferences );
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder( "Services{" );
-        String sep = " ";
-        for( ServiceReference serviceReference : serviceReferences )
-        {
-            sb.append( sep ).
-                append( serviceReference.identity() ).
-                append( "(active=" ).append( serviceReference.isActive() ).append( ")" );
-            sep = ", ";
-        }
-        return sb.append( " }" ).toString();
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
deleted file mode 100644
index 5d19cc9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.service;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * JAVADOC
- */
-public class ImportedServicesModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private List<ImportedServiceModel> importedServiceModels;
-
-    public ImportedServicesModel( List<ImportedServiceModel> importedServiceModels )
-    {
-        this.importedServiceModels = importedServiceModels;
-    }
-
-    public ImportedServicesInstance newInstance( ModuleInstance module )
-    {
-        List<ServiceReference> serviceReferences = new ArrayList<ServiceReference>();
-        for( ImportedServiceModel serviceModel : importedServiceModels )
-        {
-            ImportedServiceReferenceInstance serviceReferenceInstance = new ImportedServiceReferenceInstance( serviceModel, module );
-            serviceReferences.add( serviceReferenceInstance );
-        }
-
-        return new ImportedServicesInstance( this, serviceReferences );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ImportedServiceModel importedServiceModel : importedServiceModels )
-            {
-                if( !importedServiceModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
deleted file mode 100644
index 727b6fd..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.runtime.service;
-
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.configuration.Enabled;
-import org.apache.zest.api.service.Availability;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.runtime.composite.TransientInstance;
-import org.apache.zest.runtime.composite.TransientStateInstance;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * JAVADOC
- */
-public class ServiceInstance
-    extends TransientInstance
-    implements Activation
-{
-    public static TransientInstance serviceInstanceOf( ServiceComposite composite )
-    {
-        return (TransientInstance) Proxy.getInvocationHandler( composite );
-    }
-
-    private final boolean implementsServiceAvailable;
-    private final boolean hasEnabledConfiguration;
-
-    public ServiceInstance( ServiceModel compositeModel,
-                            ModuleInstance moduleInstance,
-                            Object[] mixins,
-                            TransientStateInstance state
-    )
-    {
-        super( compositeModel, moduleInstance, mixins, state );
-
-        implementsServiceAvailable =
-            Classes.assignableTypeSpecification( Availability.class ).satisfiedBy( descriptor() );
-        hasEnabledConfiguration = compositeModel.configurationType() != null
-                                  && Enabled.class.isAssignableFrom( compositeModel.configurationType() );
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        // NOOP
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        // NOOP
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public boolean isAvailable()
-    {
-        // Check Enabled in configuration first
-        if( hasEnabledConfiguration && !( (Configuration<Enabled>) proxy() ).get().enabled().get() )
-        {
-            return false;
-        }
-
-        // Ask service if it's available
-        return !implementsServiceAvailable || ( (Availability) proxy() ).isAvailable();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
deleted file mode 100644
index 86eaa3f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.service;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.CompositeModel;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.composite.TransientStateInstance;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Specifications.and;
-import static org.apache.zest.functional.Specifications.translate;
-
-/**
- * JAVADOC
- */
-public final class ServiceModel extends CompositeModel
-    implements ServiceDescriptor
-{
-    private static Method identityMethod;
-
-    static
-    {
-        try
-        {
-            identityMethod = Identity.class.getMethod( "identity" );
-        }
-        catch( NoSuchMethodException e )
-        {
-            e.printStackTrace();
-        }
-    }
-
-    private final String identity;
-    private final boolean instantiateOnStartup;
-    private final ActivatorsModel<?> activatorsModel;
-    @SuppressWarnings( "raw" )
-    private final Class configurationType;
-
-    public ServiceModel( Iterable<Class<?>> types,
-                         Visibility visibility,
-                         MetaInfo metaInfo,
-                         ActivatorsModel<?> activatorsModel,
-                         MixinsModel mixinsModel,
-                         StateModel stateModel,
-                         CompositeMethodsModel compositeMethodsModel,
-                         String identity,
-                         boolean instantiateOnStartup
-    )
-    {
-        super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-
-        this.identity = identity;
-        this.instantiateOnStartup = instantiateOnStartup;
-        this.activatorsModel = activatorsModel;
-
-        // Calculate configuration type
-        this.configurationType = calculateConfigurationType();
-    }
-
-    @Override
-    public boolean isInstantiateOnStartup()
-    {
-        return instantiateOnStartup;
-    }
-
-    @Override
-    public String identity()
-    {
-        return identity;
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public ActivatorsInstance<?> newActivatorsInstance( Module module ) throws Exception
-    {
-        return new ActivatorsInstance( activatorsModel.newInstances( module ) );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> Class<T> configurationType()
-    {
-        return configurationType;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( activatorsModel.accept( visitor ) )
-            {
-                if( compositeMethodsModel.accept( visitor ) )
-                {
-                    if( stateModel.accept( visitor ) )
-                    {
-                        mixinsModel.accept( visitor );
-                    }
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-    
-    public ServiceInstance newInstance( final ModuleInstance module )
-    {
-        Object[] mixins = mixinsModel.newMixinHolder();
-
-        Map<AccessibleObject, Property<?>> properties = new HashMap<>();
-        for( PropertyModel propertyModel : stateModel.properties() )
-        {
-            Object initialValue = propertyModel.initialValue( module );
-            if( propertyModel.accessor().equals( identityMethod ) )
-            {
-                initialValue = identity;
-            }
-
-            Property<?> property = new PropertyInstance<>( propertyModel, initialValue );
-            properties.put( propertyModel.accessor(), property );
-        }
-
-        TransientStateInstance state = new TransientStateInstance( properties );
-        ServiceInstance compositeInstance = new ServiceInstance( this, module, mixins, state );
-
-        // Instantiate all mixins
-        int i = 0;
-        UsesInstance uses = UsesInstance.EMPTY_USES.use( this );
-        InjectionContext injectionContext = new InjectionContext( compositeInstance, uses, state );
-        for( MixinModel mixinModel : mixinsModel.mixinModels() )
-        {
-            mixins[ i++ ] = mixinModel.newInstance( injectionContext );
-        }
-
-        return compositeInstance;
-    }
-
-    @Override
-    public String toString()
-    {
-        return super.toString() + ":" + identity;
-    }
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public Class calculateConfigurationType()
-    {
-        Class injectionClass = null;
-        Iterable<DependencyModel> configurationThisDependencies = filter( and( translate( new DependencyModel.InjectionTypeFunction(), Specifications
-            .<Class<?>>in( Configuration.class ) ), new DependencyModel.ScopeSpecification( This.class ) ), dependencies() );
-        for( DependencyModel dependencyModel : configurationThisDependencies )
-        {
-            if( dependencyModel.rawInjectionType()
-                    .equals( Configuration.class ) && dependencyModel.injectionType() instanceof ParameterizedType )
-            {
-                Class<?> type = Classes.RAW_CLASS
-                    .map( ( (ParameterizedType) dependencyModel.injectionType() ).getActualTypeArguments()[ 0 ] );
-                if( injectionClass == null )
-                {
-                    injectionClass = type;
-                }
-                else
-                {
-                    if( injectionClass.isAssignableFrom( type ) )
-                    {
-                        injectionClass = type;
-                    }
-                }
-            }
-        }
-        return injectionClass;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
deleted file mode 100644
index 6543917..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.service;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.ServiceUnavailableException;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * Implementation of ServiceReference.
- * <p>
- * This manages the actual instance of the service and implements the service Activation.
- * </p>
- * <p>
- * Whenever the service is requested a proxy is returned which points to this class. This means
- * that the instance can be passivated even though a client is holding on to a service proxy.
- * </p>
- * @param <T> Service Type
- */
-public final class ServiceReferenceInstance<T>
-    implements ServiceReference<T>, Activation
-{
-    private volatile ServiceInstance instance;
-    private final T serviceProxy;
-    private final ModuleInstance module;
-    private final ServiceModel serviceModel;
-    private final ActivationDelegate activation = new ActivationDelegate( this );
-    private boolean active = false;
-
-    public ServiceReferenceInstance( ServiceModel serviceModel, ModuleInstance module )
-    {
-        this.module = module;
-        this.serviceModel = serviceModel;
-
-        serviceProxy = newProxy();
-    }
-
-    @Override
-    public String identity()
-    {
-        return serviceModel.identity();
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return serviceModel.types();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return serviceModel.metaInfo( infoType );
-    }
-
-    @Override
-    public synchronized T get()
-    {
-        return serviceProxy;
-    }
-
-    @Override
-    public boolean isActive()
-    {
-        return active;
-    }
-
-    @Override
-    public boolean isAvailable()
-    {
-        return getInstance().isAvailable();
-    }
-
-    public Module module()
-    {
-        return module;
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        if( serviceModel.isInstantiateOnStartup() )
-        {
-            getInstance();
-        }
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        if( instance != null )
-        {
-            try {
-                activation.passivate( new Runnable()
-                {
-                    @Override
-                    public void run()
-                    {
-                        active = false;
-                    }
-                } );
-            } finally {
-                instance = null;
-                active = false;
-            }
-        }
-    }
-
-    private ServiceInstance getInstance()
-        throws ServiceImporterException
-    {
-        // DCL that works with Java 1.5 volatile semantics
-        if( instance == null )
-        {
-            synchronized( this )
-            {
-                if( instance == null )
-                {
-                    instance = serviceModel.newInstance( module );
-
-                    try
-                    {
-                        activation.activate( serviceModel.newActivatorsInstance( module ), instance, new Runnable()
-                        {
-                            @Override
-                            public void run()
-                            {
-                                active = true;
-                            }
-                        } );
-                    }
-                    catch( Exception e )
-                    {
-                        instance = null;
-                        throw new ServiceUnavailableException( "Could not activate service " + serviceModel.identity(), e );
-                    }
-                }
-            }
-        }
-
-        return instance;
-    }
-
-    @Override
-    public String toString()
-    {
-        return serviceModel.identity() + "(active=" + isActive() + ",module='" + module.name() + "')";
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public T newProxy()
-    {
-        return (T) serviceModel.newProxy( new ServiceReferenceInstance.ServiceInvocationHandler() );
-    }
-
-    public ServiceDescriptor serviceDescriptor()
-    {
-        return serviceModel;
-    }
-
-    public final class ServiceInvocationHandler
-        implements CompositeInstance
-    {
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public <T> T proxy()
-        {
-            return (T) ServiceReferenceInstance.this.get();
-        }
-
-        @Override
-        public <T> T newProxy( Class<T> mixinType )
-            throws IllegalArgumentException
-        {
-            return getInstance().newProxy( mixinType );
-        }
-
-        @Override
-        public <T> T metaInfo( Class<T> infoType )
-        {
-            return ServiceReferenceInstance.this.metaInfo( infoType );
-        }
-
-        @Override
-        public Iterable<Class<?>> types()
-        {
-            return ServiceReferenceInstance.this.types();
-        }
-
-        @Override
-        public CompositeDescriptor descriptor()
-        {
-            return ServiceReferenceInstance.this.serviceDescriptor();
-        }
-
-        @Override
-        public Object invokeComposite( Method method, Object[] args )
-            throws Throwable
-        {
-            return getInstance().invokeComposite( method, args );
-        }
-
-        @Override
-        public StateHolder state()
-        {
-            return getInstance().state();
-        }
-
-        @Override
-        public Object invoke( Object object, Method method, Object[] objects )
-            throws Throwable
-        {
-            if( method.getDeclaringClass().equals( Object.class ) )
-            {
-                switch( method.getName() )
-                {
-                    case "toString":
-                        return serviceModel.toString();
-                    case "equals":
-                        return objects[0] == object;
-                    case "hashCode":
-                        return serviceModel.toString().hashCode();
-                }
-            }
-
-            ServiceInstance instance = getInstance();
-
-/*
-            if (!instance.isAvailable())
-            {
-                throw new ServiceUnavailableException("Service is currently not available");
-            }
-
-*/
-            return instance.invoke( object, method, objects );
-        }
-
-        @Override
-        public String toString()
-        {
-            return serviceModel.toString();
-        }
-
-        @Override
-        public Module module()
-        {
-            return module;
-        }
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return identity().hashCode();
-    }
-
-    @Override
-    @SuppressWarnings( "raw" )
-    public boolean equals( Object obj )
-    {
-        if ( obj == null ) {
-            return false;
-        }
-        if ( getClass() != obj.getClass() ) {
-            return false;
-        }
-        final ServiceReference other = ( ServiceReference ) obj;
-        return identity().equals( other.identity() );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
deleted file mode 100644
index bb03428..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.service;
-
-import java.util.List;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-
-import static org.apache.zest.api.util.Classes.instanceOf;
-import static org.apache.zest.functional.Iterables.filter;
-
-/**
- * JAVADOC
- */
-public class ServicesInstance
-    implements Activation, ActivationEventListenerRegistration
-{
-    private final ServicesModel servicesModel;
-    private final List<ServiceReference> serviceReferences;
-    private final ActivationDelegate activation = new ActivationDelegate( this, false );
-
-    public ServicesInstance( ServicesModel servicesModel, List<ServiceReference> serviceReferences )
-    {
-        this.servicesModel = servicesModel;
-        this.serviceReferences = serviceReferences;
-        for( ServiceReference serviceReference : serviceReferences )
-        {
-            serviceReference.registerActivationEventListener( activation );
-        }
-    }
-
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        Iterable<Activation> activatees = Iterables.<Activation>cast( filter( instanceOf( Activation.class ), serviceReferences ) );
-        activation.activate( ActivatorsInstance.EMPTY, activatees );
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        activation.passivate();
-    }
-
-    public Iterable<ServiceReference> visibleServices( final Visibility visibility )
-    {
-        return Iterables.filter( new Specification<ServiceReference>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference item )
-            {
-                return ( (ServiceReferenceInstance) item ).serviceDescriptor()
-                           .visibility()
-                           .ordinal() >= visibility.ordinal();
-            }
-        }, serviceReferences );
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder( "Services{" );
-        String sep = " ";
-        for( ServiceReference serviceReference : serviceReferences )
-        {
-            sb.append( sep ).
-                append( serviceReference.identity() ).
-                append( "(active=" ).append( serviceReference.isActive() ).append( ")" );
-            sep = ", ";
-        }
-        return sb.append( " }" ).toString();
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
deleted file mode 100644
index ee8b46e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.service;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * JAVADOC
- */
-public class ServicesModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final Iterable<ServiceModel> serviceModels;
-
-    public ServicesModel( Iterable<ServiceModel> serviceModels )
-    {
-        this.serviceModels = serviceModels;
-    }
-
-    public ServicesInstance newInstance( ModuleInstance module )
-    {
-        List<ServiceReference> serviceReferences = new ArrayList<ServiceReference>();
-        for( ServiceModel serviceModel : serviceModels )
-        {
-            ServiceReferenceInstance serviceReferenceInstance = new ServiceReferenceInstance( serviceModel, module );
-            serviceReferences.add( serviceReferenceInstance );
-        }
-
-        return new ServicesInstance( this, serviceReferences );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ServiceModel serviceModel : serviceModels )
-            {
-                if( !serviceModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
deleted file mode 100644
index cd739e0..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Niclas Hedhman.
- *
- * 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.zest.runtime.structure;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.bootstrap.Qi4jRuntime;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-
-/**
- * Instance of a Zest application. Contains a list of layers which are managed by this application
- */
-public class ApplicationInstance
-    implements Application
-{
-
-    // Constructor parameters
-    private final ApplicationModel applicationModel;
-    private final Qi4jRuntime runtime;
-    private final MetaInfo instanceMetaInfo;
-    // Eager instance objects
-    private final ActivationDelegate activation;
-    private final List<LayerInstance> layerInstances;
-
-    public ApplicationInstance( ApplicationModel model, Qi4jRuntime runtime, MetaInfo instanceMetaInfo )
-    {
-        // Constructor parameters
-        this.applicationModel = model;
-        this.runtime = runtime;
-        this.instanceMetaInfo = instanceMetaInfo;
-
-        // Eager instance objects
-        activation = new ActivationDelegate( this );
-        layerInstances = new ArrayList<>();
-    }
-
-    @Override
-    public String toString()
-    {
-        return name();
-    }
-
-    // Implementation of Application
-    @Override
-    public String name()
-    {
-        return applicationModel.name();
-    }
-
-    @Override
-    public String version()
-    {
-        return applicationModel.version();
-    }
-
-    @Override
-    public Mode mode()
-    {
-        return applicationModel.mode();
-    }
-
-    @Override
-    public Layer findLayer( String layerName )
-    {
-        for( LayerInstance layerInstance : layerInstances )
-        {
-            if( layerInstance.model().name().equals( layerName ) )
-            {
-                return layerInstance;
-            }
-        }
-
-        throw new IllegalArgumentException( "No such layer:" + layerName );
-    }
-
-    @Override
-    public Module findModule( String layerName, String moduleName )
-    {
-        for( LayerInstance layerInstance : layerInstances )
-        {
-            if( layerInstance.model().name().equals( layerName ) )
-            {
-                return layerInstance.findModule( moduleName );
-            }
-        }
-
-        throw new IllegalArgumentException( "No such layer:" + layerName );
-    }
-
-    @Override
-    public ApplicationDescriptor descriptor()
-    {
-        return applicationModel;
-    }
-
-    // Implementation of MetaInfoHolder
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return instanceMetaInfo.get( infoType );
-    }
-
-    // Implementation of Activation
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        activation.activate( applicationModel.newActivatorsInstance(), layerInstances );
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        activation.passivate();
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-
-    // Other methods
-    /* package */ void addLayer( LayerInstance layer )
-    {
-        layer.registerActivationEventListener( activation );
-        layerInstances.add( layer );
-    }
-
-    public Qi4jRuntime runtime()
-    {
-        return runtime;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
deleted file mode 100644
index a5e9d5b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.structure;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.Qi4jRuntime;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.injection.provider.InjectionProviderFactoryStrategy;
-
-/**
- * JAVADOC
- */
-public final class ApplicationModel
-    implements ApplicationDescriptor
-{
-    private final String name;
-    private final String version;
-    private final Application.Mode mode;
-    private final MetaInfo metaInfo;
-    private final ActivatorsModel<Application> activatorsModel;
-    private final List<LayerModel> layers;
-    private final InjectionProviderFactory ipf;
-
-    public ApplicationModel( String name,
-                             String version,
-                             Application.Mode mode,
-                             MetaInfo metaInfo,
-                             ActivatorsModel<Application> activatorsModel,
-                             List<LayerModel> layers
-    )
-    {
-        this.name = name;
-        this.version = version;
-        this.mode = mode;
-        this.metaInfo = metaInfo;
-        this.activatorsModel = activatorsModel;
-        this.layers = layers;
-        ipf = new InjectionProviderFactoryStrategy( metaInfo );
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public String version()
-    {
-        return version;
-    }
-
-    public Application.Mode mode()
-    {
-        return mode;
-    }
-
-    public MetaInfo metaInfo()
-    {
-        return metaInfo;
-    }
-
-    public ActivatorsInstance<Application> newActivatorsInstance()
-        throws ActivationException
-    {
-        return new ActivatorsInstance<>( activatorsModel.newInstances() );
-    }
-
-    // SPI
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( activatorsModel.accept( visitor ) )
-            {
-                for( LayerModel layer : layers )
-                {
-                    if( !layer.accept( visitor ) )
-                    {
-                        break;
-                    }
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    @Override
-    public ApplicationInstance newInstance( Qi4j runtime, Object... importedServiceInstances )
-        throws InvalidApplicationException
-    {
-        MetaInfo instanceMetaInfo = new MetaInfo( metaInfo );
-        for( Object importedServiceInstance : importedServiceInstances )
-        {
-            instanceMetaInfo.set( importedServiceInstance );
-        }
-
-        ApplicationInstance applicationInstance = new ApplicationInstance( this, (Qi4jRuntime) runtime, instanceMetaInfo );
-
-        // Create layer instances
-        Map<LayerModel, LayerInstance> layerInstanceMap = new HashMap<>();
-        Map<LayerModel, List<LayerInstance>> usedLayers = new HashMap<>();
-        for( LayerModel layer : layers )
-        {
-            List<LayerInstance> usedLayerInstances = new ArrayList<>();
-            usedLayers.put( layer, usedLayerInstances );
-            UsedLayersInstance usedLayersInstance = layer.usedLayers().newInstance( usedLayerInstances );
-            LayerInstance layerInstance = layer.newInstance( applicationInstance, usedLayersInstance );
-            applicationInstance.addLayer( layerInstance );
-            layerInstanceMap.put( layer, layerInstance );
-        }
-
-        // Resolve used layer instances
-        for( LayerModel layer : layers )
-        {
-            List<LayerInstance> usedLayerInstances = usedLayers.get( layer );
-            for( LayerModel usedLayer : layer.usedLayers().layers() )
-            {
-                LayerInstance layerInstance = layerInstanceMap.get( usedLayer );
-                if( layerInstance == null )
-                {
-                    throw new InvalidApplicationException( "Could not find used layer:" + usedLayer.name() );
-                }
-                usedLayerInstances.add( layerInstance );
-            }
-        }
-
-        return applicationInstance;
-    }
-
-    public InjectionProviderFactory injectionProviderFactory()
-    {
-        return ipf;
-    }
-
-    @Override
-    public String toString()
-    {
-        final StringBuilder sb = new StringBuilder();
-        sb.append( "ApplicationModel" );
-        sb.append( "{name='" ).append( name ).append( '\'' );
-        sb.append( ", version='" ).append( version ).append( '\'' );
-        sb.append( ", mode=" ).append( mode );
-        sb.append( '}' );
-        return sb.toString();
-    }
-}


[44/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationFunction.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationFunction.java
deleted file mode 100644
index d60468e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationFunction.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2011-2012 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.functional.Function;
-
-/**
- * Function to get Entity NamedAssociations.
- */
-public class NamedAssociationFunction<T>
-    implements Function<Composite, NamedAssociation<T>>
-{
-    private final AssociationFunction<?> traversedAssociation;
-    private final ManyAssociationFunction<?> traversedManyAssociation;
-    private final NamedAssociationFunction<?> traversedNamedAssociation;
-    private final AccessibleObject accessor;
-
-    public NamedAssociationFunction( AssociationFunction<?> traversedAssociation,
-                                     ManyAssociationFunction<?> traversedManyAssociation,
-                                     NamedAssociationFunction<?> traversedNamedAssociation,
-                                     AccessibleObject accessor
-    )
-    {
-        this.traversedAssociation = traversedAssociation;
-        this.traversedManyAssociation = traversedManyAssociation;
-        this.traversedNamedAssociation = traversedNamedAssociation;
-        this.accessor = accessor;
-    }
-
-    public AssociationFunction<?> traversedAssociation()
-    {
-        return traversedAssociation;
-    }
-
-    public ManyAssociationFunction<?> traversedManyAssociation()
-    {
-        return traversedManyAssociation;
-    }
-
-    public NamedAssociationFunction<?> traversedNamedAssociation()
-    {
-        return traversedNamedAssociation;
-    }
-
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public NamedAssociation<T> map( Composite entity )
-    {
-        try
-        {
-            Object target = entity;
-            if( traversedAssociation != null )
-            {
-                target = traversedAssociation.map( entity ).get();
-            }
-            if( traversedManyAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot traverse ManyAssociations" );
-            }
-            if( traversedNamedAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot traverse NamedAssociations" );
-            }
-
-            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
-            return ( (AssociationStateHolder) handler.state() ).namedAssociationFor( accessor );
-        }
-        catch( IllegalArgumentException e )
-        {
-            throw e;
-        }
-        catch( Throwable e )
-        {
-            throw new IllegalArgumentException( e );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        if( traversedAssociation != null )
-        {
-            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
-        }
-        else
-        {
-            return ( (Member) accessor ).getName();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
deleted file mode 100644
index 42b26c7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NeSpecification.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Not equals Specification.
- */
-public class NeSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public NeSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    protected boolean compare( T value )
-    {
-        return !value.equals( this.value );
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "!=" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
deleted file mode 100644
index 046db37..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NotSpecification.java
+++ /dev/null
@@ -1,53 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * NOT Specification.
- */
-public class NotSpecification implements Specification<Composite>
-{
-    private Specification<Composite> operand;
-
-    public NotSpecification( Specification<Composite> operand )
-    {
-        this.operand = operand;
-    }
-
-    public Specification<Composite> operand()
-    {
-        return operand;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        return Specifications.not( operand ).satisfiedBy( item );
-    }
-
-    @Override
-    public String toString()
-    {
-        return "!" + operand.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
deleted file mode 100644
index 1daa1ad..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrSpecification.java
+++ /dev/null
@@ -1,56 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * OR Specification.
- */
-public class OrSpecification
-    extends BinarySpecification
-{
-
-    public OrSpecification( Iterable<Specification<Composite>> operands )
-    {
-        super( operands );
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        return Specifications.or( operands ).satisfiedBy( item );
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder( "(" );
-        String or = "";
-        for( Specification<Composite> operand : operands )
-        {
-            sb.append( or ).append( operand );
-            or = " or ";
-        }
-        return sb.append( ")" ).toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/OrderBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrderBy.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/OrderBy.java
deleted file mode 100644
index 4fac4d4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/OrderBy.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2007 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.api.query.grammar;
-
-/**
- * Query sorting segment.
- */
-public class OrderBy
-{
-    /**
-     * Order direction.
-     */
-    public enum Order
-    {
-        ASCENDING, DESCENDING
-    }
-
-    /**
-     * Order.
-     */
-    private final PropertyFunction<?> propertyReference;
-    /**
-     * Direction.
-     */
-    private final Order order;
-
-    /**
-     * Constructor.
-     *
-     * @param propertyReference property that determines the order; cannot be null
-     * @param order             direction
-     *
-     * @throws IllegalArgumentException - If property is null
-     */
-    public OrderBy( final PropertyFunction<?> propertyReference,
-                    final Order order
-    )
-    {
-        if( propertyReference == null )
-        {
-            throw new IllegalArgumentException( "Ordering property cannot be null" );
-        }
-        this.propertyReference = propertyReference;
-        this.order = order;
-    }
-
-    /**
-     * Getter.
-     *
-     * @return property; cannot be null
-     */
-    public PropertyFunction<?> property()
-    {
-        return propertyReference;
-    }
-
-    /**
-     * Getter.
-     *
-     * @return direction; cannot be null
-     */
-    public Order order()
-    {
-        return order;
-    }
-
-    @Override
-    public String toString()
-    {
-        return new StringBuilder()
-            .append( propertyReference )
-            .append( " " )
-            .append( order )
-            .toString();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyFunction.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyFunction.java
deleted file mode 100644
index 7b6db53..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyFunction.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.NotQueryableException;
-import org.apache.zest.api.query.QueryExpressionException;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.Function;
-
-import static org.apache.zest.api.util.Classes.typeOf;
-
-/**
- * Function to get Entity Properties.
- */
-public class PropertyFunction<T>
-    implements Function<Composite, Property<T>>
-{
-    private final PropertyFunction<?> traversedProperty;
-    private final AssociationFunction<?> traversedAssociation;
-    private final ManyAssociationFunction<?> traversedManyAssociation;
-    private final NamedAssociationFunction<?> traversedNamedAssociation;
-    private final AccessibleObject accessor;
-
-    public PropertyFunction( PropertyFunction<?> traversedProperty,
-                             AssociationFunction<?> traversedAssociation,
-                             ManyAssociationFunction<?> traversedManyAssociation,
-                             NamedAssociationFunction<?> traversedNamedAssociation,
-                             AccessibleObject accessor
-    )
-    {
-        this.traversedProperty = traversedProperty;
-        this.traversedAssociation = traversedAssociation;
-        this.traversedManyAssociation = traversedManyAssociation;
-        this.traversedNamedAssociation = traversedNamedAssociation;
-        this.accessor = accessor;
-
-        // Verify that the property accessor is not marked as non queryable
-        NotQueryableException.throwIfNotQueryable( accessor );
-        // Verify that the property type itself (value composites) is not marked as non queryable
-
-        Type returnType = typeOf( accessor );
-        if( !Property.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) ) )
-        {
-            throw new QueryExpressionException( "Not a property type:" + returnType );
-        }
-        Type propertyTypeAsType = GenericPropertyInfo.toPropertyType( returnType );
-        if( propertyTypeAsType instanceof ParameterizedType )
-        {
-            propertyTypeAsType = ( (ParameterizedType) propertyTypeAsType ).getRawType();
-        }
-
-        if( !( propertyTypeAsType instanceof Class ) )
-        {
-            throw new QueryExpressionException( "Unsupported property type:" + propertyTypeAsType );
-        }
-        @SuppressWarnings( "unchecked" )
-        Class<T> type = (Class<T>) propertyTypeAsType;
-        NotQueryableException.throwIfNotQueryable( type );
-    }
-
-    public PropertyFunction<?> traversedProperty()
-    {
-        return traversedProperty;
-    }
-
-    public AssociationFunction<?> traversedAssociation()
-    {
-        return traversedAssociation;
-    }
-
-    public ManyAssociationFunction<?> traversedManyAssociation()
-    {
-        return traversedManyAssociation;
-    }
-
-    public NamedAssociationFunction<?> traversedNamedAssociation()
-    {
-        return traversedNamedAssociation;
-    }
-
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public Property<T> map( Composite entity )
-    {
-        try
-        {
-            Object target = entity;
-            if( traversedProperty != null )
-            {
-                Property<?> property = traversedProperty.map( entity );
-                if( property == null )
-                {
-                    return null;
-                }
-                target = property.get();
-            }
-            else if( traversedAssociation != null )
-            {
-                Association<?> association = traversedAssociation.map( entity );
-                if( association == null )
-                {
-                    return null;
-                }
-                target = association.get();
-            }
-            else if( traversedManyAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );
-            }
-            else if( traversedNamedAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot evaluate a NamedAssociation" );
-            }
-
-            if( target == null )
-            {
-                return null;
-            }
-
-            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
-            return handler.state().propertyFor( accessor );
-        }
-        catch( IllegalArgumentException e )
-        {
-            throw e;
-        }
-        catch( Throwable e )
-        {
-            throw new IllegalArgumentException( e );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        if( traversedProperty != null )
-        {
-            return traversedProperty.toString() + "." + ( (Member) accessor ).getName();
-        }
-        else if( traversedAssociation != null )
-        {
-            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
-        }
-        else
-        {
-            return ( (Member) accessor ).getName();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
deleted file mode 100644
index c140542..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNotNullSpecification.java
+++ /dev/null
@@ -1,60 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Property not null Specification.
- */
-public class PropertyNotNullSpecification<T>
-    extends ExpressionSpecification
-{
-    private PropertyFunction<T> property;
-
-    public PropertyNotNullSpecification( PropertyFunction<T> property )
-    {
-        this.property = property;
-    }
-
-    public PropertyFunction<T> property()
-    {
-        return property;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        Property<T> prop = property.map( item );
-
-        if( prop == null )
-        {
-            return false;
-        }
-
-        return prop.get() != null;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "is not null";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
deleted file mode 100644
index b0acfa7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyNullSpecification.java
+++ /dev/null
@@ -1,60 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Property null Specification.
- */
-public class PropertyNullSpecification<T>
-    extends ExpressionSpecification
-{
-    private PropertyFunction<T> property;
-
-    public PropertyNullSpecification( PropertyFunction<T> property )
-    {
-        this.property = property;
-    }
-
-    public PropertyFunction<T> property()
-    {
-        return property;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        Property<T> prop = property.map( item );
-
-        if( prop == null )
-        {
-            return true;
-        }
-
-        return prop.get() == null;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "is null";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyReference.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyReference.java
deleted file mode 100644
index 4b30a56..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/PropertyReference.java
+++ /dev/null
@@ -1,31 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.functional.Function;
-
-/**
- * Property Reference.
- */
-public interface PropertyReference
-{
-    <T> Function<Composite, Property<T>> reference();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
deleted file mode 100644
index a0ce311..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/QuerySpecification.java
+++ /dev/null
@@ -1,71 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-
-/**
- * This should be used when doing native queries, such as SQL, SPARQL or similar. EntityFinders can choose
- * what type of query languages they can understand by checking the language property of a QuerySpecification
- */
-public class QuerySpecification
-    implements Specification<Composite>
-{
-    public static boolean isQueryLanguage( String language, Specification<Composite> specification )
-    {
-        if( !( specification instanceof QuerySpecification ) )
-        {
-            return false;
-        }
-
-        return ( (QuerySpecification) specification ).language().equals( language );
-    }
-
-    private String language;
-    private String query;
-
-    public QuerySpecification( String language, String query )
-    {
-        this.language = language;
-        this.query = query;
-    }
-
-    public String language()
-    {
-        return language;
-    }
-
-    public String query()
-    {
-        return query;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        return false;
-    }
-
-    @Override
-    public String toString()
-    {
-        return language + ":" + query;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/Variable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/Variable.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/Variable.java
deleted file mode 100644
index 0255d52..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/Variable.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Query Variable name.
- */
-public class Variable
-{
-    private String name;
-
-    public Variable( String name )
-    {
-        this.name = name;
-    }
-
-    public String variableName()
-    {
-        return name;
-    }
-
-    @Override
-    public String toString()
-    {
-        return name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/package.html b/core/api/src/main/java/org/apache/zest/api/query/grammar/package.html
deleted file mode 100644
index e0b80f6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Query Grammar.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/package.html b/core/api/src/main/java/org/apache/zest/api/query/package.html
deleted file mode 100644
index 27e4455..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Query API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/Availability.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/Availability.java b/core/api/src/main/java/org/apache/zest/api/service/Availability.java
deleted file mode 100644
index b1b7d25..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/Availability.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.api.service;
-
-/**
- * Services can implement this interface in order to allow Zest to ask
- * it whether it is currently available for use or not. This is accessed
- * by clients through the ServiceReference of the service. Services that do not
- * implement this are always considered to be available.
- */
-public interface Availability
-{
-    /**
-     * Implementations should return true if the underlying service is currently available for use.
-     *
-     * Reasons why a service might not be available is either if it has been configured not to be (see
-     * the Enabled interface), or if an underlying resource is currently unavailable.
-     *
-     * @return true if the service is available, false otherwise.
-     */
-    boolean isAvailable();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java b/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java
deleted file mode 100644
index 54b663b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-
-/**
- * Thrown when a duplicate service identity is detected.
- */
-public class DuplicateServiceIdentityException
-    extends InvalidApplicationException
-{
-    public DuplicateServiceIdentityException( String string )
-    {
-        super( string );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java
deleted file mode 100644
index 5539a60..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java
+++ /dev/null
@@ -1,27 +0,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.
- */
-package org.apache.zest.api.service;
-
-/**
- * Identity Descriptor.
- */
-public interface IdentityDescriptor
-{
-    String identity();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java
deleted file mode 100644
index 95270da..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.service;
-
-import org.apache.zest.api.composite.ModelDescriptor;
-
-/**
- * {@code ServiceDescriptor} provides meta information of a service.
- */
-public interface ImportedServiceDescriptor
-    extends ModelDescriptor, IdentityDescriptor
-{
-    Class<? extends ServiceImporter> serviceImporter();
-
-    Class<?> type();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/NoSuchServiceException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/NoSuchServiceException.java b/core/api/src/main/java/org/apache/zest/api/service/NoSuchServiceException.java
deleted file mode 100644
index cee08a3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/NoSuchServiceException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.service;
-
-import org.apache.zest.api.composite.NoSuchCompositeException;
-
-/**
- * Thrown when no visible service of the requested type is found.
- */
-public class NoSuchServiceException extends NoSuchCompositeException
-{
-    public NoSuchServiceException( String typeName, String moduleName )
-    {
-        super( "ServiceComposite", typeName, moduleName );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceActivation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceActivation.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceActivation.java
deleted file mode 100644
index 0ef3260..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceActivation.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.api.service;
-
-import org.apache.zest.api.activation.Activators;
-
-/**
- * Convenience interface for simple Service Activation.
- *
- * Let your ServiceComposite extends ServiceActivation and implement it in one of its Mixins.
- * A corresponding Activator is automatically registered.
- */
-@Activators( ServiceActivation.ServiceActivator.class )
-public interface ServiceActivation
-{
-
-    /**
-     * Called after ServiceComposite Activation.
-     */
-    void activateService()
-        throws Exception;
-
-    /**
-     * Called before ServiceComposite Passivation.
-     */
-    void passivateService()
-        throws Exception;
-
-    /**
-     * Service Activator.
-     */
-    class ServiceActivator
-        extends ServiceActivatorAdapter<ServiceActivation>
-    {
-
-        @Override
-        public void afterActivation( ServiceReference<ServiceActivation> activated )
-            throws Exception
-        {
-            activated.get().activateService();
-        }
-
-        @Override
-        public void beforePassivation( ServiceReference<ServiceActivation> passivating )
-            throws Exception
-        {
-            passivating.get().passivateService();
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceActivatorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceActivatorAdapter.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceActivatorAdapter.java
deleted file mode 100644
index a2ee7a7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceActivatorAdapter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.api.service;
-
-import org.apache.zest.api.activation.Activator;
-
-/**
- * Adapter for Service Activator.
- *
- * @param <ServiceType> Type of the service.
- */
-public class ServiceActivatorAdapter<ServiceType>
-    implements Activator<ServiceReference<ServiceType>>
-{
-    /**
-     * Called before Service activation.
-     * @param activating Activating Service
-     */
-    @Override
-    public void beforeActivation( ServiceReference<ServiceType> activating )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called after Service activation.
-     * @param activated Activated Service
-     */
-    @Override
-    public void afterActivation( ServiceReference<ServiceType> activated )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called before Service passivation.
-     * @param passivating Passivating Service
-     */
-    @Override
-    public void beforePassivation( ServiceReference<ServiceType> passivating )
-        throws Exception
-    {
-    }
-
-    /**
-     * Called after Service passivation.
-     * @param passivated Passivated Service
-     */
-    @Override
-    public void afterPassivation( ServiceReference<ServiceType> passivated )
-        throws Exception
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java
deleted file mode 100644
index 6a40250..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.service;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.Identity;
-
-/**
- * All Composites being used to implement Services
- * must extend this interface.
- */
-public interface ServiceComposite
-    extends Identity, Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java
deleted file mode 100644
index 98cfd89..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.service;
-
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.StatefulCompositeDescriptor;
-
-/**
- * {@code ServiceDescriptor} provides meta informations of a service.
- */
-public interface ServiceDescriptor
-    extends CompositeDescriptor, IdentityDescriptor, StatefulCompositeDescriptor
-{
-    boolean isInstantiateOnStartup();
-
-    <T> Class<T> configurationType();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceFinder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceFinder.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceFinder.java
deleted file mode 100644
index 5f9be65..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceFinder.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service;
-
-import java.lang.reflect.Type;
-
-/**
- * Interface used to query for ServiceReferences.
- * <p>
- * Each ServiceFinder is
- * obtained from a specific Module, and the lookup rules are the following:
- * </p>
- * <ol>
- * <li>First look in the same Module as the ServiceFinder</li>
- * <li>Then look in the same Layer as the ServiceFinder. Any Services declared
- * with Visibility Layer and Application should be included</li>
- * <li>Then look in the used Layers. Any Services declared with Visibility Application
- * should be included</li>
- * </ol>
- * <p>
- * Both native Zest services and imported services are considered, with preference to native services.
- * </p>
- */
-public interface ServiceFinder
-{
-    /**
-     * Find a ServiceReference that implements the given type.
-     *
-     * @param serviceType the type that the Service must implement
-     *
-     * @return a ServiceReference if one is found
-     *
-     * @throws NoSuchServiceException if no service of serviceType is found
-     */
-    <T> ServiceReference<T> findService( Class<T> serviceType )
-        throws NoSuchServiceException;
-
-    /**
-     * Find a ServiceReference that implements the given type.
-     *
-     * @param serviceType the type that the Service must implement
-     *
-     * @return a ServiceReference if one is found
-     *
-     * @throws NoSuchServiceException if no service of serviceType is found
-     */
-    <T> ServiceReference<T> findService( Type serviceType )
-        throws NoSuchServiceException;
-
-    /**
-     * Find ServiceReferences that implements the given type.
-     * <p>
-     * The order of the references is such that Services more local to the querying
-     * Module is earlier in the list.
-     * </p>
-     *
-     * @param serviceType the type that the Services must implement
-     *
-     * @return an iterable of ServiceReferences for the given type. It is empty if none exist
-     */
-    <T> Iterable<ServiceReference<T>> findServices( Class<T> serviceType );
-
-    /**
-     * Find ServiceReferences that implements the given type.
-     * <p>
-     * The order of the references is such that Services more local to the querying
-     * Module is earlier in the list.
-     * </p>
-     *
-     * @param serviceType the type that the Services must implement
-     *
-     * @return an iterable of ServiceReferences for the given type. It is empty if none exist
-     */
-    <T> Iterable<ServiceReference<T>> findServices( Type serviceType );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceImporter.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceImporter.java
deleted file mode 100644
index c6b5bc3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceImporter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.service;
-
-/**
- * Import a service from some external source.
- */
-public interface ServiceImporter<T>
-{
-    /**
-     * Imports an instance of the service type described in the service descriptor.
-     *
-     * @param serviceDescriptor The service descriptor.
-     *
-     * @return The imported service instance.
-     *
-     * @throws ServiceImporterException if import failed.
-     */
-    T importService( ImportedServiceDescriptor serviceDescriptor )
-        throws ServiceImporterException;
-
-    /**
-     * Ask if the service is available or not.
-     *
-     * @param instance the instance to be checked
-     *
-     * @return true if the service is available, false if not
-     */
-    boolean isAvailable( T instance );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceImporterException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceImporterException.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceImporterException.java
deleted file mode 100644
index 116404b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceImporterException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.service;
-
-/**
- * If a ServiceImporter could not import a service
- * instance it must throw this exception.
- */
-public class ServiceImporterException
-    extends RuntimeException
-{
-    public ServiceImporterException()
-    {
-    }
-
-    public ServiceImporterException( String string )
-    {
-        super( string );
-    }
-
-    public ServiceImporterException( String string, Throwable throwable )
-    {
-        super( string, throwable );
-    }
-
-    public ServiceImporterException( Throwable throwable )
-    {
-        super( throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
deleted file mode 100644
index dd17618..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service;
-
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * From a ServiceReference you can access and modify metadata about a service.
- * You can also access the actual service through get(), that can then be invoked.
- */
-public interface ServiceReference<T>
-    extends HasTypes, ActivationEventListenerRegistration, MetaInfoHolder
-{
-    /**
-     * @return the service's identity
-     */
-    String identity();
-
-    /**
-     * @return the actual service
-     */
-    T get();
-
-    /**
-     * @return TRUE if the service is active, otherwise return FALSE
-     */
-    boolean isActive();
-
-    /**
-     * @return TRUE if the service is available, otherwise return FALSE
-     */
-    boolean isAvailable();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/ServiceUnavailableException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceUnavailableException.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceUnavailableException.java
deleted file mode 100644
index c5ba3fd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceUnavailableException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman.
- *
- * 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.zest.api.service;
-
-/**
- * Thrown when no available service is found.
- */
-public class ServiceUnavailableException
-    extends RuntimeException
-{
-    public ServiceUnavailableException( String message )
-    {
-        super( message );
-    }
-
-    public ServiceUnavailableException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/importer/InstanceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/InstanceImporter.java b/core/api/src/main/java/org/apache/zest/api/service/importer/InstanceImporter.java
deleted file mode 100644
index 35e0bd0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/InstanceImporter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service.importer;
-
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Specifications.notNull;
-
-/**
- * Return a predefined service instance that was provided as meta-info. Search for meta-info in the following order:
- * the service itself, the module of the service, the layer of the service, the whole application.
- */
-public final class InstanceImporter<T>
-    implements ServiceImporter<T>
-{
-    @Structure
-    private Application application;
-
-    @Structure
-    private Layer layer;
-
-    @Structure
-    private Module module;
-
-    @Override
-    public T importService( final ImportedServiceDescriptor serviceDescriptor )
-        throws ServiceImporterException
-    {
-        T instance = null;
-        Iterable<MetaInfoHolder> holders = Iterables.iterable( serviceDescriptor, module, layer, application );
-        for( final MetaInfoHolder metaInfoHolder : holders )
-        {
-            Function<Class<?>, T> metaFinder = new Function<Class<?>, T>()
-            {
-                @Override
-                @SuppressWarnings( "unchecked" )
-                public T map( Class<?> type )
-                {
-                    return (T) metaInfoHolder.metaInfo( type );
-                }
-            };
-            instance = first( filter( notNull(), map( metaFinder, serviceDescriptor.types() ) ) );
-            if( instance != null )
-            {
-                break;
-            }
-        }
-        return instance;
-    }
-
-    @Override
-    public boolean isAvailable( T instance )
-    {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/importer/NewObjectImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/NewObjectImporter.java b/core/api/src/main/java/org/apache/zest/api/service/importer/NewObjectImporter.java
deleted file mode 100644
index 55df2c0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/NewObjectImporter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.importer;
-
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.object.ObjectFactory;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.functional.Iterables;
-
-/**
- * Import Services using a new registered Object instance.
- */
-public final class NewObjectImporter<T>
-    implements ServiceImporter<T>
-{
-    @Structure
-    private ObjectFactory obf;
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public T importService( ImportedServiceDescriptor serviceDescriptor )
-        throws ServiceImporterException
-    {
-        return obf.newObject( (Class<T>) Iterables.first( serviceDescriptor.types() ) );
-    }
-
-    @Override
-    public boolean isAvailable( T instance )
-    {
-        return true;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceInstanceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceInstanceImporter.java b/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceInstanceImporter.java
deleted file mode 100644
index 5a497e6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceInstanceImporter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.api.service.importer;
-
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.service.ServiceReference;
-
-/**
- * Use a registered service that implements ServiceImporter to do the actual
- * import. The service id of the service that this importer should delegate to must
- * be set as meta-info on this service. Example:
- * <pre><code>
- * module.services(MyServiceImporterService.class).identifiedBy("someid");
- * module.importedServices(OtherService.class).importedBy(ServiceInstanceImporter.class).setMetaInfo("someid");
- * </code></pre>
- */
-public class ServiceInstanceImporter<T>
-    implements ServiceImporter<T>
-{
-    @Structure
-    ServiceFinder finder;
-
-    ServiceImporter<T> service;
-
-    String serviceId;
-
-    @Override
-    public T importService( ImportedServiceDescriptor importedServiceDescriptor )
-        throws ServiceImporterException
-    {
-        serviceId = importedServiceDescriptor.metaInfo( String.class );
-
-        return serviceImporter().importService( importedServiceDescriptor );
-    }
-
-    @Override
-    public boolean isAvailable( T instance )
-    {
-        return serviceImporter().isAvailable( instance );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    private ServiceImporter<T> serviceImporter()
-    {
-        if( service == null )
-        {
-            for( ServiceReference<ServiceImporter> reference : finder.<ServiceImporter>findServices( ServiceImporter.class ) )
-            {
-                if( reference.identity().equals( serviceId ) )
-                {
-                    service = reference.get();
-                    break;
-                }
-            }
-        }
-
-        if( service == null )
-        {
-            throw new ServiceImporterException( "No service importer with id '" + serviceId + "' was found" );
-        }
-
-        return service;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java b/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
deleted file mode 100644
index c1ced8c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/ServiceSelectorImporter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service.importer;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.Availability;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.qualifier.ServiceQualifier;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-/**
- * If several services are available with a given type, and you want to constrain
- * the current module to use a specific one, then use this importer. Specify a
- * Specification&lt;ServiceReference&lt;T&gt;&gt; criteria as meta-info for the service, which will be applied
- * to the list of available services, and the first match will be chosen.
- *
- * This importer will avoid selecting itself, as could be possible if the ServiceQualifier.first()
- * filter is used.
- */
-public final class ServiceSelectorImporter<T>
-    implements ServiceImporter<T>
-{
-    @Structure
-    private ServiceFinder locator;
-
-    @Override
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public T importService( ImportedServiceDescriptor serviceDescriptor )
-        throws ServiceImporterException
-    {
-        Specification<ServiceReference<?>> selector = serviceDescriptor.metaInfo( Specification.class );
-        Class serviceType = Iterables.first( serviceDescriptor.types() );
-        Iterable<ServiceReference<T>> services = locator.findServices( serviceType );
-        List<ServiceReference<T>> filteredServices = new ArrayList<>();
-        for( ServiceReference<T> service : services )
-        {
-            Specification selector1 = service.metaInfo( Specification.class );
-            if( selector1 != null && selector1 == selector )
-            {
-                continue;
-            }
-
-            filteredServices.add( service );
-        }
-        T service = ServiceQualifier.firstService( selector, filteredServices );
-        if( service == null )
-        {
-            throw new ServiceImporterException( "Could not find any service to import that matches the given specification for " + serviceDescriptor
-                .identity() );
-        }
-        return service;
-    }
-
-    @Override
-    public boolean isAvailable( T instance )
-    {
-        return !( instance instanceof Availability ) || ( (Availability) instance ).isAvailable();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/importer/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/importer/package.html b/core/api/src/main/java/org/apache/zest/api/service/importer/package.html
deleted file mode 100644
index d960b3d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/importer/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Service Importers.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/package.html b/core/api/src/main/java/org/apache/zest/api/service/package.html
deleted file mode 100644
index 587937c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Service API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
deleted file mode 100644
index c961eb9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Active.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Filter services based on whether they are active or not.
- * <p>
- * At an injection point you can do this:
- * </p>
- * <pre><code>
- * &#64;Service &#64;Active MyService service;
- * </code></pre>
- * <p>
- * to get only a service that is currently active.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Qualifier( Active.ActiveQualifier.class )
-public @interface Active
-{
-    /**
-     * Active Annotation Qualifier.
-     * See {@link Active}.
-     */
-    public final class ActiveQualifier
-        implements AnnotationQualifier<Active>
-    {
-        @Override
-        public <T> Specification<ServiceReference<?>> qualifier( Active active )
-        {
-            return ServiceQualifier.whereActive();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
deleted file mode 100644
index 38e45c5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/AnnotationQualifier.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Annotation;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Constructs a Specification for a given qualifier annotation
- */
-public interface AnnotationQualifier<QUALIFIER extends Annotation>
-{
-    public <T> Specification<ServiceReference<?>> qualifier( QUALIFIER qualifier );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
deleted file mode 100644
index 6638061..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Available.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Filter services based on whether they are available or not.
- *
- * At an injection point you can do this:
- *
- * <pre><code>
- * &#64;Service &#64;Available MyService service;
- * </code></pre>
- * to get only a service that is currently available.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Qualifier( Available.AvailableQualifier.class )
-public @interface Available
-{
-    /**
-     * Available Annotation Qualifier.
-     * See {@link Available}.
-     */
-    public final class AvailableQualifier
-        implements AnnotationQualifier<Available>
-    {
-        @Override
-        public <T> Specification<ServiceReference<?>> qualifier( Available active )
-        {
-            return ServiceQualifier.whereAvailable();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
deleted file mode 100644
index 887e5a7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/HasMetaInfo.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2009, Niclas Hedhman. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Filter services based on Meta Info being declared on the Service.
- * <p>
- * Meta Info of any type can be set on the service during assembly, e.g.;
- * </p>
- * <pre><code>
- * module.addService( MyService.class ).setMetaInfo( new MyCustomInfo(someData) );
- * </code></pre>
- * <p>
- * and then at an injection point you can do this:
- * </p>
- * <pre><code>
- * &#64;Service &#64;HasMetaInfo(MyCustomInfo.class) MyService service;
- * </code></pre>
- * <p>
- * to get only a service that has a MyCustomInfo instance set as meta info.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Qualifier( HasMetaInfo.HasMetaInfoQualifier.class )
-@Documented
-public @interface HasMetaInfo
-{
-    /**
-     * The Class(es) needed to have been defined in the Service meta info for a qualifier to evaluate true.
-     *
-     * @return One or more classes that should be defined in the service's meta info for the service to be considered
-     *         qualified. If more than one class is defined, the {@code anded()} parameter will define if they must be
-     *         AND'ed or OR'ed together.
-     */
-    Class[] value();
-
-    /**
-     * True if the Classes defined in the value() field should be AND'ed instead of OR'ed.
-     *
-     * @return If true, all the Class types defined in {@code value()} must be defined for the service for it to be
-     *         qualified. If false, if any of the Class types defined in {@code value()} is defined for the service
-     *         the service is qualified.
-     */
-    boolean anded() default false;
-
-    /**
-     * HasMetaInfo Annotation Qualifier.
-     * See {@link HasMetaInfo}.
-     */
-    public static class HasMetaInfoQualifier
-        implements AnnotationQualifier<HasMetaInfo>
-    {
-        @Override
-        public <T> Specification<ServiceReference<?>> qualifier( final HasMetaInfo hasMetaInfo )
-        {
-            return new Specification<ServiceReference<?>>()
-            {
-                @Override
-                @SuppressWarnings( {"raw", "unchecked"} )
-                public boolean satisfiedBy( ServiceReference<?> service )
-                {
-                    for( Class metaInfoType : hasMetaInfo.value() )
-                    {
-                        Object metaInfo = service.metaInfo( metaInfoType );
-                        if( hasMetaInfo.anded() )
-                        {
-                            if( metaInfo == null )
-                            {
-                                return false;
-                            }
-                        }
-                        else
-                        {
-                            if( metaInfo != null )
-                            {
-                                return true;
-                            }
-                        }
-                    }
-                    return false;
-                }
-            };
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
deleted file mode 100644
index 6f18f56..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/IdentifiedBy.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Filter services based on identity. Identity can be set during assembly, like so:
- * <pre><code>
- * module.addService(MyService.class).identifiedBy("myservice1");
- * </code></pre>
- *
- * and then at an injection point you can do this:
- * <pre><code>
- * &#64;Service @IdentifiedBy("myservice1") MyService service;
- * </code></pre>
- * to get only a service identified "myservice1".
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Qualifier( IdentifiedBy.IdentifiedByQualifier.class )
-public @interface IdentifiedBy
-{
-    public abstract String value();
-
-    /**
-     * IdentifiedBy Annotation Qualifier.
-     * See {@link IdentifiedBy}.
-     */
-    public final class IdentifiedByQualifier
-        implements AnnotationQualifier<IdentifiedBy>
-    {
-        @Override
-        public <T> Specification<ServiceReference<?>> qualifier( IdentifiedBy identifiedBy )
-        {
-            return ServiceQualifier.withId( identifiedBy.value() );
-        }
-    }
-}


[35/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/BinarySpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/BinarySpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/BinarySpecification.java
new file mode 100644
index 0000000..07c5d99
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/BinarySpecification.java
@@ -0,0 +1,41 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+
+/**
+ * Base binary Specification, used for AND and OR Specifications..
+ */
+public abstract class BinarySpecification
+    extends ExpressionSpecification
+{
+    protected final Iterable<Specification<Composite>> operands;
+
+    protected BinarySpecification( Iterable<Specification<Composite>> operands )
+    {
+        this.operands = operands;
+    }
+
+    public Iterable<Specification<Composite>> operands()
+    {
+        return operands;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ComparisonSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ComparisonSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ComparisonSpecification.java
new file mode 100644
index 0000000..f855054
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ComparisonSpecification.java
@@ -0,0 +1,76 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.property.Property;
+
+/**
+ * Base comparison Specification.
+ */
+public abstract class ComparisonSpecification<T>
+    extends ExpressionSpecification
+{
+    protected final PropertyFunction<T> property;
+    protected final T value;
+
+    public ComparisonSpecification( PropertyFunction<T> property, T value )
+    {
+        this.property = property;
+        this.value = value;
+    }
+
+    public PropertyFunction<T> property()
+    {
+        return property;
+    }
+
+    @Override
+    public final boolean satisfiedBy( Composite item )
+    {
+        try
+        {
+            Property<T> prop = property.map( item );
+
+            if( prop == null )
+            {
+                return false;
+            }
+
+            T propValue = prop.get();
+            if( propValue == null )
+            {
+                return false;
+            }
+
+            return compare( propValue );
+        }
+        catch( IllegalArgumentException e )
+        {
+            return false;
+        }
+    }
+
+    protected abstract boolean compare( T value );
+
+    public T value()
+    {
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsAllSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsAllSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsAllSpecification.java
new file mode 100644
index 0000000..7ff3e1b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsAllSpecification.java
@@ -0,0 +1,78 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import java.util.Collection;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Iterables;
+
+/**
+ * Contains All Specification.
+ */
+public class ContainsAllSpecification<T>
+    extends ExpressionSpecification
+{
+    private PropertyFunction<? extends Collection<T>> collectionProperty;
+    private Iterable<T> valueCollection;
+
+    public ContainsAllSpecification( PropertyFunction<? extends Collection<T>> collectionProperty,
+                                     Iterable<T> valueCollection
+    )
+    {
+        this.collectionProperty = collectionProperty;
+        this.valueCollection = valueCollection;
+    }
+
+    public PropertyFunction<? extends Collection<T>> collectionProperty()
+    {
+        return collectionProperty;
+    }
+
+    public Iterable<T> containedValues()
+    {
+        return valueCollection;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        Collection<T> collection = collectionProperty.map( item ).get();
+
+        if( collection == null )
+        {
+            return false;
+        }
+
+        for( T value : valueCollection )
+        {
+            if( !collection.contains( value ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        return collectionProperty + " contains " + Iterables.toList( valueCollection );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsSpecification.java
new file mode 100644
index 0000000..ea049de
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ContainsSpecification.java
@@ -0,0 +1,67 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import java.util.Collection;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * Contains Specification.
+ */
+public class ContainsSpecification<T>
+    extends ExpressionSpecification
+{
+    private PropertyFunction<? extends Collection<T>> collectionProperty;
+    private T value;
+
+    public ContainsSpecification( PropertyFunction<? extends Collection<T>> collectionProperty, T value )
+    {
+        this.collectionProperty = collectionProperty;
+        this.value = value;
+    }
+
+    public PropertyFunction<? extends Collection<T>> collectionProperty()
+    {
+        return collectionProperty;
+    }
+
+    public T value()
+    {
+        return value;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        Collection<T> collection = collectionProperty.map( item ).get();
+
+        if( collection == null )
+        {
+            return false;
+        }
+
+        return collection.contains( value );
+    }
+
+    @Override
+    public String toString()
+    {
+        return collectionProperty + " contains " + value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/EqSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/EqSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/EqSpecification.java
new file mode 100644
index 0000000..b4c1d90
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/EqSpecification.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+/**
+ * Equals Specification.
+ */
+public class EqSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public EqSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    protected boolean compare( T value )
+    {
+        return value.equals( this.value );
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "=" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ExpressionSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ExpressionSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ExpressionSpecification.java
new file mode 100644
index 0000000..9886ca9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ExpressionSpecification.java
@@ -0,0 +1,60 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.functional.Iterables.append;
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * Base expression Specification.
+ */
+public abstract class ExpressionSpecification
+    implements Specification<Composite>
+{
+
+    @SuppressWarnings( "unchecked" )
+    public AndSpecification and( Specification<Composite> specification )
+    {
+        if( this instanceof AndSpecification )
+        {
+            return new AndSpecification( append( specification, ( (AndSpecification) this ).operands() ) );
+        }
+        else
+        {
+            return new AndSpecification( iterable( this, specification ) );
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public OrSpecification or( Specification<Composite> specification )
+    {
+        if( this instanceof OrSpecification )
+        {
+            return new OrSpecification( append( specification, ( (OrSpecification) this ).operands() ) );
+        }
+        else
+        {
+            return new OrSpecification( iterable( this, specification ) );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/GeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/GeSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/GeSpecification.java
new file mode 100644
index 0000000..82e9e38
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/GeSpecification.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+/**
+ * Greater or equals Specification.
+ */
+public class GeSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public GeSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected boolean compare( T value )
+    {
+        return ( (Comparable) value ).compareTo( this.value ) >= 0;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + ">=" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/GtSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/GtSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/GtSpecification.java
new file mode 100644
index 0000000..883120b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/GtSpecification.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+/**
+ * Greater than Specification.
+ */
+public class GtSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public GtSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected boolean compare( T value )
+    {
+        return ( (Comparable) value ).compareTo( this.value ) > 0;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + ">" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/LeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/LeSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/LeSpecification.java
new file mode 100644
index 0000000..3715ffd
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/LeSpecification.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+/**
+ * Less or equals Specification.
+ */
+public class LeSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public LeSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected boolean compare( T value )
+    {
+        return ( (Comparable) value ).compareTo( this.value ) <= 0;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "<=" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/LtSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/LtSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/LtSpecification.java
new file mode 100644
index 0000000..6d3002a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/LtSpecification.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+/**
+ * Lesser than Specification.
+ */
+public class LtSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public LtSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected boolean compare( T value )
+    {
+        return ( (Comparable) value ).compareTo( this.value ) < 0;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "<" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationContainsSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationContainsSpecification.java
new file mode 100644
index 0000000..d8a6b2e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationContainsSpecification.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * ManyAssociation Contains Specification.
+ */
+public class ManyAssociationContainsSpecification<T>
+    extends ExpressionSpecification
+{
+    private final ManyAssociationFunction<T> manyAssociationFunction;
+    private final T value;
+
+    public ManyAssociationContainsSpecification( ManyAssociationFunction<T> manyAssociationFunction, T value )
+    {
+        this.manyAssociationFunction = manyAssociationFunction;
+        this.value = value;
+    }
+
+    public ManyAssociationFunction<T> manyAssociation()
+    {
+        return manyAssociationFunction;
+    }
+
+    public T value()
+    {
+        return value;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        ManyAssociation<T> collection = manyAssociationFunction.map( item );
+        if( collection == null )
+        {
+            return false;
+        }
+        return collection.contains( value );
+    }
+
+    @Override
+    public String toString()
+    {
+        return manyAssociationFunction + " contains:" + value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationFunction.java b/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationFunction.java
new file mode 100644
index 0000000..e91cdeb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/ManyAssociationFunction.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.functional.Function;
+
+/**
+ * Function to get Entity ManyAssociations.
+ */
+public class ManyAssociationFunction<T>
+    implements Function<Composite, ManyAssociation<T>>
+{
+    private final AssociationFunction<?> traversedAssociation;
+    private final ManyAssociationFunction<?> traversedManyAssociation;
+    private final NamedAssociationFunction<?> traversedNamedAssociation;
+    private final AccessibleObject accessor;
+
+    public ManyAssociationFunction( AssociationFunction<?> traversedAssociation,
+                                    ManyAssociationFunction<?> traversedManyAssociation,
+                                    NamedAssociationFunction<?> traversedNamedAssociation,
+                                    AccessibleObject accessor
+    )
+    {
+        this.traversedAssociation = traversedAssociation;
+        this.traversedManyAssociation = traversedManyAssociation;
+        this.traversedNamedAssociation = traversedNamedAssociation;
+        this.accessor = accessor;
+    }
+
+    public AssociationFunction<?> traversedAssociation()
+    {
+        return traversedAssociation;
+    }
+
+    public ManyAssociationFunction<?> traversedManyAssociation()
+    {
+        return traversedManyAssociation;
+    }
+
+    public NamedAssociationFunction<?> traversedNamedAssociation()
+    {
+        return traversedNamedAssociation;
+    }
+
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public ManyAssociation<T> map( Composite entity )
+    {
+        try
+        {
+            Object target = entity;
+            if( traversedAssociation != null )
+            {
+                target = traversedAssociation.map( entity ).get();
+            }
+            if( traversedManyAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot traverse ManyAssociations" );
+            }
+            if( traversedNamedAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot traverse NamedAssociations" );
+            }
+
+            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
+            return ( (AssociationStateHolder) handler.state() ).manyAssociationFor( accessor );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw e;
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalArgumentException( e );
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        if( traversedAssociation != null )
+        {
+            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
+        }
+        else
+        {
+            return ( (Member) accessor ).getName();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/MatchesSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/MatchesSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/MatchesSpecification.java
new file mode 100644
index 0000000..6cde577
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/MatchesSpecification.java
@@ -0,0 +1,93 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.property.Property;
+
+/**
+ * Regular expression match Specification.
+ */
+public class MatchesSpecification
+    extends ExpressionSpecification
+{
+    private PropertyFunction<String> property;
+    private Object value;
+
+    public MatchesSpecification( PropertyFunction<String> property, String regexp )
+    {
+        this.property = property;
+        this.value = regexp;
+    }
+
+    public MatchesSpecification( PropertyFunction<String> property, Variable variable )
+    {
+        this.property = property;
+        this.value = variable;
+    }
+
+    public PropertyFunction<String> property()
+    {
+        return property;
+    }
+
+    public Object value()
+    {
+        return value;
+    }
+
+    public String regexp()
+    {
+        return ( String ) value;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        Property<String> prop = property.map( item );
+
+        if( prop == null )
+        {
+            return false;
+        }
+
+        String val = prop.get();
+
+        if( val == null )
+        {
+            return false;
+        }
+
+        return val.matches( ( String ) value );
+    }
+
+    @Override
+    public String toString()
+    {
+        return new StringBuilder()
+            .append( "( " )
+            .append( property )
+            .append( " matches " )
+            .append( "\"" )
+            .append( value )
+            .append( "\"" )
+            .append( " )" )
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsNameSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsNameSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsNameSpecification.java
new file mode 100644
index 0000000..c20987e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsNameSpecification.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2012 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * NamedAssociation Contains Specification.
+ */
+public class NamedAssociationContainsNameSpecification<T>
+    extends ExpressionSpecification
+{
+    private final NamedAssociationFunction<T> namedAssociationFunction;
+    private final String name;
+
+    public NamedAssociationContainsNameSpecification( NamedAssociationFunction<T> namedAssociationFunction, String name )
+    {
+        this.namedAssociationFunction = namedAssociationFunction;
+        this.name = name;
+    }
+
+    public NamedAssociationFunction<T> namedAssociation()
+    {
+        return namedAssociationFunction;
+    }
+
+    public String name()
+    {
+        return name;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        NamedAssociation<T> collection = namedAssociationFunction.map( item );
+        if( collection == null )
+        {
+            return false;
+        }
+        return collection.containsName( name );
+    }
+
+    @Override
+    public String toString()
+    {
+        return namedAssociationFunction + " contains name:" + name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsSpecification.java
new file mode 100644
index 0000000..22079aa
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationContainsSpecification.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2012 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * NamedAssociation Contains Specification.
+ */
+public class NamedAssociationContainsSpecification<T>
+    extends ExpressionSpecification
+{
+    private final NamedAssociationFunction<T> namedAssociationFunction;
+    private final T value;
+
+    public NamedAssociationContainsSpecification( NamedAssociationFunction<T> namedAssociationFunction, T value )
+    {
+        this.namedAssociationFunction = namedAssociationFunction;
+        this.value = value;
+    }
+
+    public NamedAssociationFunction<T> namedAssociation()
+    {
+        return namedAssociationFunction;
+    }
+
+    public T value()
+    {
+        return value;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        NamedAssociation<T> collection = namedAssociationFunction.map( item );
+        if( collection == null )
+        {
+            return false;
+        }
+        return collection.nameOf( value ) != null;
+    }
+
+    @Override
+    public String toString()
+    {
+        return namedAssociationFunction + " contains:" + value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationFunction.java b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationFunction.java
new file mode 100644
index 0000000..3f7b8e3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/NamedAssociationFunction.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2011-2012 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.functional.Function;
+
+/**
+ * Function to get Entity NamedAssociations.
+ */
+public class NamedAssociationFunction<T>
+    implements Function<Composite, NamedAssociation<T>>
+{
+    private final AssociationFunction<?> traversedAssociation;
+    private final ManyAssociationFunction<?> traversedManyAssociation;
+    private final NamedAssociationFunction<?> traversedNamedAssociation;
+    private final AccessibleObject accessor;
+
+    public NamedAssociationFunction( AssociationFunction<?> traversedAssociation,
+                                     ManyAssociationFunction<?> traversedManyAssociation,
+                                     NamedAssociationFunction<?> traversedNamedAssociation,
+                                     AccessibleObject accessor
+    )
+    {
+        this.traversedAssociation = traversedAssociation;
+        this.traversedManyAssociation = traversedManyAssociation;
+        this.traversedNamedAssociation = traversedNamedAssociation;
+        this.accessor = accessor;
+    }
+
+    public AssociationFunction<?> traversedAssociation()
+    {
+        return traversedAssociation;
+    }
+
+    public ManyAssociationFunction<?> traversedManyAssociation()
+    {
+        return traversedManyAssociation;
+    }
+
+    public NamedAssociationFunction<?> traversedNamedAssociation()
+    {
+        return traversedNamedAssociation;
+    }
+
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public NamedAssociation<T> map( Composite entity )
+    {
+        try
+        {
+            Object target = entity;
+            if( traversedAssociation != null )
+            {
+                target = traversedAssociation.map( entity ).get();
+            }
+            if( traversedManyAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot traverse ManyAssociations" );
+            }
+            if( traversedNamedAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot traverse NamedAssociations" );
+            }
+
+            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
+            return ( (AssociationStateHolder) handler.state() ).namedAssociationFor( accessor );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw e;
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalArgumentException( e );
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        if( traversedAssociation != null )
+        {
+            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
+        }
+        else
+        {
+            return ( (Member) accessor ).getName();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/NeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/NeSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/NeSpecification.java
new file mode 100644
index 0000000..e864184
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/NeSpecification.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+/**
+ * Not equals Specification.
+ */
+public class NeSpecification<T>
+    extends ComparisonSpecification<T>
+{
+    public NeSpecification( PropertyFunction<T> property, T value )
+    {
+        super( property, value );
+    }
+
+    @Override
+    protected boolean compare( T value )
+    {
+        return !value.equals( this.value );
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "!=" + value.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/NotSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/NotSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/NotSpecification.java
new file mode 100644
index 0000000..a85500d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/NotSpecification.java
@@ -0,0 +1,53 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+
+/**
+ * NOT Specification.
+ */
+public class NotSpecification implements Specification<Composite>
+{
+    private Specification<Composite> operand;
+
+    public NotSpecification( Specification<Composite> operand )
+    {
+        this.operand = operand;
+    }
+
+    public Specification<Composite> operand()
+    {
+        return operand;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        return Specifications.not( operand ).satisfiedBy( item );
+    }
+
+    @Override
+    public String toString()
+    {
+        return "!" + operand.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/OrSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/OrSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/OrSpecification.java
new file mode 100644
index 0000000..ac775d6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/OrSpecification.java
@@ -0,0 +1,56 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+
+/**
+ * OR Specification.
+ */
+public class OrSpecification
+    extends BinarySpecification
+{
+
+    public OrSpecification( Iterable<Specification<Composite>> operands )
+    {
+        super( operands );
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        return Specifications.or( operands ).satisfiedBy( item );
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder( "(" );
+        String or = "";
+        for( Specification<Composite> operand : operands )
+        {
+            sb.append( or ).append( operand );
+            or = " or ";
+        }
+        return sb.append( ")" ).toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/OrderBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/OrderBy.java b/core/api/src/main/java/org/qi4j/api/query/grammar/OrderBy.java
new file mode 100644
index 0000000..097171b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/OrderBy.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2007 Niclas Hedhman.
+ * Copyright 2008 Alin Dreghiciu.
+ *
+ * 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.qi4j.api.query.grammar;
+
+/**
+ * Query sorting segment.
+ */
+public class OrderBy
+{
+    /**
+     * Order direction.
+     */
+    public enum Order
+    {
+        ASCENDING, DESCENDING
+    }
+
+    /**
+     * Order.
+     */
+    private final PropertyFunction<?> propertyReference;
+    /**
+     * Direction.
+     */
+    private final Order order;
+
+    /**
+     * Constructor.
+     *
+     * @param propertyReference property that determines the order; cannot be null
+     * @param order             direction
+     *
+     * @throws IllegalArgumentException - If property is null
+     */
+    public OrderBy( final PropertyFunction<?> propertyReference,
+                    final Order order
+    )
+    {
+        if( propertyReference == null )
+        {
+            throw new IllegalArgumentException( "Ordering property cannot be null" );
+        }
+        this.propertyReference = propertyReference;
+        this.order = order;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return property; cannot be null
+     */
+    public PropertyFunction<?> property()
+    {
+        return propertyReference;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return direction; cannot be null
+     */
+    public Order order()
+    {
+        return order;
+    }
+
+    @Override
+    public String toString()
+    {
+        return new StringBuilder()
+            .append( propertyReference )
+            .append( " " )
+            .append( order )
+            .toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyFunction.java b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyFunction.java
new file mode 100644
index 0000000..b3f4c37
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyFunction.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.NotQueryableException;
+import org.qi4j.api.query.QueryExpressionException;
+import org.qi4j.api.util.Classes;
+import org.qi4j.functional.Function;
+
+import static org.qi4j.api.util.Classes.typeOf;
+
+/**
+ * Function to get Entity Properties.
+ */
+public class PropertyFunction<T>
+    implements Function<Composite, Property<T>>
+{
+    private final PropertyFunction<?> traversedProperty;
+    private final AssociationFunction<?> traversedAssociation;
+    private final ManyAssociationFunction<?> traversedManyAssociation;
+    private final NamedAssociationFunction<?> traversedNamedAssociation;
+    private final AccessibleObject accessor;
+
+    public PropertyFunction( PropertyFunction<?> traversedProperty,
+                             AssociationFunction<?> traversedAssociation,
+                             ManyAssociationFunction<?> traversedManyAssociation,
+                             NamedAssociationFunction<?> traversedNamedAssociation,
+                             AccessibleObject accessor
+    )
+    {
+        this.traversedProperty = traversedProperty;
+        this.traversedAssociation = traversedAssociation;
+        this.traversedManyAssociation = traversedManyAssociation;
+        this.traversedNamedAssociation = traversedNamedAssociation;
+        this.accessor = accessor;
+
+        // Verify that the property accessor is not marked as non queryable
+        NotQueryableException.throwIfNotQueryable( accessor );
+        // Verify that the property type itself (value composites) is not marked as non queryable
+
+        Type returnType = typeOf( accessor );
+        if( !Property.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) ) )
+        {
+            throw new QueryExpressionException( "Not a property type:" + returnType );
+        }
+        Type propertyTypeAsType = GenericPropertyInfo.toPropertyType( returnType );
+        if( propertyTypeAsType instanceof ParameterizedType )
+        {
+            propertyTypeAsType = ( (ParameterizedType) propertyTypeAsType ).getRawType();
+        }
+
+        if( !( propertyTypeAsType instanceof Class ) )
+        {
+            throw new QueryExpressionException( "Unsupported property type:" + propertyTypeAsType );
+        }
+        @SuppressWarnings( "unchecked" )
+        Class<T> type = (Class<T>) propertyTypeAsType;
+        NotQueryableException.throwIfNotQueryable( type );
+    }
+
+    public PropertyFunction<?> traversedProperty()
+    {
+        return traversedProperty;
+    }
+
+    public AssociationFunction<?> traversedAssociation()
+    {
+        return traversedAssociation;
+    }
+
+    public ManyAssociationFunction<?> traversedManyAssociation()
+    {
+        return traversedManyAssociation;
+    }
+
+    public NamedAssociationFunction<?> traversedNamedAssociation()
+    {
+        return traversedNamedAssociation;
+    }
+
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public Property<T> map( Composite entity )
+    {
+        try
+        {
+            Object target = entity;
+            if( traversedProperty != null )
+            {
+                Property<?> property = traversedProperty.map( entity );
+                if( property == null )
+                {
+                    return null;
+                }
+                target = property.get();
+            }
+            else if( traversedAssociation != null )
+            {
+                Association<?> association = traversedAssociation.map( entity );
+                if( association == null )
+                {
+                    return null;
+                }
+                target = association.get();
+            }
+            else if( traversedManyAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );
+            }
+            else if( traversedNamedAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot evaluate a NamedAssociation" );
+            }
+
+            if( target == null )
+            {
+                return null;
+            }
+
+            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
+            return handler.state().propertyFor( accessor );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw e;
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalArgumentException( e );
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        if( traversedProperty != null )
+        {
+            return traversedProperty.toString() + "." + ( (Member) accessor ).getName();
+        }
+        else if( traversedAssociation != null )
+        {
+            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
+        }
+        else
+        {
+            return ( (Member) accessor ).getName();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNotNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNotNullSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNotNullSpecification.java
new file mode 100644
index 0000000..c73afa8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNotNullSpecification.java
@@ -0,0 +1,60 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.property.Property;
+
+/**
+ * Property not null Specification.
+ */
+public class PropertyNotNullSpecification<T>
+    extends ExpressionSpecification
+{
+    private PropertyFunction<T> property;
+
+    public PropertyNotNullSpecification( PropertyFunction<T> property )
+    {
+        this.property = property;
+    }
+
+    public PropertyFunction<T> property()
+    {
+        return property;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        Property<T> prop = property.map( item );
+
+        if( prop == null )
+        {
+            return false;
+        }
+
+        return prop.get() != null;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "is not null";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNullSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNullSpecification.java
new file mode 100644
index 0000000..7f7908f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyNullSpecification.java
@@ -0,0 +1,60 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.property.Property;
+
+/**
+ * Property null Specification.
+ */
+public class PropertyNullSpecification<T>
+    extends ExpressionSpecification
+{
+    private PropertyFunction<T> property;
+
+    public PropertyNullSpecification( PropertyFunction<T> property )
+    {
+        this.property = property;
+    }
+
+    public PropertyFunction<T> property()
+    {
+        return property;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        Property<T> prop = property.map( item );
+
+        if( prop == null )
+        {
+            return true;
+        }
+
+        return prop.get() == null;
+    }
+
+    @Override
+    public String toString()
+    {
+        return property.toString() + "is null";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyReference.java b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyReference.java
new file mode 100644
index 0000000..7b865de
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/PropertyReference.java
@@ -0,0 +1,31 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.property.Property;
+import org.qi4j.functional.Function;
+
+/**
+ * Property Reference.
+ */
+public interface PropertyReference
+{
+    <T> Function<Composite, Property<T>> reference();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/QuerySpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/QuerySpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/QuerySpecification.java
new file mode 100644
index 0000000..3c033d7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/QuerySpecification.java
@@ -0,0 +1,71 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+
+/**
+ * This should be used when doing native queries, such as SQL, SPARQL or similar. EntityFinders can choose
+ * what type of query languages they can understand by checking the language property of a QuerySpecification
+ */
+public class QuerySpecification
+    implements Specification<Composite>
+{
+    public static boolean isQueryLanguage( String language, Specification<Composite> specification )
+    {
+        if( !( specification instanceof QuerySpecification ) )
+        {
+            return false;
+        }
+
+        return ( (QuerySpecification) specification ).language().equals( language );
+    }
+
+    private String language;
+    private String query;
+
+    public QuerySpecification( String language, String query )
+    {
+        this.language = language;
+        this.query = query;
+    }
+
+    public String language()
+    {
+        return language;
+    }
+
+    public String query()
+    {
+        return query;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        return false;
+    }
+
+    @Override
+    public String toString()
+    {
+        return language + ":" + query;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/Variable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/Variable.java b/core/api/src/main/java/org/qi4j/api/query/grammar/Variable.java
new file mode 100644
index 0000000..205347b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/Variable.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+/**
+ * Query Variable name.
+ */
+public class Variable
+{
+    private String name;
+
+    public Variable( String name )
+    {
+        this.name = name;
+    }
+
+    public String variableName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/package.html b/core/api/src/main/java/org/qi4j/api/query/grammar/package.html
new file mode 100644
index 0000000..e0b80f6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Query Grammar.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/package.html b/core/api/src/main/java/org/qi4j/api/query/package.html
new file mode 100644
index 0000000..27e4455
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Query API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/Availability.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/Availability.java b/core/api/src/main/java/org/qi4j/api/service/Availability.java
new file mode 100644
index 0000000..3905a1d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/Availability.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.api.service;
+
+/**
+ * Services can implement this interface in order to allow Zest to ask
+ * it whether it is currently available for use or not. This is accessed
+ * by clients through the ServiceReference of the service. Services that do not
+ * implement this are always considered to be available.
+ */
+public interface Availability
+{
+    /**
+     * Implementations should return true if the underlying service is currently available for use.
+     *
+     * Reasons why a service might not be available is either if it has been configured not to be (see
+     * the Enabled interface), or if an underlying resource is currently unavailable.
+     *
+     * @return true if the service is available, false otherwise.
+     */
+    boolean isAvailable();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/DuplicateServiceIdentityException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/DuplicateServiceIdentityException.java b/core/api/src/main/java/org/qi4j/api/service/DuplicateServiceIdentityException.java
new file mode 100644
index 0000000..fffa42a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/DuplicateServiceIdentityException.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service;
+
+import org.qi4j.api.common.InvalidApplicationException;
+
+/**
+ * Thrown when a duplicate service identity is detected.
+ */
+public class DuplicateServiceIdentityException
+    extends InvalidApplicationException
+{
+    public DuplicateServiceIdentityException( String string )
+    {
+        super( string );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/IdentityDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/IdentityDescriptor.java b/core/api/src/main/java/org/qi4j/api/service/IdentityDescriptor.java
new file mode 100644
index 0000000..13e0ee5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/IdentityDescriptor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.qi4j.api.service;
+
+/**
+ * Identity Descriptor.
+ */
+public interface IdentityDescriptor
+{
+    String identity();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ImportedServiceDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ImportedServiceDescriptor.java b/core/api/src/main/java/org/qi4j/api/service/ImportedServiceDescriptor.java
new file mode 100644
index 0000000..6590049
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ImportedServiceDescriptor.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.service;
+
+import org.qi4j.api.composite.ModelDescriptor;
+
+/**
+ * {@code ServiceDescriptor} provides meta information of a service.
+ */
+public interface ImportedServiceDescriptor
+    extends ModelDescriptor, IdentityDescriptor
+{
+    Class<? extends ServiceImporter> serviceImporter();
+
+    Class<?> type();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/NoSuchServiceException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/NoSuchServiceException.java b/core/api/src/main/java/org/qi4j/api/service/NoSuchServiceException.java
new file mode 100644
index 0000000..9ce08ae
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/NoSuchServiceException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.service;
+
+import org.qi4j.api.composite.NoSuchCompositeException;
+
+/**
+ * Thrown when no visible service of the requested type is found.
+ */
+public class NoSuchServiceException extends NoSuchCompositeException
+{
+    public NoSuchServiceException( String typeName, String moduleName )
+    {
+        super( "ServiceComposite", typeName, moduleName );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceActivation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceActivation.java b/core/api/src/main/java/org/qi4j/api/service/ServiceActivation.java
new file mode 100644
index 0000000..87a7cad
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceActivation.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.api.service;
+
+import org.qi4j.api.activation.Activators;
+
+/**
+ * Convenience interface for simple Service Activation.
+ *
+ * Let your ServiceComposite extends ServiceActivation and implement it in one of its Mixins.
+ * A corresponding Activator is automatically registered.
+ */
+@Activators( ServiceActivation.ServiceActivator.class )
+public interface ServiceActivation
+{
+
+    /**
+     * Called after ServiceComposite Activation.
+     */
+    void activateService()
+        throws Exception;
+
+    /**
+     * Called before ServiceComposite Passivation.
+     */
+    void passivateService()
+        throws Exception;
+
+    /**
+     * Service Activator.
+     */
+    class ServiceActivator
+        extends ServiceActivatorAdapter<ServiceActivation>
+    {
+
+        @Override
+        public void afterActivation( ServiceReference<ServiceActivation> activated )
+            throws Exception
+        {
+            activated.get().activateService();
+        }
+
+        @Override
+        public void beforePassivation( ServiceReference<ServiceActivation> passivating )
+            throws Exception
+        {
+            passivating.get().passivateService();
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceActivatorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceActivatorAdapter.java b/core/api/src/main/java/org/qi4j/api/service/ServiceActivatorAdapter.java
new file mode 100644
index 0000000..966226e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceActivatorAdapter.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.api.service;
+
+import org.qi4j.api.activation.Activator;
+
+/**
+ * Adapter for Service Activator.
+ *
+ * @param <ServiceType> Type of the service.
+ */
+public class ServiceActivatorAdapter<ServiceType>
+    implements Activator<ServiceReference<ServiceType>>
+{
+    /**
+     * Called before Service activation.
+     * @param activating Activating Service
+     */
+    @Override
+    public void beforeActivation( ServiceReference<ServiceType> activating )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called after Service activation.
+     * @param activated Activated Service
+     */
+    @Override
+    public void afterActivation( ServiceReference<ServiceType> activated )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called before Service passivation.
+     * @param passivating Passivating Service
+     */
+    @Override
+    public void beforePassivation( ServiceReference<ServiceType> passivating )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called after Service passivation.
+     * @param passivated Passivated Service
+     */
+    @Override
+    public void afterPassivation( ServiceReference<ServiceType> passivated )
+        throws Exception
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceComposite.java b/core/api/src/main/java/org/qi4j/api/service/ServiceComposite.java
new file mode 100644
index 0000000..f27b994
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceComposite.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.service;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.entity.Identity;
+
+/**
+ * All Composites being used to implement Services
+ * must extend this interface.
+ */
+public interface ServiceComposite
+    extends Identity, Composite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceDescriptor.java b/core/api/src/main/java/org/qi4j/api/service/ServiceDescriptor.java
new file mode 100644
index 0000000..d6a55ee
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceDescriptor.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.service;
+
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.StatefulCompositeDescriptor;
+
+/**
+ * {@code ServiceDescriptor} provides meta informations of a service.
+ */
+public interface ServiceDescriptor
+    extends CompositeDescriptor, IdentityDescriptor, StatefulCompositeDescriptor
+{
+    boolean isInstantiateOnStartup();
+
+    <T> Class<T> configurationType();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceFinder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceFinder.java b/core/api/src/main/java/org/qi4j/api/service/ServiceFinder.java
new file mode 100644
index 0000000..3ffb213
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceFinder.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service;
+
+import java.lang.reflect.Type;
+
+/**
+ * Interface used to query for ServiceReferences.
+ * <p>
+ * Each ServiceFinder is
+ * obtained from a specific Module, and the lookup rules are the following:
+ * </p>
+ * <ol>
+ * <li>First look in the same Module as the ServiceFinder</li>
+ * <li>Then look in the same Layer as the ServiceFinder. Any Services declared
+ * with Visibility Layer and Application should be included</li>
+ * <li>Then look in the used Layers. Any Services declared with Visibility Application
+ * should be included</li>
+ * </ol>
+ * <p>
+ * Both native Zest services and imported services are considered, with preference to native services.
+ * </p>
+ */
+public interface ServiceFinder
+{
+    /**
+     * Find a ServiceReference that implements the given type.
+     *
+     * @param serviceType the type that the Service must implement
+     *
+     * @return a ServiceReference if one is found
+     *
+     * @throws NoSuchServiceException if no service of serviceType is found
+     */
+    <T> ServiceReference<T> findService( Class<T> serviceType )
+        throws NoSuchServiceException;
+
+    /**
+     * Find a ServiceReference that implements the given type.
+     *
+     * @param serviceType the type that the Service must implement
+     *
+     * @return a ServiceReference if one is found
+     *
+     * @throws NoSuchServiceException if no service of serviceType is found
+     */
+    <T> ServiceReference<T> findService( Type serviceType )
+        throws NoSuchServiceException;
+
+    /**
+     * Find ServiceReferences that implements the given type.
+     * <p>
+     * The order of the references is such that Services more local to the querying
+     * Module is earlier in the list.
+     * </p>
+     *
+     * @param serviceType the type that the Services must implement
+     *
+     * @return an iterable of ServiceReferences for the given type. It is empty if none exist
+     */
+    <T> Iterable<ServiceReference<T>> findServices( Class<T> serviceType );
+
+    /**
+     * Find ServiceReferences that implements the given type.
+     * <p>
+     * The order of the references is such that Services more local to the querying
+     * Module is earlier in the list.
+     * </p>
+     *
+     * @param serviceType the type that the Services must implement
+     *
+     * @return an iterable of ServiceReferences for the given type. It is empty if none exist
+     */
+    <T> Iterable<ServiceReference<T>> findServices( Type serviceType );
+}


[18/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/test/java/org/qi4j/io/InputOutputTest.java
----------------------------------------------------------------------
diff --git a/core/io/src/test/java/org/qi4j/io/InputOutputTest.java b/core/io/src/test/java/org/qi4j/io/InputOutputTest.java
new file mode 100644
index 0000000..220e856
--- /dev/null
+++ b/core/io/src/test/java/org/qi4j/io/InputOutputTest.java
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Logger;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Visitor;
+
+import static java.util.Arrays.asList;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.io.Inputs.text;
+import static org.qi4j.io.Transforms.lock;
+import static org.qi4j.test.util.Assume.assumeConnectivity;
+
+/**
+ * Test Input/Output.
+ */
+public class InputOutputTest
+{
+    @Test
+    public void testCopyFileNoAPI()
+        throws IOException
+    {
+        File source = sourceFile();
+        File destination = File.createTempFile( "test", ".txt" );
+        destination.deleteOnExit();
+
+        BufferedReader reader = new BufferedReader( new FileReader( source ) );
+        long count = 0;
+        try
+        {
+            BufferedWriter writer = new BufferedWriter( new FileWriter( destination ) );
+            try
+            {
+                String line;
+                while( ( line = reader.readLine() ) != null )
+                {
+                    count++;
+                    writer.append( line ).append( '\n' );
+                }
+                writer.close();
+            }
+            catch( IOException e )
+            {
+                writer.close();
+                destination.delete();
+            }
+        }
+        finally
+        {
+            reader.close();
+        }
+        System.out.println( count );
+    }
+
+    @Test
+    public void testInputOutput()
+        throws IOException
+    {
+        URL source = getClass().getResource( "/iotest.txt" );
+        File destination = File.createTempFile( "test", ".txt" );
+        destination.deleteOnExit();
+        text( source ).transferTo( Outputs.text( destination ) );
+    }
+
+    @Test
+    public void testCopyFile()
+        throws IOException
+    {
+        File source = sourceFile();
+        File tempFile = File.createTempFile( "test", ".txt" );
+        tempFile.deleteOnExit();
+
+        Inputs.byteBuffer( source, 1024 ).transferTo( Outputs.byteBuffer( tempFile ) );
+
+        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( source.length() ) );
+    }
+
+    @Test
+    public void testCopyURL()
+        throws IOException
+    {
+        assumeConnectivity( "www.google.com", 80 );
+
+        File tempFile = File.createTempFile( "test", ".txt" );
+        tempFile.deleteOnExit();
+
+        Inputs.text( new URL( "http://www.google.com" ) ).transferTo( Outputs.text( tempFile ) );
+
+// Uncomment to check output        Inputs.text( tempFile ).transferTo( Outputs.systemOut() );
+    }
+
+    @Test
+    public void testCopyFileStreams()
+        throws IOException
+    {
+        File source = sourceFile();
+        File tempFile = File.createTempFile( "test", ".txt" );
+        tempFile.deleteOnExit();
+
+        Inputs.byteBuffer( new FileInputStream( source ), 1024 ).transferTo(
+            Outputs.byteBuffer( new FileOutputStream( tempFile ) ) );
+
+        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( source.length() ) );
+    }
+
+    @Test
+    public void testLog()
+        throws IOException
+    {
+        File source = sourceFile();
+
+        text( source ).transferTo(
+            Transforms.map( new Transforms.Log<String>( Logger.getLogger( getClass().getName() ), "Line: {0}" ),
+                            Outputs.<String>noop() ) );
+    }
+
+    @Test
+    public void testProgressLog()
+        throws Throwable
+    {
+        Integer[] data = new Integer[ 105 ];
+        Arrays.fill( data, 42 );
+
+        Inputs.iterable( iterable( data ) ).transferTo(
+            Transforms.map(
+                new Transforms.ProgressLog<Integer>(
+                    Logger.getLogger( InputOutputTest.class.getName() ), "Data transferred: {0}", 10 ),
+                Outputs.<Integer>noop() ) );
+    }
+
+    @Test
+    public void testTextInputsOutputs()
+        throws IOException
+    {
+        File tempFile = File.createTempFile( "test", ".txt" );
+        tempFile.deleteOnExit();
+        File sourceFile = sourceFile();
+        Transforms.Counter<String> stringCounter = new Transforms.Counter<>();
+        text( sourceFile ).transferTo(
+            Transforms.map(
+                stringCounter,
+                Transforms.map( new Function<String, String>()
+                {
+                    public String map( String s )
+                    {
+                        System.out.println( s );
+                        return s;
+                    }
+                }, Outputs.text( tempFile ) )
+            )
+        );
+
+        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( sourceFile.length() ) );
+        Assert.assertThat( stringCounter.count(), CoreMatchers.equalTo( 4L ) );
+    }
+
+    @Test
+    public void testCombineInputs()
+        throws IOException
+    {
+        File tempFile = File.createTempFile( "test", ".txt" );
+        tempFile.deleteOnExit();
+        File sourceFile = sourceFile();
+        Transforms.Counter<String> stringCounter = new Transforms.Counter<>();
+        Input<String, IOException> text1 = text( sourceFile );
+        Input<String, IOException> text2 = text( sourceFile );
+        List<Input<String, IOException>> list = createList( text1, text2 );
+        Inputs.combine( list ).transferTo(
+            Transforms.map(
+                stringCounter,
+                Transforms.map( new Function<String, String>()
+            {
+                public String map( String s )
+                {
+                    System.out.println( s );
+                    return s;
+                }
+                }, Outputs.text( tempFile ) )
+            )
+        );
+
+        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( sourceFile.length() * 2 ) );
+        Assert.assertThat( stringCounter.count(), CoreMatchers.equalTo( 8L ) );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private List<Input<String, IOException>> createList( Input<String, IOException> text1,
+                                                         Input<String, IOException> text2
+    )
+    {
+        return asList( text1, text2 );
+    }
+
+    @Test( expected = IOException.class )
+    public void testInputOutputOutputException()
+        throws IOException
+    {
+
+        text( sourceFile() ).
+            transferTo( writerOutput( new Writer()
+                    {
+                        @Override
+                        public void write( char[] cbuf, int off, int len )
+                        throws IOException
+                        {
+                            throw new IOException();
+                        }
+
+                        @Override
+                        public void flush()
+                        throws IOException
+                        {
+                            throw new IOException();
+                        }
+
+                        @Override
+                        public void close()
+                        throws IOException
+                        {
+                            throw new IOException();
+                        }
+            } ) );
+    }
+
+    @Test( expected = RemoteException.class )
+    public void testInputOutputInputException()
+        throws IOException
+    {
+
+        Input<String, RemoteException> input = new Input<String, RemoteException>()
+        {
+            @Override
+            public <OutputThrowableType extends Throwable> void transferTo( Output<? super String, OutputThrowableType> output )
+                throws RemoteException, OutputThrowableType
+            {
+                output.receiveFrom( new Sender<String, RemoteException>()
+                {
+                    @Override
+                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiverThrowableTypeReceiver )
+                        throws ReceiverThrowableType, RemoteException
+                    {
+                        throw new RemoteException();
+                    }
+                } );
+            }
+        };
+
+        input.transferTo(
+            Transforms.map(
+                new Transforms.Log<String>( Logger.getLogger( getClass().getName() ), "Line: {0}" ),
+                Outputs.systemOut()
+            )
+        );
+    }
+
+    @Test
+    public void testLock()
+        throws IOException
+    {
+        Lock inputLock = new ReentrantLock();
+        Lock outputLock = new ReentrantLock();
+
+        URL source = getClass().getResource( "/iotest.txt" );
+        File destination = File.createTempFile( "test", ".txt" );
+        destination.deleteOnExit();
+        lock( inputLock, text( source ) ).transferTo( lock( outputLock, Outputs.text( destination ) ) );
+    }
+
+    @Test
+    public void testGenerics()
+    {
+        ArrayList<Object> objects = new ArrayList<>( 3 );
+        Inputs.iterable( Arrays.asList( "Foo", "Bar", "Xyzzy" ) ).transferTo( Outputs.collection( objects ) );
+
+        Inputs.iterable( objects ).transferTo( Outputs.systemOut() );
+    }
+
+    @Test
+    public void testOutputstreamInput()
+        throws Throwable
+    {
+        Input<ByteBuffer, IOException> input = Inputs.output( new Visitor<OutputStream, IOException>()
+        {
+            @Override
+            public boolean visit( OutputStream visited )
+                throws IOException
+            {
+                try( PrintWriter writer = new PrintWriter( visited ) )
+                {
+                    writer.print( "Hello World!" );
+                }
+                return true;
+            }
+        }, 256 );
+
+        input.transferTo( Transforms.map( new Transforms.ByteBuffer2String( Charset.defaultCharset() ), Outputs.systemOut() ) );
+        input.transferTo( Transforms.map( new Transforms.ByteBuffer2String( Charset.defaultCharset() ), Outputs.systemOut() ) );
+    }
+
+    public Output<String, IOException> writerOutput( final Writer writer )
+    {
+        return new Output<String, IOException>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                // Here we initiate the transfer
+                System.out.println( "Open output" );
+                final StringBuilder builder = new StringBuilder();
+                try
+                {
+                    sender.sendTo( new Receiver<String, IOException>()
+                    {
+                        @Override
+                        public void receive( String item )
+                            throws IOException
+                        {
+                            System.out.println( "Receive input" );
+
+                            // Here we can do batch writes if needed
+                            builder.append( item ).append( "\n" );
+                        }
+                    } );
+
+                    // If transfer went well, do something with it
+                    writer.write( builder.toString() );
+                    writer.flush();
+                    System.out.println( "Output written" );
+                }
+                catch( IOException e )
+                {
+                    // If transfer failed, potentially rollback writes
+                    System.out.println( "Input failed" );
+                    throw e;
+                }
+            }
+        };
+    }
+
+    private File sourceFile()
+    {
+        String path = getClass().getResource( "/iotest.txt" ).getFile();
+        return new File( path.replaceAll( "%20", " " ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/test/java/org/qi4j/io/docsupport/IoDocs.java
----------------------------------------------------------------------
diff --git a/core/io/src/test/java/org/qi4j/io/docsupport/IoDocs.java b/core/io/src/test/java/org/qi4j/io/docsupport/IoDocs.java
new file mode 100644
index 0000000..6028886
--- /dev/null
+++ b/core/io/src/test/java/org/qi4j/io/docsupport/IoDocs.java
@@ -0,0 +1,53 @@
+/*
+ * 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.qi4j.io.docsupport;
+
+import java.io.File;
+import java.io.IOException;
+import org.qi4j.io.Inputs;
+import org.qi4j.io.Outputs;
+
+// START SNIPPET: io2
+import org.qi4j.io.Transforms.Counter;
+import static org.qi4j.io.Transforms.map;
+// END SNIPPET: io2
+
+public class IoDocs
+{
+    public static void main( String[] args )
+        throws IOException
+    {
+        {
+// START SNIPPET: io1
+            File source = new File( "source.txt" );
+            File destination = new File( "destination.txt" );
+            Inputs.text( source ).transferTo( Outputs.text( destination ) );
+// END SNIPPET: io1
+        }
+        {
+// START SNIPPET: io2
+            File source = new File( "source.txt" );
+            File destination = new File( "destination.txt" );
+            Counter<String> counter = new Counter<String>();
+            Inputs.text( source ).transferTo( map(counter, Outputs.text(destination) ));
+            System.out.println( "Lines: " + counter.count() );
+// END SNIPPET: io2
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/Qi4jRuntimeImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/Qi4jRuntimeImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/Qi4jRuntimeImpl.java
deleted file mode 100644
index bbab6cb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/Qi4jRuntimeImpl.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime;
-
-import java.lang.reflect.InvocationHandler;
-import java.util.Arrays;
-import java.util.Map;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.association.AbstractAssociation;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.AssociationWrapper;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.ManyAssociationWrapper;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.association.NamedAssociationWrapper;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.composite.TransientComposite;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.PropertyWrapper;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.ApplicationModelFactory;
-import org.apache.zest.bootstrap.Qi4jRuntime;
-import org.apache.zest.runtime.association.AbstractAssociationInstance;
-import org.apache.zest.runtime.association.AssociationInstance;
-import org.apache.zest.runtime.association.ManyAssociationInstance;
-import org.apache.zest.runtime.association.NamedAssociationInstance;
-import org.apache.zest.runtime.bootstrap.ApplicationAssemblyFactoryImpl;
-import org.apache.zest.runtime.bootstrap.ApplicationModelFactoryImpl;
-import org.apache.zest.runtime.composite.ProxyReferenceInvocationHandler;
-import org.apache.zest.runtime.composite.TransientInstance;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.service.ImportedServiceReferenceInstance;
-import org.apache.zest.runtime.service.ServiceInstance;
-import org.apache.zest.runtime.service.ServiceReferenceInstance;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.spi.Qi4jSPI;
-import org.apache.zest.spi.entity.EntityState;
-
-import static java.lang.reflect.Proxy.getInvocationHandler;
-import static org.apache.zest.runtime.composite.TransientInstance.compositeInstanceOf;
-
-/**
- * Incarnation of Zest.
- */
-public final class Qi4jRuntimeImpl
-    implements Qi4jSPI, Qi4jRuntime
-{
-    private final ApplicationAssemblyFactory applicationAssemblyFactory;
-    private final ApplicationModelFactory applicationModelFactory;
-
-    public Qi4jRuntimeImpl()
-    {
-        applicationAssemblyFactory = new ApplicationAssemblyFactoryImpl();
-        applicationModelFactory = new ApplicationModelFactoryImpl();
-    }
-
-    @Override
-    public ApplicationAssemblyFactory applicationAssemblyFactory()
-    {
-        return applicationAssemblyFactory;
-    }
-
-    @Override
-    public ApplicationModelFactory applicationModelFactory()
-    {
-        return applicationModelFactory;
-    }
-
-    @Override
-    public Qi4j api()
-    {
-        return this;
-    }
-
-    @Override
-    public Qi4jSPI spi()
-    {
-        return this;
-    }
-
-    // API
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> T dereference( T composite )
-    {
-        InvocationHandler handler = getInvocationHandler( composite );
-        if( handler instanceof ProxyReferenceInvocationHandler )
-        {
-            return (T) ( (ProxyReferenceInvocationHandler) handler ).proxy();
-        }
-        if( handler instanceof CompositeInstance )
-        {
-            return composite;
-        }
-        return null;
-    }
-
-    @Override
-    public Module moduleOf( Object compositeOrServiceReferenceOrUow )
-    {
-        if( compositeOrServiceReferenceOrUow instanceof TransientComposite )
-        {
-            TransientComposite composite = (TransientComposite) compositeOrServiceReferenceOrUow;
-            return TransientInstance.compositeInstanceOf( composite ).module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof EntityComposite )
-        {
-            EntityComposite composite = (EntityComposite) compositeOrServiceReferenceOrUow;
-            return EntityInstance.entityInstanceOf( composite ).module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof ValueComposite )
-        {
-            ValueComposite composite = (ValueComposite) compositeOrServiceReferenceOrUow;
-            return ValueInstance.valueInstanceOf( composite ).module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof ServiceComposite )
-        {
-            ServiceComposite composite = (ServiceComposite) compositeOrServiceReferenceOrUow;
-            InvocationHandler handler = getInvocationHandler( composite );
-            if( handler instanceof ServiceInstance )
-            {
-                return ( (ServiceInstance) handler ).module();
-            }
-            return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof UnitOfWork )
-        {
-            ModuleUnitOfWork unitOfWork = (ModuleUnitOfWork) compositeOrServiceReferenceOrUow;
-            return unitOfWork.module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof ServiceReferenceInstance )
-        {
-            ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow;
-            return reference.module();
-        }
-        else if( compositeOrServiceReferenceOrUow instanceof ImportedServiceReferenceInstance )
-        {
-            ImportedServiceReferenceInstance<?> importedServiceReference
-                = (ImportedServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow;
-            return importedServiceReference.module();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be one of "
-                                            + Arrays.asList( TransientComposite.class, ValueComposite.class,
-                                                             ServiceComposite.class, ServiceReference.class,
-                                                             UnitOfWork.class ) );
-    }
-
-    @Override
-    public ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference )
-    {
-        if( compositeOrServiceReference instanceof TransientComposite )
-        {
-            TransientComposite composite = (TransientComposite) compositeOrServiceReference;
-            return TransientInstance.compositeInstanceOf( composite ).descriptor();
-        }
-        else if( compositeOrServiceReference instanceof EntityComposite )
-        {
-            EntityComposite composite = (EntityComposite) compositeOrServiceReference;
-            return EntityInstance.entityInstanceOf( composite ).descriptor();
-        }
-        else if( compositeOrServiceReference instanceof ValueComposite )
-        {
-            ValueComposite composite = (ValueComposite) compositeOrServiceReference;
-            return ValueInstance.valueInstanceOf( composite ).descriptor();
-        }
-        else if( compositeOrServiceReference instanceof ServiceComposite )
-        {
-            ServiceComposite composite = (ServiceComposite) compositeOrServiceReference;
-            InvocationHandler handler = getInvocationHandler( composite );
-            if( handler instanceof ServiceInstance )
-            {
-                return ( (ServiceInstance) handler ).descriptor();
-            }
-            return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).descriptor();
-        }
-        else if( compositeOrServiceReference instanceof ServiceReferenceInstance )
-        {
-            ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReference;
-            return reference.serviceDescriptor();
-        }
-        else if( compositeOrServiceReference instanceof ImportedServiceReferenceInstance )
-        {
-            ImportedServiceReferenceInstance<?> importedServiceReference
-                = (ImportedServiceReferenceInstance<?>) compositeOrServiceReference;
-            return importedServiceReference.serviceDescriptor();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be one of "
-                                            + Arrays.asList( TransientComposite.class, ValueComposite.class,
-                                                             ServiceComposite.class, ServiceReference.class ) );
-    }
-
-    @Override
-    public CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference )
-    {
-        return (CompositeDescriptor) modelDescriptorFor( compositeOrServiceReference );
-    }
-
-    // Descriptors
-
-    @Override
-    public TransientDescriptor transientDescriptorFor( Object transsient )
-    {
-        if( transsient instanceof TransientComposite )
-        {
-            TransientInstance transientInstance = compositeInstanceOf( (Composite) transsient );
-            return (TransientDescriptor) transientInstance.descriptor();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + TransientComposite.class );
-    }
-
-    @Override
-    public StateHolder stateOf( TransientComposite composite )
-    {
-        return TransientInstance.compositeInstanceOf( composite ).state();
-    }
-
-    @Override
-    public EntityDescriptor entityDescriptorFor( Object entity )
-    {
-        if( entity instanceof EntityComposite )
-        {
-            EntityInstance entityInstance = (EntityInstance) getInvocationHandler( entity );
-            return entityInstance.entityModel();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + EntityComposite.class );
-    }
-
-    @Override
-    public AssociationStateHolder stateOf( EntityComposite composite )
-    {
-        return EntityInstance.entityInstanceOf( composite ).state();
-    }
-
-    @Override
-    public ValueDescriptor valueDescriptorFor( Object value )
-    {
-        if( value instanceof ValueComposite )
-        {
-            ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) value );
-            return valueInstance.descriptor();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be subtype of " + ValueComposite.class );
-    }
-
-    @Override
-    public AssociationStateHolder stateOf( ValueComposite composite )
-    {
-        return ValueInstance.valueInstanceOf( composite ).state();
-    }
-
-    @Override
-    public ServiceDescriptor serviceDescriptorFor( Object service )
-    {
-        if( service instanceof ServiceReferenceInstance )
-        {
-            ServiceReferenceInstance<?> ref = (ServiceReferenceInstance<?>) service;
-            return ref.serviceDescriptor();
-        }
-        if( service instanceof ServiceComposite )
-        {
-            ServiceComposite composite = (ServiceComposite) service;
-            return (ServiceDescriptor) ServiceInstance.serviceInstanceOf( composite ).descriptor();
-        }
-        throw new IllegalArgumentException( "Wrong type. Must be subtype of "
-                                            + ServiceComposite.class + " or " + ServiceReference.class );
-    }
-
-    @Override
-    public PropertyDescriptor propertyDescriptorFor( Property<?> property )
-    {
-        while( property instanceof PropertyWrapper )
-        {
-            property = ( (PropertyWrapper) property ).next();
-        }
-
-        return (PropertyDescriptor) ( (PropertyInstance<?>) property ).propertyInfo();
-    }
-
-    @Override
-    public AssociationDescriptor associationDescriptorFor( AbstractAssociation association )
-    {
-        while( association instanceof AssociationWrapper )
-        {
-            association = ( (AssociationWrapper) association ).next();
-        }
-
-        while( association instanceof ManyAssociationWrapper )
-        {
-            association = ( (ManyAssociationWrapper) association ).next();
-        }
-
-        while( association instanceof NamedAssociationWrapper )
-        {
-            association = ( (NamedAssociationWrapper) association ).next();
-        }
-
-        return (AssociationDescriptor) ( (AbstractAssociationInstance) association ).associationInfo();
-    }
-
-    // SPI
-    @Override
-    public EntityState entityStateOf( EntityComposite composite )
-    {
-        return EntityInstance.entityInstanceOf( composite ).entityState();
-    }
-
-    @Override
-    public EntityReference entityReferenceOf( Association assoc )
-    {
-        @SuppressWarnings( "unchecked" )
-        Property<EntityReference> associationState = ( (AssociationInstance) assoc ).getAssociationState();
-        return associationState.get();
-    }
-
-    @Override
-    public Iterable<EntityReference> entityReferenceOf( ManyAssociation assoc )
-    {
-        return ( (ManyAssociationInstance) assoc ).getManyAssociationState();
-    }
-
-    @Override
-    public Iterable<Map.Entry<String, EntityReference>> entityReferenceOf( NamedAssociation assoc )
-    {
-        return ( (NamedAssociationInstance) assoc ).getEntityReferences();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
deleted file mode 100644
index e7406b2..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.activation;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEvent;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.service.ServiceReference;
-
-import static org.apache.zest.api.activation.ActivationEvent.EventType.ACTIVATED;
-import static org.apache.zest.api.activation.ActivationEvent.EventType.ACTIVATING;
-import static org.apache.zest.api.activation.ActivationEvent.EventType.PASSIVATED;
-import static org.apache.zest.api.activation.ActivationEvent.EventType.PASSIVATING;
-
-/**
- * This class manage Activation of a target and propagates to children.
- */
-@SuppressWarnings( "raw" )
-public final class ActivationDelegate
-    extends ActivationEventListenerSupport
-{
-    private final Object target;
-    private final boolean fireEvents;
-    private ActivatorsInstance targetActivators = null;
-    private final LinkedList<Activation> activeChildren = new LinkedList<>();
-
-    /**
-     * Create a new ActivationDelegate that will fire events.
-     * @param target target of Activation
-     */
-    public ActivationDelegate( Object target )
-    {
-        this( target, true );
-    }
-
-    /**
-     * Create a new ActivationDelegate.
-     * @param target target of Activation
-     * @param fireEvents if {@link ActivationEvent}s should be fired
-     */
-    public ActivationDelegate( Object target, boolean fireEvents )
-    {
-        super();
-        this.target = target;
-        this.fireEvents = fireEvents;
-    }
-
-    public void activate( ActivatorsInstance targetActivators, Activation child )
-        throws Exception
-    {
-        activate( targetActivators, Collections.singleton( child ), null );
-    }
-
-    public void activate( ActivatorsInstance targetActivators, Activation child, Runnable callback )
-        throws Exception
-    {
-        activate( targetActivators, Collections.singleton( child ), callback );
-    }
-
-    public void activate( ActivatorsInstance targetActivators, Iterable<? extends Activation> children )
-        throws ActivationException
-    {
-        activate( targetActivators, children, null );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void activate( ActivatorsInstance targetActivators, Iterable<? extends Activation> children, Runnable callback )
-        throws ActivationException
-    {
-        if( this.targetActivators != null )
-        {
-            throw new IllegalStateException( "Activation.activate() called multiple times "
-                                             + "or without calling passivate() first!" );
-        }
-
-        try
-        {
-            // Before Activation Events
-            if( fireEvents )
-            {
-                fireEvent( new ActivationEvent( target, ACTIVATING ) );
-            }
-
-            // Before Activation for Activators
-            targetActivators.beforeActivation( target instanceof ServiceReference
-                                               ? new PassiveServiceReference( (ServiceReference) target )
-                                               : target );
-
-            // Activation
-            for( Activation child : children )
-            {
-                if( !activeChildren.contains( child ) )
-                {
-                    child.activate();
-                }
-                activeChildren.addFirst( child );
-            }
-
-            // Internal Activation Callback
-            if( callback != null )
-            {
-                callback.run();
-            }
-
-            // After Activation
-            targetActivators.afterActivation( target );
-
-            // After Activation Events
-            if( fireEvents )
-            {
-                fireEvent( new ActivationEvent( target, ACTIVATED ) );
-            }
-
-            // Activated
-            this.targetActivators = targetActivators;
-        }
-        catch( Exception e )
-        {
-            // Passivate actives
-            try
-            {
-                passivate();
-            }
-            catch( PassivationException e1 )
-            {
-                ActivationException activationEx = new ActivationException( "Unable to Activate application.", e );
-                activationEx.addSuppressed( e1 );
-                throw activationEx;
-            }
-            if( e instanceof ActivationException )
-            {
-                throw ( (ActivationException) e );
-            }
-            throw new ActivationException( "Unable to Activate application.", e );
-        }
-    }
-
-    public void passivate()
-        throws PassivationException
-    {
-        passivate( (Runnable) null );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void passivate( Runnable callback )
-        throws PassivationException
-    {
-        Set<Exception> exceptions = new LinkedHashSet<>();
-
-        // Before Passivation Events
-        if( fireEvents )
-        {
-            ActivationEvent event = new ActivationEvent( target, PASSIVATING );
-            for( ActivationEventListener listener : listeners )
-            {
-                try
-                {
-                    listener.onEvent( event );
-                }
-                catch( Exception ex )
-                {
-                    if( ex instanceof PassivationException )
-                    {
-                        exceptions.addAll( ( (PassivationException) ex ).causes() );
-                    }
-                    else
-                    {
-                        exceptions.add( ex );
-                    }
-                }
-            }
-        }
-
-        // Before Passivation for Activators
-        if( targetActivators != null )
-        {
-            try
-            {
-                targetActivators.beforePassivation( target );
-            }
-            catch( PassivationException ex )
-            {
-                exceptions.addAll( ex.causes() );
-            }
-            catch( Exception ex )
-            {
-                exceptions.add( ex );
-            }
-        }
-
-        // Passivation
-        while( !activeChildren.isEmpty() )
-        {
-            passivateOneChild( exceptions );
-        }
-
-        // Internal Passivation Callback
-        if( callback != null )
-        {
-            try
-            {
-                callback.run();
-            }
-            catch( Exception ex )
-            {
-                if( ex instanceof PassivationException )
-                {
-                    exceptions.addAll( ( (PassivationException) ex ).causes() );
-                }
-                else
-                {
-                    exceptions.add( ex );
-                }
-            }
-        }
-
-        // After Passivation for Activators
-        if( targetActivators != null )
-        {
-            try
-            {
-                targetActivators.afterPassivation( target instanceof ServiceReference
-                                                   ? new PassiveServiceReference( (ServiceReference) target )
-                                                   : target );
-            }
-            catch( PassivationException ex )
-            {
-                exceptions.addAll( ex.causes() );
-            }
-            catch( Exception ex )
-            {
-                exceptions.add( ex );
-            }
-        }
-        targetActivators = null;
-
-        // After Passivation Events
-        if( fireEvents )
-        {
-            ActivationEvent event = new ActivationEvent( target, PASSIVATED );
-            for( ActivationEventListener listener : listeners )
-            {
-                try
-                {
-                    listener.onEvent( event );
-                }
-                catch( Exception ex )
-                {
-                    if( ex instanceof PassivationException )
-                    {
-                        exceptions.addAll( ( (PassivationException) ex ).causes() );
-                    }
-                    else
-                    {
-                        exceptions.add( ex );
-                    }
-                }
-            }
-        }
-
-        // Error handling
-        if( exceptions.isEmpty() )
-        {
-            return;
-        }
-        throw new PassivationException( exceptions );
-    }
-
-    @SuppressWarnings( "TooBroadCatch" )
-    private void passivateOneChild( Set<Exception> exceptions )
-    {
-        Activation activeChild = activeChildren.removeFirst();
-        try
-        {
-            activeChild.passivate();
-        }
-        catch( PassivationException ex )
-        {
-            exceptions.addAll( ex.causes() );
-        }
-        catch( Exception ex )
-        {
-            exceptions.add( ex );
-        }
-    }
-
-    @SuppressWarnings( "raw" )
-    private static class PassiveServiceReference
-        implements ServiceReference
-    {
-
-        private final ServiceReference reference;
-
-        private PassiveServiceReference( ServiceReference reference )
-        {
-            this.reference = reference;
-        }
-
-        @Override
-        public String identity()
-        {
-            return reference.identity();
-        }
-
-        @Override
-        public Object get()
-        {
-            throw new IllegalStateException( "Service is passive, either activating and"
-                                             + " cannot be used yet or passivating and cannot be used anymore." );
-        }
-
-        @Override
-        public boolean isActive()
-        {
-            return false;
-        }
-
-        @Override
-        public boolean isAvailable()
-        {
-            return false;
-        }
-
-        @Override
-        public Iterable<Class<?>> types()
-        {
-            return reference.types();
-        }
-
-        @Override
-        public <T> T metaInfo( Class<T> infoType )
-        {
-            return reference.metaInfo( infoType );
-        }
-
-        @Override
-        public void registerActivationEventListener( ActivationEventListener listener )
-        {
-            reference.registerActivationEventListener( listener );
-        }
-
-        @Override
-        public void deregisterActivationEventListener( ActivationEventListener listener )
-        {
-            reference.deregisterActivationEventListener( listener );
-        }
-
-        @Override
-        public int hashCode()
-        {
-            return identity().hashCode();
-        }
-
-        @Override
-        public boolean equals( Object obj )
-        {
-            if( obj == null )
-            {
-                return false;
-            }
-            if( getClass() != obj.getClass() )
-            {
-                return false;
-            }
-            final ServiceReference other = (ServiceReference) obj;
-            return identity().equals( other.identity() );
-        }
-
-        @Override
-        public String toString()
-        {
-            return reference.toString();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationEventListenerSupport.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationEventListenerSupport.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationEventListenerSupport.java
deleted file mode 100644
index fb8a9b7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationEventListenerSupport.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg.
- * Copyright (c) 2012, Niclas Hedhman.
- *
- * 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.zest.runtime.activation;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.ActivationEvent;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-
-/**
- * Internal helper for managing registrations and firing events
- */
-/* package */ class ActivationEventListenerSupport
-    implements ActivationEventListenerRegistration, ActivationEventListener
-{
-    protected List<ActivationEventListener> listeners = new ArrayList<>();
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        List<ActivationEventListener> newListeners = new ArrayList<>();
-        newListeners.addAll( listeners );
-        newListeners.add( listener );
-        listeners = newListeners;
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        List<ActivationEventListener> newListeners = new ArrayList<>();
-        newListeners.addAll( listeners );
-        newListeners.remove( listener );
-        listeners = newListeners;
-    }
-
-    /* package */ void fireEvent( ActivationEvent event )
-        throws Exception
-    {
-        for( ActivationEventListener listener : listeners )
-        {
-            listener.onEvent( event );
-        }
-    }
-
-    @Override
-    public void onEvent( ActivationEvent event )
-        throws Exception
-    {
-        fireEvent( event );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorModel.java
deleted file mode 100644
index 034d3a6..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorModel.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.activation;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.activation.ActivatorDescriptor;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.composite.ConstructorsModel;
-import org.apache.zest.runtime.injection.InjectedFieldsModel;
-import org.apache.zest.runtime.injection.InjectedMethodsModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-
-/**
- * Model for a single Activator.
- *
- * @param <ActivateeType> Type of the activation target
- */
-public class ActivatorModel<ActivateeType>
-    implements ActivatorDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final Class<? extends Activator<ActivateeType>> activatorType;
-    private final ConstructorsModel constructorsModel;
-    private final InjectedFieldsModel injectedFieldsModel;
-    private final InjectedMethodsModel injectedMethodsModel;
-
-    public ActivatorModel( Class<? extends Activator<ActivateeType>> activatorType )
-    {
-        this.activatorType = activatorType;
-        this.constructorsModel = new ConstructorsModel( activatorType );
-        this.injectedFieldsModel = new InjectedFieldsModel( activatorType );
-        this.injectedMethodsModel = new InjectedMethodsModel( activatorType );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( constructorsModel.accept( visitor ) )
-            {
-                if( injectedFieldsModel.accept( visitor ) )
-                {
-                    injectedMethodsModel.accept( visitor );
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Activator<ActivateeType> newInstance()
-    {
-        try
-        {
-            return activatorType.newInstance();
-        }
-        catch( InstantiationException | IllegalAccessException ex )
-        {
-            throw new ConstructionException( "Could not instantiate " + activatorType.getName(), ex );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Activator<ActivateeType> newInstance( InjectionContext injectionContext )
-    {
-        try
-        {
-            Activator<ActivateeType> instance = (Activator<ActivateeType>) constructorsModel.newInstance( injectionContext );
-            injectionContext = new InjectionContext( injectionContext.module(), injectionContext.uses(), instance );
-            inject( injectionContext, instance );
-            return instance;
-        }
-        catch( Exception ex )
-        {
-            throw new ConstructionException( "Could not instantiate " + activatorType.getName(), ex );
-        }
-    }
-
-    public void inject( InjectionContext injectionContext, Activator<ActivateeType> instance )
-    {
-        injectedFieldsModel.inject( injectionContext, instance );
-        injectedMethodsModel.inject( injectionContext, instance );
-    }
-
-    @Override
-    public String toString()
-    {
-        return activatorType.getName();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsInstance.java
deleted file mode 100644
index e8a6e49..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsInstance.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.activation;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.functional.Iterables;
-
-/**
- * Instance of a Zest Activators of one Activation target. Contains ordered
- * Activators and roll the Activation on the target.
- *
- * @param <ActivateeType> Type of the activation target
- */
-public class ActivatorsInstance<ActivateeType>
-    implements Activator<ActivateeType>
-{
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static final ActivatorsInstance EMPTY = new ActivatorsInstance( Collections.emptyList() );
-
-    private final Iterable<Activator<ActivateeType>> activators;
-
-    public ActivatorsInstance( Iterable<Activator<ActivateeType>> activators )
-    {
-        this.activators = activators;
-    }
-
-    @Override
-    public void beforeActivation( ActivateeType activating )
-        throws Exception
-    {
-        for( Activator<ActivateeType> activator : activators )
-        {
-            activator.beforeActivation( activating );
-        }
-    }
-
-    @Override
-    public void afterActivation( ActivateeType activated )
-        throws Exception
-    {
-        for( Activator<ActivateeType> activator : activators )
-        {
-            activator.afterActivation( activated );
-        }
-    }
-
-    @Override
-    public void beforePassivation( ActivateeType passivating )
-        throws Exception
-    {
-        Set<Exception> exceptions = new LinkedHashSet<>();
-        for( Activator<ActivateeType> activator : Iterables.reverse( activators ) )
-        {
-            try
-            {
-                activator.beforePassivation( passivating );
-            }
-            catch( Exception ex )
-            {
-                exceptions.add( ex );
-            }
-        }
-        if( !exceptions.isEmpty() )
-        {
-            throw new PassivationException( exceptions );
-        }
-    }
-
-    @Override
-    public void afterPassivation( ActivateeType passivated )
-        throws Exception
-    {
-        Set<Exception> exceptions = new LinkedHashSet<>();
-        for( Activator<ActivateeType> activator : Iterables.reverse( activators ) )
-        {
-            try
-            {
-                activator.afterPassivation( passivated );
-            }
-            catch( Exception ex )
-            {
-                exceptions.add( ex );
-            }
-        }
-        if( !exceptions.isEmpty() )
-        {
-            throw new PassivationException( exceptions );
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
deleted file mode 100644
index 2483461..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.activation;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.structure.ModuleInstance;
-
-/**
- * Activators Model.
- *
- * @param <ActivateeType> Type of the activation target
- */
-public class ActivatorsModel<ActivateeType>
-    implements VisitableHierarchy<Object, Object>
-{
-
-    private final List<ActivatorModel<ActivateeType>> activatorModels = new ArrayList<>();
-    private final Iterable<Class<? extends Activator<ActivateeType>>> activatorsClasses;
-
-    public ActivatorsModel( Iterable<Class<? extends Activator<ActivateeType>>> activatorsClasses )
-    {
-        this.activatorsClasses = activatorsClasses;
-        for( Class<? extends Activator<ActivateeType>> activatorClass : activatorsClasses )
-        {
-            activatorModels.add( new ActivatorModel<>( activatorClass ) );
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
-            {
-                if( !activatorModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Iterable<ActivatorModel<ActivateeType>> models()
-    {
-        return activatorModels;
-    }
-
-    public Iterable<Activator<ActivateeType>> newInstances()
-        throws ActivationException
-    {
-        List<Activator<ActivateeType>> activators = new ArrayList<>();
-        for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
-        {
-            activators.add( activatorModel.newInstance() );
-        }
-        return activators;
-    }
-
-    public Iterable<Activator<ActivateeType>> newInstances( Module module )
-        throws ActivationException
-    {
-        List<Activator<ActivateeType>> activators = new ArrayList<>();
-        for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
-        {
-            InjectionContext injectionContext = new InjectionContext( (ModuleInstance) module, UsesInstance.EMPTY_USES );
-            activators.add( activatorModel.newInstance( injectionContext ) );
-        }
-        return activators;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/AbstractAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/AbstractAssociationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/AbstractAssociationInstance.java
deleted file mode 100644
index f2ca0a3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/AbstractAssociationInstance.java
+++ /dev/null
@@ -1,93 +0,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.
- */
-package org.apache.zest.runtime.association;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.association.AbstractAssociation;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.functional.Function2;
-
-/**
- * Implementation of AbstractAssociation. Includes helper methods for subclasses
- */
-public abstract class AbstractAssociationInstance<T>
-    implements AbstractAssociation
-{
-    protected AssociationInfo associationInfo;
-    private final Function2<EntityReference, Type, Object> entityFunction;
-
-    public AbstractAssociationInstance( AssociationInfo associationInfo,
-                                        Function2<EntityReference, Type, Object> entityFunction
-    )
-    {
-        this.associationInfo = associationInfo;
-        this.entityFunction = entityFunction;
-    }
-
-    public AssociationInfo associationInfo()
-    {
-        return associationInfo;
-    }
-
-    public void setAssociationInfo( AssociationInfo newInfo )
-    {
-        this.associationInfo = newInfo;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected T getEntity( EntityReference entityId )
-    {
-        if( entityId == null )
-        {
-            return null;
-        }
-
-        return (T) entityFunction.map( entityId, associationInfo.type() );
-    }
-
-    protected EntityReference getEntityReference( Object composite )
-    {
-        if( composite == null )
-        {
-            return null;
-        }
-
-        return new EntityReference( ( (Identity) composite ).identity().get() );
-    }
-
-    protected void checkType( Object instance )
-    {
-
-        if( instance instanceof Identity || instance == null )
-        {
-            return;
-        }
-        throw new IllegalArgumentException( "Object must be a subtype of org.qi4j.api.identity.Identity: " + instance.getClass() );
-    }
-
-    protected void checkImmutable()
-        throws IllegalStateException
-    {
-        if( associationInfo.isImmutable() )
-        {
-            throw new IllegalStateException( "Association [" + associationInfo.qualifiedName() + "] is immutable." );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInfo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInfo.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInfo.java
deleted file mode 100644
index 1e70643..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInfo.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.runtime.association;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.runtime.composite.ConstraintsCheck;
-
-/**
- * TODO
- */
-public interface AssociationInfo
-    extends ConstraintsCheck
-{
-    boolean isImmutable();
-
-    QualifiedName qualifiedName();
-
-    Type type();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInstance.java
deleted file mode 100644
index 84568d4..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationInstance.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.association;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationWrapper;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.functional.Function2;
-
-/**
- * Implementation of Association to a single Entity.
- */
-public final class AssociationInstance<T>
-    extends AbstractAssociationInstance<T>
-    implements Association<T>
-{
-    private Property<EntityReference> associationState;
-
-    public AssociationInstance( AssociationInfo associationInfo,
-                                Function2<EntityReference, Type, Object> entityFunction,
-                                Property<EntityReference> associationState
-    )
-    {
-        super( associationInfo, entityFunction );
-        this.associationState = associationState;
-    }
-
-    // Association implementation
-    @Override
-    public T get()
-    {
-        return getEntity( associationState.get() );
-    }
-
-    @Override
-    public void set( T newValue )
-        throws IllegalArgumentException
-    {
-        checkImmutable();
-        checkType( newValue );
-
-        associationInfo.checkConstraints( newValue );
-
-        // Change association
-        associationState.set( EntityReference.create( (Identity) newValue ));
-    }
-
-    @Override
-    public EntityReference reference()
-    {
-        return associationState.get();
-    }
-
-    public Property<EntityReference> getAssociationState()
-    {
-        return associationState;
-    }
-
-    @Override
-    public String toString()
-    {
-        if( associationState.get() == null )
-        {
-            return "";
-        }
-        else
-        {
-            return associationState.get().toString();
-        }
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = associationInfo.hashCode() * 39; // Descriptor
-        if( associationState.get() != null )
-        {
-            hash = hash * 997 + associationState.get().hashCode(); // State
-        }
-        return hash;
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        Association<?> that = (Association) o;
-        // Unwrap if needed
-        while( that instanceof AssociationWrapper )
-        {
-            that = ( (AssociationWrapper) that ).next();
-        }
-        // Descriptor equality
-        AssociationInstance<?> thatInstance = (AssociationInstance) that;
-        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
-        if( !associationInfo.equals( thatDescriptor ) )
-        {
-            return false;
-        }
-        // State equality
-        if( associationState.get() != null
-            ? !associationState.get().equals( thatInstance.associationState.get() )
-            : thatInstance.associationState.get() != null )
-        {
-            return false;
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationModel.java
deleted file mode 100644
index 323b5aa..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationModel.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.List;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.constraint.ConstraintViolation;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.Aggregated;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Model for an Association.
- *
- * <p>Equality is based on the Association accessor object (associated type and name), not on the QualifiedName.</p>
- */
-public final class AssociationModel
-    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<AssociationModel>
-{
-    private MetaInfo metaInfo;
-    private Type type;
-    private AccessibleObject accessor;
-    private QualifiedName qualifiedName;
-    private ValueConstraintsInstance constraints;
-    private ValueConstraintsInstance associationConstraints;
-    private boolean queryable;
-    private boolean immutable;
-    private boolean aggregated;
-    private AssociationInfo builderInfo;
-
-    public AssociationModel( AccessibleObject accessor,
-                             ValueConstraintsInstance valueConstraintsInstance,
-                             ValueConstraintsInstance associationConstraintsInstance,
-                             MetaInfo metaInfo
-    )
-    {
-        this.metaInfo = metaInfo;
-        this.constraints = valueConstraintsInstance;
-        this.associationConstraints = associationConstraintsInstance;
-        this.accessor = accessor;
-        initialize();
-    }
-
-    private void initialize()
-    {
-        this.type = GenericAssociationInfo.associationTypeOf( accessor );
-        this.qualifiedName = QualifiedName.fromAccessor( accessor );
-        this.immutable = metaInfo.get( Immutable.class ) != null;
-        this.aggregated = metaInfo.get( Aggregated.class ) != null;
-
-        final Queryable queryable = accessor.getAnnotation( Queryable.class );
-        this.queryable = queryable == null || queryable.value();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public QualifiedName qualifiedName()
-    {
-        return qualifiedName;
-    }
-
-    @Override
-    public Type type()
-    {
-        return type;
-    }
-
-    @Override
-    public boolean isImmutable()
-    {
-        return immutable;
-    }
-
-    @Override
-    public boolean isAggregated()
-    {
-        return aggregated;
-    }
-
-    @Override
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public boolean queryable()
-    {
-        return queryable;
-    }
-
-    public AssociationInfo getBuilderInfo()
-    {
-        return builderInfo;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super AssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        return visitor.visit( this );
-    }
-
-    @Override
-    public void checkConstraints( Object value )
-        throws ConstraintViolationException
-    {
-        if( constraints != null )
-        {
-            List<ConstraintViolation> violations = constraints.checkConstraints( value );
-            if( !violations.isEmpty() )
-            {
-                Iterable<Class<?>> empty = empty();
-                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
-            }
-        }
-    }
-
-    public void checkAssociationConstraints( Association<?> association )
-        throws ConstraintViolationException
-    {
-        if( associationConstraints != null )
-        {
-            List<ConstraintViolation> violations = associationConstraints.checkConstraints( association );
-            if( !violations.isEmpty() )
-            {
-                throw new ConstraintViolationException( (Composite) association.get(), (Member) accessor, violations );
-            }
-        }
-    }
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        builderInfo = new AssociationInfo()
-        {
-            @Override
-            public boolean isImmutable()
-            {
-                return false;
-            }
-
-            @Override
-            public QualifiedName qualifiedName()
-            {
-                return qualifiedName;
-            }
-
-            @Override
-            public Type type()
-            {
-                return type;
-            }
-
-            @Override
-            public void checkConstraints( Object value )
-                throws ConstraintViolationException
-            {
-                AssociationModel.this.checkConstraints( value );
-            }
-        };
-
-        if( type instanceof TypeVariable )
-        {
-
-            Class mainType = first( resolution.model().types() );
-            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
-        }
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        AssociationModel that = (AssociationModel) o;
-
-        if( !accessor.equals( that.accessor ) )
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return accessor.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        if( accessor instanceof Field )
-        {
-            return ( (Field) accessor ).toGenericString();
-        }
-        else
-        {
-            return ( (Method) accessor ).toGenericString();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationsModel.java
deleted file mode 100644
index a0f3d67..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/AssociationsModel.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. 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.zest.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * Model for Associations.
- */
-public final class AssociationsModel
-    implements VisitableHierarchy<AssociationsModel, AssociationModel>
-{
-    private final Map<AccessibleObject, AssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
-
-    public AssociationsModel()
-    {
-    }
-
-    public Iterable<AssociationModel> associations()
-    {
-        return mapAccessorAssociationModel.values();
-    }
-
-    public void addAssociation( AssociationModel associationModel )
-    {
-        mapAccessorAssociationModel.put( associationModel.accessor(), associationModel );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super AssociationsModel, ? super AssociationModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
-            {
-                if( !associationModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public AssociationModel getAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        AssociationModel associationModel = mapAccessorAssociationModel.get( accessor );
-        if( associationModel == null )
-        {
-            throw new IllegalArgumentException( "No association found with name:" + ( (Member) accessor ).getName() );
-        }
-        return associationModel;
-    }
-
-    public AssociationDescriptor getAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().name().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No association found with name:" + name );
-    }
-
-    public AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            if( associationModel.qualifiedName().equals( name ) )
-            {
-                return associationModel;
-            }
-        }
-        throw new IllegalArgumentException( "No association found with qualified name:" + name );
-    }
-
-    public void checkConstraints( AssociationStateHolder state )
-    {
-        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
-        {
-            Association<Object> association = state.<Object>associationFor( associationModel.accessor() );
-            associationModel.checkAssociationConstraints( association );
-            associationModel.checkConstraints( association.get() );
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationInstance.java
deleted file mode 100644
index 4dce5a7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationInstance.java
+++ /dev/null
@@ -1,225 +0,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.
- */
-package org.apache.zest.runtime.association;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.ManyAssociationWrapper;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.spi.entity.ManyAssociationState;
-
-/**
- * JAVADOC
- */
-public class ManyAssociationInstance<T>
-    extends AbstractAssociationInstance<T>
-    implements ManyAssociation<T>
-{
-    private ManyAssociationState manyAssociationState;
-
-    public ManyAssociationInstance( AssociationInfo associationInfo,
-                                    Function2<EntityReference, Type, Object> associationFunction,
-                                    ManyAssociationState manyAssociationState
-    )
-    {
-        super( associationInfo, associationFunction );
-        this.manyAssociationState = manyAssociationState;
-    }
-
-    @Override
-    public int count()
-    {
-        return manyAssociationState.count();
-    }
-
-    @Override
-    public boolean contains( T entity )
-    {
-        return manyAssociationState.contains( getEntityReference( entity ) );
-    }
-
-    @Override
-    public boolean add( int i, T entity )
-    {
-        NullArgumentException.validateNotNull( "entity", entity );
-        checkImmutable();
-        checkType( entity );
-        associationInfo.checkConstraints( entity );
-        return manyAssociationState.add( i, new EntityReference( ( (Identity) entity ).identity().get() ) );
-    }
-
-    @Override
-    public boolean add( T entity )
-    {
-        return add( manyAssociationState.count(), entity );
-    }
-
-    @Override
-    public boolean remove( T entity )
-    {
-        NullArgumentException.validateNotNull( "entity", entity );
-        checkImmutable();
-        checkType( entity );
-
-        return manyAssociationState.remove( new EntityReference( ( (Identity) entity ).identity().get() ) );
-    }
-
-    @Override
-    public T get( int i )
-    {
-        return getEntity( manyAssociationState.get( i ) );
-    }
-
-    @Override
-    public List<T> toList()
-    {
-        ArrayList<T> list = new ArrayList<>();
-        for( EntityReference entityReference : manyAssociationState )
-        {
-            list.add( getEntity( entityReference ) );
-        }
-
-        return list;
-    }
-
-    @Override
-    public Set<T> toSet()
-    {
-        Set<T> set = new HashSet<>();
-        for( EntityReference entityReference : manyAssociationState )
-        {
-            set.add( getEntity( entityReference ) );
-        }
-
-        return set;
-    }
-
-    @Override
-    public Iterable<EntityReference> references()
-    {
-        return Iterables.toList( manyAssociationState );
-    }
-
-    @Override
-    public String toString()
-    {
-        return manyAssociationState.toString();
-    }
-
-    @Override
-    public Iterator<T> iterator()
-    {
-        return new ManyAssociationIterator( manyAssociationState.iterator() );
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        ManyAssociation<?> that = (ManyAssociation) o;
-        // Unwrap if needed
-        while( that instanceof ManyAssociationWrapper )
-        {
-            that = ( (ManyAssociationWrapper) that ).next();
-        }
-        // Descriptor equality
-        ManyAssociationInstance<?> thatInstance = (ManyAssociationInstance) that;
-        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
-        if( !associationInfo.equals( thatDescriptor ) )
-        {
-            return false;
-        }
-        // State equality
-        if( manyAssociationState.count() != thatInstance.manyAssociationState.count() )
-        {
-            return false;
-        }
-        for( EntityReference ref : manyAssociationState )
-        {
-            if( !thatInstance.manyAssociationState.contains( ref ) )
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = associationInfo.hashCode() * 31; // Descriptor
-        for( EntityReference ref : manyAssociationState )
-        {
-            hash += ref.hashCode() * 7; // State
-        }
-        return hash;
-    }
-
-    public ManyAssociationState getManyAssociationState()
-    {
-        return manyAssociationState;
-    }
-
-    protected class ManyAssociationIterator
-        implements Iterator<T>
-    {
-        private final Iterator<EntityReference> idIterator;
-
-        public ManyAssociationIterator( Iterator<EntityReference> idIterator )
-        {
-            this.idIterator = idIterator;
-        }
-
-        @Override
-        public boolean hasNext()
-        {
-            return idIterator.hasNext();
-        }
-
-        @Override
-        public T next()
-        {
-            return getEntity( idIterator.next() );
-        }
-
-        @Override
-        public void remove()
-        {
-            checkImmutable();
-            idIterator.remove();
-        }
-    }
-}


[46/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsProvider.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsProvider.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsProvider.java
deleted file mode 100644
index 78ad9d8..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Metrics Provider SPI.
- * <p>
- * The Zest Runtime will automatically ook for a service that implements the MetricsProvider interdace
- * and use it for internal Runtime metrics, such as the UnitOfWork measuring the time from creation to close.
- * </p>
- * <p>
- * The Metrics Library is available to add metric functionality to applications in the same way, and
- * will use the same MetricsProvider.
- * </p>
- * <p>
- * Note that the usual visibitlity rules applies, so you might have more than one MetricsProvider server,
- * perhaps per layer.
- * </p>
- */
-public interface MetricsProvider
-{
-    /**
-     * Creates a new factory instance.
-     *
-     * The instanctiation is done by providing a Metric type, which is one of
-     * <ul>
-     * <li>{@link MetricsCounter}</li>
-     * <li>{@link MetricsGauge}</li>
-     * <li>{@link MetricsHealthCheck}</li>
-     * <li>{@link MetricsHistogram}</li>
-     * <li>{@link MetricsMeter}</li>
-     * <li>{@link MetricsTimer}</li>
-     * </ul>
-     *
-     * @param factoryType The class of the metric type needed.
-     * @param <T>         The metric type requested.
-     *
-     * @return A factory instance
-     *
-     * @throws MetricsNotSupportedException when the MetricsProvider is not supporting the factory type requested.
-     */
-    <T extends MetricsFactory> T createFactory( Class<T> factoryType )
-        throws MetricsNotSupportedException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimer.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimer.java
deleted file mode 100644
index 2065e6a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Timer Metrics.
- */
-public interface MetricsTimer extends Metric
-{
-    /**
-     * Start the Timer Metrics.
-     */
-    Context start();
-
-    /**
-     * Timer Metrics Context.
-     */
-    public interface Context
-    {
-        /**
-         * Stop the Timer Metrics.
-         */
-        void stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimerFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimerFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimerFactory.java
deleted file mode 100644
index 74a7b7f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsTimerFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Create MetricsTimer instances.
- */
-public interface MetricsTimerFactory extends MetricsFactory
-{
-    /**
-     * Create a MetricsTimer instance.
-     * If the same arguments are given twice, the same instance must be returned.
-     *
-     * @param origin   The class that instantiate the metric
-     * @param name     A human readable, short name of the metric.
-     * @param duration the scale unit for this timer's duration metrics
-     * @param rate     the scale unit for this timer's rate metrics
-     *
-     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
-     *
-     */
-    MetricsTimer createTimer( Class<?> origin, String name, TimeUnit duration, TimeUnit rate );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/package.html b/core/api/src/main/java/org/apache/zest/api/metrics/package.html
deleted file mode 100644
index d0280bd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Metrics API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/Initializable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/Initializable.java b/core/api/src/main/java/org/apache/zest/api/mixin/Initializable.java
deleted file mode 100644
index be551c2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/Initializable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.mixin;
-
-/**
- * Fragments which want to be initialized can implement
- * this callback interface. It will be invoked after
- * the fragment has bee instantiated and all injections have been done.
- */
-public interface Initializable
-{
-    /**
-     * Initialize the fragment
-     *
-     * @throws org.apache.zest.api.mixin.InitializationException
-     *          if something went wrong
-     */
-    void initialize()
-        throws InitializationException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/InitializationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/InitializationException.java b/core/api/src/main/java/org/apache/zest/api/mixin/InitializationException.java
deleted file mode 100644
index c46c3af..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/InitializationException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.mixin;
-
-/**
- * Thrown when a Fragment or object could not be instantiated.
- */
-public class InitializationException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = 1L;
-
-    public InitializationException()
-    {
-    }
-
-    public InitializationException( String message )
-    {
-        super( message );
-    }
-
-    public InitializationException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    public InitializationException( Throwable cause )
-    {
-        super( cause );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/InvalidMixinException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/InvalidMixinException.java b/core/api/src/main/java/org/apache/zest/api/mixin/InvalidMixinException.java
deleted file mode 100644
index 10a3375..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/InvalidMixinException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.mixin;
-
-import java.lang.reflect.Method;
-
-/**
- * This exception is thrown if a Mixin is invalid (missing method implementation).
- */
-public class InvalidMixinException
-    extends RuntimeException
-{
-    public InvalidMixinException( Class mixinClass, Method method )
-    {
-        super( mixinClass.getName() + "does not have a method implementation for " + method );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/MixinDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/MixinDescriptor.java b/core/api/src/main/java/org/apache/zest/api/mixin/MixinDescriptor.java
deleted file mode 100644
index 9ae3600..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/MixinDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.mixin;
-
-/**
- * Mixin Descriptor.
- */
-public interface MixinDescriptor
-{
-    Class<?> mixinClass();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/MixinMappingException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/MixinMappingException.java b/core/api/src/main/java/org/apache/zest/api/mixin/MixinMappingException.java
deleted file mode 100644
index 13692a1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/MixinMappingException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.mixin;
-
-/**
- * This Exception is thrown when it is not possible to map the MixinType to a valid
- * CompositeType.
- */
-public class MixinMappingException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = 6843167709252705294L;
-
-    public MixinMappingException( String message )
-    {
-        super( message );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/Mixins.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/Mixins.java b/core/api/src/main/java/org/apache/zest/api/mixin/Mixins.java
deleted file mode 100644
index 1573589..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/Mixins.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.mixin;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used in composites to declare mixin implementation classes.
- * <p>
- * Mixins tells the runtime which implementation class of a Mixin should be
- * used. The &#64;Mixins annotation can occur at any level in the composite hierarchy
- * and the runtime will match each found Mixin implementation against a Mixins annotation.
- * All mixin interfaces must have a Mixin implementation in the composite hierarchy or
- * a runtime exception will occur.
- * </p>
- * <p>
- * Example;
- * </p>
- * <pre><code>
- *
- * &#64;Mixins( MyBeerOrder.class )
- * public interface BeerOrderComposite extends BeerOrder, Composite
- * {
- * }
- *
- * public class MyBeerOrder
- * implements BeerOrder
- * {
- * :
- * }
- * </code></pre>
- * <p>
- * Many implementations can be listed,
- * </p>
- * <pre><code>
- * &#64;Mixins( { MyBeerOrder.class, DescriptionImpl.class } )
- * public interface BeerOrderComposite extends BeerOrder, Description, Composite
- * {
- * }
- * </code></pre>
- * <p>
- * If the Mixins is a class that implements InvocationHandler, it will be
- * used for all mixins. To avoid that an invocation handler based implementation
- * not service all mixin, use the AppliesTo annotation.
- * </p>
- *
- * <p>
- * It is valid to have multiple Mixins for a mixin. The first one found
- * will be used. The search order is in the order they are written in the Mixins
- * annotation left-to-right, and depth-first recursive search of the super-interfaces again
- * left-to-right.
- * </p>
- *
- * @see org.apache.zest.api.common.AppliesTo
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( ElementType.TYPE )
-@Documented
-public @interface Mixins
-{
-    Class<?>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/NoopMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/NoopMixin.java b/core/api/src/main/java/org/apache/zest/api/mixin/NoopMixin.java
deleted file mode 100644
index 86a8a26..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/NoopMixin.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.mixin;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * Generic mixin that is a no-op. Can be useful if the functionality
- * of a method is mainly provided by concerns and side-effects.
- */
-public final class NoopMixin
-    implements InvocationHandler
-{
-    private static final Boolean BOOLEAN_DEFAULT = Boolean.FALSE;
-    private static final Short SHORT_DEFAULT = 0;
-    private static final Character CHARACTER_DEFAULT = 0;
-    private static final Integer INTEGER_DEFAULT = 0;
-    private static final Long LONG_DEFAULT = 0L;
-    private static final Float FLOAT_DEFAULT = 0f;
-    private static final Double DOUBLE_DEFAULT = 0.0;
-
-    @Override
-    public Object invoke( Object object, Method method, Object[] args )
-        throws Throwable
-    {
-        Class<?> retType = method.getReturnType();
-        if( !retType.isPrimitive() )
-        {
-            return null;
-        }
-        if( Void.TYPE == retType )
-        {
-            return null;
-        }
-        if( Boolean.TYPE == retType )
-        {
-            return BOOLEAN_DEFAULT;
-        }
-        if( Short.TYPE == retType )
-        {
-            return SHORT_DEFAULT;
-        }
-        if( Character.TYPE == retType )
-        {
-            return CHARACTER_DEFAULT;
-        }
-        if( Integer.TYPE == retType )
-        {
-            return INTEGER_DEFAULT;
-        }
-        if( Long.TYPE == retType )
-        {
-            return LONG_DEFAULT;
-        }
-        if( Float.TYPE == retType )
-        {
-            return FLOAT_DEFAULT;
-        }
-        if( Double.TYPE == retType )
-        {
-            return DOUBLE_DEFAULT;
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/mixin/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/mixin/package.html b/core/api/src/main/java/org/apache/zest/api/mixin/package.html
deleted file mode 100644
index a0ebe07..0000000
--- a/core/api/src/main/java/org/apache/zest/api/mixin/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Mixin API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/object/NoSuchObjectException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/object/NoSuchObjectException.java b/core/api/src/main/java/org/apache/zest/api/object/NoSuchObjectException.java
deleted file mode 100644
index 35e2655..0000000
--- a/core/api/src/main/java/org/apache/zest/api/object/NoSuchObjectException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.object;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-
-/**
- * This exception is thrown if no visible Object of the requested type can be found.
- */
-public class NoSuchObjectException
-    extends InvalidApplicationException
-{
-    private static final long serialVersionUID = -1121690536365682511L;
-
-    private final String objectType;
-    private final String moduleName;
-
-    public NoSuchObjectException( String type, String moduleName )
-    {
-        super( "Could not find any visible Object of type [" + type + "] in module [" +
-               moduleName + "]." );
-        this.objectType = type;
-        this.moduleName = moduleName;
-    }
-
-    public String objectType()
-    {
-        return objectType;
-    }
-
-    public String moduleName()
-    {
-        return moduleName;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/object/ObjectDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/object/ObjectDescriptor.java b/core/api/src/main/java/org/apache/zest/api/object/ObjectDescriptor.java
deleted file mode 100644
index 00c6363..0000000
--- a/core/api/src/main/java/org/apache/zest/api/object/ObjectDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.object;
-
-import org.apache.zest.api.composite.ModelDescriptor;
-
-/**
- * Object Descriptor.
- */
-public interface ObjectDescriptor
-    extends ModelDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/object/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/object/ObjectFactory.java b/core/api/src/main/java/org/apache/zest/api/object/ObjectFactory.java
deleted file mode 100644
index 23b95da..0000000
--- a/core/api/src/main/java/org/apache/zest/api/object/ObjectFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.object;
-
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * This factory creates and injects POJO's.
- */
-public interface ObjectFactory
-{
-    /**
-     * Create new objects of the given type.
-     *
-     * @param type an object class which will be instantiated.
-     *
-     * @return new objects.
-     *
-     * @throws ConstructionException Thrown if instantiation fails.
-     * @throws NoSuchObjectException Thrown if {@code type} class is not an object.
-     */
-    <T> T newObject( Class<T> type, Object... uses )
-        throws NoSuchObjectException, ConstructionException;
-
-    /**
-     * Inject an existing instance. Only fields and methods will be called.
-     *
-     * @param instance
-     *
-     * @throws ConstructionException
-     */
-    void injectTo( Object instance, Object... uses )
-        throws ConstructionException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/object/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/object/package.html b/core/api/src/main/java/org/apache/zest/api/object/package.html
deleted file mode 100644
index 1e06504..0000000
--- a/core/api/src/main/java/org/apache/zest/api/object/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Object API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/package.html b/core/api/src/main/java/org/apache/zest/api/package.html
deleted file mode 100644
index ff7d9af..0000000
--- a/core/api/src/main/java/org/apache/zest/api/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Apache Zest™ API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/DefaultValues.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/DefaultValues.java b/core/api/src/main/java/org/apache/zest/api/property/DefaultValues.java
deleted file mode 100644
index db6545e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/DefaultValues.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2008, Michael Hunger. 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.zest.api.property;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Default values for various property types
- */
-public final class DefaultValues
-{
-    private static final Map<Type, Object> DEFAULT_VALUES = new HashMap<Type, Object>();
-
-    static
-    {
-        DEFAULT_VALUES.put( Byte.class, 0 );
-        DEFAULT_VALUES.put( Short.class, 0 );
-        DEFAULT_VALUES.put( Character.class, 0 );
-        DEFAULT_VALUES.put( Integer.class, 0 );
-        DEFAULT_VALUES.put( Long.class, 0L );
-        DEFAULT_VALUES.put( Double.class, 0D );
-        DEFAULT_VALUES.put( Float.class, 0F );
-        DEFAULT_VALUES.put( Boolean.class, false );
-        DEFAULT_VALUES.put( String.class, "" );
-    }
-
-    public static Object getDefaultValueOf( Type type )
-    {
-        Object value = DEFAULT_VALUES.get( type );
-        if( value != null )
-        {
-            return value;
-        }
-        if( type instanceof ParameterizedType )
-        {
-            // List<Foo> -> List
-            type = ( (ParameterizedType) type ).getRawType();
-        }
-
-        if( type instanceof Class )
-        {
-            Class typeAsClass = (Class) type;
-            if( Set.class.isAssignableFrom( typeAsClass ) )
-            {
-                return new HashSet();
-            }
-            else if( Map.class.isAssignableFrom( typeAsClass ) )
-            {
-                return new LinkedHashMap();
-            }
-            else if( Collection.class.isAssignableFrom( typeAsClass ) )
-            {
-                return new ArrayList();
-            }
-            else if( typeAsClass.isEnum() )
-            {
-                return ( (Class) type ).getEnumConstants()[ 0 ];
-            }
-        }
-        throw new IllegalArgumentException( "Cannot use @UseDefaults with type " + type.toString() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/GenericPropertyInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/GenericPropertyInfo.java b/core/api/src/main/java/org/apache/zest/api/property/GenericPropertyInfo.java
deleted file mode 100644
index 5c8e419..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/GenericPropertyInfo.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2007,2008 Niclas Hedhman.
- *
- * 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.zest.api.property;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-import static org.apache.zest.api.util.Classes.typeOf;
-
-/**
- * Generic Property info utility class.
- */
-public final class GenericPropertyInfo
-{
-    public static Type propertyTypeOf( AccessibleObject accessor )
-    {
-        return toPropertyType( typeOf( accessor ) );
-    }
-
-    public static Type toPropertyType( Type methodReturnType )
-    {
-        if( methodReturnType instanceof ParameterizedType )
-        {
-            ParameterizedType parameterizedType = (ParameterizedType) methodReturnType;
-            if( Property.class.isAssignableFrom( (Class<?>) parameterizedType.getRawType() ) )
-            {
-                return parameterizedType.getActualTypeArguments()[ 0 ];
-            }
-        }
-
-        if( methodReturnType instanceof Class<?> )
-        {
-            Type[] interfaces = ( (Class<?>) methodReturnType ).getGenericInterfaces();
-            for( Type anInterface : interfaces )
-            {
-                Type propertyType = toPropertyType( anInterface );
-                if( propertyType != null )
-                {
-                    return propertyType;
-                }
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/Immutable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/Immutable.java b/core/api/src/main/java/org/apache/zest/api/property/Immutable.java
deleted file mode 100644
index 5611a5a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/Immutable.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.property;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation adds Immutability to Types, Properties and Associations
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface Immutable
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/InvalidPropertyTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/InvalidPropertyTypeException.java b/core/api/src/main/java/org/apache/zest/api/property/InvalidPropertyTypeException.java
deleted file mode 100644
index 8d5b87d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/InvalidPropertyTypeException.java
+++ /dev/null
@@ -1,40 +0,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.
- */
-package org.apache.zest.api.property;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * Thrown when attempting to subclass Property.
- */
-public class InvalidPropertyTypeException extends ConstructionException
-{
-    public InvalidPropertyTypeException( AccessibleObject accessor )
-    {
-        super( createMessage(accessor) );
-    }
-
-    private static String createMessage( AccessibleObject accessor )
-    {
-        StringBuilder builder = new StringBuilder();
-        builder.append( "Not allowed to subclass " + Property.class.getName() + ". Property accessor " + accessor + " is returning a Property subclass." );
-        return builder.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/Numbers.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/Numbers.java b/core/api/src/main/java/org/apache/zest/api/property/Numbers.java
deleted file mode 100644
index 2fd39bf..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/Numbers.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.property;
-
-import java.math.BigDecimal;
-
-/**
- * Convenience class for mathematical operations on numerical properties.
- * <pre>import static org.qi4j.api.property.Numbers.*;
- * ...
- * add( object.numberProperty(), 5 );</pre>
- */
-public final class Numbers
-{
-    // Integer operations
-
-    public static Property<Integer> add( Property<Integer> property, int amount )
-    {
-        property.set( property.get() + amount );
-        return property;
-    }
-
-    public static Property<Integer> mult( Property<Integer> property, int amount )
-    {
-        property.set( property.get() * amount );
-        return property;
-    }
-
-    public static Property<Integer> sub( Property<Integer> property, int amount )
-    {
-        property.set( property.get() - amount );
-        return property;
-    }
-
-    public static Property<Integer> div( Property<Integer> property, int amount )
-    {
-        property.set( property.get() / amount );
-        return property;
-    }
-
-    // Long operations
-
-    public static Property<Long> add( Property<Long> property, long amount )
-    {
-        property.set( property.get() + amount );
-        return property;
-    }
-
-    public static Property<Long> mult( Property<Long> property, long amount )
-    {
-        property.set( property.get() * amount );
-        return property;
-    }
-
-    public static Property<Long> sub( Property<Long> property, long amount )
-    {
-        property.set( property.get() - amount );
-        return property;
-    }
-
-    public static Property<Long> div( Property<Long> property, long amount )
-    {
-        property.set( property.get() / amount );
-        return property;
-    }
-
-    // Double operations
-
-    public static Property<Double> add( Property<Double> property, double amount )
-    {
-        property.set( property.get() + amount );
-        return property;
-    }
-
-    public static Property<Double> mult( Property<Double> property, double amount )
-    {
-        property.set( property.get() * amount );
-        return property;
-    }
-
-    public static Property<Double> sub( Property<Double> property, double amount )
-    {
-        property.set( property.get() - amount );
-        return property;
-    }
-
-    public static Property<Double> div( Property<Double> property, double amount )
-    {
-        property.set( property.get() / amount );
-        return property;
-    }
-
-    // Float operations
-
-    public static Property<Float> add( Property<Float> property, float amount )
-    {
-        property.set( property.get() + amount );
-        return property;
-    }
-
-    public static Property<Float> mult( Property<Float> property, float amount )
-    {
-        property.set( property.get() * amount );
-        return property;
-    }
-
-    public static Property<Float> sub( Property<Float> property, float amount )
-    {
-        property.set( property.get() - amount );
-        return property;
-    }
-
-    public static Property<Float> div( Property<Float> property, float amount )
-    {
-        property.set( property.get() / amount );
-        return property;
-    }
-
-    // BigDecimal operations
-
-    public static Property<BigDecimal> add( Property<BigDecimal> property, BigDecimal amount )
-    {
-        property.set( property.get().add( amount ) );
-        return property;
-    }
-
-    public static Property<BigDecimal> mult( Property<BigDecimal> property, BigDecimal amount )
-    {
-        property.set( property.get().multiply( amount ) );
-        return property;
-    }
-
-    public static Property<BigDecimal> sub( Property<BigDecimal> property, BigDecimal amount )
-    {
-        property.set( property.get().subtract( amount ) );
-        return property;
-    }
-
-    public static Property<BigDecimal> div( Property<BigDecimal> property, BigDecimal amount )
-    {
-        property.set( property.get().divide( amount ) );
-        return property;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/Property.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/Property.java b/core/api/src/main/java/org/apache/zest/api/property/Property.java
deleted file mode 100644
index 9721e92..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/Property.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. 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.zest.api.property;
-
-/**
- * Properties are declared in Composite interfaces by using this interface.
- * <p>
- * It creates a first-class object for the property from which you can get and set the value, and access any
- * metadata about it.
- * </p>
- * <p>The type of the Property can be one of the following:</p>
- * <ul>
- * <li> A boxed primitive (Long,Integer,Boolean, etc.)</li>
- * <li> String</li>
- * <li> BigInteger</li>
- * <li> BigDecimal</li>
- * <li> Date</li>
- * <li> DateTime (Joda Time)</li>
- * <li> LocalDateTime (Joda Time)</li>
- * <li> A serializable</li>
- * <li> A ValueComposite</li>
- * <li> A List, Set or Collection of any of the above</li>
- * </ul>
- *
- * @param <T> Parameterized type of the Property
- */
-public interface Property<T>
-{
-    /**
-     * Get the value of the property.
-     *
-     * @return the value
-     */
-    T get();
-
-    /**
-     * Set the value of the property
-     *
-     * @param newValue the new value
-     *
-     * @throws IllegalArgumentException if the value has an invalid value
-     * @throws IllegalStateException    if the property is immutable
-     */
-    void set( T newValue )
-        throws IllegalArgumentException, IllegalStateException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java b/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
deleted file mode 100644
index 649b1fc..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.property;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Type;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.ValueType;
-
-/**
- * Property Descriptor.
- */
-public interface PropertyDescriptor extends MetaInfoHolder
-{
-    boolean isImmutable();
-
-    /**
-     * Get the qualified name of the property which is equal to:
-     * <pre><code>
-     * &lt;interface name&gt;:&lt;method name&gt;
-     * </code></pre>
-     *
-     * @return the qualified name of the property
-     */
-    QualifiedName qualifiedName();
-
-    /**
-     * Get the type of the property. If the property is declared
-     * as Property&lt;X&gt; then X is returned.
-     *
-     * @return the property type
-     */
-    Type type();
-
-    AccessibleObject accessor();
-
-    Object initialValue( Module module );
-
-    ValueType valueType();
-
-    boolean queryable();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/PropertyMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/PropertyMixin.java b/core/api/src/main/java/org/apache/zest/api/property/PropertyMixin.java
deleted file mode 100644
index 4e08f5c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/PropertyMixin.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.property;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.injection.scope.State;
-
-/**
- * Generic mixin for properties.
- */
-// START SNIPPET: actual
-@AppliesTo( { PropertyMixin.PropertyFilter.class } )
-public final class PropertyMixin
-    implements InvocationHandler
-{
-    @State
-    private StateHolder state;
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return state.propertyFor( method );
-    }
-
-    /**
-     * Filter Property methods to apply generic Property Mixin.
-     */
-    public static class PropertyFilter
-        implements AppliesToFilter
-    {
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
-        {
-            return Property.class.isAssignableFrom( method.getReturnType() );
-        }
-    }
-}
-// END SNIPPET: actual

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/PropertyWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/PropertyWrapper.java b/core/api/src/main/java/org/apache/zest/api/property/PropertyWrapper.java
deleted file mode 100644
index f397908..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/PropertyWrapper.java
+++ /dev/null
@@ -1,71 +0,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.
- */
-package org.apache.zest.api.property;
-
-/**
- * If you want to catch getting and setting properties, then create a GenericConcern
- * that wraps the Zest-supplied Property instance with PropertyWrappers. Override
- * get() and/or set() to perform your custom code.
- */
-public class PropertyWrapper
-    implements Property<Object>
-{
-    protected Property<Object> next;
-
-    public PropertyWrapper( Property<Object> next )
-    {
-        this.next = next;
-    }
-
-    public Property<Object> next()
-    {
-        return next;
-    }
-
-    @Override
-    public Object get()
-    {
-        return next.get();
-    }
-
-    @Override
-    public void set( Object newValue )
-        throws IllegalArgumentException, IllegalStateException
-    {
-        next.set( newValue );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return next.hashCode();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        return next.equals( obj );
-    }
-
-    @Override
-    public String toString()
-    {
-        return next.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/StateHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/StateHolder.java b/core/api/src/main/java/org/apache/zest/api/property/StateHolder.java
deleted file mode 100644
index d188d3d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/StateHolder.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.property;
-
-import java.lang.reflect.AccessibleObject;
-
-/**
- * This represents the state of a composite (properties).
- */
-public interface StateHolder
-{
-    /**
-     * Get a property for a specific accessor
-     *
-     * @param accessor of the property
-     *
-     * @return the property
-     *
-     * @throws IllegalArgumentException if no property for given accessor exists
-     */
-    <T> Property<T> propertyFor( AccessibleObject accessor )
-        throws IllegalArgumentException;
-
-    Iterable<? extends Property<?>> properties();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/property/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/package.html b/core/api/src/main/java/org/apache/zest/api/property/package.html
deleted file mode 100644
index 8fc2a93..0000000
--- a/core/api/src/main/java/org/apache/zest/api/property/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Property API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/MissingIndexingSystemException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/MissingIndexingSystemException.java b/core/api/src/main/java/org/apache/zest/api/query/MissingIndexingSystemException.java
deleted file mode 100644
index aca06c4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/MissingIndexingSystemException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.query;
-
-/**
- * This Exception is thrown in <code>QueryBuilderFactory.newQueryBuilder()</code> method if
- * no indexing subsystem has been declared in the assembly.
- */
-public final class MissingIndexingSystemException
-    extends QueryException
-{
-    private static final long serialVersionUID = 5147421865890379209L;
-
-    public MissingIndexingSystemException()
-    {
-        super( "No EntityFinder has been declared in the assembly of the application." );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/NotQueryableException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/NotQueryableException.java b/core/api/src/main/java/org/apache/zest/api/query/NotQueryableException.java
deleted file mode 100644
index 403ba4c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/NotQueryableException.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2009 Alin Dreghiciu.
- *
- * 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.zest.api.query;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.util.Classes;
-
-/**
- * Thrown in case that a non queryable type or accessor (marked with @Queriable(false)) is used during query building,
- * or when non-Property, non-Associations are trying to be queried (possibly can not happen).
- */
-public class NotQueryableException
-    extends QueryException
-{
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Constructor.
-     *
-     * @param message exception message
-     */
-    public NotQueryableException( final String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Verify that the provided accessor method has not been marked with a Queryable(false).
-     *
-     * @param accessor accessor method
-     *
-     * @throws NotQueryableException - If accessor method has been marked as not queryable
-     */
-    public static void throwIfNotQueryable( final AccessibleObject accessor )
-    {
-        Queryable queryable = accessor.getAnnotation( Queryable.class );
-        if( queryable != null && !queryable.value() )
-        {
-            throw new NotQueryableException(
-                String.format(
-                    "%1$s \"%2$s\" (%3$s) is not queryable as has been marked with @Queryable(false)",
-                    Classes.RAW_CLASS.map( GenericPropertyInfo.propertyTypeOf( accessor ) ).getSimpleName(),
-                    ( (Member) accessor ).getName(),
-                    ( (Member) accessor ).getDeclaringClass().getName()
-                )
-            );
-        }
-    }
-
-    /**
-     * Verify that the provided type has not been marked with a Queryable(false).
-     *
-     * @param type a type
-     *
-     * @throws NotQueryableException - If type has been marked as not queryable
-     */
-    public static void throwIfNotQueryable( final Class<?> type )
-    {
-        Queryable queryable = type.getAnnotation( Queryable.class );
-        if( queryable != null && !queryable.value() )
-        {
-            throw new NotQueryableException(
-                String.format(
-                    "Type \"%1$s\" is not queryable as has been marked with @Queryable(false)",
-                    type.getName()
-                )
-            );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/Query.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/Query.java b/core/api/src/main/java/org/apache/zest/api/query/Query.java
deleted file mode 100644
index 84e2c9c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/Query.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2007 Rickard Öberg.
- * Copyright 2007 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.api.query;
-
-import java.io.Serializable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.grammar.OrderBy;
-
-/**
- * This represents a Query in an indexing system. It is created from a
- * {@link QueryBuilder}, which decides the "where" clause in the query.
- * <p>
- * Additional limitations, such as paging, ordering, and variables, can be set on
- * a Query before it is executed by calling one of find(), iterator(),
- * or count().
- * </p>
- * <p>
- * DDD tip: typically Queries are created in the Domain Model and passed to the UI,
- * which sets the order and paging before executing it.
- * </p>
- */
-public interface Query<T>
-    extends Iterable<T>, Serializable
-{
-    /**
-     * Set the ordering rules. If many segments are used for ordering
-     * then they will be applied in order.
-     *
-     * @param segments the segments to order by
-     *
-     * @return the Query
-     */
-    Query<T> orderBy( OrderBy... segments );
-
-    /**
-     * Append an ordering rule to the existing segments.
-     *
-     * @param property the property to order by
-     * @param order the order to apply
-     *
-     * @return the Query
-     */
-    Query<T> orderBy( final Property<?> property, final OrderBy.Order order );
-
-    /**
-     * Append an ascending ordering rule to the existing segments.
-     *
-     * @param property the property to order by
-     *
-     * @return the Query
-     */
-    Query<T> orderBy( Property<?> property );
-
-    /**
-     * Set the index of the first result. Default is 0 (zero).
-     *
-     * @param firstResult which index to use as the first one
-     *
-     * @return the Query
-     */
-    Query<T> firstResult( int firstResult );
-
-    /**
-     * Set how many results should be returned. Default is that
-     * there is no limit set.
-     *
-     * @param maxResults that shouldbe returned
-     *
-     * @return the query
-     */
-    Query<T> maxResults( int maxResults );
-
-    /**
-     * Get the first Entity that matches the criteria. This
-     * executes the Query.
-     *
-     * @return the first found Entity or null if none were found
-     *
-     * @throws QueryExecutionException if the query fails
-     */
-    T find()
-        throws QueryExecutionException;
-
-    /**
-     * Set the value of a named variable.
-     *
-     * @param name  of the variable
-     * @param value of the variable
-     *
-     * @return the query
-     */
-    Query<T> setVariable( String name, Object value );
-
-    /**
-     * Get the value of a named variable.
-     *
-     * @param name of the variable
-     *
-     * @return value of the variable
-     */
-    <V> V getVariable( String name );
-
-    /**
-     * Get the result type of this Query
-     *
-     * @return the result type
-     */
-    Class<T> resultType();
-
-    /**
-     * Count how many results would be returned by this Query.
-     * This executes the Query.
-     *
-     * @return result count
-     *
-     * @throws QueryExecutionException if the query fails
-     */
-    long count()
-        throws QueryExecutionException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryBuilder.java b/core/api/src/main/java/org/apache/zest/api/query/QueryBuilder.java
deleted file mode 100644
index 38b010c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2007 Rickard Öberg.
- * Copyright 2008 Alin Dreghiciu.
- *
- * 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.zest.api.query;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-
-/**
- * QueryBuilders are used to create {@link Query} instances.
- * Iteratively add where() clauses to the query, and then use
- * {@link org.apache.zest.api.unitofwork.UnitOfWork#newQuery(QueryBuilder)}  to instantiate the Query.
- * QueryBuilders are immutable, so when adding new where-clauses you get new instances. This
- *
- * DDD tip: Query objects are not executed immediately, so they
- * should be constructed in the domain model and handed over to
- * the UI, which can then further constrain it before actual
- * execution.
- */
-public interface QueryBuilder<T>
-{
-    /**
-     * Add a where-clause to the Query. Use {@link QueryExpressions}
-     * to create the expression.
-     *
-     * @param specification the where clause
-     *
-     * @return a new builder with the added where-clause
-     */
-    QueryBuilder<T> where( Specification<Composite> specification );
-
-    /**
-     * Create a new query with the declared where-clauses that will be evaluated against the iterable entries.
-     *
-     * @param iterable collection of objects (composites?)
-     *
-     * @return a new Query instance
-     */
-    Query<T> newQuery( Iterable<T> iterable );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryBuilderFactory.java b/core/api/src/main/java/org/apache/zest/api/query/QueryBuilderFactory.java
deleted file mode 100644
index fe40289..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryBuilderFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.query;
-
-/**
- * This is used to create QueryBuilders.
- *
- * @see QueryBuilder
- */
-public interface QueryBuilderFactory
-{
-    /**
-     * Create a new QueryBuilder.
-     *
-     * @param resultType the type of the result that you want
-     *
-     * @return a QueryBuilder
-     *
-     * @throws MissingIndexingSystemException if there is no EntityFinder service available
-     */
-    <T> QueryBuilder<T> newQueryBuilder( Class<T> resultType )
-        throws MissingIndexingSystemException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryException.java b/core/api/src/main/java/org/apache/zest/api/query/QueryException.java
deleted file mode 100644
index a0bd0f6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.query;
-
-/**
- * Base class for Query exceptions.
- */
-public abstract class QueryException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = -3602596752342902060L;
-
-    public QueryException()
-    {
-    }
-
-    public QueryException( final String message )
-    {
-        super( message );
-    }
-
-    public QueryException( final String message, final Throwable cause )
-    {
-        super( message, cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryExecutionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryExecutionException.java b/core/api/src/main/java/org/apache/zest/api/query/QueryExecutionException.java
deleted file mode 100644
index f068843..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryExecutionException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.query;
-
-/**
- * Throw this exception if a query could not be executed
- */
-public final class QueryExecutionException
-    extends QueryException
-{
-    private static final long serialVersionUID = 5147421865890379209L;
-
-    public QueryExecutionException( String message )
-    {
-        super( message );
-    }
-
-    public QueryExecutionException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryExpressionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressionException.java b/core/api/src/main/java/org/apache/zest/api/query/QueryExpressionException.java
deleted file mode 100644
index 676bed0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressionException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.query;
-
-/**
- * Throw this exception if a QueryExpression is invalid.
- */
-public class QueryExpressionException
-    extends QueryException
-{
-
-    private static final long serialVersionUID = 1L;
-
-    public QueryExpressionException( String message )
-    {
-        super( message );
-    }
-
-}


[03/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/LayerAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/LayerAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/LayerAssemblyImpl.java
new file mode 100644
index 0000000..8853f92
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/LayerAssemblyImpl.java
@@ -0,0 +1,625 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.structure.Layer;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.AssemblyVisitor;
+import org.qi4j.bootstrap.EntityAssembly;
+import org.qi4j.bootstrap.EntityDeclaration;
+import org.qi4j.bootstrap.ImportedServiceAssembly;
+import org.qi4j.bootstrap.ImportedServiceDeclaration;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.ObjectAssembly;
+import org.qi4j.bootstrap.ObjectDeclaration;
+import org.qi4j.bootstrap.ServiceAssembly;
+import org.qi4j.bootstrap.ServiceDeclaration;
+import org.qi4j.bootstrap.TransientAssembly;
+import org.qi4j.bootstrap.TransientDeclaration;
+import org.qi4j.bootstrap.ValueAssembly;
+import org.qi4j.bootstrap.ValueDeclaration;
+import org.qi4j.functional.Specification;
+
+/**
+ * Assembly of a Layer. From here you can create more ModuleAssemblies for
+ * the Layer that is being assembled. It is also here that you define
+ * what other Layers this Layer is using by calling {@link org.qi4j.runtime.bootstrap.LayerAssemblyImpl#uses()}.
+ */
+public final class LayerAssemblyImpl
+    implements LayerAssembly
+{
+    private final ApplicationAssembly applicationAssembly;
+    private final HashMap<String, ModuleAssemblyImpl> moduleAssemblies;
+    private final Set<LayerAssembly> uses;
+
+    private String name;
+    private final MetaInfo metaInfo = new MetaInfo();
+    private final List<Class<? extends Activator<Layer>>> activators = new ArrayList<>();
+
+    public LayerAssemblyImpl( ApplicationAssembly applicationAssembly, String name )
+    {
+        this.applicationAssembly = applicationAssembly;
+        this.name = name;
+
+        moduleAssemblies = new LinkedHashMap<>();
+        uses = new LinkedHashSet<>();
+    }
+
+    @Override
+    public ModuleAssembly module( String name )
+    {
+        if( name != null )
+        {
+            ModuleAssemblyImpl existing = moduleAssemblies.get( name );
+            if( existing != null )
+            {
+                return existing;
+            }
+        }
+        ModuleAssemblyImpl moduleAssembly = new ModuleAssemblyImpl( this, name );
+        moduleAssemblies.put( name, moduleAssembly );
+        return moduleAssembly;
+    }
+
+    @Override
+    public ApplicationAssembly application()
+    {
+        return applicationAssembly;
+    }
+
+    @Override
+    public LayerAssembly setName( String name )
+    {
+        this.name = name;
+        return this;
+    }
+
+    @Override
+    public LayerAssembly setMetaInfo( Object info )
+    {
+        metaInfo.set( info );
+        return this;
+    }
+
+    @Override
+    public LayerAssembly uses( LayerAssembly... layerAssembly )
+        throws IllegalArgumentException
+    {
+        uses.addAll( Arrays.asList( layerAssembly ) );
+        return this;
+    }
+
+    @Override
+    @SafeVarargs
+    public final LayerAssembly withActivators( Class<? extends Activator<Layer>>... activators )
+    {
+        this.activators.addAll( Arrays.asList( activators ) );
+        return this;
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType
+    {
+        visitor.visitLayer( this );
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            moduleAssembly.visit( visitor );
+        }
+    }
+
+    @Override
+    public EntityDeclaration entities( Specification<? super EntityAssembly> specification )
+    {
+        final List<EntityDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.entities( specification ) );
+        }
+
+        return new EntityDeclaration()
+        {
+            @Override
+            public EntityDeclaration setMetaInfo( Object info )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( info );
+                }
+                return this;
+            }
+
+            @Override
+            public EntityDeclaration visibleIn( Visibility visibility )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+
+            @Override
+            public EntityDeclaration withConcerns( Class<?>... concerns )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.withConcerns( concerns );
+                }
+                return this;
+            }
+
+            @Override
+            public EntityDeclaration withSideEffects( Class<?>... sideEffects )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.withSideEffects( sideEffects );
+                }
+                return this;
+            }
+
+            @Override
+            public EntityDeclaration withMixins( Class<?>... mixins )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.withMixins( mixins );
+                }
+                return this;
+            }
+
+            @Override
+            public EntityDeclaration withTypes( Class<?>... types )
+            {
+                for( EntityDeclaration declaration : declarations )
+                {
+                    declaration.withTypes( types );
+                }
+                return this;
+            }
+        };
+    }
+
+    @Override
+    public ServiceDeclaration services( Specification<? super ServiceAssembly> specification )
+    {
+        final List<ServiceDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.services( specification ) );
+        }
+
+        return new ServiceDeclaration()
+        {
+            @Override
+            public ServiceDeclaration setMetaInfo( Object serviceAttribute )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( serviceAttribute );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration visibleIn( Visibility visibility )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration withConcerns( Class<?>... concerns )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.withConcerns( concerns );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration withSideEffects( Class<?>... sideEffects )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.withSideEffects( sideEffects );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration withMixins( Class<?>... mixins )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.withMixins( mixins );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration withTypes( Class<?>... types )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.withTypes( types );
+                }
+                return this;
+            }
+
+            @Override
+            @SafeVarargs
+            public final ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.withActivators( activators );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration identifiedBy( String identity )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.identifiedBy( identity );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration taggedWith( String... tags )
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.taggedWith( tags );
+                }
+                return this;
+            }
+
+            @Override
+            public ServiceDeclaration instantiateOnStartup()
+            {
+                for( ServiceDeclaration declaration : declarations )
+                {
+                    declaration.instantiateOnStartup();
+                }
+
+                return this;
+            }
+        };
+    }
+
+    @Override
+    public TransientDeclaration transients( Specification<? super TransientAssembly> specification )
+    {
+        final List<TransientDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.transients( specification ) );
+        }
+
+        return new TransientDeclaration()
+        {
+            @Override
+            public TransientDeclaration setMetaInfo( Object info )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( info );
+                }
+                return this;
+            }
+
+            @Override
+            public TransientDeclaration visibleIn( Visibility visibility )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+
+            @Override
+            public TransientDeclaration withConcerns( Class<?>... concerns )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.withConcerns( concerns );
+                }
+                return this;
+            }
+
+            @Override
+            public TransientDeclaration withSideEffects( Class<?>... sideEffects )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.withSideEffects( sideEffects );
+                }
+                return this;
+            }
+
+            @Override
+            public TransientDeclaration withMixins( Class<?>... mixins )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.withMixins( mixins );
+                }
+                return this;
+            }
+
+            @Override
+            public TransientDeclaration withTypes( Class<?>... types )
+            {
+                for( TransientDeclaration declaration : declarations )
+                {
+                    declaration.withTypes( types );
+                }
+                return this;
+            }
+        };
+    }
+
+    @Override
+    public ValueDeclaration values( Specification<? super ValueAssembly> specification )
+    {
+        final List<ValueDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.values( specification ) );
+        }
+        return new ValueDeclaration()
+        {
+            @Override
+            public ValueDeclaration setMetaInfo( Object info )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( info );
+                }
+                return this;
+            }
+
+            @Override
+            public ValueDeclaration visibleIn( Visibility visibility )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+
+            @Override
+            public ValueDeclaration withConcerns( Class<?>... concerns )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.withConcerns( concerns );
+                }
+                return this;
+            }
+
+            @Override
+            public ValueDeclaration withSideEffects( Class<?>... sideEffects )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.withSideEffects( sideEffects );
+                }
+                return this;
+            }
+
+            @Override
+            public ValueDeclaration withMixins( Class<?>... mixins )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.withMixins( mixins );
+                }
+                return this;
+            }
+
+            @Override
+            public ValueDeclaration withTypes( Class<?>... types )
+            {
+                for( ValueDeclaration declaration : declarations )
+                {
+                    declaration.withTypes( types );
+                }
+                return this;
+            }
+        };
+    }
+
+    @Override
+    public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification )
+    {
+        final List<ObjectDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.objects( specification ) );
+        }
+        return new ObjectDeclaration()
+        {
+            @Override
+            public ObjectDeclaration setMetaInfo( Object info )
+            {
+                for( ObjectDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( info );
+                }
+                return this;
+            }
+
+            @Override
+            public ObjectDeclaration visibleIn( Visibility visibility )
+                throws IllegalStateException
+            {
+                for( ObjectDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+        };
+    }
+
+    @Override
+    public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification )
+    {
+        final List<ImportedServiceDeclaration> declarations = new ArrayList<>();
+
+        for( ModuleAssemblyImpl moduleAssembly : moduleAssemblies.values() )
+        {
+            declarations.add( moduleAssembly.importedServices( specification ) );
+        }
+        return new ImportedServiceDeclaration()
+        {
+
+            @Override
+            public ImportedServiceDeclaration importOnStartup()
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.importOnStartup();
+                }
+                return this;
+            }
+
+            @Override
+            public ImportedServiceDeclaration visibleIn( Visibility visibility )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.visibleIn( visibility );
+                }
+                return this;
+            }
+
+            @Override
+            public ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.importedBy( serviceImporterClass );
+                }
+                return this;
+            }
+
+            @Override
+            public ImportedServiceDeclaration identifiedBy( String identity )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.identifiedBy( identity );
+                }
+                return this;
+            }
+
+            @Override
+            public ImportedServiceDeclaration taggedWith( String... tags )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.taggedWith( tags );
+                }
+                return this;
+            }
+
+            @Override
+            public ImportedServiceDeclaration setMetaInfo( Object serviceAttribute )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.setMetaInfo( serviceAttribute );
+                }
+                return this;
+            }
+
+            @Override
+            @SafeVarargs
+            public final ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
+            {
+                for( ImportedServiceDeclaration declaration : declarations )
+                {
+                    declaration.withActivators( activators );
+                }
+                return this;
+            }
+
+        };
+    }
+
+    Collection<ModuleAssemblyImpl> moduleAssemblies()
+    {
+        return moduleAssemblies.values();
+    }
+
+    Set<LayerAssembly> uses()
+    {
+        return uses;
+    }
+
+    public MetaInfo metaInfo()
+    {
+        return metaInfo;
+    }
+
+    @Override
+    public String name()
+    {
+        return name;
+    }
+
+    public List<Class<? extends Activator<Layer>>> activators()
+    {
+        return activators;
+    }
+
+    @Override
+    public final String toString()
+    {
+        return "LayerAssembly [" + name + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ModuleAssemblyImpl.java
new file mode 100644
index 0000000..1f470dc
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -0,0 +1,635 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.composite.TransientComposite;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.service.DuplicateServiceIdentityException;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.HasTypes;
+import org.qi4j.api.type.MatchTypeSpecification;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.AssemblySpecifications;
+import org.qi4j.bootstrap.AssemblyVisitor;
+import org.qi4j.bootstrap.ConfigurationDeclaration;
+import org.qi4j.bootstrap.EntityAssembly;
+import org.qi4j.bootstrap.EntityDeclaration;
+import org.qi4j.bootstrap.ImportedServiceAssembly;
+import org.qi4j.bootstrap.ImportedServiceDeclaration;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.MetaInfoDeclaration;
+import org.qi4j.bootstrap.MixinDeclaration;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.ObjectAssembly;
+import org.qi4j.bootstrap.ObjectDeclaration;
+import org.qi4j.bootstrap.ServiceAssembly;
+import org.qi4j.bootstrap.ServiceDeclaration;
+import org.qi4j.bootstrap.TransientAssembly;
+import org.qi4j.bootstrap.TransientDeclaration;
+import org.qi4j.bootstrap.ValueAssembly;
+import org.qi4j.bootstrap.ValueDeclaration;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+import org.qi4j.runtime.activation.ActivatorsModel;
+import org.qi4j.runtime.composite.TransientModel;
+import org.qi4j.runtime.composite.TransientsModel;
+import org.qi4j.runtime.entity.EntitiesModel;
+import org.qi4j.runtime.entity.EntityModel;
+import org.qi4j.runtime.object.ObjectModel;
+import org.qi4j.runtime.object.ObjectsModel;
+import org.qi4j.runtime.service.ImportedServiceModel;
+import org.qi4j.runtime.service.ImportedServicesModel;
+import org.qi4j.runtime.service.ServiceModel;
+import org.qi4j.runtime.service.ServicesModel;
+import org.qi4j.runtime.structure.ModuleModel;
+import org.qi4j.runtime.value.ValueModel;
+import org.qi4j.runtime.value.ValuesModel;
+
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * Assembly of a Module. This is where you register all objects, Composites,
+ * Services. Each "add" method returns a declaration that you can use to add
+ * additional information and metadata. If you call an "add" method with many
+ * parameters then the declared metadata will apply to all types in the method
+ * call.
+ */
+public final class ModuleAssemblyImpl
+    implements ModuleAssembly
+{
+    private final LayerAssembly layerAssembly;
+    private String name;
+    private final MetaInfo metaInfo = new MetaInfo();
+    private final List<Class<? extends Activator<Module>>> activators = new ArrayList<>();
+
+    private final List<ServiceAssemblyImpl> serviceAssemblies = new ArrayList<>();
+    private final Map<Class<?>, ImportedServiceAssemblyImpl> importedServiceAssemblies = new LinkedHashMap<>();
+    private final Map<Class<? extends EntityComposite>, EntityAssemblyImpl> entityAssemblies = new LinkedHashMap<>();
+    private final Map<Class<? extends ValueComposite>, ValueAssemblyImpl> valueAssemblies = new LinkedHashMap<>();
+    private final Map<Class<? extends TransientComposite>, TransientAssemblyImpl> transientAssemblies = new LinkedHashMap<>();
+    private final Map<Class<?>, ObjectAssemblyImpl> objectAssemblies = new LinkedHashMap<>();
+
+    private final MetaInfoDeclaration metaInfoDeclaration = new MetaInfoDeclaration();
+
+    public ModuleAssemblyImpl( LayerAssembly layerAssembly, String name )
+    {
+        this.layerAssembly = layerAssembly;
+        this.name = name;
+    }
+
+    @Override
+    public LayerAssembly layer()
+    {
+        return layerAssembly;
+    }
+
+    @Override
+    public ModuleAssembly module( String layerName, String moduleName )
+    {
+        return layerAssembly.application().module( layerName, moduleName );
+    }
+
+    @Override
+    public ModuleAssembly setName( String name )
+    {
+        this.name = name;
+        return this;
+    }
+
+    @Override
+    public String name()
+    {
+        return name;
+    }
+
+    public ModuleAssembly setMetaInfo( Object info )
+    {
+        metaInfo.set( info );
+        return this;
+    }
+
+    @Override
+    @SafeVarargs
+    public final ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators )
+    {
+        this.activators.addAll( Arrays.asList( activators ) );
+        return this;
+    }
+
+    @Override
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public ValueDeclaration values( Class<?>... valueTypes )
+    {
+        List<ValueAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class valueType : valueTypes )
+        {
+            if( valueAssemblies.containsKey( valueType ) )
+            {
+                assemblies.add( valueAssemblies.get( valueType ) );
+            }
+            else
+            {
+                ValueAssemblyImpl valueAssembly = new ValueAssemblyImpl( valueType );
+                valueAssemblies.put( valueType, valueAssembly );
+                assemblies.add( valueAssembly );
+            }
+        }
+
+        return new ValueDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ValueDeclaration values( Specification<? super ValueAssembly> specification )
+    {
+        List<ValueAssemblyImpl> assemblies = new ArrayList<>();
+        for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() )
+        {
+            if( specification.satisfiedBy( transientAssembly ) )
+            {
+                assemblies.add( transientAssembly );
+            }
+        }
+
+        return new ValueDeclarationImpl( assemblies );
+    }
+
+    @Override
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public TransientDeclaration transients( Class<?>... transientTypes )
+    {
+        List<TransientAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class valueType : transientTypes )
+        {
+            if( transientAssemblies.containsKey( valueType ) )
+            {
+                assemblies.add( transientAssemblies.get( valueType ) );
+            }
+            else
+            {
+                TransientAssemblyImpl transientAssembly = new TransientAssemblyImpl( valueType );
+                transientAssemblies.put( valueType, transientAssembly );
+                assemblies.add( transientAssembly );
+            }
+        }
+
+        return new TransientDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public TransientDeclaration transients( Specification<? super TransientAssembly> specification )
+    {
+        List<TransientAssemblyImpl> assemblies = new ArrayList<>();
+        for( TransientAssemblyImpl transientAssembly : transientAssemblies.values() )
+        {
+            if( specification.satisfiedBy( transientAssembly ) )
+            {
+                assemblies.add( transientAssembly );
+            }
+        }
+
+        return new TransientDeclarationImpl( assemblies );
+    }
+
+    @Override
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public EntityDeclaration entities( Class<?>... entityTypes )
+    {
+        List<EntityAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class entityType : entityTypes )
+        {
+            if( entityAssemblies.containsKey( entityType ) )
+            {
+                assemblies.add( entityAssemblies.get( entityType ) );
+            }
+            else
+            {
+                EntityAssemblyImpl entityAssembly = new EntityAssemblyImpl( entityType );
+                entityAssemblies.put( entityType, entityAssembly );
+                assemblies.add( entityAssembly );
+            }
+        }
+
+        return new EntityDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public EntityDeclaration entities( Specification<? super EntityAssembly> specification )
+    {
+        List<EntityAssemblyImpl> assemblies = new ArrayList<>();
+        for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() )
+        {
+            if( specification.satisfiedBy( entityAssembly ) )
+            {
+                assemblies.add( entityAssembly );
+            }
+        }
+
+        return new EntityDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ConfigurationDeclaration configurations( Class<?>... configurationTypes )
+    {
+        List<EntityAssemblyImpl> entityAssemblyList = new ArrayList<>();
+
+        for( Class entityType : configurationTypes )
+        {
+            if( this.entityAssemblies.containsKey( entityType ) )
+            {
+                entityAssemblyList.add( this.entityAssemblies.get( entityType ) );
+            }
+            else
+            {
+                EntityAssemblyImpl entityAssembly = new EntityAssemblyImpl( entityType );
+                this.entityAssemblies.put( entityType, entityAssembly );
+                entityAssemblyList.add( entityAssembly );
+            }
+        }
+
+        List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>();
+
+        for( Class valueType : configurationTypes )
+        {
+            if( valueAssemblies.containsKey( valueType ) )
+            {
+                valueAssemblyList.add( valueAssemblies.get( valueType ) );
+            }
+            else
+            {
+                ValueAssemblyImpl valueAssembly = new ValueAssemblyImpl( valueType );
+                valueAssemblies.put( valueType, valueAssembly );
+                valueAssemblyList.add( valueAssembly );
+                valueAssembly.types.add( Identity.class );
+            }
+        }
+
+        return new ConfigurationDeclarationImpl( entityAssemblyList, valueAssemblyList  );
+    }
+
+    @Override
+    public ConfigurationDeclaration configurations( Specification<HasTypes> specification )
+    {
+        Specification<HasTypes> isConfigurationComposite = new MatchTypeSpecification( Identity.class );
+        specification = Specifications.and( specification, isConfigurationComposite );
+        List<EntityAssemblyImpl> entityAssmblyList = new ArrayList<>();
+        for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() )
+        {
+            if( specification.satisfiedBy( entityAssembly ) )
+            {
+                entityAssmblyList.add( entityAssembly );
+            }
+        }
+        List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>();
+        for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() )
+        {
+            if( specification.satisfiedBy( transientAssembly ) )
+            {
+                valueAssemblyList.add( transientAssembly );
+            }
+        }
+        return new ConfigurationDeclarationImpl( entityAssmblyList, valueAssemblyList );
+    }
+
+    @Override
+    public ObjectDeclaration objects( Class<?>... objectTypes )
+        throws AssemblyException
+    {
+        List<ObjectAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class<?> objectType : objectTypes )
+        {
+            if( objectType.isInterface() )
+            {
+                throw new AssemblyException( "Interfaces can not be Zest Objects." );
+            }
+            if( objectAssemblies.containsKey( objectType ) )
+            {
+                assemblies.add( objectAssemblies.get( objectType ) );
+            }
+            else
+            {
+                ObjectAssemblyImpl objectAssembly = new ObjectAssemblyImpl( objectType );
+                objectAssemblies.put( objectType, objectAssembly );
+                assemblies.add( objectAssembly );
+            }
+        }
+
+        return new ObjectDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ObjectDeclaration objects( Specification<? super ObjectAssembly> specification )
+    {
+        List<ObjectAssemblyImpl> assemblies = new ArrayList<>();
+        for( ObjectAssemblyImpl objectAssembly : objectAssemblies.values() )
+        {
+            if( specification.satisfiedBy( objectAssembly ) )
+            {
+                assemblies.add( objectAssembly );
+            }
+        }
+
+        return new ObjectDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ServiceDeclaration addServices( Class<?>... serviceTypes )
+    {
+        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class<?> serviceType : serviceTypes )
+        {
+            ServiceAssemblyImpl serviceAssembly = new ServiceAssemblyImpl( serviceType );
+            serviceAssemblies.add( serviceAssembly );
+            assemblies.add( serviceAssembly );
+        }
+
+        return new ServiceDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ServiceDeclaration services( Class<?>... serviceTypes )
+    {
+        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class<?> serviceType : serviceTypes )
+        {
+            if( Iterables.matchesAny( AssemblySpecifications.types( serviceType ), serviceAssemblies ) )
+            {
+                Iterables.addAll( assemblies, Iterables.filter( AssemblySpecifications.types( serviceType ), serviceAssemblies ) );
+            }
+            else
+            {
+                ServiceAssemblyImpl serviceAssembly = new ServiceAssemblyImpl( serviceType );
+                serviceAssemblies.add( serviceAssembly );
+                assemblies.add( serviceAssembly );
+            }
+        }
+
+        return new ServiceDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ServiceDeclaration services( Specification<? super ServiceAssembly> specification )
+    {
+        List<ServiceAssemblyImpl> assemblies = new ArrayList<>();
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            if( specification.satisfiedBy( serviceAssembly ) )
+            {
+                assemblies.add( serviceAssembly );
+            }
+        }
+
+        return new ServiceDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ImportedServiceDeclaration importedServices( Class<?>... serviceTypes )
+    {
+        List<ImportedServiceAssemblyImpl> assemblies = new ArrayList<>();
+
+        for( Class<?> serviceType : serviceTypes )
+        {
+            if( importedServiceAssemblies.containsKey( serviceType ) )
+            {
+                assemblies.add( importedServiceAssemblies.get( serviceType ) );
+            }
+            else
+            {
+                ImportedServiceAssemblyImpl serviceAssembly = new ImportedServiceAssemblyImpl( serviceType, this );
+                importedServiceAssemblies.put( serviceType, serviceAssembly );
+                assemblies.add( serviceAssembly );
+            }
+        }
+
+        return new ImportedServiceDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification )
+    {
+        List<ImportedServiceAssemblyImpl> assemblies = new ArrayList<>();
+        for( ImportedServiceAssemblyImpl objectAssembly : importedServiceAssemblies.values() )
+        {
+            if( specification.satisfiedBy( objectAssembly ) )
+            {
+                assemblies.add( objectAssembly );
+            }
+        }
+
+        return new ImportedServiceDeclarationImpl( assemblies );
+    }
+
+    @Override
+    public <T> MixinDeclaration<T> forMixin( Class<T> mixinType )
+    {
+        return metaInfoDeclaration.on( mixinType );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType
+    {
+        visitor.visitModule( this );
+
+        for( TransientAssemblyImpl compositeDeclaration : transientAssemblies.values() )
+        {
+            visitor.visitComposite( new TransientDeclarationImpl( iterable( compositeDeclaration ) ) );
+        }
+
+        for( EntityAssemblyImpl entityDeclaration : entityAssemblies.values() )
+        {
+            visitor.visitEntity( new EntityDeclarationImpl( iterable( entityDeclaration ) ) );
+        }
+
+        for( ObjectAssemblyImpl objectDeclaration : objectAssemblies.values() )
+        {
+            visitor.visitObject( new ObjectDeclarationImpl( iterable( objectDeclaration ) ) );
+        }
+
+        for( ServiceAssemblyImpl serviceDeclaration : serviceAssemblies )
+        {
+            visitor.visitService( new ServiceDeclarationImpl( iterable( serviceDeclaration ) ) );
+        }
+
+        for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
+        {
+            visitor.visitImportedService( new ImportedServiceDeclarationImpl( iterable( importedServiceDeclaration ) ) );
+        }
+
+        for( ValueAssemblyImpl valueDeclaration : valueAssemblies.values() )
+        {
+            visitor.visitValue( new ValueDeclarationImpl( iterable( valueDeclaration ) ) );
+        }
+    }
+
+    ModuleModel assembleModule( AssemblyHelper helper )
+        throws AssemblyException
+    {
+        List<TransientModel> transientModels = new ArrayList<>();
+        List<ObjectModel> objectModels = new ArrayList<>();
+        List<ValueModel> valueModels = new ArrayList<>();
+        List<ServiceModel> serviceModels = new ArrayList<>();
+        List<ImportedServiceModel> importedServiceModels = new ArrayList<>();
+
+        if( name == null )
+        {
+            throw new AssemblyException( "Module must have name set" );
+        }
+
+        for( TransientAssemblyImpl compositeDeclaration : transientAssemblies.values() )
+        {
+            transientModels.add( compositeDeclaration.newTransientModel( metaInfoDeclaration, helper ) );
+        }
+
+        for( ValueAssemblyImpl valueDeclaration : valueAssemblies.values() )
+        {
+            valueModels.add( valueDeclaration.newValueModel( metaInfoDeclaration, helper ) );
+        }
+
+        List<EntityModel> entityModels = new ArrayList<>();
+        for( EntityAssemblyImpl entityDeclaration : entityAssemblies.values() )
+        {
+            entityModels.add( entityDeclaration.newEntityModel( metaInfoDeclaration, 
+                                                                metaInfoDeclaration, 
+                                                                metaInfoDeclaration, 
+                                                                metaInfoDeclaration, 
+                                                                helper ) );
+        }
+
+        for( ObjectAssemblyImpl objectDeclaration : objectAssemblies.values() )
+        {
+            objectDeclaration.addObjectModel( objectModels );
+        }
+
+        for( ServiceAssemblyImpl serviceDeclaration : serviceAssemblies )
+        {
+            if( serviceDeclaration.identity == null )
+            {
+                serviceDeclaration.identity = generateId( serviceDeclaration.types() );
+            }
+
+            serviceModels.add( serviceDeclaration.newServiceModel( metaInfoDeclaration, helper ) );
+        }
+
+        for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
+        {
+            importedServiceDeclaration.addImportedServiceModel( importedServiceModels );
+        }
+
+        ModuleModel moduleModel = new ModuleModel( name,
+                                                   metaInfo,
+                                                   new ActivatorsModel<>( activators ),
+                                                   new TransientsModel( transientModels ),
+                                                   new EntitiesModel( entityModels ),
+                                                   new ObjectsModel( objectModels ),
+                                                   new ValuesModel( valueModels ),
+                                                   new ServicesModel( serviceModels ),
+                                                   new ImportedServicesModel( importedServiceModels ) );
+
+        // Check for duplicate service identities
+        Set<String> identities = new HashSet<>();
+        for( ServiceModel serviceModel : serviceModels )
+        {
+            String identity = serviceModel.identity();
+            if( identities.contains( identity ) )
+            {
+                throw new DuplicateServiceIdentityException(
+                    "Duplicated service identity: " + identity + " in module " + moduleModel.name()
+                );
+            }
+            identities.add( identity );
+        }
+        for( ImportedServiceModel serviceModel : importedServiceModels )
+        {
+            String identity = serviceModel.identity();
+            if( identities.contains( identity ) )
+            {
+                throw new DuplicateServiceIdentityException(
+                    "Duplicated service identity: " + identity + " in module " + moduleModel.name()
+                );
+            }
+            identities.add( identity );
+        }
+
+        for( ImportedServiceModel importedServiceModel : importedServiceModels )
+        {
+            boolean found = false;
+            for( ObjectModel objectModel : objectModels )
+            {
+                if( first( objectModel.types() ).equals( importedServiceModel.serviceImporter() ) )
+                {
+                    found = true;
+                    break;
+                }
+            }
+            if( !found )
+            {
+                @SuppressWarnings( "raw" )
+                Class<? extends ServiceImporter> serviceFactoryType = importedServiceModel.serviceImporter();
+                ObjectModel objectModel = new ObjectModel( serviceFactoryType, Visibility.module, new MetaInfo() );
+                objectModels.add( objectModel );
+            }
+        }
+
+        return moduleModel;
+    }
+
+    private String generateId( Iterable<Class<?>> serviceTypes )
+    {
+        // Find service identity that is not yet used
+        Class<?> serviceType = serviceTypes.iterator()
+            .next(); // Use the first Iterable, which *SHOULD* be the main serviceType
+        int idx = 0;
+        String id = serviceType.getSimpleName();
+        boolean invalid;
+        do
+        {
+            invalid = false;
+            for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+            {
+                if( serviceAssembly.identity() != null && serviceAssembly.identity().equals( id ) )
+                {
+                    idx++;
+                    id = serviceType.getSimpleName() + "_" + idx;
+                    invalid = true;
+                    break;
+                }
+            }
+        }
+        while( invalid );
+        return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectAssemblyImpl.java
new file mode 100644
index 0000000..71475aa
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectAssemblyImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Modifier;
+import java.util.List;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.bootstrap.ObjectAssembly;
+import org.qi4j.functional.Iterables;
+import org.qi4j.runtime.object.ObjectModel;
+
+/**
+ * Assembly of an Object.
+ */
+public final class ObjectAssemblyImpl
+    implements ObjectAssembly
+{
+    private Class<?> objectType;
+    MetaInfo metaInfo = new MetaInfo();
+    Visibility visibility = Visibility.module;
+
+    public ObjectAssemblyImpl( Class<?> clazz )
+    {
+        // best try to find out if the class is a concrete class
+        if( clazz.isEnum() ||
+            ( !Composite.class.isAssignableFrom( clazz ) && Modifier.isAbstract( clazz.getModifiers() ) ) )
+        {
+            throw new IllegalArgumentException( "Declared objects must be concrete classes: " + clazz );
+        }
+        this.objectType = clazz;
+    }
+
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return Iterables.<Class<?>>iterable( objectType );
+    }
+
+    void addObjectModel( List<ObjectModel> objectModels )
+    {
+        try
+        {
+            ObjectModel objectModel = new ObjectModel( objectType, visibility, metaInfo );
+            objectModels.add( objectModel );
+        }
+        catch( Throwable e )
+        {
+            throw new InvalidApplicationException( "Could not register " + objectType.getName(), e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectDeclarationImpl.java
new file mode 100644
index 0000000..c06032e
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ObjectDeclarationImpl.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.ObjectDeclaration;
+
+/**
+ * Declaration of an Object. Created by {@link org.qi4j.runtime.bootstrap.ModuleAssemblyImpl#objects(Class[])}.
+ */
+public final class ObjectDeclarationImpl
+    implements ObjectDeclaration
+{
+    private final Iterable<ObjectAssemblyImpl> assemblies;
+
+    public ObjectDeclarationImpl( Iterable<ObjectAssemblyImpl> assemblies )
+    {
+        this.assemblies = assemblies;
+    }
+
+    @Override
+    public ObjectDeclaration setMetaInfo( Object info )
+    {
+        for( ObjectAssemblyImpl assembly : assemblies )
+        {
+            assembly.metaInfo.set( info );
+        }
+        return this;
+    }
+
+    @Override
+    public ObjectDeclaration visibleIn( Visibility visibility )
+        throws IllegalStateException
+    {
+        for( ObjectAssemblyImpl assembly : assemblies )
+        {
+            assembly.visibility = visibility;
+        }
+        return this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/OrAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/OrAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/OrAppliesToFilter.java
new file mode 100644
index 0000000..e50b748
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/OrAppliesToFilter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class OrAppliesToFilter
+    implements AppliesToFilter
+{
+    private final AppliesToFilter left;
+    private final AppliesToFilter right;
+
+    OrAppliesToFilter( AppliesToFilter left, AppliesToFilter right )
+    {
+        this.left = left;
+        this.right = right;
+    }
+
+    @Override
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        return left.appliesTo( method, mixin, compositeType, fragmentClass ) ||
+               right.appliesTo( method, mixin, compositeType, fragmentClass );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceAssemblyImpl.java
new file mode 100644
index 0000000..1adbfe6
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceAssemblyImpl.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.activation.Activators;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.ServiceAssembly;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+import org.qi4j.runtime.activation.ActivatorsModel;
+import org.qi4j.runtime.service.ServiceModel;
+
+/**
+ * Assembly of a Service.
+ */
+public final class ServiceAssemblyImpl extends CompositeAssemblyImpl
+    implements ServiceAssembly
+{
+    String identity;
+    boolean instantiateOnStartup = false;
+    List<Class<? extends Activator<?>>> activators = new ArrayList<>();
+
+    public ServiceAssemblyImpl( Class<?> serviceType )
+    {
+        super( serviceType );
+        // The composite must always implement ServiceComposite, as a marker interface
+        if( !ServiceComposite.class.isAssignableFrom( serviceType ) )
+        {
+            types.add( ServiceComposite.class );
+        }
+    }
+
+    @Override
+    public String identity()
+    {
+        return identity;
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    ServiceModel newServiceModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
+    {
+        try
+        {
+            buildComposite( helper, stateDeclarations );
+            List<Class<? extends Activator<?>>> activatorClasses = Iterables.toList(
+                    Iterables.<Class<? extends Activator<?>>>flatten( activators, activatorsDeclarations( types ) ) );
+            return new ServiceModel( types, visibility, metaInfo,
+                                     new ActivatorsModel( activatorClasses ),
+                                     mixinsModel, stateModel, compositeMethodsModel,
+                                     identity, instantiateOnStartup );
+        }
+        catch( Exception e )
+        {
+            throw new InvalidApplicationException( "Could not register " + types, e );
+        }
+    }
+    
+    private Iterable<Class<? extends Activator<?>>> activatorsDeclarations( Iterable<? extends Class<?>> typess )
+    {
+        // Find activator declarations
+        ArrayList<Type> allTypes = new ArrayList<>();
+        for( Class<?> type : typess )
+        {
+            Iterable<Type> types = Classes.typesOf( type );
+            Iterables.addAll( allTypes, types );
+        }
+        // Find all activators and flattern them into an iterable
+        Function<Type, Iterable<Class<? extends Activator<?>>>> function = new Function<Type, Iterable<Class<? extends Activator<?>>>>()
+        {
+            @Override
+            public Iterable<Class<? extends Activator<?>>> map( Type type )
+            {
+                Activators activators = Annotations.annotationOn( type, Activators.class );
+                if( activators == null )
+                {
+                    return Iterables.empty();
+                }
+                else
+                {
+                    return Iterables.iterable( activators.value() );
+                }
+            }
+        };
+        Iterable<Class<? extends Activator<?>>> flatten = Iterables.flattenIterables( Iterables.map( function, allTypes ) );
+        return Iterables.toList( flatten );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceDeclarationImpl.java
new file mode 100644
index 0000000..34e1f6d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ServiceDeclarationImpl.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.service.qualifier.ServiceTags;
+import org.qi4j.bootstrap.ServiceDeclaration;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Declaration of a Service. Created by {@link org.qi4j.runtime.bootstrap.ModuleAssemblyImpl#services(Class[])}.
+ */
+public final class ServiceDeclarationImpl
+    implements ServiceDeclaration
+{
+    private final Iterable<ServiceAssemblyImpl> serviceAssemblies;
+
+    public ServiceDeclarationImpl( Iterable<ServiceAssemblyImpl> serviceAssemblies )
+    {
+        this.serviceAssemblies = serviceAssemblies;
+    }
+
+    @Override
+    public ServiceDeclaration visibleIn( Visibility visibility )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration identifiedBy( String identity )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.identity = identity;
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration taggedWith( String... tags )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            ServiceTags previousTags = serviceAssembly.metaInfo.get( ServiceTags.class );
+            if( previousTags != null )
+            {
+                List<String> tagList = new ArrayList<>();
+                tagList.addAll( asList( previousTags.tags() ) );
+                tagList.addAll( asList( tags ) );
+                serviceAssembly.metaInfo.set( new ServiceTags( tagList.toArray( new String[ tagList.size() ] ) ) );
+            }
+            else
+            {
+                serviceAssembly.metaInfo.set( new ServiceTags( tags ) );
+            }
+        }
+
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration instantiateOnStartup()
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.instantiateOnStartup = true;
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration setMetaInfo( Object serviceAttribute )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.metaInfo.set( serviceAttribute );
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration withConcerns( Class<?>... concerns )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.concerns.addAll( asList( concerns ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration withSideEffects( Class<?>... sideEffects )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.sideEffects.addAll( asList( sideEffects ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration withMixins( Class<?>... mixins )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.mixins.addAll( asList( mixins ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ServiceDeclaration withTypes( Class<?>... types )
+    {
+        for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
+        {
+            serviceAssembly.types.addAll( asList( types ) );
+        }
+        return this;
+    }
+
+    @Override
+    @SafeVarargs
+    public final ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators )
+    {
+        for ( ServiceAssemblyImpl serviceAssembly : serviceAssemblies ) {
+            serviceAssembly.activators.addAll( asList( activators ) );
+        }
+        return this;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientAssemblyImpl.java
new file mode 100644
index 0000000..dfc9721
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientAssemblyImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.composite.TransientComposite;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.bootstrap.TransientAssembly;
+import org.qi4j.runtime.composite.TransientModel;
+
+/**
+ * Declaration of a TransientComposite.
+ */
+public final class TransientAssemblyImpl extends CompositeAssemblyImpl
+    implements TransientAssembly
+{
+    public TransientAssemblyImpl( Class<?> transientType )
+    {
+        super( transientType );
+
+        // The composite must always implement TransientComposite, as a marker interface
+        if( !TransientComposite.class.isAssignableFrom( transientType ) )
+        {
+            types.add( TransientComposite.class );
+        }
+
+        // If type is a class, register it as a mixin
+        if( !transientType.isInterface() )
+        {
+            mixins.add( transientType );
+        }
+    }
+
+    TransientModel newTransientModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
+    {
+        try
+        {
+            buildComposite( helper, stateDeclarations );
+            TransientModel transientModel = new TransientModel(
+                types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
+
+            return transientModel;
+        }
+        catch( Exception e )
+        {
+            throw new InvalidApplicationException( "Could not register " + types, e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientDeclarationImpl.java
new file mode 100644
index 0000000..9a9154f
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TransientDeclarationImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.TransientDeclaration;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Declaration of a Composite. Created by {@link org.qi4j.bootstrap.ModuleAssembly#transients(Class[])}.
+ */
+public final class TransientDeclarationImpl
+    implements TransientDeclaration
+{
+    private final Iterable<TransientAssemblyImpl> assemblies;
+
+    public TransientDeclarationImpl( Iterable<TransientAssemblyImpl> assemblies )
+    {
+        this.assemblies = assemblies;
+    }
+
+    @Override
+    public TransientDeclaration setMetaInfo( Object info )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.metaInfo.set( info );
+        }
+        return this;
+    }
+
+    @Override
+    public TransientDeclaration visibleIn( Visibility visibility )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    public TransientDeclaration withConcerns( Class<?>... concerns )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.concerns.addAll( asList( concerns ) );
+        }
+        return this;
+    }
+
+    @Override
+    public TransientDeclaration withSideEffects( Class<?>... sideEffects )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.sideEffects.addAll( asList( sideEffects ) );
+        }
+        return this;
+    }
+
+    @Override
+    public TransientDeclaration withMixins( Class<?>... mixins )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.mixins.addAll( asList( mixins ) );
+        }
+        return this;
+    }
+
+    @Override
+    public TransientDeclaration withTypes( Class<?>... types )
+    {
+        for( TransientAssemblyImpl assembly : assemblies )
+        {
+            assembly.types.addAll( asList( types ) );
+        }
+        return this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypeCheckAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypeCheckAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypeCheckAppliesToFilter.java
new file mode 100644
index 0000000..dee1993
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypeCheckAppliesToFilter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class TypeCheckAppliesToFilter
+    implements AppliesToFilter
+{
+    @SuppressWarnings( "raw" )
+    private final Class type;
+
+    @SuppressWarnings( "raw" )
+    TypeCheckAppliesToFilter( Class type )
+    {
+        this.type = type;
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        return type.isAssignableFrom( compositeType );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypedFragmentAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypedFragmentAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypedFragmentAppliesToFilter.java
new file mode 100644
index 0000000..e007697
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/TypedFragmentAppliesToFilter.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class TypedFragmentAppliesToFilter
+    implements AppliesToFilter
+{
+    @Override
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        return method.getDeclaringClass().isAssignableFrom( fragmentClass );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueAssemblyImpl.java
new file mode 100644
index 0000000..605efa1
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueAssemblyImpl.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.bootstrap;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.common.InvalidApplicationException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.bootstrap.StateDeclarations;
+import org.qi4j.bootstrap.ValueAssembly;
+import org.qi4j.runtime.association.AssociationModel;
+import org.qi4j.runtime.association.AssociationsModel;
+import org.qi4j.runtime.association.ManyAssociationModel;
+import org.qi4j.runtime.association.ManyAssociationsModel;
+import org.qi4j.runtime.association.NamedAssociationModel;
+import org.qi4j.runtime.association.NamedAssociationsModel;
+import org.qi4j.runtime.composite.StateModel;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.composite.ValueConstraintsModel;
+import org.qi4j.runtime.property.PropertyModel;
+import org.qi4j.runtime.value.ValueModel;
+import org.qi4j.runtime.value.ValueStateModel;
+
+import static org.qi4j.api.util.Annotations.isType;
+import static org.qi4j.api.util.Classes.typeOf;
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Declaration of a ValueComposite.
+ */
+public final class ValueAssemblyImpl
+    extends CompositeAssemblyImpl
+    implements ValueAssembly
+{
+    private AssociationsModel associationsModel;
+    private ManyAssociationsModel manyAssociationsModel;
+    private NamedAssociationsModel namedAssociationsModel;
+
+    public ValueAssemblyImpl( Class<?> compositeType )
+    {
+        super( compositeType );
+        // The composite must always implement ValueComposite, as a marker interface
+        if( !ValueComposite.class.isAssignableFrom( compositeType ) )
+        {
+            types.add( ValueComposite.class );
+        }
+    }
+
+    @Override
+    protected StateModel createStateModel()
+    {
+        return new ValueStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
+    }
+
+    ValueModel newValueModel(
+        StateDeclarations stateDeclarations,
+        AssemblyHelper helper
+    )
+    {
+        try
+        {
+            associationsModel = new AssociationsModel();
+            manyAssociationsModel = new ManyAssociationsModel();
+            namedAssociationsModel = new NamedAssociationsModel();
+            buildComposite( helper, stateDeclarations );
+
+            ValueModel valueModel = new ValueModel(
+                types, visibility, metaInfo, mixinsModel, (ValueStateModel) stateModel, compositeMethodsModel );
+
+            return valueModel;
+        }
+        catch( Exception e )
+        {
+            throw new InvalidApplicationException( "Could not register " + types, e );
+        }
+    }
+
+    @Override
+    protected void addStateFor( AccessibleObject accessor,
+                                Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        String stateName = QualifiedName.fromAccessor( accessor ).name();
+
+        if( registeredStateNames.contains( stateName ) )
+        {
+            return; // Skip already registered names
+        }
+
+        Class<?> accessorType = Classes.RAW_CLASS.map( typeOf( accessor ) );
+        if( Property.class.isAssignableFrom( accessorType ) )
+        {
+            propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( Association.class.isAssignableFrom( accessorType ) )
+        {
+            associationsModel.addAssociation( newAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( ManyAssociation.class.isAssignableFrom( accessorType ) )
+        {
+            manyAssociationsModel.addManyAssociation( newManyAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+        else if( NamedAssociation.class.isAssignableFrom( accessorType ) )
+        {
+            namedAssociationsModel.addNamedAssociation( newNamedAssociationModel( accessor, constraintClasses ) );
+            registeredStateNames.add( stateName );
+        }
+    }
+
+    @Override
+    protected PropertyModel newPropertyModel( AccessibleObject accessor,
+                                              Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member) accessor )
+            .getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        boolean useDefaults = metaInfo.get( UseDefaults.class ) != null || stateDeclarations.useDefaults( accessor );
+        Object initialValue = stateDeclarations.initialValueOf( accessor );
+        return new PropertyModel( accessor, true, useDefaults, valueConstraintsInstance, metaInfo, initialValue );
+    }
+
+    public AssociationModel newAssociationModel( AccessibleObject accessor,
+                                                 Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for Association references
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the Association itself
+        valueConstraintsModel = constraintsFor( annotations, Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance associationValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            associationValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        AssociationModel associationModel = new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+
+    public ManyAssociationModel newManyAssociationModel( AccessibleObject accessor,
+                                                         Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for entities in ManyAssociation
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the ManyAssociation itself
+        valueConstraintsModel = constraintsFor( annotations, ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance manyValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            manyValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        ManyAssociationModel associationModel = new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+    
+    public NamedAssociationModel newNamedAssociationModel( AccessibleObject accessor,
+                                                           Iterable<Class<? extends Constraint<?, ?>>> constraintClasses
+    )
+    {
+        Iterable<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+        boolean optional = first( filter( isType( Optional.class ), annotations ) ) != null;
+
+        // Constraints for entities in NamedAssociation
+        ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations, GenericAssociationInfo
+            .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance valueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            valueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+
+        // Constraints for the NamedAssociation itself
+        valueConstraintsModel = constraintsFor( annotations, NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
+        ValueConstraintsInstance namedValueConstraintsInstance = null;
+        if( valueConstraintsModel.isConstrained() )
+        {
+            namedValueConstraintsInstance = valueConstraintsModel.newInstance();
+        }
+        MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
+        NamedAssociationModel associationModel = new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
+        return associationModel;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueDeclarationImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueDeclarationImpl.java
new file mode 100644
index 0000000..22169bf
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ValueDeclarationImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.ValueDeclaration;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Declaration of a ValueComposite.
+ */
+public final class ValueDeclarationImpl
+    implements ValueDeclaration
+{
+    private final Iterable<ValueAssemblyImpl> assemblies;
+
+    public ValueDeclarationImpl( Iterable<ValueAssemblyImpl> assemblies )
+    {
+        this.assemblies = assemblies;
+    }
+
+    @Override
+    public ValueDeclaration setMetaInfo( Object info )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.metaInfo.set( info );
+        }
+        return this;
+    }
+
+    @Override
+    public ValueDeclaration visibleIn( Visibility visibility )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.visibility = visibility;
+        }
+        return this;
+    }
+
+    @Override
+    public ValueDeclaration withConcerns( Class<?>... concerns )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.concerns.addAll( asList( concerns ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ValueDeclaration withSideEffects( Class<?>... sideEffects )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.sideEffects.addAll( asList( sideEffects ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ValueDeclaration withMixins( Class<?>... mixins )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.mixins.addAll( asList( mixins ) );
+        }
+        return this;
+    }
+
+    @Override
+    public ValueDeclaration withTypes( Class<?>... types )
+    {
+        for( ValueAssemblyImpl assembly : assemblies )
+        {
+            assembly.types.addAll( asList( types ) );
+        }
+        return this;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractConstraintModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractConstraintModel.java
new file mode 100644
index 0000000..d9ffbbd
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractConstraintModel.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import org.qi4j.api.constraint.ConstraintDescriptor;
+import org.qi4j.functional.Visitable;
+import org.qi4j.functional.Visitor;
+
+/**
+ * JAVADOC
+ */
+public abstract class AbstractConstraintModel
+    implements ConstraintDescriptor, Visitable<ConstraintDescriptor>
+{
+    protected final Annotation annotation;
+
+    public AbstractConstraintModel( Annotation annotation )
+    {
+        this.annotation = annotation;
+    }
+
+    @Override
+    public Annotation annotation()
+    {
+        return annotation;
+    }
+
+    public abstract ConstraintInstance<?, ?> newInstance();
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( Visitor<? super ConstraintDescriptor, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        return modelVisitor.visit( this );
+    }
+}
\ No newline at end of file


[22/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/IndexingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/IndexingModule.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/IndexingModule.java
new file mode 100644
index 0000000..437f4f9
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/IndexingModule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.bootstrap.assembly.infrastructure;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.ModuleAssembler;
+
+public class IndexingModule
+    implements ModuleAssembler
+{
+    public static final String NAME = "Indexing Module";
+    private final ModuleAssembly configModule;
+
+    public IndexingModule( ModuleAssembly configModule )
+    {
+        this.configModule = configModule;
+    }
+
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/InfrastructureLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/InfrastructureLayer.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/InfrastructureLayer.java
new file mode 100644
index 0000000..a75ef35
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/InfrastructureLayer.java
@@ -0,0 +1,47 @@
+/*
+ * 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.qi4j.bootstrap.assembly.infrastructure;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.LayerAssembler;
+import org.qi4j.bootstrap.layered.LayeredLayerAssembler;
+
+public class InfrastructureLayer extends LayeredLayerAssembler
+    implements LayerAssembler
+{
+    public static final String NAME = "Infrastructure Layer";
+    private final ModuleAssembly configModule;
+
+    public InfrastructureLayer( ModuleAssembly configModule )
+    {
+        this.configModule = configModule;
+    }
+
+    @Override
+    public LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException
+    {
+        new StorageModule( configModule ).assemble( layer, layer.module( StorageModule.NAME ) );
+        new IndexingModule( configModule ).assemble( layer, layer.module( IndexingModule.NAME ) );
+        createModule( layer, SerializationModule.class );
+        return layer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/SerializationModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/SerializationModule.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/SerializationModule.java
new file mode 100644
index 0000000..ad33c16
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/SerializationModule.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.bootstrap.assembly.infrastructure;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.ModuleAssembler;
+
+public class SerializationModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module
+    )
+        throws AssemblyException
+    {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/StorageModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/StorageModule.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/StorageModule.java
new file mode 100644
index 0000000..0b51230
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/infrastructure/StorageModule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.qi4j.bootstrap.assembly.infrastructure;
+
+import org.qi4j.api.common.Visibility;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.ModuleAssembler;
+
+public class StorageModule
+    implements ModuleAssembler
+{
+    public static final String NAME = "Storage Module";
+    private final ModuleAssembly configModule;
+
+    public StorageModule( ModuleAssembly configModule )
+    {
+        this.configModule = configModule;
+    }
+
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/service/ServiceLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/service/ServiceLayer.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/service/ServiceLayer.java
new file mode 100644
index 0000000..85e29a1
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/service/ServiceLayer.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap.assembly.service;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.layered.LayerAssembler;
+import org.qi4j.bootstrap.LayerAssembly;
+
+public class ServiceLayer implements LayerAssembler
+{
+    public static final String NAME = "Service";
+
+    @Override
+    public LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException
+    {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/builder/ApplicationBuilderTest.java
new file mode 100644
index 0000000..56f17f7
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/builder/ApplicationBuilderTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2014 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap.builder;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.json.JSONException;
+import org.junit.Test;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Module;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.qi4j.bootstrap.ClassScanner.findClasses;
+import static org.qi4j.bootstrap.ClassScanner.matches;
+import static org.qi4j.functional.Iterables.filter;
+
+public class ApplicationBuilderTest
+{
+    @Test
+    public void givenBuilderUseWhenBuildingApplicationExpectSuccess()
+        throws AssemblyException, ActivationException
+    {
+        ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." );
+        builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" );
+        builder.withLayer( "layer2" );
+        builder.withLayer( "layer3" ).withModule( "test module" ).
+            withAssemblers( filter( matches( ".*ServiceAssembler" ), findClasses( getClass() ) ) );
+        Application application = builder.newApplication();
+        Module module = application.findModule( "layer3", "test module" );
+        TestService service = module.findService( TestService.class ).get();
+        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
+    }
+
+    @Test
+    public void givenJsonWhenBuildingApplicationExpectSuccess()
+        throws JSONException, ActivationException, AssemblyException
+    {
+        ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION );
+        Application application = builder.newApplication();
+        Module module = application.findModule( "layer3", "test module" );
+        TestService service = module.findService( TestService.class ).get();
+        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
+    }
+
+    @Test
+    public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess()
+        throws IOException, JSONException, ActivationException, AssemblyException
+    {
+        InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) );
+        ApplicationBuilder builder = ApplicationBuilder.fromJson( input );
+        Application application = builder.newApplication();
+        Module module = application.findModule( "layer3", "test module" );
+        TestService service = module.findService( TestService.class ).get();
+        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
+    }
+
+
+    private static final String APPLICATION =
+        "{\n" +
+        "    \"name\": \"Build from JSON test.\",\n" +
+        "    \"layers\": [\n" +
+        "        {\n" +
+        "            \"name\": \"layer1\",\n" +
+        "            \"uses\": [ \"layer2\", \"layer3\"]\n" +
+        "        },\n" +
+        "        {\n" +
+        "            \"name\": \"layer2\"\n" +
+        "        },\n" +
+        "        {\n" +
+        "            \"name\": \"layer3\",\n" +
+        "            \"modules\" : [\n" +
+        "                {\n" +
+        "                    \"name\" : \"test module\",\n" +
+        "                    \"assemblers\" : [\n" +
+        "                            \"org.qi4j.bootstrap.builder.ApplicationBuilderTest$TestServiceAssembler\"\n" +
+        "                    ]\n" +
+        "                }\n" +
+        "            ]\n" +
+        "        }\n" +
+        "    ]\n" +
+        "}";
+
+    public static class TestServiceAssembler
+        implements Assembler
+    {
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+            module.addServices( TestService.class );
+        }
+    }
+
+    @Mixins( TestService.TestMixin.class )
+    public interface TestService
+    {
+        String sayHello();
+
+        class TestMixin
+            implements TestService
+        {
+
+            @Override
+            public String sayHello()
+            {
+                return "Hello Zest!";
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/somepackage/Test2Value.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/somepackage/Test2Value.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/somepackage/Test2Value.java
new file mode 100644
index 0000000..5b0d6c9
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/somepackage/Test2Value.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap.somepackage;
+
+import org.qi4j.api.value.ValueComposite;
+
+/**
+ */
+public interface Test2Value
+    extends ValueComposite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/ForEach.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/ForEach.java b/core/functional/src/main/java/org/apache/zest/functional/ForEach.java
deleted file mode 100644
index 7126ff1..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/ForEach.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-import java.util.Iterator;
-
-/**
- * When using Iterables with map() and filter() the code often reads "in reverse", with the first item last in the code.
- * Example: Iterables.map(function,Iterables.filter(specification, iterable))
- * <p>
- * This ForEach class reverses that order and makes the code more readable, and allows easy application of visitors on iterables.
- * </p>
- * <p>
- * Example: forEach(iterable).filter(specification).map(function).visit(visitor)
- * </p>
- */
-public final class ForEach<T>
-    implements Iterable<T>
-{
-    public static <T> ForEach<T> forEach( Iterable<T> iterable )
-    {
-        return new ForEach<>( iterable );
-    }
-
-    private final Iterable<T> iterable;
-
-    public ForEach( Iterable<T> iterable )
-    {
-        this.iterable = iterable;
-    }
-
-    @Override
-    public Iterator<T> iterator()
-    {
-        return iterable.iterator();
-    }
-
-    public ForEach<T> filter( Specification<? super T> specification )
-    {
-        return new ForEach<>( Iterables.filter( specification, iterable ) );
-    }
-
-    public <TO> ForEach<TO> map( Function<? /* super T */, TO> function )
-    {
-        return new ForEach<>( Iterables.map( function, iterable ) );
-    }
-
-    public <TO> ForEach<TO> flatten()
-    {
-        Iterable<Iterable<TO>> original = iterable();
-        Iterable<TO> iterable1 = Iterables.flattenIterables( original );
-        return new ForEach<>( iterable1 );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private <TO> Iterable<Iterable<TO>> iterable()
-    {
-        return (Iterable<Iterable<TO>>) iterable;
-    }
-
-    public T last()
-    {
-        T lastItem = null;
-        for( T item : iterable )
-        {
-            lastItem = item;
-        }
-        return lastItem;
-    }
-
-    public <ThrowableType extends Throwable> boolean visit( final Visitor<T, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        for( T item : iterable )
-        {
-            if( !visitor.visit( item ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Function.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Function.java b/core/functional/src/main/java/org/apache/zest/functional/Function.java
deleted file mode 100644
index 8107787..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Function.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-/**
- * Generic function interface to map from one type to another.
- *
- * This can be used with the Iterables methods to transform lists of objects.
- *
- * @param <From>
- * @param <To>
- */
-public interface Function<From, To>
-{
-    /**
-     * Map a single item from one type to another
-     *
-     * @param from the input item
-     *
-     * @return the mapped item
-     */
-    To map( From from );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Function2.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Function2.java b/core/functional/src/main/java/org/apache/zest/functional/Function2.java
deleted file mode 100644
index 1cc01c3..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Function2.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-/**
- * Generic function interface to map from two parameters to a third.
- *
- * This can be used with the Iterables methods to transform lists of objects.
- */
-public interface Function2<First, Second, To>
-{
-    /**
-     * Map a single item from one type to another
-     *
-     * @param first
-     * @param second
-     *
-     * @return the mapped item
-     */
-    To map( First first, Second second );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Functions.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Functions.java b/core/functional/src/main/java/org/apache/zest/functional/Functions.java
deleted file mode 100644
index be72310..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Functions.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Utility functions. Combine these with methods in Iterables, for example. See FunctionsTest for usages.
- */
-public final class Functions
-{
-    public static <A, B, C> Function2<Function<? super B, C>, Function<A, B>, Function<A, C>> compose()
-    {
-        return new Function2<Function<? super B, C>, Function<A, B>, Function<A, C>>()
-        {
-            @Override
-            public Function<A, C> map( Function<? super B, C> bcFunction, Function<A, B> abFunction )
-            {
-                return compose( bcFunction, abFunction );
-            }
-        };
-    }
-
-    /**
-     * compose(F1(M,T),F2(F,M)) = F1(F2(F)) -&gt; T
-     *
-     * @param outer The outer/encapsulating function
-     * @param inner The inner/encapsulated function
-     *
-     * @return A function that is a composition of an outer and inner function.
-     */
-    public static <FROM, MIDDLE, TO> Function<FROM, TO> compose( final Function<? super MIDDLE, TO> outer,
-                                                                 final Function<FROM, MIDDLE> inner
-    )
-    {
-        return new Function<FROM, TO>()
-        {
-            @Override
-            public TO map( FROM from )
-            {
-                return outer.map( inner.map( from ) );
-            }
-        };
-    }
-
-    public static <TO, FROM extends TO> Function<FROM, TO> identity()
-    {
-        return new Function<FROM, TO>()
-        {
-            @Override
-            public TO map( FROM from )
-            {
-                return from;
-            }
-        };
-    }
-
-    public static <FROM, TO> Function<FROM, TO> fromMap( final Map<FROM, TO> map )
-    {
-        return new Function<FROM, TO>()
-        {
-            @Override
-            public TO map( FROM from )
-            {
-                return map.get( from );
-            }
-        };
-    }
-
-    public static <T> Function<T, T> withDefault( final T defaultValue )
-    {
-        return new Function<T, T>()
-        {
-            @Override
-            public T map( T from )
-            {
-                if( from == null )
-                {
-                    return defaultValue;
-                }
-                else
-                {
-                    return from;
-                }
-            }
-        };
-    }
-
-    public static Function<Number, Long> longSum()
-    {
-        return new Function<Number, Long>()
-        {
-            long sum;
-
-            @Override
-            public Long map( Number number )
-            {
-                sum += number.longValue();
-                return sum;
-            }
-        };
-    }
-
-    public static Function<Number, Integer> intSum()
-    {
-        return new Function<Number, Integer>()
-        {
-            int sum;
-
-            @Override
-            public Integer map( Number number )
-            {
-                sum += number.intValue();
-                return sum;
-            }
-        };
-    }
-
-    /**
-     * Count the number of items in an iterable that matches a given specification.
-     *
-     * Sample usage: last( map( count( in( "X" ) ), iterable( "X","Y","X","X","Y" ) ) )
-     * Returns: 3
-     *
-     * @param specification The items that adhere to the Specification is counted.
-     * @param <T> The type of the items.
-     *
-     * @return A Function that can count items adhering to a Specification.
-     */
-    public static <T> Function<T, Integer> count( final Specification<T> specification )
-    {
-        return new Function<T, Integer>()
-        {
-            int count;
-
-            @Override
-            public Integer map( T item )
-            {
-                if( specification.satisfiedBy( item ) )
-                {
-                    count++;
-                }
-
-                return count;
-            }
-        };
-    }
-
-    /**
-     * Find out the index of an item matching a given specification in an iterable.
-     * Returns -1 if it is not found.
-     *
-     * @param specification The Specification that specifies what to look for.
-     * @param <T> The type of the items.
-     *
-     * @return A Function that will provide the 'index' where the Specifcation is fulfilled. The Function will
-     * return -1 if the current item doesn't fulfill the Specification.
-     */
-    public static <T> Function<T, Integer> indexOf( final Specification<T> specification )
-    {
-        return new Function<T, Integer>()
-        {
-            int index = -1;
-            int current = 0;
-
-            @Override
-            public Integer map( T item )
-            {
-                if( index == -1 && specification.satisfiedBy( item ) )
-                {
-                    index = current;
-                }
-
-                current++;
-
-                return index;
-            }
-        };
-    }
-
-    /**
-     * Find out the index of an item in an iterable.
-     *
-     * @param item The item to look for.
-     * @param iterable The Iterable to search.
-     * @param <T> The type of the items.
-     *
-     * @return The index in the Iterable where the item is located.
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> int indexOf( T item, Iterable<T> iterable )
-    {
-        return Iterables.first( Iterables.filter( Specifications.not( Specifications.in( -1 ) ),
-                                                  Iterables.map( indexOf( Specifications.in( item ) ), iterable ) ) );
-    }
-
-    /**
-     * Only apply given function on objects that satisfies the given specification.
-     *
-     * @param specification A Specification that specifies what should be included in the filtered result.
-     * @param function The function to be applied to items that fulfills the Specification
-     * @param <T> The type of the items.
-     *
-     * @return A Function that performs the filter operation when applied to Iterables.
-     */
-    public static <T> Function<T, T> filteredMap( final Specification<T> specification, final Function<T, T> function )
-    {
-        return new Function<T, T>()
-        {
-            @Override
-            public T map( T from )
-            {
-                return specification.satisfiedBy( from ) ? function.map( from ) : from;
-            }
-        };
-    }
-
-    /**
-     * Creates a comparator that takes a function as input. The returned comparator will use the
-     * function once for each item in the list to be sorted by Collections.sort.
-     *
-     * This should be used if the function to generate the sort key from an object is expensive, so
-     * that it is not done many times for each item in a list.
-     *
-     * @param comparableFunction The Function that the Comparator will delegate to.
-     * @param <T>                The generic type to be used.
-     *
-     * @return A comparator that uses a Function for the compare operation.
-     */
-    @SuppressWarnings( "raw" )
-    public static <T> Comparator<T> comparator( final Function<T, Comparable> comparableFunction )
-    {
-        return new Comparator<T>()
-        {
-            Map<T, Comparable> compareKeys = new HashMap<>();
-
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public int compare( T o1, T o2 )
-            {
-                Comparable key1 = compareKeys.get( o1 );
-                if( key1 == null )
-                {
-                    key1 = comparableFunction.map( o1 );
-                    compareKeys.put( o1, key1 );
-                }
-
-                Comparable key2 = compareKeys.get( o2 );
-                if( key2 == null )
-                {
-                    key2 = comparableFunction.map( o2 );
-                    compareKeys.put( o2, key2 );
-                }
-
-                return key1.compareTo( key2 );
-            }
-        };
-    }
-
-    private Functions()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitor.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitor.java b/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitor.java
deleted file mode 100644
index 6b5913b..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.functional;
-
-/**
- * Visitor to visit hierarchies.
- */
-public interface HierarchicalVisitor<NODE, LEAF, ThrowableType extends Throwable> extends Visitor<LEAF, ThrowableType>
-{
-    /**
-     * Enter an instance of T
-     *
-     * @param visited the visited instance which is now entered
-     *
-     * @return true if the visitor pattern should continue, false if it should be aborted for this level
-     *
-     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
-     *                       get the exception in order to handle it properly.
-     */
-    boolean visitEnter( NODE visited )
-        throws ThrowableType;
-
-    /**
-     * Leave an instance of T
-     *
-     * @param visited the visited instance which is now left
-     *
-     * @return true if the visitor pattern should continue, false if it should be aborted for the level of this node
-     *
-     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
-     *                       get the exception in order to handle it properly.
-     */
-    boolean visitLeave( NODE visited )
-        throws ThrowableType;
-
-    @Override
-    boolean visit( LEAF visited )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitorAdapter.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitorAdapter.java b/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitorAdapter.java
deleted file mode 100644
index 2c4ef80..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitorAdapter.java
+++ /dev/null
@@ -1,47 +0,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.
- */
-package org.apache.zest.functional;
-
-/**
- * Generic Hierarchical Visitor interface.
- */
-public class HierarchicalVisitorAdapter<NODE, LEAF, ThrowableType extends Throwable>
-    implements HierarchicalVisitor<NODE, LEAF, ThrowableType>
-{
-    @Override
-    public boolean visitEnter( NODE visited )
-        throws ThrowableType
-    {
-        return true;
-    }
-
-    @Override
-    public boolean visitLeave( NODE visited )
-        throws ThrowableType
-    {
-        return true;
-    }
-
-    @Override
-    public boolean visit( LEAF visited )
-        throws ThrowableType
-    {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Iterables.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Iterables.java b/core/functional/src/main/java/org/apache/zest/functional/Iterables.java
deleted file mode 100644
index a77a519..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Iterables.java
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-import java.lang.reflect.Array;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * Utility methods for working with Iterables. See test for examples of how to use.
- */
-public final class Iterables
-{
-    @SuppressWarnings( "raw" )
-    private static final Iterable EMPTY = new Iterable()
-    {
-        Iterator iterator = new Iterator()
-        {
-            @Override
-            public boolean hasNext()
-            {
-                return false;
-            }
-
-            @Override
-            public Object next()
-            {
-                throw new NoSuchElementException();
-            }
-
-            @Override
-            public void remove()
-            {
-            }
-        };
-
-        @Override
-        public Iterator iterator()
-        {
-            return iterator;
-        }
-    };
-
-    @SuppressWarnings( "unchecked" )
-    public static <T> Iterable<T> empty()
-    {
-        return EMPTY;
-    }
-
-    public static <T> Iterable<T> constant( final T item )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                return new Iterator<T>()
-                {
-                    @Override
-                    public boolean hasNext()
-                    {
-                        return true;
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        return item;
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                    }
-                };
-            }
-        };
-    }
-
-    public static <T> Iterable<T> limit( final int limitItems, final Iterable<T> iterable )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                final Iterator<T> iterator = iterable.iterator();
-
-                return new Iterator<T>()
-                {
-                    int count;
-
-                    @Override
-                    public boolean hasNext()
-                    {
-                        return count < limitItems && iterator.hasNext();
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        count++;
-                        return iterator.next();
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                        iterator.remove();
-                    }
-                };
-            }
-        };
-    }
-
-    public static <T> Iterable<T> unique( final Iterable<T> iterable )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                final Iterator<T> iterator = iterable.iterator();
-
-                return new Iterator<T>()
-                {
-                    private final Set<T> items = new HashSet<>();
-                    private T nextItem;
-
-                    @Override
-                    public boolean hasNext()
-                    {
-                        while( iterator.hasNext() )
-                        {
-                            nextItem = iterator.next();
-                            if( items.add( nextItem ) )
-                            {
-                                return true;
-                            }
-                        }
-
-                        return false;
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        if( nextItem == null && !hasNext() )
-                        {
-                            throw new NoSuchElementException();
-                        }
-
-                        return nextItem;
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                    }
-                };
-            }
-        };
-    }
-
-    public static <T, C extends Collection<T>> C addAll( C collection, Iterable<? extends T> iterable )
-    {
-        for( T item : iterable )
-        {
-            collection.add( item );
-        }
-        return collection;
-    }
-
-    public static long count( Iterable<?> iterable )
-    {
-        long c = 0;
-        for( Object anIterable : iterable )
-        {
-            c++;
-        }
-        return c;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public static <X> Iterable<X> filter( Specification<? /* super X*/> specification, Iterable<X> i )
-    {
-        return new FilterIterable<>( i, (Specification<? super X>) specification );
-    }
-
-    public static <X> X first( Iterable<X> i )
-    {
-        Iterator<X> iter = i.iterator();
-        if( iter.hasNext() )
-        {
-            return iter.next();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    public static <X> X single( Iterable<X> i )
-    {
-        Iterator<X> iter = i.iterator();
-        if( iter.hasNext() )
-        {
-            X result = iter.next();
-
-            if( iter.hasNext() )
-            {
-                throw new IllegalArgumentException( "More than one element in iterable" );
-            }
-
-            return result;
-        }
-        else
-        {
-            throw new IllegalArgumentException( "No elements in iterable" );
-        }
-    }
-
-    public static <X> Iterable<X> skip( final int skip, final Iterable<X> iterable )
-    {
-        return new Iterable<X>()
-        {
-            @Override
-            public Iterator<X> iterator()
-            {
-                Iterator<X> iterator = iterable.iterator();
-
-                for( int i = 0; i < skip; i++ )
-                {
-                    if( iterator.hasNext() )
-                    {
-                        iterator.next();
-                    }
-                    else
-                    {
-                        return Iterables.<X>empty().iterator();
-                    }
-                }
-
-                return iterator;
-            }
-        };
-    }
-
-    public static <X> X last( Iterable<X> i )
-    {
-        Iterator<X> iter = i.iterator();
-        X item = null;
-        while( iter.hasNext() )
-        {
-            item = iter.next();
-        }
-
-        return item;
-    }
-
-    public static <X> Iterable<X> reverse( Iterable<X> iterable )
-    {
-        List<X> list = toList( iterable );
-        Collections.reverse( list );
-        return list;
-    }
-
-    public static <T> boolean matchesAny( Specification<? super T> specification, Iterable<T> iterable )
-    {
-        boolean result = false;
-
-        for( T item : iterable )
-        {
-            if( ( (Specification<? super T>) specification ).satisfiedBy( item ) )
-            {
-                result = true;
-                break;
-            }
-        }
-
-        return result;
-    }
-
-    public static <T> boolean matchesAll( Specification<? super T> specification, Iterable<T> iterable )
-    {
-        boolean result = true;
-        for( T item : iterable )
-        {
-            if( !specification.satisfiedBy( item ) )
-            {
-                result = false;
-            }
-        }
-
-        return result;
-    }
-
-    public static <X> Iterable<X> flatten( Iterable<?>... multiIterator )
-    {
-        return new FlattenIterable<>( Iterables.<Iterable<X>>cast( Arrays.asList( multiIterator ) ) );
-    }
-
-    public static <X, I extends Iterable<? extends X>> Iterable<X> flattenIterables( Iterable<I> multiIterator )
-    // public static <X> Iterable<X> flattenIterables( Iterable<Iterable<?>> multiIterator )
-    {
-        return new FlattenIterable<>( Iterables.<Iterable<X>>cast( multiIterator ) );
-    }
-
-    @SafeVarargs
-    public static <T> Iterable<T> mix( final Iterable<T>... iterables )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                final Iterable<Iterator<T>> iterators = toList( map( new Function<Iterable<T>, Iterator<T>>()
-                {
-                    @Override
-                    public Iterator<T> map( Iterable<T> iterable )
-                    {
-                        return iterable.iterator();
-                    }
-                }, Iterables.iterable( iterables ) ) );
-
-                return new Iterator<T>()
-                {
-                    Iterator<Iterator<T>> iterator;
-
-                    Iterator<T> iter;
-
-                    @Override
-                    public boolean hasNext()
-                    {
-                        for( Iterator<T> iterator : iterators )
-                        {
-                            if( iterator.hasNext() )
-                            {
-                                return true;
-                            }
-                        }
-
-                        return false;
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        if( iterator == null )
-                        {
-                            iterator = iterators.iterator();
-                        }
-
-                        while( iterator.hasNext() )
-                        {
-                            iter = iterator.next();
-
-                            if( iter.hasNext() )
-                            {
-                                return iter.next();
-                            }
-                        }
-
-                        iterator = null;
-
-                        return next();
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                        if( iter != null )
-                        {
-                            iter.remove();
-                        }
-                    }
-                };
-            }
-        };
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public static <FROM, TO> Iterable<TO> map( Function<? /* super FROM */, TO> function, Iterable<FROM> from )
-    {
-        return new MapIterable<>( from, (Function<FROM, TO>) function );
-    }
-
-    public static <T> Iterable<T> iterable( Enumeration<T> enumeration )
-    {
-        List<T> list = new ArrayList<>();
-        while( enumeration.hasMoreElements() )
-        {
-            T item = enumeration.nextElement();
-            list.add( item );
-        }
-
-        return list;
-    }
-
-    @SafeVarargs
-    public static <T> Iterable<T> iterable( T... items )
-    {
-        return Arrays.asList( items );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> Iterable<T> cast( Iterable<?> iterable )
-    {
-        Iterable iter = iterable;
-        return iter;
-    }
-
-    public static <FROM, TO> Function<FROM, TO> cast()
-    {
-        return new Function<FROM, TO>()
-        {
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public TO map( FROM from )
-            {
-                return (TO) from;
-            }
-        };
-    }
-
-    public static <FROM, TO> TO fold( Function<? super FROM, TO> function, Iterable<? extends FROM> i )
-    {
-        return last( map( function, i ) );
-    }
-
-    public static <T> Iterable<T> prepend( final T item, final Iterable<T> iterable )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                return new Iterator<T>()
-                {
-                    T first = item;
-                    Iterator<T> iterator;
-
-                    @Override
-                    public boolean hasNext()
-                    {
-                        if( first != null )
-                        {
-                            return true;
-                        }
-                        else
-                        {
-                            if( iterator == null )
-                            {
-                                iterator = iterable.iterator();
-                            }
-                        }
-
-                        return iterator.hasNext();
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        if( first != null )
-                        {
-                            try
-                            {
-                                return first;
-                            }
-                            finally
-                            {
-                                first = null;
-                            }
-                        }
-                        else
-                        {
-                            return iterator.next();
-                        }
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                    }
-                };
-            }
-        };
-    }
-
-    public static <T> Iterable<T> append( final T item, final Iterable<T> iterable )
-    {
-        return new Iterable<T>()
-        {
-            @Override
-            public Iterator<T> iterator()
-            {
-                final Iterator<T> iterator = iterable.iterator();
-
-                return new Iterator<T>()
-                {
-                    T last = item;
-
-                    @Override
-                    public boolean hasNext()
-                    {
-                        if( iterator.hasNext() )
-                        {
-                            return true;
-                        }
-                        else
-                        {
-                            return last != null;
-                        }
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        if( iterator.hasNext() )
-                        {
-                            return iterator.next();
-                        }
-                        else
-                        {
-                            try
-                            {
-                                return last;
-                            }
-                            finally
-                            {
-                                last = null;
-                            }
-                        }
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                    }
-                };
-            }
-        };
-    }
-
-    @SafeVarargs
-    public static <T> Iterable<T> debug( String format,
-                                         final Iterable<T> iterable,
-                                         final Function<T, String>... functions
-    )
-    {
-        final MessageFormat msgFormat = new MessageFormat( format );
-
-        return map( new Function<T, T>()
-        {
-            @Override
-            public T map( T t )
-            {
-                if( functions.length != 0 )
-                {
-                    String[] mapped = new String[ functions.length ];
-                    for( int i = 0; i < functions.length; i++ )
-                    {
-                        Function<T, String> function = functions[i];
-                        mapped[i] = function.map( t );
-                    }
-                }
-                return t;
-            }
-        }, iterable );
-    }
-
-    public static <T> Iterable<T> cache( Iterable<T> iterable )
-    {
-        return new CacheIterable<>( iterable );
-    }
-
-    public static <T> String toString( Iterable<T> iterable )
-    {
-        return toString( iterable, new Function<T, String>()
-        {
-            @Override
-            public String map( T t )
-            {
-                return t == null ? "[null]" : t.toString();
-            }
-        }, "," );
-    }
-
-    public static <T> String toString( Iterable<T> iterable, Function<T, String> toStringFunction, String separator )
-    {
-        StringBuilder builder = new StringBuilder();
-        boolean first = true;
-        for( T item : iterable )
-        {
-            if( !first )
-            {
-                builder.append( separator );
-            }
-            builder.append( toStringFunction.map( item ) );
-            first = false;
-        }
-        return builder.toString();
-    }
-
-    public static <T> List<T> toList( Iterable<T> iterable )
-    {
-        return addAll( new ArrayList<T>(), iterable );
-    }
-
-    public static Object[] toArray( Iterable<Object> iterable )
-    {
-        return toArray( Object.class, iterable );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public static <T> T[] toArray( Class<T> componentType, Iterable<T> iterable )
-    {
-        if( iterable == null )
-        {
-            return null;
-        }
-        List<T> list = toList( iterable );
-        return list.toArray( (T[]) Array.newInstance( componentType, list.size() ) );
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <X extends Comparable> Iterable<X> sort( Iterable<X> iterable )
-    {
-        List<X> list = toList( iterable );
-        Collections.sort( list );
-        return list;
-    }
-
-    public static <X> Iterable<X> sort( Comparator<? super X> comparator, Iterable<X> iterable )
-    {
-        List<X> list = toList( iterable );
-        Collections.sort( list, comparator );
-        return list;
-    }
-
-    private static class MapIterable<FROM, TO>
-        implements Iterable<TO>
-    {
-        private final Iterable<FROM> from;
-        private final Function<? super FROM, TO> function;
-
-        private MapIterable( Iterable<FROM> from, Function<? super FROM, TO> function )
-        {
-            this.from = from;
-            this.function = function;
-        }
-
-        @Override
-        public Iterator<TO> iterator()
-        {
-            return new MapIterator<>( from.iterator(), function );
-        }
-
-        static class MapIterator<FROM, TO>
-            implements Iterator<TO>
-        {
-            private final Iterator<FROM> fromIterator;
-            private final Function<? super FROM, TO> function;
-
-            private MapIterator( Iterator<FROM> fromIterator, Function<? super FROM, TO> function )
-            {
-                this.fromIterator = fromIterator;
-                this.function = function;
-            }
-
-            @Override
-            public boolean hasNext()
-            {
-                return fromIterator.hasNext();
-            }
-
-            @Override
-            public TO next()
-            {
-                FROM from = fromIterator.next();
-                return function.map( from );
-            }
-
-            @Override
-            public void remove()
-            {
-                fromIterator.remove();
-            }
-        }
-
-    }
-
-    private static class FilterIterable<T>
-        implements Iterable<T>
-    {
-        private final Iterable<T> iterable;
-
-        private final Specification<? super T> specification;
-
-        private FilterIterable( Iterable<T> iterable, Specification<? super T> specification )
-        {
-            this.iterable = iterable;
-            this.specification = specification;
-        }
-
-        @Override
-        public Iterator<T> iterator()
-        {
-            return new FilterIterator<>( iterable.iterator(), specification );
-        }
-
-        private static class FilterIterator<T>
-            implements Iterator<T>
-        {
-            private final Iterator<T> iterator;
-
-            private final Specification<? super T> specification;
-
-            private T currentValue;
-            boolean finished = false;
-            boolean nextConsumed = true;
-
-            private FilterIterator( Iterator<T> iterator, Specification<? super T> specification )
-            {
-                this.specification = specification;
-                this.iterator = iterator;
-            }
-
-            public boolean moveToNextValid()
-            {
-                boolean found = false;
-                while( !found && iterator.hasNext() )
-                {
-                    T currentValue = iterator.next();
-                    boolean satisfies = specification.satisfiedBy( currentValue );
-
-                    if( satisfies )
-                    {
-                        found = true;
-                        this.currentValue = currentValue;
-                        nextConsumed = false;
-                    }
-                }
-                if( !found )
-                {
-                    finished = true;
-                }
-                return found;
-            }
-
-            @Override
-            public T next()
-            {
-                if( !nextConsumed )
-                {
-                    nextConsumed = true;
-                    return currentValue;
-                }
-                else
-                {
-                    if( !finished )
-                    {
-                        if( moveToNextValid() )
-                        {
-                            nextConsumed = true;
-                            return currentValue;
-                        }
-                    }
-                }
-                return null;
-            }
-
-            @Override
-            public boolean hasNext()
-            {
-                return !finished
-                       && ( !nextConsumed || moveToNextValid() );
-            }
-
-            @Override
-            public void remove()
-            {
-            }
-        }
-
-    }
-
-    private static class FlattenIterable<T, I extends Iterable<? extends T>>
-        implements Iterable<T>
-    {
-        private final Iterable<I> iterable;
-
-        private FlattenIterable( Iterable<I> iterable )
-        {
-            this.iterable = iterable;
-        }
-
-        @Override
-        public Iterator<T> iterator()
-        {
-            return new FlattenIterator<>( iterable.iterator() );
-        }
-
-        static class FlattenIterator<T, I extends Iterable<? extends T>>
-            implements Iterator<T>
-        {
-            private final Iterator<I> iterator;
-            private Iterator<? extends T> currentIterator;
-
-            private FlattenIterator( Iterator<I> iterator )
-            {
-                this.iterator = iterator;
-                currentIterator = null;
-            }
-
-            @Override
-            public boolean hasNext()
-            {
-                if( currentIterator == null )
-                {
-                    if( iterator.hasNext() )
-                    {
-                        I next = iterator.next();
-                        currentIterator = next.iterator();
-                    }
-                    else
-                    {
-                        return false;
-                    }
-                }
-
-                while( !currentIterator.hasNext()
-                       && iterator.hasNext() )
-                {
-                    currentIterator = iterator.next().iterator();
-                }
-
-                return currentIterator.hasNext();
-            }
-
-            @Override
-            public T next()
-            {
-                return currentIterator.next();
-            }
-
-            @Override
-            public void remove()
-            {
-                if( currentIterator == null )
-                {
-                    throw new IllegalStateException();
-                }
-
-                currentIterator.remove();
-            }
-        }
-
-    }
-
-    private static class CacheIterable<T>
-        implements Iterable<T>
-    {
-        private final Iterable<T> iterable;
-        private Iterable<T> cache;
-
-        private CacheIterable( Iterable<T> iterable )
-        {
-            this.iterable = iterable;
-        }
-
-        @Override
-        public Iterator<T> iterator()
-        {
-            if( cache != null )
-            {
-                return cache.iterator();
-            }
-
-            final Iterator<T> source = iterable.iterator();
-
-            return new Iterator<T>()
-            {
-                List<T> iteratorCache = new ArrayList<>();
-
-                @Override
-                public boolean hasNext()
-                {
-                    boolean hasNext = source.hasNext();
-                    if( !hasNext )
-                    {
-                        cache = iteratorCache;
-                    }
-                    return hasNext;
-                }
-
-                @Override
-                public T next()
-                {
-                    T next = source.next();
-                    iteratorCache.add( next );
-                    return next;
-                }
-
-                @Override
-                public void remove()
-                {
-
-                }
-            };
-        }
-    }
-
-    private Iterables()
-    {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Specification.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Specification.java b/core/functional/src/main/java/org/apache/zest/functional/Specification.java
deleted file mode 100644
index 3ff725d..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Specification.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-/**
- * Generic specification interface.
- *
- * @param <T>
- */
-// START SNIPPET: specification
-public interface Specification<T>
-{
-// END SNIPPET: specification
-
-    /**
-     * Test whether an item matches the given specification
-     *
-     * @param item the item to be tested
-     *
-     * @return true if the item matches, false otherwise
-     */
-// START SNIPPET: specification
-    boolean satisfiedBy( T item );
-}
-// END SNIPPET: specification

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Specifications.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Specifications.java b/core/functional/src/main/java/org/apache/zest/functional/Specifications.java
deleted file mode 100644
index 6da1739..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Specifications.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-/**
- * Common generic specification expressions
- */
-public class Specifications
-{
-    public static <T> Specification<T> TRUE()
-    {
-        return new Specification<T>()
-        {
-            @Override
-            public boolean satisfiedBy( T instance )
-            {
-                return true;
-            }
-        };
-    }
-
-    public static <T> Specification<T> not( final Specification<T> specification )
-    {
-        return new Specification<T>()
-        {
-            @Override
-            public boolean satisfiedBy( T instance )
-            {
-                return !specification.satisfiedBy( instance );
-            }
-        };
-    }
-
-    @SafeVarargs
-    public static <T> AndSpecification<T> and( final Specification<T>... specifications )
-    {
-        return and( Iterables.iterable( specifications ) );
-    }
-
-    public static <T> AndSpecification<T> and( final Iterable<Specification<T>> specifications )
-    {
-        return new AndSpecification<>( specifications );
-    }
-
-    @SafeVarargs
-    public static <T> OrSpecification<T> or( final Specification<T>... specifications )
-    {
-        return or( Iterables.iterable( specifications ) );
-    }
-
-    public static <T> OrSpecification<T> or( final Iterable<Specification<T>> specifications )
-    {
-        return new OrSpecification<>( specifications );
-    }
-
-    @SafeVarargs
-    public static <T> Specification<T> in( final T... allowed )
-    {
-        return in( Iterables.iterable( allowed ) );
-    }
-
-    public static <T> Specification<T> in( final Iterable<T> allowed )
-    {
-        return new Specification<T>()
-        {
-            @Override
-            public boolean satisfiedBy( T item )
-            {
-                for( T allow : allowed )
-                {
-                    if( allow.equals( item ) )
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-        };
-    }
-
-    public static <T> Specification<T> notNull()
-    {
-        return new Specification<T>()
-        {
-            @Override
-            public boolean satisfiedBy( T item )
-            {
-                return item != null;
-            }
-        };
-    }
-
-    public static <FROM, TO> Specification<FROM> translate( final Function<FROM, TO> function,
-                                                            final Specification<? super TO> specification
-    )
-    {
-        return new Specification<FROM>()
-        {
-            @Override
-            public boolean satisfiedBy( FROM item )
-            {
-                return specification.satisfiedBy( function.map( item ) );
-            }
-        };
-    }
-
-    /**
-     * AND Specification.
-     */
-    public static class AndSpecification<T>
-        implements Specification<T>
-    {
-        private final Iterable<Specification<T>> specifications;
-
-        private AndSpecification( Iterable<Specification<T>> specifications )
-        {
-            this.specifications = specifications;
-        }
-
-        @Override
-        public boolean satisfiedBy( T instance )
-        {
-            for( Specification<T> specification : specifications )
-            {
-                if( !specification.satisfiedBy( instance ) )
-                {
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
-        @SafeVarargs
-        public final AndSpecification<T> and( Specification<T>... specifications )
-        {
-            Iterable<Specification<T>> iterable = Iterables.iterable( specifications );
-            Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable );
-            return Specifications.and( flatten );
-        }
-
-        @SafeVarargs
-        public final OrSpecification<T> or( Specification<T>... specifications )
-        {
-            return Specifications.or( Iterables.prepend( this, Iterables.iterable( specifications ) ) );
-        }
-    }
-
-    /**
-     * OR Specification.
-     */
-    public static class OrSpecification<T>
-        implements Specification<T>
-    {
-        private final Iterable<Specification<T>> specifications;
-
-        private OrSpecification( Iterable<Specification<T>> specifications )
-        {
-            this.specifications = specifications;
-        }
-
-        @Override
-        public boolean satisfiedBy( T instance )
-        {
-            for( Specification<T> specification : specifications )
-            {
-                if( specification.satisfiedBy( instance ) )
-                {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        @SafeVarargs
-        public final AndSpecification<T> and( Specification<T>... specifications )
-        {
-            return Specifications.and( Iterables.prepend( this, Iterables.iterable( specifications ) ) );
-        }
-
-        @SafeVarargs
-        public final OrSpecification<T> or( Specification<T>... specifications )
-        {
-            Iterable<Specification<T>> iterable = Iterables.iterable( specifications );
-            Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable );
-            return Specifications.or( flatten );
-        }
-    }
-
-    private Specifications()
-    {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Visitable.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Visitable.java b/core/functional/src/main/java/org/apache/zest/functional/Visitable.java
deleted file mode 100644
index ee05807..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Visitable.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.functional;
-
-/**
- * Interface that visitable objects should implement.
- */
-public interface Visitable<T>
-{
-    <ThrowableType extends Throwable> boolean accept( Visitor<? super T, ThrowableType> visitor )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/VisitableHierarchy.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/VisitableHierarchy.java b/core/functional/src/main/java/org/apache/zest/functional/VisitableHierarchy.java
deleted file mode 100644
index 60d99af..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/VisitableHierarchy.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.functional;
-
-/**
- * Interface that visitable hierarchies of objects should implement.
- */
-public interface VisitableHierarchy<NODE, LEAF>
-{
-    <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super NODE, ? super LEAF, ThrowableType> visitor )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/Visitor.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/Visitor.java b/core/functional/src/main/java/org/apache/zest/functional/Visitor.java
deleted file mode 100644
index 9a72a1f..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Visitor.java
+++ /dev/null
@@ -1,38 +0,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.
- */
-package org.apache.zest.functional;
-
-/**
- * Generic Visitor interface.
- */
-public interface Visitor<T, ThrowableType extends Throwable>
-{
-    /**
-     * Visit an instance of T
-     *
-     * @param visited the visited instance
-     *
-     * @return true if the visitor pattern should continue, false if it should be aborted
-     *
-     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
-     *                       get the exception in order to handle it properly.
-     */
-    boolean visit( T visited )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/apache/zest/functional/package.html
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/apache/zest/functional/package.html b/core/functional/src/main/java/org/apache/zest/functional/package.html
deleted file mode 100644
index 920a9ef..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Functional API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/ForEach.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/ForEach.java b/core/functional/src/main/java/org/qi4j/functional/ForEach.java
new file mode 100644
index 0000000..c2bbe3e
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/ForEach.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+import java.util.Iterator;
+
+/**
+ * When using Iterables with map() and filter() the code often reads "in reverse", with the first item last in the code.
+ * Example: Iterables.map(function,Iterables.filter(specification, iterable))
+ * <p>
+ * This ForEach class reverses that order and makes the code more readable, and allows easy application of visitors on iterables.
+ * </p>
+ * <p>
+ * Example: forEach(iterable).filter(specification).map(function).visit(visitor)
+ * </p>
+ */
+public final class ForEach<T>
+    implements Iterable<T>
+{
+    public static <T> ForEach<T> forEach( Iterable<T> iterable )
+    {
+        return new ForEach<>( iterable );
+    }
+
+    private final Iterable<T> iterable;
+
+    public ForEach( Iterable<T> iterable )
+    {
+        this.iterable = iterable;
+    }
+
+    @Override
+    public Iterator<T> iterator()
+    {
+        return iterable.iterator();
+    }
+
+    public ForEach<T> filter( Specification<? super T> specification )
+    {
+        return new ForEach<>( Iterables.filter( specification, iterable ) );
+    }
+
+    public <TO> ForEach<TO> map( Function<? /* super T */, TO> function )
+    {
+        return new ForEach<>( Iterables.map( function, iterable ) );
+    }
+
+    public <TO> ForEach<TO> flatten()
+    {
+        Iterable<Iterable<TO>> original = iterable();
+        Iterable<TO> iterable1 = Iterables.flattenIterables( original );
+        return new ForEach<>( iterable1 );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private <TO> Iterable<Iterable<TO>> iterable()
+    {
+        return (Iterable<Iterable<TO>>) iterable;
+    }
+
+    public T last()
+    {
+        T lastItem = null;
+        for( T item : iterable )
+        {
+            lastItem = item;
+        }
+        return lastItem;
+    }
+
+    public <ThrowableType extends Throwable> boolean visit( final Visitor<T, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        for( T item : iterable )
+        {
+            if( !visitor.visit( item ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Function.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Function.java b/core/functional/src/main/java/org/qi4j/functional/Function.java
new file mode 100644
index 0000000..3edd3f1
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Function.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+/**
+ * Generic function interface to map from one type to another.
+ *
+ * This can be used with the Iterables methods to transform lists of objects.
+ *
+ * @param <From>
+ * @param <To>
+ */
+public interface Function<From, To>
+{
+    /**
+     * Map a single item from one type to another
+     *
+     * @param from the input item
+     *
+     * @return the mapped item
+     */
+    To map( From from );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Function2.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Function2.java b/core/functional/src/main/java/org/qi4j/functional/Function2.java
new file mode 100644
index 0000000..7803965
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Function2.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+/**
+ * Generic function interface to map from two parameters to a third.
+ *
+ * This can be used with the Iterables methods to transform lists of objects.
+ */
+public interface Function2<First, Second, To>
+{
+    /**
+     * Map a single item from one type to another
+     *
+     * @param first
+     * @param second
+     *
+     * @return the mapped item
+     */
+    To map( First first, Second second );
+}


[49/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationWrapper.java b/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationWrapper.java
deleted file mode 100644
index ed47e31..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/NamedAssociationWrapper.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.api.association;
-
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * If you want to catch calls to NamedAssociations, then create a GenericConcern
- * that wraps the Zest-supplied NamedAssociations instance with NamedAssociationsWrapper. Override
- * methods to perform your custom code.
- */
-public class NamedAssociationWrapper
-    implements NamedAssociation<Object>
-{
-    protected NamedAssociation<Object> next;
-
-    public NamedAssociationWrapper( NamedAssociation<Object> next )
-    {
-        this.next = next;
-    }
-
-    public NamedAssociation<Object> next()
-    {
-        return next;
-    }
-
-    @Override
-    public Iterator<String> iterator()
-    {
-        return next.iterator();
-    }
-
-    @Override
-    public int count()
-    {
-        return next.count();
-    }
-
-    @Override
-    public boolean containsName( String name )
-    {
-        return next.containsName( name );
-    }
-
-    @Override
-    public boolean put( String name, Object entity )
-    {
-        return next.put( name, entity );
-    }
-
-    @Override
-    public boolean remove( String name )
-    {
-        return next.remove( name );
-    }
-
-    @Override
-    public Object get( String name )
-    {
-        return next.get( name );
-    }
-
-    @Override
-    public String nameOf( Object entity )
-    {
-        return next.nameOf( entity );
-    }
-
-    @Override
-    public Map<String, Object> toMap()
-    {
-        return next.toMap();
-    }
-
-    @Override
-    public Iterable<EntityReference> references()
-    {
-        return next.references();
-    }
-
-    @Override
-    public EntityReference referenceOf( String name )
-    {
-        return next.referenceOf( name );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return next.hashCode();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        return next.equals( obj );
-    }
-
-    @Override
-    public String toString()
-    {
-        return next.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/association/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/association/package.html b/core/api/src/main/java/org/apache/zest/api/association/package.html
deleted file mode 100644
index cf48596..0000000
--- a/core/api/src/main/java/org/apache/zest/api/association/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Association API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/cache/CacheOptions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/cache/CacheOptions.java b/core/api/src/main/java/org/apache/zest/api/cache/CacheOptions.java
deleted file mode 100644
index 4f609b6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/cache/CacheOptions.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2010 Niclas Hedhman.
- *
- * 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.zest.api.cache;
-
-/**
- * CacheOptions is a metaInfo class for the Cache system for Entity persistence.
- * CacheOptions should be assigned to the Usecase of the UnitOfWork, to give hint on caching to entity stores.
- * See {@link org.apache.zest.api.usecase.UsecaseBuilder} on how to set the metaInfo on Usecases.
- */
-public final class CacheOptions
-{
-    public static final CacheOptions ALWAYS = new CacheOptions( true, true, true );
-    public static final CacheOptions NEVER = new CacheOptions( false, false, false );
-
-    private final boolean cacheOnRead;
-    private final boolean cacheOnWrite;
-    private final boolean cacheOnNew;
-
-    /**
-     * Constructor for CacheOptions.
-     *
-     * @param cacheOnRead  if true, give the hint to the Cache system that it may not be a good idea to cache the
-     *                     read values. This is useful when it is known that the read will be over a large set and
-     *                     shouldn't affect the existing cached entities. For instance, when traversing the EntityStore
-     *                     this option is set to false.
-     * @param cacheOnWrite if true, give the hint to the Cache system that it may not be a good idea to cache the
-     *                     entity when the value is updated. If this is false, the cache should be emptied from any
-     *                     cached entity instead of updated. There are few cases when this is useful, and if this is
-     *                     false, it makes sense that the <i>cacheOnRead</i> is also false.
-     * @param cacheOnNew   if true, give the hint to the Cache system that it may not be a good idea to cache a newly
-     *                     created Entity, as it is not likely to be read in the near future. This is useful when
-     *                     batch inserts are being made.
-     */
-    public CacheOptions( boolean cacheOnRead, boolean cacheOnWrite, boolean cacheOnNew )
-    {
-        this.cacheOnRead = cacheOnRead;
-        this.cacheOnWrite = cacheOnWrite;
-        this.cacheOnNew = cacheOnNew;
-    }
-
-    /**
-     * @return if true, give the hint to the Cache system that it may not be a good idea to cache the
-     *         read values. This is useful when it is known that the read will be over a large set and
-     *         shouldn't affect the existing cached entities. For instance, when traversing the EntityStore
-     */
-    public boolean cacheOnRead()
-    {
-        return cacheOnRead;
-    }
-
-    /**
-     * @return if true, give the hint to the Cache system that it may not be a good idea to cache the
-     *         entity when the value is updated. If this is false, the cache should be emptied from any
-     *         cached entity instead of updated. There are few cases when this is useful, and if this is
-     *         false, it makes sense that the <i>cacheOnRead</i> is also false.
-     */
-    public boolean cacheOnWrite()
-    {
-        return cacheOnWrite;
-    }
-
-    /**
-     * @return if true, give the hint to the Cache system that it may not be a good idea to cache a newly
-     *         created Entity, as it is not likely to be read in the near future. This is useful when
-     *         batch inserts are being made.
-     */
-    public boolean cacheOnNew()
-    {
-        return cacheOnNew;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/cache/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/cache/package.html b/core/api/src/main/java/org/apache/zest/api/cache/package.html
deleted file mode 100644
index a62da34..0000000
--- a/core/api/src/main/java/org/apache/zest/api/cache/package.html
+++ /dev/null
@@ -1,40 +0,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.
--->
-<html>
-    <body>
-        <h2>Cache API.</h2>
-        <p>
-            The Cache API/SPI is an extension point for Entity Store caching.
-        </p>
-        <p>
-            The API part is only to allow caching options to be passed to the underlying extension in a uniform and
-            standard way. CacheOptions are to be passed as meta info on the optional Cache extension that is specified
-            during assembly phase. Example;
-        </p>
-<pre><code>
-public void assemble( ModuleAssembly module )
-{
-    CacheOptions options = new CacheOptions( true, true, false );
-    module.addServices( EhCacheService.class ).setMetaInfo( options );
-}
-</code></pre>
-        <p>
-            Not all EntityStore implementations use the Cache extension, so check the implementation details of the
-            EntityStore whether the cache extension can bring any benefits or not.
-        </p>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/AppliesTo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/AppliesTo.java b/core/api/src/main/java/org/apache/zest/api/common/AppliesTo.java
deleted file mode 100644
index a9b1262..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/AppliesTo.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.common;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Fragments that implement InvocationHandler and which should only be applied to methods that have a particular
- * annotation or implement a known interface should use this annotation.
- * <p>
- * &#64;AppliesTo can specify one of;
- * </p>
- * <ul>
- * <li>An annotation,</li>
- * <li>An interface,</li>
- * <li>An AppliesToFilter implementation.</li>
- * </ul>
- * <p>
- * Example with annotation:
- * </p>
- * <pre><code>
- *
- * &#64;AppliesTo( Sessional.class )   // Tells Zest to apply this concern on methods with &#64;Sessional annotation
- * public class SessionConcern extends GenericConcern
- * {
- *     public Object invoke( Object proxy, Method method, Object[] args )
- *         throws Throwable
- *     {
- *         ... do session stuff ...
- *     }
- * }
- *
- * &#64;Retention( RetentionPolicy.RUNTIME )
- * &#64;Target( ElementType.METHOD )
- * &#64;Documented
- * &#64;Inherited
- * public @interface Sessional
- * {
- * }
- *
- * public class MyMixin
- *     implements My
- * {
- *     &#64;Sessional
- *     public void doSomethingSessional()
- *     {
- *        // ... do your logic wrapped in a session
- *     }
- *
- *     public void doSomethingWithoutSession()
- *     {
- *        // ... do stuff that are not wrapped in session.
- *     }
- * }
- *
- * public interface My
- * {
- *     void doSomethingSessional();
- *
- *     void doSomethingWithoutSession();
- * }
- *
- * &#64;Concerns( SessionConcern.class )
- * &#64;Mixins( MyMixin.class )
- * public interface MyComposite extends My, TransientComposite
- * {}
- * </code></pre>
- * <p>
- * The doSomethingWithoutSession method do not have the &#64;Sessional annotation, therefore the SessionConcern will
- * not be placed into the call sequence of these methods, and
- * vice-versa. The &#64;Sessional annotation can be placed either on the interface method or the implementation
- * method, depending on whether it is a contract or implementation detail.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface AppliesTo
-{
-    /**
-     * List of interfaces, annotations or AppliesToFilter
-     * implementation classes.
-     * If one of them matches the current element it will be
-     * accepted, so this list can be considered an "or".
-     *
-     * @return array of classes or interfaces to be used by the filter
-     */
-    Class<?>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/AppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/AppliesToFilter.java b/core/api/src/main/java/org/apache/zest/api/common/AppliesToFilter.java
deleted file mode 100644
index e217ebe..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/AppliesToFilter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.common;
-
-import java.lang.reflect.Method;
-
-/**
- * Implementations of this interface can be specified in the &#64;AppliesTo.
- * <p>
- * AppliesTo filters are one of the driving technologies in Zest. They allow you to apply fragments (Mixins,
- * Concerns, SideEffects), often generic ones, depending on the context that they are evaluated under. This
- * mechanism is heavily used internally in Zest to achieve many other features.
- * </p>
- * <p>
- * The starting point is the basic use of AppliesToFilter, where the &#64;AppliesTo annotation is given an
- * AppliesToFilter implementation as an argument, for instance at a Mixin implementation;
- * </p>
- * <pre><code>
- * &#64;AppliesTo( MyAppliesToFilter.class )
- * public class SomeMixin
- *     implements InvocationHandler
- * {
- *
- * }
- *
- * public class MyAppliesToFilter
- *     implements AppliesToFilter
- * {
- *     public boolean appliesTo( Method method, Class&lt;?&gt; mixin, Class&lt;?&gt; compositeType, Class&lt;?&gt; fragmentClass )
- *     {
- *         return method.getName().startsWith( "my" );
- *     }
- * }
- * </code></pre>
- * <p>
- * In the case above, the generic mixin will only be applied to the methods that that is defined by the
- * AppliesToFilter. This is the primary way to define limits on the application of generic fragments, since
- * especially mixins are rarely applied to all methods.
- * </p>
- */
-public interface AppliesToFilter
-{
-    /**
-     * This is an internal AppliesToFilter which is assigned if no other AppliesToFilters are found for a given
-     * fragment.
-     * <p>
-     * There is no reason for user code to use this AppliesToFilter directly, and should be perceived as an
-     * internal class in Zest.
-     * </p>
-     */
-    AppliesToFilter ALWAYS = new AppliesToFilter()
-    {
-        @Override
-        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
-        {
-            return true;
-        }
-    };
-
-    /**
-     * Check if the Fragment should be applied or not. Will be call when applied to Mixins, Concerns, SideEffects.
-     *
-     * @param method        method that is invoked
-     * @param mixin         mixin implementation for the method
-     * @param compositeType composite type
-     * @param fragmentClass fragment that is being applies
-     *
-     * @return true if the filter passes, otherwise false
-     */
-    boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/ConstructionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/ConstructionException.java b/core/api/src/main/java/org/apache/zest/api/common/ConstructionException.java
deleted file mode 100644
index 3a5fff1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/ConstructionException.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.common;
-
-/**
- * Thrown when a Fragment or object could not be instantiated.
- * This includes, but not be limited to;
- * <ul>
- * <li>private constructor.</li>
- * <li>abstract class for Constraints.</li>
- * <li>interface instead of a class.</li>
- * <li>useful constructor missing.</li>
- * <li>exception thrown in the constructor.</li>
- * <li>Subclassing of org.qi4j.api.property.Property</li>
- * </ul>
- * <p>
- * See the nested exception for additional details.
- * </p>
- */
-public class ConstructionException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = 1L;
-
-    public ConstructionException()
-    {
-    }
-
-    public ConstructionException( String message )
-    {
-        super( message );
-    }
-
-    public ConstructionException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    public ConstructionException( Throwable cause )
-    {
-        super( cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/InvalidApplicationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/InvalidApplicationException.java b/core/api/src/main/java/org/apache/zest/api/common/InvalidApplicationException.java
deleted file mode 100644
index d0cb8aa..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/InvalidApplicationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.common;
-
-/**
- * Thrown when an application is considered to not be constructed properly.
- * This happens primarily when client code tries to instantiate Composites
- * and objects which have not been registered in the ModuleAssembly.
- */
-public class InvalidApplicationException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = 1L;
-
-    public InvalidApplicationException( String string )
-    {
-        super( string );
-    }
-
-    public InvalidApplicationException( String string, Throwable cause )
-    {
-        super( string, cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/MetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/MetaInfo.java b/core/api/src/main/java/org/apache/zest/api/common/MetaInfo.java
deleted file mode 100644
index 6856c61..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/MetaInfo.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.common;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.sideeffect.SideEffects;
-import org.apache.zest.api.util.Classes;
-
-import static java.util.Arrays.asList;
-import static org.apache.zest.api.util.Classes.typesOf;
-
-/**
- * Used to declare and access meta-info.
- * <p>
- * <strong>This is effectively an internal class and should not be used directly.</strong>
- * </p>
- * <p>
- * MetaInfo can be set on composites during the assembly phase, a.k.a the bootstrap
- * process. MetaInfo is any additional data that one wishes to associate at the 'class level' instead of instance
- * level of a composite declaration.
- * </p>
- * <p>
- * To set the MetaInfo on a Composite, call the {@code setMetaInfo()} methods on the various composite declaration
- * types, such as;
- * </p>
- * <pre><code>
- * public void assemble( ModuleAssembly module )
- *     throws AssemblyException
- * {
- *     Map&lt;String,String&gt; properties = ...;
- *     module.services( MyService.class ).setMetaInfo( properties );
- * }
- * </code></pre>
- * <p>
- * which can later be retrieved by calling the {@code metaInfo()} method on the composite itself. For the example
- * above that would be;
- * </p>
- * <pre><code>
- * &#64;Mixins(MyServiceMixin.class)
- * public interface MyService extends ServiceComposite
- * {
- *
- * }
- *
- * public abstract class MyServiceMixin
- *     implements MyService
- * {
- *     private Properties props;
- *
- *     public MyServiceMixin()
- *     {
- *         props = metaInfo( Map.class );
- *     }
- * }
- * </code></pre>
- */
-public final class MetaInfo
-{
-    private final static Collection<Class> ignored;
-
-    static
-    {
-        ignored = new HashSet<Class>( 4, 0.8f ); // Optimize size used.
-        ignored.addAll( asList( Mixins.class, Concerns.class, SideEffects.class ) );
-    }
-
-    private final Map<Class<?>, Object> metaInfoMap;
-
-    public MetaInfo()
-    {
-        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
-    }
-
-    public MetaInfo( MetaInfo metaInfo )
-    {
-        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
-        metaInfoMap.putAll( metaInfo.metaInfoMap );
-    }
-
-    public void set( Object metaInfo )
-    {
-        if( metaInfo instanceof Annotation )
-        {
-            Annotation annotation = (Annotation) metaInfo;
-            metaInfoMap.put( annotation.annotationType(), metaInfo );
-        }
-        else
-        {
-            Class<?> metaInfoclass = metaInfo.getClass();
-            Iterable<Type> types = typesOf( metaInfoclass );
-            for( Type type : types )
-            {
-                metaInfoMap.put( Classes.RAW_CLASS.map( type ), metaInfo );
-            }
-        }
-    }
-
-    public <T> T get( Class<T> metaInfoType )
-    {
-        return metaInfoType.cast( metaInfoMap.get( metaInfoType ) );
-    }
-
-    public <T> void add( Class<T> infoType, T info )
-    {
-        metaInfoMap.put( infoType, info );
-    }
-
-    public MetaInfo withAnnotations( AnnotatedElement annotatedElement )
-    {
-        for( Annotation annotation : annotatedElement.getAnnotations() )
-        {
-            if( !ignored.contains( annotation.annotationType() )
-                && get( annotation.annotationType() ) == null )
-            {
-                set( annotation );
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return metaInfoMap.toString();
-    }
-
-    public void remove( Class serviceFinderClass )
-    {
-        metaInfoMap.remove( serviceFinderClass );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/Optional.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/Optional.java b/core/api/src/main/java/org/apache/zest/api/common/Optional.java
deleted file mode 100644
index f19b8fb..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/Optional.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.common;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to denote that something is optional.
- * <ul>
- * <li>
- * If applied to a method parameter, then the value is allowed to be null. Default
- * is that method parameters have to be non-null.
- * </li>
- * <li>
- * If applied to a Property declaration, then the value may be null after construction of
- * the instance, or may be set to null at a later time.
- * </li>
- * <li>
- * If applied to an injected member field, it is allowed tha none get injected. For instance, an <code>&#64;Optional
- * &#64;Service</code> would allow a service to not have been declared and the field will be null.
- * </li>
- * </ul>
- * <p>
- * Optionality is not the default in Zest, and if injections, property values and parameters in methods are not
- * non-null, the Zest runtime will throw an {@link org.apache.zest.api.constraint.ConstraintViolationException}, indicating
- * which field/property/parameter in which composite and mixin the problem has been detected.
- * </p>
- * <p>
- * Example;
- * </p>
- * <pre><code>
- * &#64;Optional &#64;Service
- * MyService service;   // If no MyService instance is declared and visible to this service injection point
- *                      // the 'service' field will be null.
- *
- * &#64;Service
- * YourService other;   // If no YourService instance is declared and visible to this service injection point
- *                      // the Zest runtime will throw a ConstraintViolationException.
- *
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD } )
-@Documented
-public @interface Optional
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/QualifiedName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/QualifiedName.java b/core/api/src/main/java/org/apache/zest/api/common/QualifiedName.java
deleted file mode 100644
index eef1cce..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/QualifiedName.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.common;
-
-import java.io.Serializable;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import org.apache.zest.api.util.NullArgumentException;
-
-/**
- * QualifiedName is a representation of Property names to their full declaration.
- * <p>
- * A QualifiedName is created by combining the name of a method and the name of the type that declares the method.
- * This class also contains many static utility methods to manage QualifiedName instances.
- * </p>
- * <p>
- * <strong>NOTE: Unless you do very generic libraries, entity stores and other extensions that is deeply coupled into
- * the Zest runtime, it is very unlikely you will need to use this class directly.</strong>
- * </p>
- * <p>
- * It is also important to notice that the QualifiedName needs to be long-term stable, as the names are written
- * to persistent storage. So any changes in the formatting <strong>must be made in a backward-compatible manner
- * </strong>.
- * </p>
- * <p>
- * The QualifiedName has two intrinsic parts, one being the {@code type} and the other the {@code name}. The
- * {@code type} comes from the class where the QualifiedName originates from and internally kept as a {@link TypeName}
- * instance. The name is the name from the method name. When the QualifiedName instance is converted to an external
- * string representation, via the offical and formal {@link #toString()} method, the {@code type} is normalized, i.e.
- * any dollar characters ($) in the name are replaced by dashes (-), to make them URI friendly.
- * </p>
- * <p>
- * QualifiedName instances are immutable, implements {@link #hashCode()} and {@link #equals(Object)} as a value
- * object and can safely be used as keys in {@link java.util.Map}.
- */
-public final class QualifiedName
-    implements Comparable<QualifiedName>, Serializable
-{
-    private final TypeName typeName;
-    private final String name;
-
-    /**
-     * Creates a QualifiedName from a method.
-     * <p>
-     * This factory method will create a QualifiedName from the Method itself.
-     *
-     * </p>
-     *
-     * @param method Type method that returns a Property, for which the QualifiedName will be representing.
-     *
-     * @return A QualifiedName representing this method.
-     *
-     * @throws NullArgumentException If the {@code method} argument passed is null.
-     */
-    public static QualifiedName fromAccessor( AccessibleObject method )
-    {
-        NullArgumentException.validateNotNull( "method", method );
-        return fromClass( ( (Member) method ).getDeclaringClass(), ( (Member) method ).getName() );
-    }
-
-    /**
-     * Creates a QualifiedName instance from the Class and a given name.
-     * <p>
-     * This factory method converts the {@code type} to a {@link TypeName} and appends the given {@code name}.
-     *
-     * @param type The Class that is the base of the QualifiedName.
-     * @param name The qualifier name which will be appended to the base name derived from the {@code type} argument.
-     *
-     * @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
-     *
-     * @throws NullArgumentException if any of the two arguments are {@code null}, or if the name string is empty.
-     */
-    public static QualifiedName fromClass( Class type, String name )
-    {
-        return new QualifiedName( TypeName.nameOf( type ), name );
-    }
-
-    /**
-     * Creates a Qualified name from a type as string and a name qualifier.
-     *
-     * @param type The type name as a a string, which must be properly formatted. No checks for correctly formatted
-     *             type name is performed.
-     * @param name The qualifier name which will be appended to the base name derived from the {@code type} argument.
-     *
-     * @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
-     *
-     * @throws NullArgumentException if any of the two arguments are {@code null} or either string is empty.
-     */
-    public static QualifiedName fromName( String type, String name )
-    {
-        return new QualifiedName( TypeName.nameOf( type ), name );
-    }
-
-    /**
-     * Creates a QualifiedName from the external string format of QualifiedName.
-     * <p>
-     * This factory method is the reverse of {@link QualifiedName#toString() }  method, and creates a new QualifiedName
-     * instance from the string representation of the QualifiedName.
-     * </p>
-     *
-     * @param fullQualifiedName The QualifiedName external string representation to be converted back into a QualifiedName
-     *                      instance.
-     *
-     * @return The QualifiedName instance represented by the {@code qualifiedName} argument.
-     *
-     * @throws IllegalArgumentException If the {@code qualifiedName} argument has wrong format.
-     */
-    public static QualifiedName fromFQN( String fullQualifiedName )
-    {
-        NullArgumentException.validateNotEmpty( "qualifiedName", fullQualifiedName );
-        int idx = fullQualifiedName.lastIndexOf( ":" );
-        if( idx == -1 )
-        {
-            throw new IllegalArgumentException( "Name '" + fullQualifiedName + "' is not a qualified name" );
-        }
-        final String type = fullQualifiedName.substring( 0, idx );
-        final String name = fullQualifiedName.substring( idx + 1 );
-        return new QualifiedName( TypeName.nameOf( type ), name );
-    }
-
-    QualifiedName( TypeName typeName, String name )
-    {
-        NullArgumentException.validateNotNull( "typeName", typeName );
-        NullArgumentException.validateNotEmpty( "name", name );
-        this.typeName = typeName;
-        this.name = name;
-    }
-
-    /**
-     * Returns the normalized string of the type part of the QualifiedName.
-     *
-     * <p>
-     * The normalized type name means that all dollar ($) characters have been replaced by dashes (-).
-     * </p>
-     *
-     * @return the normalized string of the type part of the QualifiedName.
-     */
-    public String type()
-    {
-        return typeName.normalized();
-    }
-
-    /**
-     * Returns the name component of the QualifiedName.
-     *
-     * @return the name component of the QualifiedName.
-     */
-    public String name()
-    {
-        return name;
-    }
-
-    /**
-     * Returns the URI of the QualifiedName.
-     *
-     * <p>
-     * The URI is the {@link #toNamespace()} followed by the {@code name} component.
-     * <p>
-     *
-     * @return the URI of the QualifiedName.
-     *
-     * @see #toNamespace()
-     */
-    public String toURI()
-    {
-        return toNamespace() + name;
-    }
-
-    /**
-     * Return the URI of the {@link TypeName} component of the QualifiedName.
-     * <p>
-     * The URI of the {@link TypeName} component is in the form of;
-     * </p>
-     * <pre>
-     * "urn:qi4j:type:" normalizedClassName
-     * </pre>
-     * <p>
-     * where {@code normalizedClassName} is the fully-qualified class name having had any dollar ($) characters replaced
-     * by URI friendly dashes (-), with a trailing hash (#). Examples;
-     * </p>
-     * <pre>
-     * urn:qi4j:type:org.qi4j.api.common.QualifiedName#
-     * urn:qi4j:type:org.qi4j.samples.MyClass-MyInnerClass#
-     * </pre>
-     *
-     * @return the URI of the {@link TypeName} component of the QualifiedName.
-     */
-    public String toNamespace()
-    {
-        return typeName.toURI() + "#";
-    }
-
-    /**
-     * Return the formal and official, long-term stable, external string representation of a QualifiedName.
-     * <p>
-     * This returns the {@link org.apache.zest.api.common.TypeName#toString()} followed by the {@code name} component.
-     * </p>
-     *
-     * @return the formal and official, long-term stable, external string representation of a QualifiedName.
-     */
-    @Override
-    public String toString()
-    {
-        return typeName + ":" + name;
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        QualifiedName that = (QualifiedName) o;
-
-        return name.equals( that.name ) && typeName.equals( that.typeName );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return 31 * typeName.hashCode() + name.hashCode();
-    }
-
-    @Override
-    public int compareTo( QualifiedName other )
-    {
-        final int result = typeName.compareTo( other.typeName );
-        if( result != 0 )
-        {
-            return result;
-        }
-        return name.compareTo( other.name );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/TypeName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/TypeName.java b/core/api/src/main/java/org/apache/zest/api/common/TypeName.java
deleted file mode 100644
index 78f03af..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/TypeName.java
+++ /dev/null
@@ -1,111 +0,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.
- */
-package org.apache.zest.api.common;
-
-import java.io.Serializable;
-import java.lang.reflect.Type;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.NullArgumentException;
-
-/**
- * Represents a Type name.
- */
-public final class TypeName
-    implements Serializable, Comparable<TypeName>
-{
-    private final String name;
-
-    public static TypeName nameOf( Class type )
-    {
-        NullArgumentException.validateNotNull( "type", type );
-        return new TypeName( type.getName() );
-    }
-
-    public static TypeName nameOf( Type type )
-    {
-        return nameOf( Classes.RAW_CLASS.map( type ) );
-    }
-
-    public static TypeName nameOf( String typeName )
-    {
-        return new TypeName( typeName );
-    }
-
-    private TypeName( String name )
-    {
-        NullArgumentException.validateNotEmpty( "name", name );
-        this.name = name;
-    }
-
-    public String normalized()
-    {
-        return Classes.normalizeClassToURI( name );
-    }
-
-    public String toURI()
-    {
-        return Classes.toURI( name );
-    }
-
-    public String name()
-    {
-        return name;
-    }
-
-    @Override
-    public String toString()
-    {
-        return name;
-    }
-
-    public boolean isClass( final Class<?> type )
-    {
-        return type.getName().equals( name );
-    }
-
-    @Override
-    public boolean equals( final Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        final TypeName other = (TypeName) o;
-
-        return name.equals( other.name );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return name.hashCode();
-    }
-
-    @Override
-    public int compareTo( final TypeName typeName )
-    {
-        return this.name.compareTo( typeName.name );
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/UseDefaults.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/UseDefaults.java b/core/api/src/main/java/org/apache/zest/api/common/UseDefaults.java
deleted file mode 100644
index a09e76a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/UseDefaults.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.common;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to denote that the initial value of a Property will be the default value for the type if none is
- * specified during construction.
- * <p>
- * These are the default values used for various types:
- * </p>
- * <pre>
- * Byte: 0
- * Short: 0
- * Character: 0
- * Integer: 0
- * Long: 0L
- * Double: 0.0d
- * Float: 0.0f
- * Boolean: false
- * String: ""
- * List: empty java.util.ArrayList
- * Set: empty java.util.HashSet
- * Collection: empty java.util.ArrayList
- * enum: first declared value
- * </pre>
- * <p>
- * If this annotation is not used, the property will be set to null, and unless {@code &#64;Optional} is declared
- * is not allowed.
- * </p>
- * <p>
- * It is also possible to change the default values for Composites during the assembly. This is done by calling the
- * {@code org.qi4j.bootstrap.ModuleAssembly#forMixin(Class)} method.
- * </p>
- * <p>
- * Example;
- * Let's assume that we have the following mixin type;
- *
- * <pre><code>
- * public interface SomeType
- * {
- *     &#64;UseDefaults
- *     Property&lt;String&gt; someValue();
- * }
- * </code></pre>
- * And that we want to have {@code someValue()} to be initialized to "&lt;unknown&gt;" instead of the empty string.
- * Then we need to declare the default for that with the following in the assembler.
- * <pre><code>
- * public void assemble( ModuleAssembly module )
- * {
- *     module.forMixin( SomeType.class ).declareDefaults().someValue().set( "&lt;unknown&gt;" );
- * }
- * }
- * </code></pre>
- */
-@SuppressWarnings( "JavadocReference" )
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.METHOD, ElementType.FIELD } )
-@Documented
-public @interface UseDefaults
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/Visibility.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/Visibility.java b/core/api/src/main/java/org/apache/zest/api/common/Visibility.java
deleted file mode 100644
index e81824b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/Visibility.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.common;
-
-/**
- * Visibility is a core concept in the Zest structure system. It defines the locale of composites and objects, i.e.
- * how far they can be 'seen' and therefor be used.
- * <p>
- * When a Composite or Object is declared in the assembly phase, and no visibility is set, only other
- * composites/objects within the same module can use that declaration. For a declared composite/object to be usable
- * from other modules a higher visibility must be set, either that the Composite/Object can be used by others within
- * the same Layer, or even to be used by those in the layer above.
- * </p>
- */
-public enum Visibility
-{
-    /**
-     * Artifact is visible only in the declaring module (default)
-     */
-    module,
-    /**
-     * Artifact is visible to all modules in the same layer
-     */
-    layer,
-    /**
-     * Artifact is visible to other modules in the same layer and any modules in extending layers
-     */
-    application
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/common/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/common/package.html b/core/api/src/main/java/org/apache/zest/api/common/package.html
deleted file mode 100644
index f29de5d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/common/package.html
+++ /dev/null
@@ -1,81 +0,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.
--->
-<html>
-    <body>
-        <h2>Common API.</h2>
-        <p>
-            The Common API package is a collection of really low-level types needed at the core of the Zest™ Runtime. It is also
-            a collection of types that are not particularly cohesive, and effectively this package contains the loose ends
-            that does not belong elsewhere.
-        </p>
-        <p>
-            In this package, you can safely ignore the following classes;
-        </p>
-        <ul>
-            <li>MetaInfo</li>
-            <li>QualifiedName</li>
-            <li>TypeName</li>
-        </ul>
-        <p>UNLESS you are into deep integration into the Zest™ Runtime.</p>
-
-        <h3>&#64;AppliesTo and AppliesToFilter</h3>
-        <p>
-            This tandem of interface + annotation are primarily used for Generic Fragments, to indicate which methods on the
-            interface the fragment should be applied to.
-        </p>
-
-        <h3>&#64;Optional</h3>
-        <p>
-            In Zest™, method arguments, property values and injected fields are not allowed to be null by default. To allow
-            any of these to be null, i.e. undeclared, it is required that the argument, field or method is marked with the
-            &#64;Optional annotation.
-        </p>
-
-        <h3>&#64;UseDefaults</h3>
-        <p>
-            Since null is not allowed without the &#64;Optional annotation, it can sometimes by tedious to initialize all
-            the property values. And the &#64;UseDefaults annotation allows us to declare that Zest™ should set the Property
-            to a default value. These are either the pre-defined ones, or can be set per property declaration during the
-            assembly.
-        </p>
-
-        <h3>&#64;Visibility</h3>
-        <p>
-            Visibility is another innovative concept in Zest™, which leverage the structure system (Application, Layer, Module)
-            to limit the 'reach' when requesting composites and objects. The Visibility is declared per Composite/Object,
-            preferably in the most restrictive mode possible, and the visibility resolver will ensure a predictable resolution
-            algorithm;
-        </p>
-        <ol>
-            <li>Search the module of the caller first. If one and only one composite type fulfilling the request is available
-                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
-                continue to the next step.
-            </li>
-            <li>Search all modules in the Layer of the caller for composite that has a declaration other than
-                <code>Visibility.module</code>. If one and only one composite type fulfilling the request is available
-                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
-                continue to the next step.
-            </li>
-            <li>Search all modules in the Layer(s) (if any) directly below of the caller for composite that has a declaration of
-                <code>Visibility.application</code>. If one and only one composite type fulfilling the request is available
-                return that to the caller. If two or more are found, throw an AmbiguousTypeException. If no composite found
-                continue to the next step.
-            </li>
-            <li>Throw an NoSuchCompositeException (or related) exception.</li>
-        </ol>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/AmbiguousTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/AmbiguousTypeException.java b/core/api/src/main/java/org/apache/zest/api/composite/AmbiguousTypeException.java
deleted file mode 100644
index 7f3a0f8..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/AmbiguousTypeException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.composite;
-
-/**
- * This Exception is thrown when more than one Composite implements a MixinType
- * that one tries to use to create a Composite instance from.
- * <p>
- * For instance;
- * </p>
- * <pre><code>
- * public interface AbcComposite extends TransientComposite, Abc
- * {}
- *
- * public interface DefComposite extends TransientComposite, Def
- * {}
- *
- * public interface Abc
- * {}
- *
- * public interface Def extends Abc
- * {}
- *
- *
- * TransientBuilder cb = factory.newTransientBuilder( Abc.class );
- * </code></pre>
- * <p>
- * In the code above, both the AbcComposite and DefComposite implement Abc, and therefore
- * the <code>newTransientBuilder</code> method can not unambiguously figure out which
- * one is intended.
- * </p>
- */
-public class AmbiguousTypeException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = 1L;
-
-    public AmbiguousTypeException( String message )
-    {
-        super( message );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/Composite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/Composite.java b/core/api/src/main/java/org/apache/zest/api/composite/Composite.java
deleted file mode 100644
index b60f19c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/Composite.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.composite;
-
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.PropertyMixin;
-
-/**
- * Base Composite interface.
- * <p>
- * All Composite objects must implement this interface. Let the
- * Composite interface extend this one. An implementation will be provided
- * by the framework.
- * </p>
- * <p>
- * Properties and associations are handled by default.
- * </p>
- */
-@Mixins( { PropertyMixin.class } )
-public interface Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
deleted file mode 100644
index b50d0d3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.Iterables;
-
-import static org.apache.zest.functional.Iterables.toArray;
-
-/**
- * Thread-associated composites. This is basically a ThreadLocal which maintains a reference
- * to a TransientComposite instance for each thread. This can be used to implement various context
- * patterns without having to pass the context explicitly as a parameter to methods.
- */
-public class CompositeContext<T extends TransientComposite>
-    extends ThreadLocal<T>
-{
-    private Module module;
-    private Class<T> type;
-
-    public CompositeContext( Module module, Class<T> type )
-    {
-        this.module = module;
-        this.type = type;
-    }
-
-    @Override
-    protected T initialValue()
-    {
-        return module.newTransient( type );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public T proxy()
-    {
-        TransientComposite composite = get();
-
-        Iterable<Class<?>> types = Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( composite ).types();
-        return (T) Proxy.newProxyInstance(
-            composite.getClass().getClassLoader(),
-            toArray( Class.class, Iterables.<Class>cast( types ) ),
-            new ContextInvocationhandler() );
-    }
-
-    private class ContextInvocationhandler
-        implements InvocationHandler
-    {
-
-        @Override
-        public Object invoke( Object object, Method method, Object[] objects )
-            throws Throwable
-        {
-            try
-            {
-                return method.invoke( get(), objects );
-            }
-            catch( InvocationTargetException e )
-            {
-                throw e.getTargetException();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/CompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeDescriptor.java
deleted file mode 100644
index 49f9f42..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeDescriptor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.composite;
-
-/**
- * Composite Descriptor.
- */
-public interface CompositeDescriptor
-    extends ModelDescriptor
-{
-    Class<?> primaryType();
-
-    Iterable<Class<?>> mixinTypes();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
deleted file mode 100644
index 63aa10d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.InvocationHandler;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * Composite Instance.
- */
-public interface CompositeInstance
-    extends InvocationHandler, CompositeInvoker, HasTypes, MetaInfoHolder
-{
-    <T> T proxy();
-
-    <T> T newProxy( Class<T> mixinType )
-        throws IllegalArgumentException;
-
-    Module module();
-
-    CompositeDescriptor descriptor();
-
-    StateHolder state();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/CompositeInvoker.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInvoker.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeInvoker.java
deleted file mode 100644
index bc8a8d0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInvoker.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.Method;
-
-/**
- * Composite method invoker.
- * <p>
- * All composites must implement this interface. Methods that are invoked
- * may reside either in the public Composite interface or in any internal mixins.
- * </p>
- * <p>
- * <strong><i>NOTE:</i></strong>Client code should never use method in this class. We have not been able to hide this
- * from client code, but IF we find a way to do, this interface may disappear.
- * </p>
- */
-public interface CompositeInvoker
-{
-
-    Object invokeComposite( Method method, Object[] args )
-        throws Throwable;
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/ConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/ConstructorDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/ConstructorDescriptor.java
deleted file mode 100644
index c235dca..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/ConstructorDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.Constructor;
-
-/**
- * Composite constructor descriptor.
- */
-public interface ConstructorDescriptor
-{
-    Constructor<?> constructor();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/DecoratorMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/DecoratorMixin.java b/core/api/src/main/java/org/apache/zest/api/composite/DecoratorMixin.java
deleted file mode 100644
index 080a799..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/DecoratorMixin.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.injection.scope.Uses;
-
-/**
- * Generic decorator mixin that allows a Composite to wrap
- * any other Composite as long as they share an interface.
- * <p>
- * Can be used to effectively implement
- * singleton mixins, since the decorated object can be shared between
- * many instances.
- * </p>
- */
-public class DecoratorMixin
-    implements InvocationHandler
-{
-    private Object delegate;
-
-    public DecoratorMixin( @Uses Object delegate )
-    {
-        if( delegate instanceof Class )
-        {
-            Thread.dumpStack();
-        }
-        this.delegate = delegate;
-    }
-
-    @Override
-    public Object invoke( Object object, Method method, Object[] args )
-        throws Throwable
-    {
-        if( delegate instanceof InvocationHandler )
-        {
-            InvocationHandler handler = (InvocationHandler) delegate;
-            return handler.invoke( object, method, args );
-        }
-        else
-        {
-            try
-            {
-                return method.invoke( delegate, args );
-            }
-            catch( InvocationTargetException e )
-            {
-                throw e.getCause();
-            }
-            catch( IllegalArgumentException e )
-            {
-                String message = constructMessage( method, args );
-                throw new IllegalArgumentException( message, e );
-            }
-        }
-    }
-
-    private String constructMessage( Method method, Object[] args )
-    {
-        StringBuilder builder = new StringBuilder();
-        builder.append( "\nmethod: " );
-        builder.append( method.getDeclaringClass().getName() );
-        builder.append( "." );
-        builder.append( method.getName() );
-        builder.append( "\ndelegate: " );
-        builder.append( delegate );
-        builder.append( "\ndelegateType: " );
-        builder.append( delegate == null ? "n/a" : delegate.getClass().getName() );
-        builder.append( "\narguments: \n" );
-        for( Object arg : args )
-        {
-            builder.append( "    " );
-            Class argClass = arg.getClass();
-            if( Proxy.isProxyClass( argClass ) )
-            {
-                builder.append( Proxy.getInvocationHandler( arg ).getClass().getName() );
-            }
-            else
-            {
-                builder.append( argClass.getName() );
-            }
-            builder.append( '\n' );
-        }
-        return builder.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/DependencyDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/DependencyDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/DependencyDescriptor.java
deleted file mode 100644
index a2de941..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/DependencyDescriptor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*  Copyright 2008 Edward Yakop.
-*
-* 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.zest.api.composite;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-/**
- * Composite dependency descriptor.
- */
-public interface DependencyDescriptor
-{
-    Annotation injectionAnnotation();
-
-    Type injectionType();
-
-    Class<?> injectedClass();
-
-    Class<?> rawInjectionType();
-
-    boolean optional();
-
-    Annotation[] annotations();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/InjectedFieldDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/InjectedFieldDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/InjectedFieldDescriptor.java
deleted file mode 100644
index 0a6b282..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/InjectedFieldDescriptor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.Field;
-
-/**
- * Composite injected field descriptor.
- */
-public interface InjectedFieldDescriptor
-{
-    Field field();
-
-    DependencyDescriptor dependency();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/InjectedMethodDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/InjectedMethodDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/InjectedMethodDescriptor.java
deleted file mode 100644
index 917e454..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/InjectedMethodDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.Method;
-
-/**
- * Composite injected method descriptor.
- */
-public interface InjectedMethodDescriptor
-{
-    Method method();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/InjectedParametersDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/InjectedParametersDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/InjectedParametersDescriptor.java
deleted file mode 100644
index 76121e2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/InjectedParametersDescriptor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-/**
- * Composite constructors and method injected parameters descriptor.
- */
-public interface InjectedParametersDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/InvalidCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/InvalidCompositeException.java b/core/api/src/main/java/org/apache/zest/api/composite/InvalidCompositeException.java
deleted file mode 100644
index 82fb572..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/InvalidCompositeException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-/**
- * This exception is thrown if a Composite is invalid.
- */
-public class InvalidCompositeException
-    extends RuntimeException
-{
-    public InvalidCompositeException( String message )
-    {
-        super( message );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/InvalidValueCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/InvalidValueCompositeException.java b/core/api/src/main/java/org/apache/zest/api/composite/InvalidValueCompositeException.java
deleted file mode 100644
index a77acd4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/InvalidValueCompositeException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-/**
- * This exception is thrown if a ValueComposite is invalid.
- */
-public class InvalidValueCompositeException
-    extends RuntimeException
-{
-    public InvalidValueCompositeException( String message )
-    {
-        super( message );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/MethodDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/MethodDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/MethodDescriptor.java
deleted file mode 100644
index df408c9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/MethodDescriptor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.composite;
-
-import java.lang.reflect.Method;
-
-/**
- * Composite Method Descriptor.
- */
-public interface MethodDescriptor
-{
-    Method method();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/MissingMethodException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/MissingMethodException.java b/core/api/src/main/java/org/apache/zest/api/composite/MissingMethodException.java
deleted file mode 100644
index 009f5e9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/MissingMethodException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.composite;
-
-/**
- * This exception is thrown if client code tries to invoke a non-existing Composite method.
- */
-public class MissingMethodException
-    extends RuntimeException
-{
-    public MissingMethodException( String message )
-    {
-        super( message );
-    }
-
-    public MissingMethodException( String message, NoSuchMethodException e )
-    {
-        super(message,e);
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
deleted file mode 100644
index a1bef87..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
+++ /dev/null
@@ -1,33 +0,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.
- */
-package org.apache.zest.api.composite;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * Composite ModelDescriptor.
- */
-public interface ModelDescriptor extends HasTypes, MetaInfoHolder
-{
-    Visibility visibility();
-
-    boolean isAssignableTo( Class<?> type );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/NoSuchCompositeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/NoSuchCompositeException.java b/core/api/src/main/java/org/apache/zest/api/composite/NoSuchCompositeException.java
deleted file mode 100644
index 3583322..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/NoSuchCompositeException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.api.composite;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-
-/**
- * This exception is thrown if client code tries to create a non-existing Composite type.
- */
-public class NoSuchCompositeException
-    extends InvalidApplicationException
-{
-    private static final long serialVersionUID = 1L;
-
-    private final String compositeType;
-    private final String moduleName;
-
-    protected NoSuchCompositeException( String metaType, String compositeType, String moduleName )
-    {
-        super( "Could not find any visible " + metaType + " of type [" + compositeType + "] in module [" +
-               moduleName + "]." );
-        this.compositeType = compositeType;
-        this.moduleName = moduleName;
-    }
-
-    public String compositeType()
-    {
-        return compositeType;
-    }
-
-    public String moduleName()
-    {
-        return moduleName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/composite/NoSuchTransientException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/NoSuchTransientException.java b/core/api/src/main/java/org/apache/zest/api/composite/NoSuchTransientException.java
deleted file mode 100644
index 5cd6046..0000000
--- a/core/api/src/main/java/org/apache/zest/api/composite/NoSuchTransientException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.composite;
-
-/**
- * This exception is thrown if client code tries to create a non-existing TransientComposite type.
- */
-public class NoSuchTransientException extends NoSuchCompositeException
-{
-    public NoSuchTransientException( String typeName, String moduleName )
-    {
-        super( "TransientComposite", typeName, moduleName );
-    }
-}


[13/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentClassLoader.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentClassLoader.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentClassLoader.java
deleted file mode 100644
index 9835128..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentClassLoader.java
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.apache.zest.api.entity.Lifecycle;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Methods;
-import org.apache.zest.functional.Iterables;
-
-import static org.objectweb.asm.Opcodes.AASTORE;
-import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
-import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
-import static org.objectweb.asm.Opcodes.ACC_STATIC;
-import static org.objectweb.asm.Opcodes.ACC_SUPER;
-import static org.objectweb.asm.Opcodes.ACONST_NULL;
-import static org.objectweb.asm.Opcodes.ALOAD;
-import static org.objectweb.asm.Opcodes.ANEWARRAY;
-import static org.objectweb.asm.Opcodes.ARETURN;
-import static org.objectweb.asm.Opcodes.ASTORE;
-import static org.objectweb.asm.Opcodes.ATHROW;
-import static org.objectweb.asm.Opcodes.BIPUSH;
-import static org.objectweb.asm.Opcodes.CHECKCAST;
-import static org.objectweb.asm.Opcodes.DLOAD;
-import static org.objectweb.asm.Opcodes.DRETURN;
-import static org.objectweb.asm.Opcodes.DUP;
-import static org.objectweb.asm.Opcodes.FLOAD;
-import static org.objectweb.asm.Opcodes.FRETURN;
-import static org.objectweb.asm.Opcodes.GETFIELD;
-import static org.objectweb.asm.Opcodes.GETSTATIC;
-import static org.objectweb.asm.Opcodes.GOTO;
-import static org.objectweb.asm.Opcodes.ICONST_0;
-import static org.objectweb.asm.Opcodes.ICONST_1;
-import static org.objectweb.asm.Opcodes.ICONST_2;
-import static org.objectweb.asm.Opcodes.ICONST_3;
-import static org.objectweb.asm.Opcodes.ICONST_4;
-import static org.objectweb.asm.Opcodes.ICONST_5;
-import static org.objectweb.asm.Opcodes.ILOAD;
-import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
-import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
-import static org.objectweb.asm.Opcodes.INVOKESTATIC;
-import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
-import static org.objectweb.asm.Opcodes.IRETURN;
-import static org.objectweb.asm.Opcodes.LLOAD;
-import static org.objectweb.asm.Opcodes.LRETURN;
-import static org.objectweb.asm.Opcodes.POP;
-import static org.objectweb.asm.Opcodes.PUTSTATIC;
-import static org.objectweb.asm.Opcodes.RETURN;
-import static org.objectweb.asm.Type.getInternalName;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-
-/**
- * Generate subclasses of mixins/modifiers that implement all interfaces not in the class itself
- * and which delegates those calls to a given composite invoker.
- */
-@SuppressWarnings( "raw" )
-public class FragmentClassLoader
-    extends ClassLoader
-{
-    private static final int JDK_VERSION;
-    public static final String GENERATED_POSTFIX = "_Stub";
-
-    static
-    {
-        String jdkString = System.getProperty( "java.specification.version" );
-        switch( jdkString )
-        {
-            case "1.8":
-                JDK_VERSION = Opcodes.V1_8;
-                break;
-            case "1.7":
-            default:
-                JDK_VERSION = Opcodes.V1_7;
-                break;
-        }
-    }
-
-    public FragmentClassLoader( ClassLoader parent )
-    {
-        super( parent );
-    }
-
-    @Override
-    protected Class findClass( String name )
-        throws ClassNotFoundException
-    {
-        if( name.endsWith( GENERATED_POSTFIX ) )
-        {
-            Class baseClass;
-            String baseName = name.substring( 0, name.length() - 5 );
-            try
-            {
-                baseClass = loadClass( baseName );
-            }
-            catch( ClassNotFoundException e )
-            {
-                // Try replacing the last _ with $
-                while( true )
-                {
-                    int idx = baseName.lastIndexOf( "_" );
-                    if( idx != -1 )
-                    {
-                        baseName = baseName.substring( 0, idx ) + "$" + baseName.substring( idx + 1 );
-                        try
-                        {
-                            baseClass = loadClass( baseName );
-                            break;
-                        }
-                        catch( ClassNotFoundException e1 )
-                        {
-                            // Try again
-                        }
-                    }
-                    else
-                    {
-                        throw e;
-                    }
-                }
-            }
-//  To Allow JDK classes to be composed.
-            if( name.startsWith( "java." ))
-                name = "qi4j." + name;
-
-            byte[] b = generateClass( name, baseClass );
-            return defineClass( name, b, 0, b.length, baseClass.getProtectionDomain() );
-        }
-
-        // Try the classloader of this classloader -> get classes in Zest such as CompositeInvoker
-        return getClass().getClassLoader().loadClass( name );
-    }
-
-    public static byte[] generateClass( String name, Class baseClass )
-        throws ClassNotFoundException
-    {
-        String classSlash = name.replace( '.', '/' );
-        String baseClassSlash = getInternalName( baseClass );
-
-        ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
-
-        // Class definition start
-        cw.visit( JDK_VERSION, ACC_PUBLIC + ACC_SUPER, classSlash, null, baseClassSlash, null );
-
-        // Composite reference
-        {
-            cw.visitField( ACC_PUBLIC, "_instance", "Lorg/qi4j/api/composite/CompositeInvoker;", null, null ).visitEnd();
-        }
-
-        // Static Method references
-        boolean hasProxyMethods = false;
-        {
-            int idx = 1;
-            for( Method method : baseClass.getMethods() )
-            {
-                if( isOverridden(method, baseClass) )
-                {
-                    cw.visitField( ACC_PRIVATE + ACC_STATIC, "m" + idx++, "Ljava/lang/reflect/Method;", null,
-                                        null ).visitEnd();
-                    hasProxyMethods = true;
-                }
-            }
-        }
-
-        // Constructors
-        for( Constructor constructor : baseClass.getDeclaredConstructors() )
-        {
-            if( Modifier.isPublic( constructor.getModifiers() ) || Modifier.isProtected( constructor.getModifiers() ) )
-            {
-                String desc = org.objectweb.asm.commons.Method.getMethod( constructor ).getDescriptor();
-                MethodVisitor cmv = cw.visitMethod( ACC_PUBLIC, "<init>", desc, null, null );
-                cmv.visitCode();
-                cmv.visitVarInsn(ALOAD, 0);
-
-                int idx = 1;
-                for( Class aClass : constructor.getParameterTypes() )
-                {
-                    final int opcode;
-                    if (aClass.equals(Integer.TYPE)) {
-                        opcode = ILOAD;
-                    } else if (aClass.equals(Long.TYPE)) {
-                        opcode = LLOAD;
-                    } else if (aClass.equals(Float.TYPE)) {
-                        opcode = FLOAD;
-                    } else if (aClass.equals(Double.TYPE)) {
-                        opcode = DLOAD;
-                    } else {
-                        opcode = ALOAD;
-                    }
-                    cmv.visitVarInsn(opcode, idx++);
-                }
-
-                cmv.visitMethodInsn(INVOKESPECIAL, baseClassSlash, "<init>", desc, false);
-                cmv.visitInsn(RETURN);
-                cmv.visitMaxs(idx, idx);
-                cmv.visitEnd();
-            }
-        }
-
-
-        // Overloaded and unimplemented methods
-        if( hasProxyMethods )
-        {
-            Method[] methods = baseClass.getMethods();
-            int idx = 0;
-            List<Label> exceptionLabels = new ArrayList<>();
-            for( Method method : methods )
-            {
-                if( isOverridden(method, baseClass) )
-                {
-                    idx++;
-                    String methodName = method.getName();
-                    String desc = org.objectweb.asm.commons.Method.getMethod( method ).getDescriptor();
-
-                    String[] exceptions = null;
-                    {
-                        MethodVisitor mv = cw.visitMethod( ACC_PUBLIC, methodName, desc, null, null );
-                        if( isInternalQi4jMethod( method, baseClass ) )
-                        {
-                            // generate a NoOp method...
-                            mv.visitInsn( RETURN );
-                        }
-                        else
-                        {
-                            Label endLabel = null; // Use this if return type is void
-                            if( method.getExceptionTypes().length > 0 )
-                            {
-                                exceptions = new String[ method.getExceptionTypes().length ];
-                                for( int i = 0; i < method.getExceptionTypes().length; i++ )
-                                {
-                                    Class<?> aClass = method.getExceptionTypes()[ i ];
-                                    exceptions[ i ] = getInternalName( aClass );
-                                }
-                            }
-                            mv.visitCode();
-                            Label l0 = new Label();
-                            Label l1 = new Label();
-
-                            exceptionLabels.clear();
-                            for( Class<?> declaredException : method.getExceptionTypes() )
-                            {
-                                Label ld = new Label();
-                                mv.visitTryCatchBlock( l0, l1, ld, getInternalName( declaredException ) );
-                                exceptionLabels.add( ld ); // Reuse this further down for the catch
-                            }
-
-                            Label lruntime = new Label();
-                            mv.visitTryCatchBlock( l0, l1, lruntime, "java/lang/RuntimeException" );
-                            Label lerror = new Label();
-                            mv.visitTryCatchBlock( l0, l1, lerror, "java/lang/Throwable" );
-
-                            mv.visitLabel( l0 );
-                            mv.visitVarInsn( ALOAD, 0 );
-                            mv.visitFieldInsn( GETFIELD, classSlash, "_instance",
-                                               "Lorg/qi4j/api/composite/CompositeInvoker;" );
-                            mv.visitFieldInsn( GETSTATIC, classSlash, "m" + idx, "Ljava/lang/reflect/Method;" );
-
-                            int paramCount = method.getParameterTypes().length;
-                            int stackIdx = 0;
-                            if( paramCount == 0 )
-                            {
-                                // Send in null as parameter
-                                mv.visitInsn( ACONST_NULL );
-                            }
-                            else
-                            {
-                                insn( mv, paramCount );
-                                mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" );
-                                int pidx = 0;
-                                for( Class<?> aClass : method.getParameterTypes() )
-                                {
-                                    mv.visitInsn( DUP );
-                                    insn( mv, pidx++ );
-                                    stackIdx = wrapParameter( mv, aClass, stackIdx + 1 );
-                                    mv.visitInsn( AASTORE );
-                                }
-                            }
-
-                            // Call method
-                            mv.visitMethodInsn( INVOKEINTERFACE, "org/qi4j/api/composite/CompositeInvoker",
-                                                "invokeComposite",
-                                                "(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;", true );
-
-                            // Return value
-                            if( !method.getReturnType().equals( Void.TYPE ) )
-                            {
-                                unwrapResult( mv, method.getReturnType(), l1 );
-                            }
-                            else
-                            {
-                                mv.visitInsn( POP );
-                                mv.visitLabel( l1 );
-                                endLabel = new Label();
-                                mv.visitJumpInsn( GOTO, endLabel );
-                            }
-
-                            // Increase stack to beyond method args
-                            stackIdx++;
-
-                            // Declared exceptions
-                            int exceptionIdx = 0;
-                            for( Class<?> aClass : method.getExceptionTypes() )
-                            {
-                                mv.visitLabel( exceptionLabels.get( exceptionIdx++ ) );
-                                mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ getInternalName( aClass ) } );
-                                mv.visitVarInsn( ASTORE, stackIdx );
-                                mv.visitVarInsn( ALOAD, stackIdx );
-                                mv.visitInsn( ATHROW );
-                            }
-
-                            // RuntimeException and Error catch-all
-                            mv.visitLabel( lruntime );
-                            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/RuntimeException" } );
-                            mv.visitVarInsn( ASTORE, stackIdx );
-                            mv.visitVarInsn( ALOAD, stackIdx );
-                            mv.visitInsn( ATHROW );
-
-                            mv.visitLabel( lerror );
-                            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/Throwable" } );
-                            mv.visitVarInsn( ASTORE, stackIdx );
-                            mv.visitVarInsn( ALOAD, stackIdx );
-                            mv.visitTypeInsn( CHECKCAST, "java/lang/Error" );
-                            mv.visitInsn( ATHROW );
-
-                            // Return type = void
-                            if( endLabel != null )
-                            {
-                                mv.visitLabel( endLabel );
-                                mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
-                                mv.visitInsn( RETURN );
-                            }
-
-                            mv.visitMaxs( 0, 0 );
-                            mv.visitEnd();
-                        }
-                    }
-
-                    if( !Modifier.isAbstract( method.getModifiers() ) )
-                    {
-                        // Add method with _ as prefix
-                        MethodVisitor mv;
-                        mv = cw.visitMethod( ACC_PUBLIC, "_" + method.getName(), desc, null, exceptions );
-                        mv.visitCode();
-                        mv.visitVarInsn( ALOAD, 0 );
-
-                        // Parameters
-                        int stackIdx = 1;
-                        for( Class<?> aClass : method.getParameterTypes() )
-                        {
-                            stackIdx = loadParameter( mv, aClass, stackIdx ) + 1;
-                        }
-
-                        // Call method
-                        mv.visitMethodInsn( INVOKESPECIAL, baseClassSlash, method.getName(), desc, false );
-
-                        // Return value
-                        if( !method.getReturnType().equals( Void.TYPE ) )
-                        {
-                            returnResult( mv, method.getReturnType() );
-                        }
-                        else
-                        {
-                            mv.visitInsn( RETURN );
-                        }
-
-                        mv.visitMaxs( 1, 1 );
-                        mv.visitEnd();
-                    }
-                }
-            }
-
-            // Class initializer
-            {
-                MethodVisitor mv;
-                mv = cw.visitMethod( ACC_STATIC, "<clinit>", "()V", null, null );
-                mv.visitCode();
-                Label l0 = new Label();
-                Label l1 = new Label();
-                Label l2 = new Label();
-                mv.visitTryCatchBlock( l0, l1, l2, "java/lang/NoSuchMethodException" );
-                mv.visitLabel( l0 );
-
-                // Lookup methods and store in static variables
-                int midx = 0;
-                for( Method method : methods )
-                {
-                    if( isOverridden(method, baseClass) )
-                    {
-                        method.setAccessible( true );
-                        Class methodClass;
-                        if( Modifier.isAbstract( method.getModifiers() ) )
-                        {
-                            methodClass = method.getDeclaringClass();
-                        }
-                        else
-                        {
-                            try
-                            {
-                                methodClass = getInterfaceMethodDeclaration( method,
-                                                                             baseClass ); // Overridden method lookup
-                            }
-                            catch( NoSuchMethodException e )
-                            {
-                                throw new ClassNotFoundException( name, e );
-                            }
-                        }
-
-                        midx++;
-
-                        mv.visitLdcInsn( Type.getType( methodClass ) );
-                        mv.visitLdcInsn( method.getName() );
-                        insn( mv, method.getParameterTypes().length );
-                        mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" );
-
-                        int pidx = 0;
-                        for( Class<?> aClass : method.getParameterTypes() )
-                        {
-                            mv.visitInsn( DUP );
-                            insn( mv, pidx++ );
-                            type( mv, aClass );
-                            mv.visitInsn( AASTORE );
-                        }
-
-                        mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod",
-                                            "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;", false );
-                        mv.visitFieldInsn( PUTSTATIC, classSlash, "m" + midx, "Ljava/lang/reflect/Method;" );
-                    }
-                }
-
-                mv.visitLabel( l1 );
-                Label l3 = new Label();
-                mv.visitJumpInsn( GOTO, l3 );
-                mv.visitLabel( l2 );
-                mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/NoSuchMethodException" } );
-                mv.visitVarInsn( ASTORE, 0 );
-                mv.visitVarInsn( ALOAD, 0 );
-                mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/NoSuchMethodException", "printStackTrace", "()V", false );
-                mv.visitLabel( l3 );
-                mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
-                mv.visitInsn( RETURN );
-                mv.visitMaxs( 6, 1 );
-                mv.visitEnd();
-            }
-        }
-        cw.visitEnd();
-        return cw.toByteArray();
-    }
-
-    private static boolean isOverridden(Method method, Class baseClass)
-    {
-        if( Modifier.isAbstract( method.getModifiers() ) )
-        {
-            return true; // Implement all abstract methods
-        }
-
-        if( Modifier.isFinal( method.getModifiers() ) )
-        {
-            return false; // Cannot override final methods
-        }
-
-        if( isInterfaceMethod( method, baseClass ) )
-        {
-            // if() used for clarity.
-            //noinspection RedundantIfStatement
-            if( isInternalQi4jMethod( method, baseClass ) )
-            {
-                return false; // Skip methods in Zest-internal interfaces
-            }
-            else
-            {
-                return true;
-            }
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    private static boolean isInternalQi4jMethod( Method method, Class baseClass )
-    {
-        return isDeclaredIn( method, Initializable.class, baseClass )
-               || isDeclaredIn( method, Lifecycle.class, baseClass );
-    }
-
-    private static boolean isDeclaredIn( Method method, Class<?> clazz, Class<?> baseClass )
-    {
-        if( !clazz.isAssignableFrom( baseClass ) )
-        {
-            return false;
-        }
-
-        try
-        {
-            clazz.getMethod( method.getName(), method.getParameterTypes() );
-            return true;
-        }
-        catch( NoSuchMethodException e )
-        {
-            return false;
-        }
-    }
-
-    private static Class getInterfaceMethodDeclaration( Method method, Class clazz )
-        throws NoSuchMethodException
-    {
-        Iterable<Class<?>> interfaces = Iterables.map( Classes.RAW_CLASS, interfacesOf( clazz ) );
-        for( Class<?> anInterface : interfaces )
-        {
-            try
-            {
-                anInterface.getMethod( method.getName(), method.getParameterTypes() );
-                return anInterface;
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Try next
-            }
-        }
-
-        throw new NoSuchMethodException( method.getName() );
-    }
-
-    private static boolean isInterfaceMethod( Method method, Class<?> baseClass )
-    {
-        for( Class<?> aClass : Iterables.filter( Methods.HAS_METHODS, Iterables.map( Classes.RAW_CLASS, interfacesOf( baseClass ) ) ) )
-        {
-            try
-            {
-                Method m = aClass.getMethod( method.getName(), method.getParameterTypes() );
-                m.setAccessible( true );
-                return true;
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Ignore
-            }
-        }
-        return false;
-    }
-
-    private static void type( MethodVisitor mv, Class<?> aClass )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;" );
-        }
-        else
-        {
-            mv.visitLdcInsn( Type.getType( aClass ) );
-        }
-    }
-
-    private static int wrapParameter( MethodVisitor mv, Class<?> aClass, int idx )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitVarInsn( LLOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitVarInsn( DLOAD, idx );
-            idx++; // Extra jump
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitVarInsn( FLOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false );
-        }
-        else
-        {
-            mv.visitVarInsn( ALOAD, idx );
-        }
-
-        return idx;
-    }
-
-    private static void unwrapResult( MethodVisitor mv, Class<?> aClass, Label label )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Integer" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Long" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false );
-            mv.visitLabel( label );
-            mv.visitInsn( LRETURN );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Short" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Byte" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Double" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false );
-            mv.visitLabel( label );
-            mv.visitInsn( DRETURN );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Float" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false );
-            mv.visitLabel( label );
-            mv.visitInsn( FRETURN );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Boolean" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Character" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else
-        {
-            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
-            mv.visitLabel( label );
-            mv.visitInsn( ARETURN );
-        }
-    }
-
-    private static int loadParameter( MethodVisitor mv, Class<?> aClass, int idx )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitVarInsn( LLOAD, idx );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitVarInsn( DLOAD, idx );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitVarInsn( FLOAD, idx );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else
-        {
-            mv.visitVarInsn( ALOAD, idx );
-        }
-
-        return idx;
-    }
-
-    private static void returnResult( MethodVisitor mv, Class<?> aClass )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitInsn( LRETURN );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitInsn( DRETURN );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitInsn( FRETURN );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else
-        {
-            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
-            mv.visitInsn( ARETURN );
-        }
-    }
-
-    private static void insn( MethodVisitor mv, int length )
-    {
-        switch( length )
-        {
-        case 0:
-            mv.visitInsn( ICONST_0 );
-            return;
-        case 1:
-            mv.visitInsn( ICONST_1 );
-            return;
-        case 2:
-            mv.visitInsn( ICONST_2 );
-            return;
-        case 3:
-            mv.visitInsn( ICONST_3 );
-            return;
-        case 4:
-            mv.visitInsn( ICONST_4 );
-            return;
-        case 5:
-            mv.visitInsn( ICONST_5 );
-            return;
-        default:
-            mv.visitIntInsn( BIPUSH, length );
-        }
-    }
-
-    public static boolean isGenerated( Class clazz )
-    {
-        return clazz.getName().endsWith( GENERATED_POSTFIX );
-    }
-
-    public static boolean isGenerated( Object object )
-    {
-        return object.getClass().getName().endsWith( GENERATED_POSTFIX );
-    }
-
-    public Class loadFragmentClass( Class fragmentClass )
-        throws ClassNotFoundException
-    {
-        return loadClass( fragmentClass.getName().replace( '$', '_' ) + GENERATED_POSTFIX );
-    }
-
-    public static Class getSourceClass( Class fragmentClass )
-    {
-        return fragmentClass.getName().endsWith( GENERATED_POSTFIX ) ? fragmentClass.getSuperclass() : fragmentClass;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentInvocationHandler.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentInvocationHandler.java
deleted file mode 100644
index 1d4c0e9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FragmentInvocationHandler.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2007 Rickard Öberg
- * 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-abstract class FragmentInvocationHandler
-    implements InvocationHandler
-{
-    private static final String COMPACT_TRACE = "qi4j.compacttrace";
-
-    private static final CompactLevel compactLevel;
-
-    static
-    {
-        compactLevel = CompactLevel.valueOf( System.getProperty( COMPACT_TRACE, "proxy" ) );
-    }
-
-    protected Object fragment;
-    protected Method method;
-
-    void setFragment( Object fragment )
-    {
-        this.fragment = fragment;
-    }
-
-    public void setMethod( Method method )
-    {
-        this.method = method;
-    }
-
-    protected Throwable cleanStackTrace( Throwable throwable, Object proxy, Method method )
-    {
-        if( compactLevel == CompactLevel.off )
-        {
-            return throwable;
-        }
-
-        StackTraceElement[] trace = throwable.getStackTrace();
-
-        // Check if exception originated within Zest or JDK - if so then skip compaction
-        if( trace.length == 0 || !isApplicationClass( trace[ 0 ].getClassName() ) )
-        {
-            return throwable;
-        }
-
-        int count = 0;
-        for( int i = 0; i < trace.length; i++ )
-        {
-            StackTraceElement stackTraceElement = trace[ i ];
-            if( !isApplicationClass( stackTraceElement.getClassName() ) )
-            {
-                // TODO: Should find stack entry outside Runtime, and compact beyond that
-                trace[ i ] = null;
-                count++;
-            }
-            else
-            {
-                boolean classOrigin = stackTraceElement.getClassName().equals( proxy.getClass().getSimpleName() );
-                boolean methodOrigin = stackTraceElement.getMethodName().equals( method.getName() );
-                if( classOrigin && methodOrigin && compactLevel == CompactLevel.proxy )
-                {
-                    // Stop removing if the originating method call has been located in the stack.
-                    // For 'semi' and 'extensive' compaction, we don't and do the entire stack instead.
-                    trace[ i ] = new StackTraceElement( proxy.getClass()
-                                                            .getInterfaces()[ 0 ].getName(), method.getName(), null, -1 );
-                    break; // Stop compacting this trace
-                }
-            }
-        }
-
-        // Create new trace array
-        int idx = 0;
-        StackTraceElement[] newTrace = new StackTraceElement[ trace.length - count ];
-        for( StackTraceElement stackTraceElement : trace )
-        {
-            if( stackTraceElement != null )
-            {
-                newTrace[ idx++ ] = stackTraceElement;
-            }
-        }
-        throwable.setStackTrace( newTrace );
-
-        Throwable nested = throwable.getCause();
-        if( nested != null )
-        {
-            //noinspection ThrowableResultOfMethodCallIgnored
-            cleanStackTrace( nested, proxy, method );
-        }
-        return throwable;
-    }
-
-    private boolean isApplicationClass( String className )
-    {
-        if( compactLevel == CompactLevel.semi )
-        {
-            return !isJdkInternals( className );
-        }
-        return !( className.endsWith( FragmentClassLoader.GENERATED_POSTFIX ) ||
-                  className.startsWith( "org.qi4j.runtime" ) ||
-                  isJdkInternals( className ) );
-    }
-
-    private boolean isJdkInternals( String className )
-    {
-        return className.startsWith( "java.lang.reflect" )
-               || className.startsWith( "com.sun.proxy" )
-               || className.startsWith( "sun.reflect" );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/FunctionStateResolver.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FunctionStateResolver.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/FunctionStateResolver.java
deleted file mode 100644
index 9c2943b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/FunctionStateResolver.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2012, Kent Sølvsten.
- *
- * 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.zest.runtime.composite;
-
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.ManyAssociationState;
-import org.apache.zest.spi.entity.NamedAssociationState;
-
-/**
- * Function based StateResolver.
- */
-public class FunctionStateResolver
-    implements StateResolver
-{
-    final Function<PropertyDescriptor, Object> propertyFunction;
-    final Function<AssociationDescriptor, EntityReference> associationFunction;
-    final Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction;
-    final Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction;
-
-    public FunctionStateResolver( Function<PropertyDescriptor, Object> propertyFunction,
-                                  Function<AssociationDescriptor, EntityReference> associationFunction,
-                                  Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-                                  Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
-    {
-        this.propertyFunction = propertyFunction;
-        this.associationFunction = associationFunction;
-        this.manyAssociationFunction = manyAssociationFunction;
-        this.namedAssociationFunction = namedAssociationFunction;
-    }
-
-    @Override
-    public Object getPropertyState( PropertyDescriptor propertyDescriptor )
-    {
-        return propertyFunction.map( propertyDescriptor );
-    }
-
-    @Override
-    public EntityReference getAssociationState( AssociationDescriptor associationDescriptor )
-    {
-        return associationFunction.map( associationDescriptor );
-    }
-
-    @Override
-    public List<EntityReference> getManyAssociationState( AssociationDescriptor associationDescriptor )
-    {
-        return Iterables.toList( manyAssociationFunction.map( associationDescriptor ) );
-    }
-
-    @Override
-    public Map<String, EntityReference> getNamedAssociationState( AssociationDescriptor associationDescriptor )
-    {
-        return namedAssociationFunction.map( associationDescriptor );
-    }
-
-    public void populateState( EntityModel model, EntityState state )
-    {
-        for( PropertyDescriptor propDesc : model.state().properties() )
-        {
-            Object value = getPropertyState( propDesc );
-            state.setPropertyValue( propDesc.qualifiedName(), value );
-        }
-        for( AssociationDescriptor assDesc : model.state().associations() )
-        {
-            EntityReference ref = getAssociationState( assDesc );
-            state.setAssociationValue( assDesc.qualifiedName(), ref );
-        }
-        for( ManyAssociationModel manyAssDesc : model.state().manyAssociations() )
-        {
-            ManyAssociationState associationState = state.manyAssociationValueOf( manyAssDesc.qualifiedName() );
-            // First clear existing ones
-            for( EntityReference ref : associationState )
-            {
-                associationState.remove( ref );
-            }
-            // then add the new ones.
-            for( EntityReference ref : getManyAssociationState( manyAssDesc ) )
-            {
-                associationState.add( 0, ref );
-            }
-        }
-        for( NamedAssociationModel namedAssDesc : model.state().namedAssociations() )
-        {
-            NamedAssociationState associationState = state.namedAssociationValueOf( namedAssDesc.qualifiedName() );
-            // First clear existing ones
-            for( String name : associationState )
-            {
-                associationState.remove( name );
-            }
-            // then add the new ones.
-            for( Map.Entry<String, EntityReference> entry : getNamedAssociationState( namedAssDesc ).entrySet() )
-            {
-                associationState.put( entry.getKey(), entry.getValue() );
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericFragmentInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericFragmentInvocationHandler.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericFragmentInvocationHandler.java
deleted file mode 100644
index dfb9750..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericFragmentInvocationHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007 Rickard Öberg
- * 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-public final class GenericFragmentInvocationHandler
-    extends FragmentInvocationHandler
-{
-    // InvocationHandler implementation ------------------------------
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        try
-        {
-            return ( (InvocationHandler) fragment ).invoke( proxy, method, args );
-        }
-        catch( InvocationTargetException throwable )
-        {
-            throw cleanStackTrace( throwable.getTargetException(), proxy, method );
-        }
-        catch( Throwable throwable )
-        {
-            throw cleanStackTrace( throwable, proxy, method );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java
deleted file mode 100644
index 47ba877..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/GenericSpecification.java
+++ /dev/null
@@ -1,37 +0,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.
- */
-package org.apache.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import org.apache.zest.functional.Specification;
-
-/**
- * Specification that checks whether a given class implements InvocationHandler or not.
- */
-public class GenericSpecification
-    implements Specification<Class<?>>
-{
-    public static final GenericSpecification INSTANCE = new GenericSpecification();
-
-    @Override
-    public boolean satisfiedBy( Class<?> item )
-    {
-        return InvocationHandler.class.isAssignableFrom( item );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/InstancePool.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/InstancePool.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/InstancePool.java
deleted file mode 100644
index 9286e2d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/InstancePool.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.runtime.composite;
-
-/**
- * JAVADOC
- */
-public interface InstancePool<T>
-{
-    public T obtainInstance();
-
-    public void releaseInstance( T instance );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
deleted file mode 100644
index c0be60b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.mixin.InitializationException;
-import org.apache.zest.api.mixin.MixinDescriptor;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectedFieldsModel;
-import org.apache.zest.runtime.injection.InjectedMethodsModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Iterables.toList;
-import static org.apache.zest.functional.Iterables.unique;
-
-/**
- * JAVADOC
- */
-public final class MixinModel
-    implements MixinDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final Class<?> mixinClass;
-    private final Class<?> instantiationClass;
-    private final ConstructorsModel constructorsModel;
-    private final InjectedFieldsModel injectedFieldsModel;
-    private final InjectedMethodsModel injectedMethodsModel;
-    private final Iterable<Class<?>> thisMixinTypes;
-
-    public MixinModel( Class<?> declaredMixinClass, Class<?> instantiationClass )
-    {
-        injectedFieldsModel = new InjectedFieldsModel( declaredMixinClass );
-        injectedMethodsModel = new InjectedMethodsModel( declaredMixinClass );
-
-        this.mixinClass = declaredMixinClass;
-        this.instantiationClass = instantiationClass;
-        constructorsModel = new ConstructorsModel( instantiationClass );
-
-        thisMixinTypes = buildThisMixinTypes();
-    }
-
-    @Override
-    public Class<?> mixinClass()
-    {
-        return mixinClass;
-    }
-
-    public Class<?> instantiationClass()
-    {
-        return instantiationClass;
-    }
-
-    public boolean isGeneric()
-    {
-        return InvocationHandler.class.isAssignableFrom( mixinClass );
-    }
-
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.flatten( constructorsModel.dependencies(), injectedFieldsModel.dependencies(), injectedMethodsModel
-            .dependencies() );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( constructorsModel.accept( visitor ) )
-            {
-                if( injectedFieldsModel.accept( visitor ) )
-                {
-                    injectedMethodsModel.accept( visitor );
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    // Context
-    public Object newInstance( CompositeInstance compositeInstance, StateHolder state, UsesInstance uses )
-    {
-        InjectionContext injectionContext = new InjectionContext( compositeInstance, uses, state );
-        return newInstance( injectionContext );
-    }
-
-    public Object newInstance( InjectionContext injectionContext )
-    {
-        Object mixin;
-        CompositeInstance compositeInstance = injectionContext.compositeInstance();
-
-        mixin = constructorsModel.newInstance( injectionContext );
-
-        if( FragmentClassLoader.isGenerated( instantiationClass ) )
-        {
-            try
-            {
-                instantiationClass.getDeclaredField( "_instance" ).set( mixin,
-                                                                        injectionContext.compositeInstance() );
-            }
-            catch( IllegalAccessException e )
-            {
-                e.printStackTrace();
-            }
-            catch( NoSuchFieldException e )
-            {
-                e.printStackTrace();
-            }
-        }
-
-        injectedFieldsModel.inject( injectionContext, mixin );
-        injectedMethodsModel.inject( injectionContext, mixin );
-        if( mixin instanceof Initializable )
-        {
-            try
-            {
-                ( (Initializable) mixin ).initialize();
-            }
-            catch( InitializationException e )
-            {
-                List<Class<?>> compositeType = toList( compositeInstance.types() );
-                String message = "Unable to initialize " + mixinClass + " in composite " + compositeType;
-                throw new ConstructionException( message, e );
-            }
-        }
-        return mixin;
-    }
-
-    public Iterable<Class<?>> thisMixinTypes()
-    {
-        return thisMixinTypes;
-    }
-
-    private Iterable<Class<?>> buildThisMixinTypes()
-    {
-        return map( new DependencyModel.InjectionTypeFunction(), unique( Iterables.filter( new DependencyModel.ScopeSpecification( This.class ), dependencies() ) ) );
-    }
-
-    protected FragmentInvocationHandler newInvocationHandler( Method method )
-    {
-        if( InvocationHandler.class.isAssignableFrom( mixinClass )
-            && !method.getDeclaringClass().isAssignableFrom( mixinClass ) )
-        {
-            return new GenericFragmentInvocationHandler();
-        }
-        else
-        {
-            return new TypedModifierInvocationHandler();
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return mixinClass.getName();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsInstance.java
deleted file mode 100644
index 2720884..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsInstance.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-public interface MixinsInstance
-{
-    Object invoke( Object composite, Object[] params, CompositeMethodInstance methodInstance )
-        throws Throwable;
-
-    Object invokeObject( Object proxy, Object[] args, Method method )
-        throws Throwable;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java
deleted file mode 100644
index d90f9d9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinsModel.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectedFieldModel;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * Base implementation of model for mixins. This records the mapping between methods in the Composite
- * and mixin implementations.
- */
-public class MixinsModel
-    implements Binder, VisitableHierarchy<Object, Object>
-{
-    protected final Map<Method, MixinModel> methodImplementation = new HashMap<Method, MixinModel>();
-    protected final Map<Method, Integer> methodIndex = new HashMap<Method, Integer>();
-    protected List<MixinModel> mixinModels = new ArrayList<MixinModel>();
-
-    private final Map<Class, Integer> mixinIndex = new HashMap<Class, Integer>();
-    private final Set<Class<?>> mixinTypes = new LinkedHashSet<Class<?>>();
-
-    public Iterable<Class<?>> mixinTypes()
-    {
-        return mixinTypes;
-    }
-
-    public <T> boolean isImplemented( Class<T> mixinType )
-    {
-        return mixinTypes.contains( mixinType );
-    }
-
-    public List<MixinModel> mixinModels()
-    {
-        return mixinModels;
-    }
-
-    public MixinModel mixinFor( Method method )
-    {
-        return methodImplementation.get( method );
-    }
-
-    public MixinModel getMixinModel( Class mixinClass )
-    {
-        for( MixinModel mixinModel : mixinModels )
-        {
-            if( mixinModel.mixinClass().equals( mixinClass ) )
-            {
-                return mixinModel;
-            }
-        }
-        return null;
-    }
-
-    public void addMixinType( Class mixinType )
-    {
-        for( Type type : interfacesOf( mixinType ) )
-        {
-            mixinTypes.add( Classes.RAW_CLASS.map( type ) );
-        }
-    }
-
-    public void addMixinModel( MixinModel mixinModel )
-    {
-        mixinModels.add( mixinModel );
-    }
-
-    public void addMethodMixin( Method method, MixinModel mixinModel )
-    {
-        methodImplementation.put( method, mixinModel );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( MixinModel mixinModel : mixinModels )
-            {
-                mixinModel.accept( visitor );
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    // Binding
-    @Override
-    public void bind( final Resolution resolution )
-        throws BindingException
-    {
-        // Order mixins based on @This usages
-        UsageGraph<MixinModel> deps = new UsageGraph<MixinModel>( mixinModels, new Uses(), true );
-        mixinModels = deps.resolveOrder();
-
-        // Populate mappings
-        for( int i = 0; i < mixinModels.size(); i++ )
-        {
-            MixinModel mixinModel = mixinModels.get( i );
-            mixinIndex.put( mixinModel.mixinClass(), i );
-        }
-
-        for( Map.Entry<Method, MixinModel> methodClassEntry : methodImplementation.entrySet() )
-        {
-            methodIndex.put( methodClassEntry.getKey(), mixinIndex.get( methodClassEntry.getValue().mixinClass() ) );
-        }
-
-        for( MixinModel mixinModel : mixinModels )
-        {
-            mixinModel.accept( new HierarchicalVisitorAdapter<Object, Object, BindingException>()
-            {
-                @Override
-                public boolean visitEnter( Object visited )
-                    throws BindingException
-                {
-                    if( visited instanceof InjectedFieldModel )
-                    {
-                        InjectedFieldModel fieldModel = (InjectedFieldModel) visited;
-                        fieldModel.bind( resolution.forField( fieldModel.field() ) );
-                        return false;
-                    }
-                    else if( visited instanceof Binder )
-                    {
-                        Binder constructorsModel = (Binder) visited;
-                        constructorsModel.bind( resolution );
-
-                        return false;
-                    }
-                    return true;
-                }
-
-                @Override
-                public boolean visit( Object visited )
-                    throws BindingException
-                {
-                    if( visited instanceof Binder )
-                    {
-                        ( (Binder) visited ).bind( resolution );
-                    }
-                    return true;
-                }
-            } );
-        }
-    }
-
-    // Context
-
-    public Object[] newMixinHolder()
-    {
-        return new Object[ mixinIndex.size() ];
-    }
-
-    public FragmentInvocationHandler newInvocationHandler( final Method method )
-    {
-        return mixinFor( method ).newInvocationHandler( method );
-    }
-
-    public Iterable<DependencyModel> dependencies()
-    {
-        return flattenIterables( map( new Function<MixinModel, Iterable<DependencyModel>>()
-        {
-            @Override
-            public Iterable<DependencyModel> map( MixinModel mixinModel )
-            {
-                return mixinModel.dependencies();
-            }
-        }, mixinModels ) );
-    }
-
-    public Iterable<Method> invocationsFor( final Class<?> mixinClass )
-    {
-        return map( new Function<Map.Entry<Method, MixinModel>, Method>()
-        {
-            @Override
-            public Method map( Map.Entry<Method, MixinModel> entry )
-            {
-                return entry.getKey();
-            }
-        }, filter( new Specification<Map.Entry<Method, MixinModel>>()
-        {
-            @Override
-            public boolean satisfiedBy( Map.Entry<Method, MixinModel> item )
-            {
-                MixinModel model = item.getValue();
-                return model.mixinClass().equals( mixinClass );
-            }
-        }, methodImplementation.entrySet() ) );
-    }
-
-    private class Uses
-        implements UsageGraph.Use<MixinModel>
-    {
-        @Override
-        public Collection<MixinModel> uses( MixinModel source )
-        {
-            Iterable<Class<?>> thisMixinTypes = source.thisMixinTypes();
-            List<MixinModel> usedMixinClasses = new ArrayList<MixinModel>();
-            for( Class thisMixinType : thisMixinTypes )
-            {
-                for( Method method : thisMixinType.getMethods() )
-                {
-                    usedMixinClasses.add( methodImplementation.get( method ) );
-                }
-            }
-            return usedMixinClasses;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyGenerator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyGenerator.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyGenerator.java
deleted file mode 100644
index 916fa45..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyGenerator.java
+++ /dev/null
@@ -1,34 +0,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.
- */
-package org.apache.zest.runtime.composite;
-
-import java.lang.reflect.Proxy;
-
-/**
- * generates proxyclasses
- */
-public class ProxyGenerator {
-    public static Class<?> createProxyClass(ClassLoader mainTypeClassLoader, Class<?>[] interfaces) {
-        ClassLoader effectiveClassLoader = Thread.currentThread().getContextClassLoader();
-        if (effectiveClassLoader == null) {
-            effectiveClassLoader = mainTypeClassLoader;
-        }
-        return Proxy.getProxyClass(effectiveClassLoader, interfaces);
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyReferenceInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyReferenceInvocationHandler.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyReferenceInvocationHandler.java
deleted file mode 100644
index 334a517..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ProxyReferenceInvocationHandler.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
-import org.apache.zest.api.composite.CompositeInvoker;
-
-public final class ProxyReferenceInvocationHandler
-    implements InvocationHandler, CompositeInvoker
-{
-    private Object proxy;
-
-    public Object proxy()
-    {
-        return proxy;
-    }
-
-    public void setProxy( Object proxy )
-    {
-        this.proxy = proxy;
-    }
-
-    public void clearProxy()
-    {
-        proxy = null;
-    }
-
-    @Override
-    public Object invokeComposite( Method method, Object[] args )
-        throws Throwable
-    {
-        try
-        {
-            InvocationHandler invocationHandler = Proxy.getInvocationHandler( this.proxy );
-            return invocationHandler.invoke( this.proxy, method, args );
-        }
-        catch( InvocationTargetException e )
-        {
-            throw e.getTargetException();
-        }
-        catch( UndeclaredThrowableException e )
-        {
-            throw e.getUndeclaredThrowable();
-        }
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        try
-        {
-            InvocationHandler invocationHandler = Proxy.getInvocationHandler( this.proxy );
-            return invocationHandler.invoke( this.proxy, method, args );
-        }
-        catch( InvocationTargetException e )
-        {
-            throw e.getTargetException();
-        }
-        catch( UndeclaredThrowableException e )
-        {
-            throw e.getUndeclaredThrowable();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectInvocationHandlerResult.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectInvocationHandlerResult.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectInvocationHandlerResult.java
deleted file mode 100644
index ed0b4cc..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectInvocationHandlerResult.java
+++ /dev/null
@@ -1,58 +0,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.
- */
-package org.apache.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * JAVADOC
- */
-public final class SideEffectInvocationHandlerResult
-    implements InvocationHandler
-{
-    private Object result;
-    private Throwable throwable;
-
-    public SideEffectInvocationHandlerResult()
-    {
-    }
-
-    public void setResult( Object result, Throwable throwable )
-    {
-        this.result = result;
-        this.throwable = throwable;
-    }
-
-    // InvocationHandler implementation ------------------------------
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        if( throwable != null )
-        {
-            throw throwable;
-        }
-        else
-        {
-            return result;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectModel.java
deleted file mode 100644
index 6643eb9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectModel.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import org.apache.zest.api.sideeffect.SideEffectDescriptor;
-
-/**
- * JAVADOC
- */
-public final class SideEffectModel
-    extends AbstractModifierModel
-    implements SideEffectDescriptor
-{
-    public SideEffectModel( Class<?> sideEffectClass, Class<?> instantiationClass )
-    {
-        super( sideEffectClass, instantiationClass );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsInstance.java
deleted file mode 100644
index 3f20d6f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsInstance.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-
-/**
- * JAVADOC
- */
-public final class SideEffectsInstance
-    implements InvocationHandler
-{
-    private final List<InvocationHandler> sideEffects;
-    private final SideEffectInvocationHandlerResult resultInvocationHandler;
-    private final ProxyReferenceInvocationHandler proxyHandler;
-    private InvocationHandler invoker;
-
-    public SideEffectsInstance( List<InvocationHandler> sideEffects,
-                                SideEffectInvocationHandlerResult resultInvocationHandler,
-                                ProxyReferenceInvocationHandler proxyHandler,
-                                InvocationHandler invoker
-    )
-    {
-        this.sideEffects = sideEffects;
-        this.resultInvocationHandler = resultInvocationHandler;
-        this.proxyHandler = proxyHandler;
-        this.invoker = invoker;
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        try
-        {
-            Object result = invoker.invoke( proxy, method, args );
-            invokeSideEffects( proxy, method, args, result, null );
-            return result;
-        }
-        catch( Throwable throwable )
-        {
-            invokeSideEffects( proxy, method, args, null, throwable );
-            throw throwable;
-        }
-    }
-
-    private void invokeSideEffects( Object proxy,
-                                    Method method,
-                                    Object[] params,
-                                    Object result,
-                                    Throwable originalThrowable
-    )
-        throws Throwable
-    {
-        proxyHandler.setProxy( proxy );
-        resultInvocationHandler.setResult( result, originalThrowable );
-
-        try
-        {
-            for( InvocationHandler sideEffect : sideEffects )
-            {
-                try
-                {
-                    sideEffect.invoke( proxy, method, params );
-                }
-                catch( Throwable throwable )
-                {
-                    if( throwable != originalThrowable )
-                    {
-                        throwable.printStackTrace();
-                    }
-                }
-            }
-        }
-        finally
-        {
-            proxyHandler.clearProxy();
-            resultInvocationHandler.setResult( null, null );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
deleted file mode 100644
index 888ec22..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.sideeffect.SideEffectsDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * JAVADOC
- */
-public final class SideEffectsModel
-    implements SideEffectsDescriptor, Dependencies, VisitableHierarchy<Object, Object>
-{
-    public static final SideEffectsModel EMPTY_SIDEEFFECTS = new SideEffectsModel( Collections.<SideEffectModel>emptyList() );
-
-    private List<SideEffectModel> sideEffectModels = null;
-
-    public SideEffectsModel( List<SideEffectModel> sideEffectModels )
-    {
-        this.sideEffectModels = sideEffectModels;
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.flattenIterables( Iterables.map( Dependencies.DEPENDENCIES_FUNCTION, sideEffectModels ) );
-    }
-
-    // Context
-    public SideEffectsInstance newInstance( Method method, ModuleSpi moduleInstance, InvocationHandler invoker )
-    {
-        ProxyReferenceInvocationHandler proxyHandler = new ProxyReferenceInvocationHandler();
-        SideEffectInvocationHandlerResult result = new SideEffectInvocationHandlerResult();
-        List<InvocationHandler> sideEffects = new ArrayList<InvocationHandler>( sideEffectModels.size() );
-        for( SideEffectModel sideEffectModel : sideEffectModels )
-        {
-            InvocationHandler sideEffect = sideEffectModel.newInstance( moduleInstance, result, proxyHandler, method );
-            sideEffects.add( sideEffect );
-        }
-        return new SideEffectsInstance( sideEffects, result, proxyHandler, invoker );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( SideEffectModel sideEffectModel : sideEffectModels )
-            {
-                if( !sideEffectModel.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateModel.java
deleted file mode 100644
index a0b17cb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateModel.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.composite.StateDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.property.PropertiesModel;
-import org.apache.zest.runtime.property.PropertyModel;
-
-/**
- * Base model for Composite state
- */
-public class StateModel
-    implements StateDescriptor, VisitableHierarchy<Object, Object>
-{
-    protected final PropertiesModel propertiesModel;
-
-    public StateModel( PropertiesModel propertiesModel )
-    {
-        this.propertiesModel = propertiesModel;
-    }
-
-    public PropertyModel propertyModelFor( AccessibleObject accessor )
-    {
-        return propertiesModel.getProperty( accessor );
-    }
-
-    @Override
-    public PropertyModel findPropertyModelByName( String name )
-        throws IllegalArgumentException
-    {
-        return propertiesModel.getPropertyByName( name );
-    }
-
-    @Override
-    public PropertyModel findPropertyModelByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        return propertiesModel.getPropertyByQualifiedName( name );
-    }
-
-    @Override
-    public Iterable<PropertyModel> properties()
-    {
-        return propertiesModel.properties();
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            ( (VisitableHierarchy<Object, Object>) propertiesModel ).accept( visitor );
-        }
-        return visitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateResolver.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateResolver.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateResolver.java
deleted file mode 100644
index 5ebe47f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/StateResolver.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012, Kent Sølvsten.
- *
- * 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.zest.runtime.composite;
-
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.PropertyDescriptor;
-
-/**
- * StateResolver.
- */
-public interface StateResolver
-{
-    Object getPropertyState( PropertyDescriptor propertyDescriptor );
-
-    EntityReference getAssociationState( AssociationDescriptor associationDescriptor );
-
-    List<EntityReference> getManyAssociationState( AssociationDescriptor associationDescriptor );
-
-    Map<String, EntityReference> getNamedAssociationState( AssociationDescriptor associationDescriptor );
-}


[21/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Functions.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Functions.java b/core/functional/src/main/java/org/qi4j/functional/Functions.java
new file mode 100644
index 0000000..bf86845
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Functions.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility functions. Combine these with methods in Iterables, for example. See FunctionsTest for usages.
+ */
+public final class Functions
+{
+    public static <A, B, C> Function2<Function<? super B, C>, Function<A, B>, Function<A, C>> compose()
+    {
+        return new Function2<Function<? super B, C>, Function<A, B>, Function<A, C>>()
+        {
+            @Override
+            public Function<A, C> map( Function<? super B, C> bcFunction, Function<A, B> abFunction )
+            {
+                return compose( bcFunction, abFunction );
+            }
+        };
+    }
+
+    /**
+     * compose(F1(M,T),F2(F,M)) = F1(F2(F)) -&gt; T
+     *
+     * @param outer The outer/encapsulating function
+     * @param inner The inner/encapsulated function
+     *
+     * @return A function that is a composition of an outer and inner function.
+     */
+    public static <FROM, MIDDLE, TO> Function<FROM, TO> compose( final Function<? super MIDDLE, TO> outer,
+                                                                 final Function<FROM, MIDDLE> inner
+    )
+    {
+        return new Function<FROM, TO>()
+        {
+            @Override
+            public TO map( FROM from )
+            {
+                return outer.map( inner.map( from ) );
+            }
+        };
+    }
+
+    public static <TO, FROM extends TO> Function<FROM, TO> identity()
+    {
+        return new Function<FROM, TO>()
+        {
+            @Override
+            public TO map( FROM from )
+            {
+                return from;
+            }
+        };
+    }
+
+    public static <FROM, TO> Function<FROM, TO> fromMap( final Map<FROM, TO> map )
+    {
+        return new Function<FROM, TO>()
+        {
+            @Override
+            public TO map( FROM from )
+            {
+                return map.get( from );
+            }
+        };
+    }
+
+    public static <T> Function<T, T> withDefault( final T defaultValue )
+    {
+        return new Function<T, T>()
+        {
+            @Override
+            public T map( T from )
+            {
+                if( from == null )
+                {
+                    return defaultValue;
+                }
+                else
+                {
+                    return from;
+                }
+            }
+        };
+    }
+
+    public static Function<Number, Long> longSum()
+    {
+        return new Function<Number, Long>()
+        {
+            long sum;
+
+            @Override
+            public Long map( Number number )
+            {
+                sum += number.longValue();
+                return sum;
+            }
+        };
+    }
+
+    public static Function<Number, Integer> intSum()
+    {
+        return new Function<Number, Integer>()
+        {
+            int sum;
+
+            @Override
+            public Integer map( Number number )
+            {
+                sum += number.intValue();
+                return sum;
+            }
+        };
+    }
+
+    /**
+     * Count the number of items in an iterable that matches a given specification.
+     *
+     * Sample usage: last( map( count( in( "X" ) ), iterable( "X","Y","X","X","Y" ) ) )
+     * Returns: 3
+     *
+     * @param specification The items that adhere to the Specification is counted.
+     * @param <T> The type of the items.
+     *
+     * @return A Function that can count items adhering to a Specification.
+     */
+    public static <T> Function<T, Integer> count( final Specification<T> specification )
+    {
+        return new Function<T, Integer>()
+        {
+            int count;
+
+            @Override
+            public Integer map( T item )
+            {
+                if( specification.satisfiedBy( item ) )
+                {
+                    count++;
+                }
+
+                return count;
+            }
+        };
+    }
+
+    /**
+     * Find out the index of an item matching a given specification in an iterable.
+     * Returns -1 if it is not found.
+     *
+     * @param specification The Specification that specifies what to look for.
+     * @param <T> The type of the items.
+     *
+     * @return A Function that will provide the 'index' where the Specifcation is fulfilled. The Function will
+     * return -1 if the current item doesn't fulfill the Specification.
+     */
+    public static <T> Function<T, Integer> indexOf( final Specification<T> specification )
+    {
+        return new Function<T, Integer>()
+        {
+            int index = -1;
+            int current = 0;
+
+            @Override
+            public Integer map( T item )
+            {
+                if( index == -1 && specification.satisfiedBy( item ) )
+                {
+                    index = current;
+                }
+
+                current++;
+
+                return index;
+            }
+        };
+    }
+
+    /**
+     * Find out the index of an item in an iterable.
+     *
+     * @param item The item to look for.
+     * @param iterable The Iterable to search.
+     * @param <T> The type of the items.
+     *
+     * @return The index in the Iterable where the item is located.
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> int indexOf( T item, Iterable<T> iterable )
+    {
+        return Iterables.first( Iterables.filter( Specifications.not( Specifications.in( -1 ) ),
+                                                  Iterables.map( indexOf( Specifications.in( item ) ), iterable ) ) );
+    }
+
+    /**
+     * Only apply given function on objects that satisfies the given specification.
+     *
+     * @param specification A Specification that specifies what should be included in the filtered result.
+     * @param function The function to be applied to items that fulfills the Specification
+     * @param <T> The type of the items.
+     *
+     * @return A Function that performs the filter operation when applied to Iterables.
+     */
+    public static <T> Function<T, T> filteredMap( final Specification<T> specification, final Function<T, T> function )
+    {
+        return new Function<T, T>()
+        {
+            @Override
+            public T map( T from )
+            {
+                return specification.satisfiedBy( from ) ? function.map( from ) : from;
+            }
+        };
+    }
+
+    /**
+     * Creates a comparator that takes a function as input. The returned comparator will use the
+     * function once for each item in the list to be sorted by Collections.sort.
+     *
+     * This should be used if the function to generate the sort key from an object is expensive, so
+     * that it is not done many times for each item in a list.
+     *
+     * @param comparableFunction The Function that the Comparator will delegate to.
+     * @param <T>                The generic type to be used.
+     *
+     * @return A comparator that uses a Function for the compare operation.
+     */
+    @SuppressWarnings( "raw" )
+    public static <T> Comparator<T> comparator( final Function<T, Comparable> comparableFunction )
+    {
+        return new Comparator<T>()
+        {
+            Map<T, Comparable> compareKeys = new HashMap<>();
+
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public int compare( T o1, T o2 )
+            {
+                Comparable key1 = compareKeys.get( o1 );
+                if( key1 == null )
+                {
+                    key1 = comparableFunction.map( o1 );
+                    compareKeys.put( o1, key1 );
+                }
+
+                Comparable key2 = compareKeys.get( o2 );
+                if( key2 == null )
+                {
+                    key2 = comparableFunction.map( o2 );
+                    compareKeys.put( o2, key2 );
+                }
+
+                return key1.compareTo( key2 );
+            }
+        };
+    }
+
+    private Functions()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitor.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitor.java b/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitor.java
new file mode 100644
index 0000000..1d328cb
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitor.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.functional;
+
+/**
+ * Visitor to visit hierarchies.
+ */
+public interface HierarchicalVisitor<NODE, LEAF, ThrowableType extends Throwable> extends Visitor<LEAF, ThrowableType>
+{
+    /**
+     * Enter an instance of T
+     *
+     * @param visited the visited instance which is now entered
+     *
+     * @return true if the visitor pattern should continue, false if it should be aborted for this level
+     *
+     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
+     *                       get the exception in order to handle it properly.
+     */
+    boolean visitEnter( NODE visited )
+        throws ThrowableType;
+
+    /**
+     * Leave an instance of T
+     *
+     * @param visited the visited instance which is now left
+     *
+     * @return true if the visitor pattern should continue, false if it should be aborted for the level of this node
+     *
+     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
+     *                       get the exception in order to handle it properly.
+     */
+    boolean visitLeave( NODE visited )
+        throws ThrowableType;
+
+    @Override
+    boolean visit( LEAF visited )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitorAdapter.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitorAdapter.java b/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitorAdapter.java
new file mode 100644
index 0000000..2023655
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/HierarchicalVisitorAdapter.java
@@ -0,0 +1,47 @@
+/*
+ * 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.qi4j.functional;
+
+/**
+ * Generic Hierarchical Visitor interface.
+ */
+public class HierarchicalVisitorAdapter<NODE, LEAF, ThrowableType extends Throwable>
+    implements HierarchicalVisitor<NODE, LEAF, ThrowableType>
+{
+    @Override
+    public boolean visitEnter( NODE visited )
+        throws ThrowableType
+    {
+        return true;
+    }
+
+    @Override
+    public boolean visitLeave( NODE visited )
+        throws ThrowableType
+    {
+        return true;
+    }
+
+    @Override
+    public boolean visit( LEAF visited )
+        throws ThrowableType
+    {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Iterables.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Iterables.java b/core/functional/src/main/java/org/qi4j/functional/Iterables.java
new file mode 100644
index 0000000..ec5ae43
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Iterables.java
@@ -0,0 +1,939 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+import java.lang.reflect.Array;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * Utility methods for working with Iterables. See test for examples of how to use.
+ */
+public final class Iterables
+{
+    @SuppressWarnings( "raw" )
+    private static final Iterable EMPTY = new Iterable()
+    {
+        Iterator iterator = new Iterator()
+        {
+            @Override
+            public boolean hasNext()
+            {
+                return false;
+            }
+
+            @Override
+            public Object next()
+            {
+                throw new NoSuchElementException();
+            }
+
+            @Override
+            public void remove()
+            {
+            }
+        };
+
+        @Override
+        public Iterator iterator()
+        {
+            return iterator;
+        }
+    };
+
+    @SuppressWarnings( "unchecked" )
+    public static <T> Iterable<T> empty()
+    {
+        return EMPTY;
+    }
+
+    public static <T> Iterable<T> constant( final T item )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                return new Iterator<T>()
+                {
+                    @Override
+                    public boolean hasNext()
+                    {
+                        return true;
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        return item;
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                    }
+                };
+            }
+        };
+    }
+
+    public static <T> Iterable<T> limit( final int limitItems, final Iterable<T> iterable )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                final Iterator<T> iterator = iterable.iterator();
+
+                return new Iterator<T>()
+                {
+                    int count;
+
+                    @Override
+                    public boolean hasNext()
+                    {
+                        return count < limitItems && iterator.hasNext();
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        count++;
+                        return iterator.next();
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                        iterator.remove();
+                    }
+                };
+            }
+        };
+    }
+
+    public static <T> Iterable<T> unique( final Iterable<T> iterable )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                final Iterator<T> iterator = iterable.iterator();
+
+                return new Iterator<T>()
+                {
+                    private final Set<T> items = new HashSet<>();
+                    private T nextItem;
+
+                    @Override
+                    public boolean hasNext()
+                    {
+                        while( iterator.hasNext() )
+                        {
+                            nextItem = iterator.next();
+                            if( items.add( nextItem ) )
+                            {
+                                return true;
+                            }
+                        }
+
+                        return false;
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        if( nextItem == null && !hasNext() )
+                        {
+                            throw new NoSuchElementException();
+                        }
+
+                        return nextItem;
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                    }
+                };
+            }
+        };
+    }
+
+    public static <T, C extends Collection<T>> C addAll( C collection, Iterable<? extends T> iterable )
+    {
+        for( T item : iterable )
+        {
+            collection.add( item );
+        }
+        return collection;
+    }
+
+    public static long count( Iterable<?> iterable )
+    {
+        long c = 0;
+        for( Object anIterable : iterable )
+        {
+            c++;
+        }
+        return c;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public static <X> Iterable<X> filter( Specification<? /* super X*/> specification, Iterable<X> i )
+    {
+        return new FilterIterable<>( i, (Specification<? super X>) specification );
+    }
+
+    public static <X> X first( Iterable<X> i )
+    {
+        Iterator<X> iter = i.iterator();
+        if( iter.hasNext() )
+        {
+            return iter.next();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    public static <X> X single( Iterable<X> i )
+    {
+        Iterator<X> iter = i.iterator();
+        if( iter.hasNext() )
+        {
+            X result = iter.next();
+
+            if( iter.hasNext() )
+            {
+                throw new IllegalArgumentException( "More than one element in iterable" );
+            }
+
+            return result;
+        }
+        else
+        {
+            throw new IllegalArgumentException( "No elements in iterable" );
+        }
+    }
+
+    public static <X> Iterable<X> skip( final int skip, final Iterable<X> iterable )
+    {
+        return new Iterable<X>()
+        {
+            @Override
+            public Iterator<X> iterator()
+            {
+                Iterator<X> iterator = iterable.iterator();
+
+                for( int i = 0; i < skip; i++ )
+                {
+                    if( iterator.hasNext() )
+                    {
+                        iterator.next();
+                    }
+                    else
+                    {
+                        return Iterables.<X>empty().iterator();
+                    }
+                }
+
+                return iterator;
+            }
+        };
+    }
+
+    public static <X> X last( Iterable<X> i )
+    {
+        Iterator<X> iter = i.iterator();
+        X item = null;
+        while( iter.hasNext() )
+        {
+            item = iter.next();
+        }
+
+        return item;
+    }
+
+    public static <X> Iterable<X> reverse( Iterable<X> iterable )
+    {
+        List<X> list = toList( iterable );
+        Collections.reverse( list );
+        return list;
+    }
+
+    public static <T> boolean matchesAny( Specification<? super T> specification, Iterable<T> iterable )
+    {
+        boolean result = false;
+
+        for( T item : iterable )
+        {
+            if( ( (Specification<? super T>) specification ).satisfiedBy( item ) )
+            {
+                result = true;
+                break;
+            }
+        }
+
+        return result;
+    }
+
+    public static <T> boolean matchesAll( Specification<? super T> specification, Iterable<T> iterable )
+    {
+        boolean result = true;
+        for( T item : iterable )
+        {
+            if( !specification.satisfiedBy( item ) )
+            {
+                result = false;
+            }
+        }
+
+        return result;
+    }
+
+    public static <X> Iterable<X> flatten( Iterable<?>... multiIterator )
+    {
+        return new FlattenIterable<>( Iterables.<Iterable<X>>cast( Arrays.asList( multiIterator ) ) );
+    }
+
+    public static <X, I extends Iterable<? extends X>> Iterable<X> flattenIterables( Iterable<I> multiIterator )
+    // public static <X> Iterable<X> flattenIterables( Iterable<Iterable<?>> multiIterator )
+    {
+        return new FlattenIterable<>( Iterables.<Iterable<X>>cast( multiIterator ) );
+    }
+
+    @SafeVarargs
+    public static <T> Iterable<T> mix( final Iterable<T>... iterables )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                final Iterable<Iterator<T>> iterators = toList( map( new Function<Iterable<T>, Iterator<T>>()
+                {
+                    @Override
+                    public Iterator<T> map( Iterable<T> iterable )
+                    {
+                        return iterable.iterator();
+                    }
+                }, Iterables.iterable( iterables ) ) );
+
+                return new Iterator<T>()
+                {
+                    Iterator<Iterator<T>> iterator;
+
+                    Iterator<T> iter;
+
+                    @Override
+                    public boolean hasNext()
+                    {
+                        for( Iterator<T> iterator : iterators )
+                        {
+                            if( iterator.hasNext() )
+                            {
+                                return true;
+                            }
+                        }
+
+                        return false;
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        if( iterator == null )
+                        {
+                            iterator = iterators.iterator();
+                        }
+
+                        while( iterator.hasNext() )
+                        {
+                            iter = iterator.next();
+
+                            if( iter.hasNext() )
+                            {
+                                return iter.next();
+                            }
+                        }
+
+                        iterator = null;
+
+                        return next();
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                        if( iter != null )
+                        {
+                            iter.remove();
+                        }
+                    }
+                };
+            }
+        };
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public static <FROM, TO> Iterable<TO> map( Function<? /* super FROM */, TO> function, Iterable<FROM> from )
+    {
+        return new MapIterable<>( from, (Function<FROM, TO>) function );
+    }
+
+    public static <T> Iterable<T> iterable( Enumeration<T> enumeration )
+    {
+        List<T> list = new ArrayList<>();
+        while( enumeration.hasMoreElements() )
+        {
+            T item = enumeration.nextElement();
+            list.add( item );
+        }
+
+        return list;
+    }
+
+    @SafeVarargs
+    public static <T> Iterable<T> iterable( T... items )
+    {
+        return Arrays.asList( items );
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> Iterable<T> cast( Iterable<?> iterable )
+    {
+        Iterable iter = iterable;
+        return iter;
+    }
+
+    public static <FROM, TO> Function<FROM, TO> cast()
+    {
+        return new Function<FROM, TO>()
+        {
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public TO map( FROM from )
+            {
+                return (TO) from;
+            }
+        };
+    }
+
+    public static <FROM, TO> TO fold( Function<? super FROM, TO> function, Iterable<? extends FROM> i )
+    {
+        return last( map( function, i ) );
+    }
+
+    public static <T> Iterable<T> prepend( final T item, final Iterable<T> iterable )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                return new Iterator<T>()
+                {
+                    T first = item;
+                    Iterator<T> iterator;
+
+                    @Override
+                    public boolean hasNext()
+                    {
+                        if( first != null )
+                        {
+                            return true;
+                        }
+                        else
+                        {
+                            if( iterator == null )
+                            {
+                                iterator = iterable.iterator();
+                            }
+                        }
+
+                        return iterator.hasNext();
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        if( first != null )
+                        {
+                            try
+                            {
+                                return first;
+                            }
+                            finally
+                            {
+                                first = null;
+                            }
+                        }
+                        else
+                        {
+                            return iterator.next();
+                        }
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                    }
+                };
+            }
+        };
+    }
+
+    public static <T> Iterable<T> append( final T item, final Iterable<T> iterable )
+    {
+        return new Iterable<T>()
+        {
+            @Override
+            public Iterator<T> iterator()
+            {
+                final Iterator<T> iterator = iterable.iterator();
+
+                return new Iterator<T>()
+                {
+                    T last = item;
+
+                    @Override
+                    public boolean hasNext()
+                    {
+                        if( iterator.hasNext() )
+                        {
+                            return true;
+                        }
+                        else
+                        {
+                            return last != null;
+                        }
+                    }
+
+                    @Override
+                    public T next()
+                    {
+                        if( iterator.hasNext() )
+                        {
+                            return iterator.next();
+                        }
+                        else
+                        {
+                            try
+                            {
+                                return last;
+                            }
+                            finally
+                            {
+                                last = null;
+                            }
+                        }
+                    }
+
+                    @Override
+                    public void remove()
+                    {
+                    }
+                };
+            }
+        };
+    }
+
+    @SafeVarargs
+    public static <T> Iterable<T> debug( String format,
+                                         final Iterable<T> iterable,
+                                         final Function<T, String>... functions
+    )
+    {
+        final MessageFormat msgFormat = new MessageFormat( format );
+
+        return map( new Function<T, T>()
+        {
+            @Override
+            public T map( T t )
+            {
+                if( functions.length != 0 )
+                {
+                    String[] mapped = new String[ functions.length ];
+                    for( int i = 0; i < functions.length; i++ )
+                    {
+                        Function<T, String> function = functions[i];
+                        mapped[i] = function.map( t );
+                    }
+                }
+                return t;
+            }
+        }, iterable );
+    }
+
+    public static <T> Iterable<T> cache( Iterable<T> iterable )
+    {
+        return new CacheIterable<>( iterable );
+    }
+
+    public static <T> String toString( Iterable<T> iterable )
+    {
+        return toString( iterable, new Function<T, String>()
+        {
+            @Override
+            public String map( T t )
+            {
+                return t == null ? "[null]" : t.toString();
+            }
+        }, "," );
+    }
+
+    public static <T> String toString( Iterable<T> iterable, Function<T, String> toStringFunction, String separator )
+    {
+        StringBuilder builder = new StringBuilder();
+        boolean first = true;
+        for( T item : iterable )
+        {
+            if( !first )
+            {
+                builder.append( separator );
+            }
+            builder.append( toStringFunction.map( item ) );
+            first = false;
+        }
+        return builder.toString();
+    }
+
+    public static <T> List<T> toList( Iterable<T> iterable )
+    {
+        return addAll( new ArrayList<T>(), iterable );
+    }
+
+    public static Object[] toArray( Iterable<Object> iterable )
+    {
+        return toArray( Object.class, iterable );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public static <T> T[] toArray( Class<T> componentType, Iterable<T> iterable )
+    {
+        if( iterable == null )
+        {
+            return null;
+        }
+        List<T> list = toList( iterable );
+        return list.toArray( (T[]) Array.newInstance( componentType, list.size() ) );
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <X extends Comparable> Iterable<X> sort( Iterable<X> iterable )
+    {
+        List<X> list = toList( iterable );
+        Collections.sort( list );
+        return list;
+    }
+
+    public static <X> Iterable<X> sort( Comparator<? super X> comparator, Iterable<X> iterable )
+    {
+        List<X> list = toList( iterable );
+        Collections.sort( list, comparator );
+        return list;
+    }
+
+    private static class MapIterable<FROM, TO>
+        implements Iterable<TO>
+    {
+        private final Iterable<FROM> from;
+        private final Function<? super FROM, TO> function;
+
+        private MapIterable( Iterable<FROM> from, Function<? super FROM, TO> function )
+        {
+            this.from = from;
+            this.function = function;
+        }
+
+        @Override
+        public Iterator<TO> iterator()
+        {
+            return new MapIterator<>( from.iterator(), function );
+        }
+
+        static class MapIterator<FROM, TO>
+            implements Iterator<TO>
+        {
+            private final Iterator<FROM> fromIterator;
+            private final Function<? super FROM, TO> function;
+
+            private MapIterator( Iterator<FROM> fromIterator, Function<? super FROM, TO> function )
+            {
+                this.fromIterator = fromIterator;
+                this.function = function;
+            }
+
+            @Override
+            public boolean hasNext()
+            {
+                return fromIterator.hasNext();
+            }
+
+            @Override
+            public TO next()
+            {
+                FROM from = fromIterator.next();
+                return function.map( from );
+            }
+
+            @Override
+            public void remove()
+            {
+                fromIterator.remove();
+            }
+        }
+
+    }
+
+    private static class FilterIterable<T>
+        implements Iterable<T>
+    {
+        private final Iterable<T> iterable;
+
+        private final Specification<? super T> specification;
+
+        private FilterIterable( Iterable<T> iterable, Specification<? super T> specification )
+        {
+            this.iterable = iterable;
+            this.specification = specification;
+        }
+
+        @Override
+        public Iterator<T> iterator()
+        {
+            return new FilterIterator<>( iterable.iterator(), specification );
+        }
+
+        private static class FilterIterator<T>
+            implements Iterator<T>
+        {
+            private final Iterator<T> iterator;
+
+            private final Specification<? super T> specification;
+
+            private T currentValue;
+            boolean finished = false;
+            boolean nextConsumed = true;
+
+            private FilterIterator( Iterator<T> iterator, Specification<? super T> specification )
+            {
+                this.specification = specification;
+                this.iterator = iterator;
+            }
+
+            public boolean moveToNextValid()
+            {
+                boolean found = false;
+                while( !found && iterator.hasNext() )
+                {
+                    T currentValue = iterator.next();
+                    boolean satisfies = specification.satisfiedBy( currentValue );
+
+                    if( satisfies )
+                    {
+                        found = true;
+                        this.currentValue = currentValue;
+                        nextConsumed = false;
+                    }
+                }
+                if( !found )
+                {
+                    finished = true;
+                }
+                return found;
+            }
+
+            @Override
+            public T next()
+            {
+                if( !nextConsumed )
+                {
+                    nextConsumed = true;
+                    return currentValue;
+                }
+                else
+                {
+                    if( !finished )
+                    {
+                        if( moveToNextValid() )
+                        {
+                            nextConsumed = true;
+                            return currentValue;
+                        }
+                    }
+                }
+                return null;
+            }
+
+            @Override
+            public boolean hasNext()
+            {
+                return !finished
+                       && ( !nextConsumed || moveToNextValid() );
+            }
+
+            @Override
+            public void remove()
+            {
+            }
+        }
+
+    }
+
+    private static class FlattenIterable<T, I extends Iterable<? extends T>>
+        implements Iterable<T>
+    {
+        private final Iterable<I> iterable;
+
+        private FlattenIterable( Iterable<I> iterable )
+        {
+            this.iterable = iterable;
+        }
+
+        @Override
+        public Iterator<T> iterator()
+        {
+            return new FlattenIterator<>( iterable.iterator() );
+        }
+
+        static class FlattenIterator<T, I extends Iterable<? extends T>>
+            implements Iterator<T>
+        {
+            private final Iterator<I> iterator;
+            private Iterator<? extends T> currentIterator;
+
+            private FlattenIterator( Iterator<I> iterator )
+            {
+                this.iterator = iterator;
+                currentIterator = null;
+            }
+
+            @Override
+            public boolean hasNext()
+            {
+                if( currentIterator == null )
+                {
+                    if( iterator.hasNext() )
+                    {
+                        I next = iterator.next();
+                        currentIterator = next.iterator();
+                    }
+                    else
+                    {
+                        return false;
+                    }
+                }
+
+                while( !currentIterator.hasNext()
+                       && iterator.hasNext() )
+                {
+                    currentIterator = iterator.next().iterator();
+                }
+
+                return currentIterator.hasNext();
+            }
+
+            @Override
+            public T next()
+            {
+                return currentIterator.next();
+            }
+
+            @Override
+            public void remove()
+            {
+                if( currentIterator == null )
+                {
+                    throw new IllegalStateException();
+                }
+
+                currentIterator.remove();
+            }
+        }
+
+    }
+
+    private static class CacheIterable<T>
+        implements Iterable<T>
+    {
+        private final Iterable<T> iterable;
+        private Iterable<T> cache;
+
+        private CacheIterable( Iterable<T> iterable )
+        {
+            this.iterable = iterable;
+        }
+
+        @Override
+        public Iterator<T> iterator()
+        {
+            if( cache != null )
+            {
+                return cache.iterator();
+            }
+
+            final Iterator<T> source = iterable.iterator();
+
+            return new Iterator<T>()
+            {
+                List<T> iteratorCache = new ArrayList<>();
+
+                @Override
+                public boolean hasNext()
+                {
+                    boolean hasNext = source.hasNext();
+                    if( !hasNext )
+                    {
+                        cache = iteratorCache;
+                    }
+                    return hasNext;
+                }
+
+                @Override
+                public T next()
+                {
+                    T next = source.next();
+                    iteratorCache.add( next );
+                    return next;
+                }
+
+                @Override
+                public void remove()
+                {
+
+                }
+            };
+        }
+    }
+
+    private Iterables()
+    {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Specification.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Specification.java b/core/functional/src/main/java/org/qi4j/functional/Specification.java
new file mode 100644
index 0000000..93c61a9
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Specification.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+/**
+ * Generic specification interface.
+ *
+ * @param <T>
+ */
+// START SNIPPET: specification
+public interface Specification<T>
+{
+// END SNIPPET: specification
+
+    /**
+     * Test whether an item matches the given specification
+     *
+     * @param item the item to be tested
+     *
+     * @return true if the item matches, false otherwise
+     */
+// START SNIPPET: specification
+    boolean satisfiedBy( T item );
+}
+// END SNIPPET: specification

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Specifications.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Specifications.java b/core/functional/src/main/java/org/qi4j/functional/Specifications.java
new file mode 100644
index 0000000..7635579
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Specifications.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+/**
+ * Common generic specification expressions
+ */
+public class Specifications
+{
+    public static <T> Specification<T> TRUE()
+    {
+        return new Specification<T>()
+        {
+            @Override
+            public boolean satisfiedBy( T instance )
+            {
+                return true;
+            }
+        };
+    }
+
+    public static <T> Specification<T> not( final Specification<T> specification )
+    {
+        return new Specification<T>()
+        {
+            @Override
+            public boolean satisfiedBy( T instance )
+            {
+                return !specification.satisfiedBy( instance );
+            }
+        };
+    }
+
+    @SafeVarargs
+    public static <T> AndSpecification<T> and( final Specification<T>... specifications )
+    {
+        return and( Iterables.iterable( specifications ) );
+    }
+
+    public static <T> AndSpecification<T> and( final Iterable<Specification<T>> specifications )
+    {
+        return new AndSpecification<>( specifications );
+    }
+
+    @SafeVarargs
+    public static <T> OrSpecification<T> or( final Specification<T>... specifications )
+    {
+        return or( Iterables.iterable( specifications ) );
+    }
+
+    public static <T> OrSpecification<T> or( final Iterable<Specification<T>> specifications )
+    {
+        return new OrSpecification<>( specifications );
+    }
+
+    @SafeVarargs
+    public static <T> Specification<T> in( final T... allowed )
+    {
+        return in( Iterables.iterable( allowed ) );
+    }
+
+    public static <T> Specification<T> in( final Iterable<T> allowed )
+    {
+        return new Specification<T>()
+        {
+            @Override
+            public boolean satisfiedBy( T item )
+            {
+                for( T allow : allowed )
+                {
+                    if( allow.equals( item ) )
+                    {
+                        return true;
+                    }
+                }
+                return false;
+            }
+        };
+    }
+
+    public static <T> Specification<T> notNull()
+    {
+        return new Specification<T>()
+        {
+            @Override
+            public boolean satisfiedBy( T item )
+            {
+                return item != null;
+            }
+        };
+    }
+
+    public static <FROM, TO> Specification<FROM> translate( final Function<FROM, TO> function,
+                                                            final Specification<? super TO> specification
+    )
+    {
+        return new Specification<FROM>()
+        {
+            @Override
+            public boolean satisfiedBy( FROM item )
+            {
+                return specification.satisfiedBy( function.map( item ) );
+            }
+        };
+    }
+
+    /**
+     * AND Specification.
+     */
+    public static class AndSpecification<T>
+        implements Specification<T>
+    {
+        private final Iterable<Specification<T>> specifications;
+
+        private AndSpecification( Iterable<Specification<T>> specifications )
+        {
+            this.specifications = specifications;
+        }
+
+        @Override
+        public boolean satisfiedBy( T instance )
+        {
+            for( Specification<T> specification : specifications )
+            {
+                if( !specification.satisfiedBy( instance ) )
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        @SafeVarargs
+        public final AndSpecification<T> and( Specification<T>... specifications )
+        {
+            Iterable<Specification<T>> iterable = Iterables.iterable( specifications );
+            Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable );
+            return Specifications.and( flatten );
+        }
+
+        @SafeVarargs
+        public final OrSpecification<T> or( Specification<T>... specifications )
+        {
+            return Specifications.or( Iterables.prepend( this, Iterables.iterable( specifications ) ) );
+        }
+    }
+
+    /**
+     * OR Specification.
+     */
+    public static class OrSpecification<T>
+        implements Specification<T>
+    {
+        private final Iterable<Specification<T>> specifications;
+
+        private OrSpecification( Iterable<Specification<T>> specifications )
+        {
+            this.specifications = specifications;
+        }
+
+        @Override
+        public boolean satisfiedBy( T instance )
+        {
+            for( Specification<T> specification : specifications )
+            {
+                if( specification.satisfiedBy( instance ) )
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        @SafeVarargs
+        public final AndSpecification<T> and( Specification<T>... specifications )
+        {
+            return Specifications.and( Iterables.prepend( this, Iterables.iterable( specifications ) ) );
+        }
+
+        @SafeVarargs
+        public final OrSpecification<T> or( Specification<T>... specifications )
+        {
+            Iterable<Specification<T>> iterable = Iterables.iterable( specifications );
+            Iterable<Specification<T>> flatten = Iterables.flatten( this.specifications, iterable );
+            return Specifications.or( flatten );
+        }
+    }
+
+    private Specifications()
+    {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Visitable.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Visitable.java b/core/functional/src/main/java/org/qi4j/functional/Visitable.java
new file mode 100644
index 0000000..b1ed8ba
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Visitable.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.functional;
+
+/**
+ * Interface that visitable objects should implement.
+ */
+public interface Visitable<T>
+{
+    <ThrowableType extends Throwable> boolean accept( Visitor<? super T, ThrowableType> visitor )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/VisitableHierarchy.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/VisitableHierarchy.java b/core/functional/src/main/java/org/qi4j/functional/VisitableHierarchy.java
new file mode 100644
index 0000000..fe37d1f
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/VisitableHierarchy.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.functional;
+
+/**
+ * Interface that visitable hierarchies of objects should implement.
+ */
+public interface VisitableHierarchy<NODE, LEAF>
+{
+    <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super NODE, ? super LEAF, ThrowableType> visitor )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/Visitor.java
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/Visitor.java b/core/functional/src/main/java/org/qi4j/functional/Visitor.java
new file mode 100644
index 0000000..3cf6005
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/Visitor.java
@@ -0,0 +1,38 @@
+/*
+ * 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.qi4j.functional;
+
+/**
+ * Generic Visitor interface.
+ */
+public interface Visitor<T, ThrowableType extends Throwable>
+{
+    /**
+     * Visit an instance of T
+     *
+     * @param visited the visited instance
+     *
+     * @return true if the visitor pattern should continue, false if it should be aborted
+     *
+     * @throws ThrowableType if an exception occurred during processing. Any client call that initiated the visiting should
+     *                       get the exception in order to handle it properly.
+     */
+    boolean visit( T visited )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/main/java/org/qi4j/functional/package.html
----------------------------------------------------------------------
diff --git a/core/functional/src/main/java/org/qi4j/functional/package.html b/core/functional/src/main/java/org/qi4j/functional/package.html
new file mode 100644
index 0000000..920a9ef
--- /dev/null
+++ b/core/functional/src/main/java/org/qi4j/functional/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Functional API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/apache/zest/functional/FunctionsTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/apache/zest/functional/FunctionsTest.java b/core/functional/src/test/java/org/apache/zest/functional/FunctionsTest.java
deleted file mode 100644
index 0c9ea0f..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/FunctionsTest.java
+++ /dev/null
@@ -1,143 +0,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.
- */
-package org.apache.zest.functional;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.apache.zest.functional.ForEach.forEach;
-import static org.apache.zest.functional.Functions.compose;
-import static org.apache.zest.functional.Functions.count;
-import static org.apache.zest.functional.Functions.indexOf;
-import static org.apache.zest.functional.Functions.intSum;
-import static org.apache.zest.functional.Functions.longSum;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.last;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Specifications.in;
-
-/**
- * Test of utility functions
- */
-public class FunctionsTest
-{
-    Function<Object, String> stringifier = new Function<Object, String>()
-    {
-        @Override
-        public String map( Object s )
-        {
-            return s.toString();
-        }
-    };
-
-    Function<String, Integer> length = new Function<String, Integer>()
-    {
-        @Override
-        public Integer map( String s )
-        {
-            return s.length();
-        }
-    };
-
-    @Test
-    public void testCompose()
-    {
-        assertThat( Functions.<Object, String, Integer>compose()
-                        .map( length, stringifier )
-                        .map( 12345L ), equalTo( 5 ) );
-        assertThat( compose( length, stringifier ).map( 12345L ), equalTo( 5 ) );
-    }
-
-    @Test
-    public void testFromMap()
-    {
-        Map<String, String> map = new HashMap<String, String>();
-        map.put( "A", "1" );
-        map.put( "B", "2" );
-        map.put( "C", "3" );
-        assertThat( Iterables.toList( Iterables.filter( Specifications.notNull(), Iterables.map( Functions.fromMap( map ), Iterables
-            .iterable( "A", "B", "D" ) ) ) ).toString(), equalTo( "[1, 2]" ) );
-    }
-
-    @Test
-    public void testWithDefault()
-    {
-        assertThat( Iterables.toList( Iterables.map( Functions.withDefault( "DEFAULT" ), Iterables.iterable( "123", null, "456" ) ) )
-                        .toString(), equalTo( "[123, DEFAULT, 456]" ) );
-    }
-
-    @Test
-    public void testLongSum()
-    {
-        assertThat( last( map( longSum(), iterable( 1, 2L, 3F, 4D ) ) ), equalTo( 10L ) );
-    }
-
-    @Test
-    public void testLongSum2()
-    {
-        assertThat( forEach( iterable( 1, 2, 3, 4 ) ).map( longSum() ).last(), equalTo( 10L ) );
-    }
-
-    @Test
-    public void testIntSum()
-    {
-        assertThat( last( map( intSum(), iterable( 1, 2L, 3F, 4D ) ) ), equalTo( 10 ) );
-    }
-
-    @Test
-    public void testCount()
-    {
-        assertThat( last( map( count( in( "X" ) ), iterable( "X", "Y", "X", "X", "Y" ) ) ), equalTo( 3 ) );
-    }
-
-    @Test
-    public void testIndexOf()
-    {
-        assertThat( last( map( indexOf( in( "D" ) ), iterable( "A", "B", "C", "D", "D" ) ) ), equalTo( 3 ) );
-    }
-
-    @Test
-    public void testIndexOf2()
-    {
-        assertThat( indexOf( "D", iterable( "A", "B", "C", "D", "D" ) ), equalTo( 3 ) );
-    }
-
-    @Test
-    public void testComparator()
-    {
-        Comparator<Integer> comparator = Functions.comparator( new Function<Integer, Comparable>()
-        {
-            @Override
-            public Comparable map( Integer integer )
-            {
-                return integer.toString();
-            }
-        } );
-        Iterable<Integer> iterable = Iterables.iterable( 1, 5, 3, 6, 8 );
-        List<Integer> integers = Iterables.toList( iterable );
-        Collections.sort( integers, comparator );
-        assertThat( integers.toString(), equalTo( "[1, 3, 5, 6, 8]" ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java b/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java
deleted file mode 100644
index fa082fe..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.functional;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-// This test exist primarily for the documentation. Don't remove.
-public class IntegerRangeSpecificationTest
-{
-    @Test
-    public void test1()
-    {
-        Specification<Integer> spec = new IntegerRangeSpecification( 10, 12 );
-        assertTrue( spec.satisfiedBy( 10 ) );
-        assertTrue( spec.satisfiedBy( 11 ) );
-        assertTrue( spec.satisfiedBy( 12 ) );
-        assertFalse( spec.satisfiedBy( 9 ) );
-        assertFalse( spec.satisfiedBy( 13 ) );
-    }
-
-    // START SNIPPET: specification
-    public static class IntegerRangeSpecification
-        implements Specification<Integer>
-    {
-
-        private int lower;
-        private int higher;
-
-        public IntegerRangeSpecification( int lower, int higher )
-        {
-            this.lower = lower;
-            this.higher = higher;
-        }
-
-        @Override
-        public boolean satisfiedBy( Integer item )
-        {
-            return item >= lower && item <= higher;
-        }
-    }
-    // END SNIPPET: specification
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java b/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java
deleted file mode 100644
index e970666..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/IterablesTest.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import static java.util.Collections.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
-/**
- * Test of Iterables utility methods
- */
-public class IterablesTest
-{
-
-    private List<String> numbers = Arrays.asList( "1", "2", "3" );
-    private Iterable<Long> numberLongs = Arrays.asList( 1L, 2L, 3L );
-    private Iterable<Integer> numberIntegers = Arrays.asList( 1, 2, 3 );
-
-    @Test
-    public void testConstant()
-    {
-        String str = "";
-
-        for( String string : Iterables.limit( 3, Iterables.constant( "123" ) ) )
-        {
-            str += string;
-        }
-
-        assertThat( str, CoreMatchers.equalTo( "123123123" ) );
-    }
-
-    @Test
-    public void testUnique()
-    {
-        String str = "";
-
-        for( String string : Iterables.unique( Iterables.<String>flatten( numbers, numbers, numbers ) ) )
-        {
-            str += string;
-        }
-        assertThat( str, CoreMatchers.equalTo( "123" ) );
-    }
-
-    @Test
-    public void testAddAll()
-    {
-        List<String> strings = Iterables.toList( numbers );
-        assertThat( strings.toString(), equalTo( "[1, 2, 3]" ) );
-        assertThat( Iterables.toList( numberLongs ).toString(), equalTo( "[1, 2, 3]" ) );
-    }
-
-    @Test
-    public void testCount()
-    {
-        assertThat( Iterables.count( numbers ), equalTo( 3L ) );
-    }
-
-    @Test
-    public void testFilter()
-    {
-        assertThat( Iterables.first( Iterables.filter( Specifications.in( "2" ), numbers ) ), equalTo( "2" ) );
-    }
-
-    @Test
-    public void testFirst()
-    {
-        assertThat( Iterables.first( numbers ), equalTo( "1" ) );
-        assertThat( Iterables.first( emptyList() ), nullValue() );
-    }
-
-    @Test
-    public void testLast()
-    {
-        assertThat( Iterables.last( numbers ), equalTo( "3" ) );
-        assertThat( Iterables.last( emptyList() ), nullValue() );
-    }
-
-    @Test
-    public void testFolding()
-    {
-        assertThat( Iterables.fold( new Function<Integer, Integer>()
-        {
-
-            int sum = 0;
-
-            @Override
-            public Integer map( Integer number )
-            {
-                return sum += number;
-            }
-
-        }, numberIntegers ), equalTo( 6 ) );
-    }
-
-    @Test
-    public void testAppend()
-    {
-        assertThat( Iterables.toList( Iterables.append( "C", Iterables.iterable( "A", "B" ) ) ).toString(),
-                    equalTo( "[A, B, C]" ) );
-    }
-
-    @Test
-    public void testReverse()
-    {
-        assertThat( Iterables.reverse( numbers ).toString(), equalTo( "[3, 2, 1]" ) );
-        assertThat( Iterables.reverse( emptyList() ), equalTo( (Object) emptyList() ) );
-    }
-
-    @Test
-    public void testMatchesAny()
-    {
-        assertThat( Iterables.matchesAny( Specifications.in( "2" ), numbers ), equalTo( true ) );
-        assertThat( Iterables.matchesAny( Specifications.in( "4" ), numbers ), equalTo( false ) );
-    }
-
-    @Test
-    public void testMatchesAll()
-    {
-        assertThat( Iterables.matchesAll( Specifications.in( "1", "2", "3" ), numbers ), equalTo( true ) );
-        assertThat( Iterables.matchesAll( Specifications.in( "2", "3", "4" ), numbers ), equalTo( false ) );
-    }
-
-    @Test
-    public void testFlatten()
-    {
-        assertThat( Iterables.toList( Iterables.flatten( numbers, numbers ) ).toString(),
-                    equalTo( "[1, 2, 3, 1, 2, 3]" ) );
-
-        Iterable<? extends Number> flatten = Iterables.flatten( numberIntegers, numberLongs );
-        assertThat( Iterables.toList( flatten ).toString(), equalTo( "[1, 2, 3, 1, 2, 3]" ) );
-    }
-
-    @Test
-    public void testFlattenIterables()
-    {
-        Iterable<List<String>> iterable = Iterables.iterable( numbers, numbers );
-        assertThat( Iterables.toList( Iterables.flattenIterables( iterable ) ).toString(),
-                    equalTo( "[1, 2, 3, 1, 2, 3]" ) );
-    }
-
-    @Test
-    public void testMix()
-    {
-        assertThat( Iterables.toList( Iterables.mix( Iterables.iterable( "A", "B", "C" ),
-                                                     Iterables.iterable( "1", "2", "3", "4", "5" ),
-                                                     Iterables.iterable( "X", "Y", "Z" ) ) ).toString(),
-                    equalTo( "[A, 1, X, B, 2, Y, C, 3, Z, 4, 5]" ) );
-    }
-
-    @Test
-    public void testMap()
-    {
-        assertThat( Iterables.toList( Iterables.map( new Function<String, String>()
-        {
-
-            public String map( String s )
-            {
-                return s + s;
-            }
-
-        }, numbers ) ).toString(), equalTo( "[11, 22, 33]" ) );
-
-        Iterable<List<String>> numberIterable = Iterables.iterable( numbers, numbers, numbers );
-        assertThat( Iterables.toList( Iterables.map( new Function<Collection, Integer>()
-        {
-
-            @Override
-            public Integer map( Collection collection )
-            {
-                return collection.size();
-            }
-
-        }, numberIterable ) ).toString(), equalTo( "[3, 3, 3]" ) );
-    }
-
-    @Test
-    public void testIterableEnumeration()
-    {
-
-        Enumeration<String> enumeration = enumeration( numbers );
-        assertThat( Iterables.toList( Iterables.iterable( enumeration ) ).toString(),
-                    equalTo( "[1, 2, 3]" ) );
-    }
-
-    @Test
-    public void testIterableVarArg()
-    {
-        assertThat( Iterables.toList( Iterables.iterable( "1", "2", "3" ) ).toString(),
-                    equalTo( "[1, 2, 3]" ) );
-    }
-
-    @Test
-    public void testCast()
-    {
-        Iterable<Long> values = numberLongs;
-        Iterable<Number> numbers = Iterables.cast( values );
-    }
-
-    @Test
-    public void testDebug()
-    {
-        assertThat( Iterables.first( Iterables.debug( "Filtered number:{0}",
-                                                      Iterables.filter( Specifications.in( "2" ),
-                                                                        Iterables.debug( "Number:{0}", numbers ) ) ) ),
-                    equalTo( "2" ) );
-    }
-
-    @Test
-    public void testDebugWithFunctions()
-    {
-        Function<String, String> fun = new Function<String, String>()
-        {
-
-            @Override
-            public String map( String s )
-            {
-                return s + ":" + s.length();
-            }
-
-        };
-        assertThat( Iterables.first( Iterables.debug( "Filtered number:{0}",
-                                                      Iterables.filter( Specifications.in( "2" ),
-                                                                        Iterables.debug( "Number:{0}", numbers, fun ) ) ) ),
-                    equalTo( "2" ) );
-    }
-
-    @Test
-    public void testCache()
-    {
-        final int[] count = new int[ 1 ];
-
-        Iterable<String> b = Iterables.cache( Iterables.filter( Specifications.and( new Specification<String>()
-        {
-
-            @Override
-            public boolean satisfiedBy( String item )
-            {
-                count[ 0] = count[ 0] + 1;
-                return true;
-            }
-
-        }, Specifications.in( "B" ) ), Iterables.iterable( "A", "B", "C" ) ) );
-
-        assertThat( count[ 0], equalTo( 0 ) );
-
-        Iterables.toList( b );
-
-        assertThat( count[ 0], equalTo( 3 ) );
-
-        Iterables.toList( b );
-
-        assertThat( count[ 0], equalTo( 3 ) );
-    }
-
-    @Test
-    public void testSort()
-    {
-        assertThat( Iterables.sort( Iterables.reverse( numberLongs ) ).toString(), equalTo( "[1, 2, 3]" ) );
-
-        Comparator<Long> inverseLongComparator = new Comparator<Long>()
-        {
-
-            @Override
-            public int compare( Long left, Long right )
-            {
-                return left.compareTo( right ) * -1;
-            }
-
-        };
-        assertThat( Iterables.sort( inverseLongComparator, numberLongs ).toString(), equalTo( "[3, 2, 1]" ) );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java b/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java
deleted file mode 100644
index 7a1601d..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/SpecificationsTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.functional;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-
-/**
- * JAVADOC
- */
-public class SpecificationsTest
-{
-    @Test
-    public void testTRUE()
-    {
-        Assert.assertThat( Specifications.<Object>TRUE().satisfiedBy( new Object() ), equalTo( true ) );
-    }
-
-    @Test
-    public void testNot()
-    {
-        Assert.assertThat( Specifications.not( Specifications.<Object>TRUE() )
-                               .satisfiedBy( new Object() ), equalTo( false ) );
-    }
-
-    @Test
-    public void testAnd()
-    {
-        Specification<Object> trueSpec = Specifications.<Object>TRUE();
-        Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() );
-
-        Assert.assertThat( Specifications.and( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
-        Assert.assertThat( Specifications.and( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
-        Assert.assertThat( Specifications.and( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( false ) );
-        Assert.assertThat( Specifications.and( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
-    }
-
-    @Test
-    public void testOr()
-    {
-        Specification<Object> trueSpec = Specifications.<Object>TRUE();
-        Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() );
-
-        Assert.assertThat( Specifications.or( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
-        Assert.assertThat( Specifications.or( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( true ) );
-        Assert.assertThat( Specifications.or( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
-        Assert.assertThat( Specifications.or( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
-    }
-
-    @Test
-    public void testIn()
-    {
-        Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "2" ), equalTo( true ) );
-        Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "4" ), equalTo( false ) );
-    }
-
-    @Test
-    public void testTranslate()
-    {
-        Function<Object, String> stringifier = new Function<Object, String>()
-        {
-            @Override
-            public String map( Object s )
-            {
-                return s.toString();
-            }
-        };
-
-        Assert.assertTrue( Specifications.translate( stringifier, Specifications.in( "3" ) ).satisfiedBy( 3L ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java b/core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
deleted file mode 100644
index 12a218d..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
+++ /dev/null
@@ -1,55 +0,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.
- */
-package org.apache.zest.functional.docsupport;
-
-import java.util.ArrayList;
-
-// START SNIPPET: func2
-import static org.apache.zest.functional.ForEach.forEach;
-import static org.apache.zest.functional.Functions.longSum;
-// END SNIPPET: func2
-
-public class FunctionalDocs
-{
-    public static void main( String[] args )
-    {
-        {
-// START SNIPPET: func1
-            Iterable<Long> data = new ArrayList<Long>();
-// END SNIPPET: func1
-// START SNIPPET: func1
-
-            long sum = 0;
-            for( Long point : data )
-            {
-                sum = sum + point;
-            }
-            System.out.println( "The sum is " + sum );
-// END SNIPPET: func1
-        }
-        {
-// START SNIPPET: func2
-            Iterable<Number> data = new ArrayList<Number>();
-            Long sum = forEach( data ).map( longSum() ).last();
-            System.out.println( "The sum is " + sum );
-
-// END SNIPPET: func2
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/qi4j/functional/FunctionsTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/qi4j/functional/FunctionsTest.java b/core/functional/src/test/java/org/qi4j/functional/FunctionsTest.java
new file mode 100644
index 0000000..a5e1956
--- /dev/null
+++ b/core/functional/src/test/java/org/qi4j/functional/FunctionsTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.qi4j.functional;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.qi4j.functional.ForEach.forEach;
+import static org.qi4j.functional.Functions.compose;
+import static org.qi4j.functional.Functions.count;
+import static org.qi4j.functional.Functions.indexOf;
+import static org.qi4j.functional.Functions.intSum;
+import static org.qi4j.functional.Functions.longSum;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.last;
+import static org.qi4j.functional.Iterables.map;
+import static org.qi4j.functional.Specifications.in;
+
+/**
+ * Test of utility functions
+ */
+public class FunctionsTest
+{
+    Function<Object, String> stringifier = new Function<Object, String>()
+    {
+        @Override
+        public String map( Object s )
+        {
+            return s.toString();
+        }
+    };
+
+    Function<String, Integer> length = new Function<String, Integer>()
+    {
+        @Override
+        public Integer map( String s )
+        {
+            return s.length();
+        }
+    };
+
+    @Test
+    public void testCompose()
+    {
+        assertThat( Functions.<Object, String, Integer>compose()
+                        .map( length, stringifier )
+                        .map( 12345L ), equalTo( 5 ) );
+        assertThat( compose( length, stringifier ).map( 12345L ), equalTo( 5 ) );
+    }
+
+    @Test
+    public void testFromMap()
+    {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put( "A", "1" );
+        map.put( "B", "2" );
+        map.put( "C", "3" );
+        assertThat( Iterables.toList( Iterables.filter( Specifications.notNull(), Iterables.map( Functions.fromMap( map ), Iterables
+            .iterable( "A", "B", "D" ) ) ) ).toString(), equalTo( "[1, 2]" ) );
+    }
+
+    @Test
+    public void testWithDefault()
+    {
+        assertThat( Iterables.toList( Iterables.map( Functions.withDefault( "DEFAULT" ), Iterables.iterable( "123", null, "456" ) ) )
+                        .toString(), equalTo( "[123, DEFAULT, 456]" ) );
+    }
+
+    @Test
+    public void testLongSum()
+    {
+        assertThat( last( map( longSum(), iterable( 1, 2L, 3F, 4D ) ) ), equalTo( 10L ) );
+    }
+
+    @Test
+    public void testLongSum2()
+    {
+        assertThat( forEach( iterable( 1, 2, 3, 4 ) ).map( longSum() ).last(), equalTo( 10L ) );
+    }
+
+    @Test
+    public void testIntSum()
+    {
+        assertThat( last( map( intSum(), iterable( 1, 2L, 3F, 4D ) ) ), equalTo( 10 ) );
+    }
+
+    @Test
+    public void testCount()
+    {
+        assertThat( last( map( count( in( "X" ) ), iterable( "X", "Y", "X", "X", "Y" ) ) ), equalTo( 3 ) );
+    }
+
+    @Test
+    public void testIndexOf()
+    {
+        assertThat( last( map( indexOf( in( "D" ) ), iterable( "A", "B", "C", "D", "D" ) ) ), equalTo( 3 ) );
+    }
+
+    @Test
+    public void testIndexOf2()
+    {
+        assertThat( indexOf( "D", iterable( "A", "B", "C", "D", "D" ) ), equalTo( 3 ) );
+    }
+
+    @Test
+    public void testComparator()
+    {
+        Comparator<Integer> comparator = Functions.comparator( new Function<Integer, Comparable>()
+        {
+            @Override
+            public Comparable map( Integer integer )
+            {
+                return integer.toString();
+            }
+        } );
+        Iterable<Integer> iterable = Iterables.iterable( 1, 5, 3, 6, 8 );
+        List<Integer> integers = Iterables.toList( iterable );
+        Collections.sort( integers, comparator );
+        assertThat( integers.toString(), equalTo( "[1, 3, 5, 6, 8]" ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/qi4j/functional/IntegerRangeSpecificationTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/qi4j/functional/IntegerRangeSpecificationTest.java b/core/functional/src/test/java/org/qi4j/functional/IntegerRangeSpecificationTest.java
new file mode 100644
index 0000000..d29b24b
--- /dev/null
+++ b/core/functional/src/test/java/org/qi4j/functional/IntegerRangeSpecificationTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.functional;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+// This test exist primarily for the documentation. Don't remove.
+public class IntegerRangeSpecificationTest
+{
+    @Test
+    public void test1()
+    {
+        Specification<Integer> spec = new IntegerRangeSpecification( 10, 12 );
+        assertTrue( spec.satisfiedBy( 10 ) );
+        assertTrue( spec.satisfiedBy( 11 ) );
+        assertTrue( spec.satisfiedBy( 12 ) );
+        assertFalse( spec.satisfiedBy( 9 ) );
+        assertFalse( spec.satisfiedBy( 13 ) );
+    }
+
+    // START SNIPPET: specification
+    public static class IntegerRangeSpecification
+        implements Specification<Integer>
+    {
+
+        private int lower;
+        private int higher;
+
+        public IntegerRangeSpecification( int lower, int higher )
+        {
+            this.lower = lower;
+            this.higher = higher;
+        }
+
+        @Override
+        public boolean satisfiedBy( Integer item )
+        {
+            return item >= lower && item <= higher;
+        }
+    }
+    // END SNIPPET: specification
+}


[34/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceImporter.java b/core/api/src/main/java/org/qi4j/api/service/ServiceImporter.java
new file mode 100644
index 0000000..ee3d6e5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceImporter.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.service;
+
+/**
+ * Import a service from some external source.
+ */
+public interface ServiceImporter<T>
+{
+    /**
+     * Imports an instance of the service type described in the service descriptor.
+     *
+     * @param serviceDescriptor The service descriptor.
+     *
+     * @return The imported service instance.
+     *
+     * @throws ServiceImporterException if import failed.
+     */
+    T importService( ImportedServiceDescriptor serviceDescriptor )
+        throws ServiceImporterException;
+
+    /**
+     * Ask if the service is available or not.
+     *
+     * @param instance the instance to be checked
+     *
+     * @return true if the service is available, false if not
+     */
+    boolean isAvailable( T instance );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceImporterException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceImporterException.java b/core/api/src/main/java/org/qi4j/api/service/ServiceImporterException.java
new file mode 100644
index 0000000..c8c8fc7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceImporterException.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.service;
+
+/**
+ * If a ServiceImporter could not import a service
+ * instance it must throw this exception.
+ */
+public class ServiceImporterException
+    extends RuntimeException
+{
+    public ServiceImporterException()
+    {
+    }
+
+    public ServiceImporterException( String string )
+    {
+        super( string );
+    }
+
+    public ServiceImporterException( String string, Throwable throwable )
+    {
+        super( string, throwable );
+    }
+
+    public ServiceImporterException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceReference.java b/core/api/src/main/java/org/qi4j/api/service/ServiceReference.java
new file mode 100644
index 0000000..7c616c2
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceReference.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service;
+
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * From a ServiceReference you can access and modify metadata about a service.
+ * You can also access the actual service through get(), that can then be invoked.
+ */
+public interface ServiceReference<T>
+    extends HasTypes, ActivationEventListenerRegistration, MetaInfoHolder
+{
+    /**
+     * @return the service's identity
+     */
+    String identity();
+
+    /**
+     * @return the actual service
+     */
+    T get();
+
+    /**
+     * @return TRUE if the service is active, otherwise return FALSE
+     */
+    boolean isActive();
+
+    /**
+     * @return TRUE if the service is available, otherwise return FALSE
+     */
+    boolean isAvailable();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/ServiceUnavailableException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/ServiceUnavailableException.java b/core/api/src/main/java/org/qi4j/api/service/ServiceUnavailableException.java
new file mode 100644
index 0000000..465c945
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/ServiceUnavailableException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Niclas Hedhman.
+ *
+ * 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.qi4j.api.service;
+
+/**
+ * Thrown when no available service is found.
+ */
+public class ServiceUnavailableException
+    extends RuntimeException
+{
+    public ServiceUnavailableException( String message )
+    {
+        super( message );
+    }
+
+    public ServiceUnavailableException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/importer/InstanceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/InstanceImporter.java b/core/api/src/main/java/org/qi4j/api/service/importer/InstanceImporter.java
new file mode 100644
index 0000000..38901fb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/InstanceImporter.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service.importer;
+
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.service.ImportedServiceDescriptor;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.ServiceImporterException;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Layer;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.structure.Module;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.map;
+import static org.qi4j.functional.Specifications.notNull;
+
+/**
+ * Return a predefined service instance that was provided as meta-info. Search for meta-info in the following order:
+ * the service itself, the module of the service, the layer of the service, the whole application.
+ */
+public final class InstanceImporter<T>
+    implements ServiceImporter<T>
+{
+    @Structure
+    private Application application;
+
+    @Structure
+    private Layer layer;
+
+    @Structure
+    private Module module;
+
+    @Override
+    public T importService( final ImportedServiceDescriptor serviceDescriptor )
+        throws ServiceImporterException
+    {
+        T instance = null;
+        Iterable<MetaInfoHolder> holders = Iterables.iterable( serviceDescriptor, module, layer, application );
+        for( final MetaInfoHolder metaInfoHolder : holders )
+        {
+            Function<Class<?>, T> metaFinder = new Function<Class<?>, T>()
+            {
+                @Override
+                @SuppressWarnings( "unchecked" )
+                public T map( Class<?> type )
+                {
+                    return (T) metaInfoHolder.metaInfo( type );
+                }
+            };
+            instance = first( filter( notNull(), map( metaFinder, serviceDescriptor.types() ) ) );
+            if( instance != null )
+            {
+                break;
+            }
+        }
+        return instance;
+    }
+
+    @Override
+    public boolean isAvailable( T instance )
+    {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java b/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
new file mode 100644
index 0000000..d29b1ce
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.importer;
+
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.object.ObjectFactory;
+import org.qi4j.api.service.ImportedServiceDescriptor;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.ServiceImporterException;
+import org.qi4j.functional.Iterables;
+
+/**
+ * Import Services using a new registered Object instance.
+ */
+public final class NewObjectImporter<T>
+    implements ServiceImporter<T>
+{
+    @Structure
+    private ObjectFactory obf;
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public T importService( ImportedServiceDescriptor serviceDescriptor )
+        throws ServiceImporterException
+    {
+        return obf.newObject( (Class<T>) Iterables.first( serviceDescriptor.types() ) );
+    }
+
+    @Override
+    public boolean isAvailable( T instance )
+    {
+        return true;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/importer/ServiceInstanceImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/ServiceInstanceImporter.java b/core/api/src/main/java/org/qi4j/api/service/importer/ServiceInstanceImporter.java
new file mode 100644
index 0000000..7910228
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/ServiceInstanceImporter.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.api.service.importer;
+
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.service.ImportedServiceDescriptor;
+import org.qi4j.api.service.ServiceFinder;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.ServiceImporterException;
+import org.qi4j.api.service.ServiceReference;
+
+/**
+ * Use a registered service that implements ServiceImporter to do the actual
+ * import. The service id of the service that this importer should delegate to must
+ * be set as meta-info on this service. Example:
+ * <pre><code>
+ * module.services(MyServiceImporterService.class).identifiedBy("someid");
+ * module.importedServices(OtherService.class).importedBy(ServiceInstanceImporter.class).setMetaInfo("someid");
+ * </code></pre>
+ */
+public class ServiceInstanceImporter<T>
+    implements ServiceImporter<T>
+{
+    @Structure
+    ServiceFinder finder;
+
+    ServiceImporter<T> service;
+
+    String serviceId;
+
+    @Override
+    public T importService( ImportedServiceDescriptor importedServiceDescriptor )
+        throws ServiceImporterException
+    {
+        serviceId = importedServiceDescriptor.metaInfo( String.class );
+
+        return serviceImporter().importService( importedServiceDescriptor );
+    }
+
+    @Override
+    public boolean isAvailable( T instance )
+    {
+        return serviceImporter().isAvailable( instance );
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    private ServiceImporter<T> serviceImporter()
+    {
+        if( service == null )
+        {
+            for( ServiceReference<ServiceImporter> reference : finder.<ServiceImporter>findServices( ServiceImporter.class ) )
+            {
+                if( reference.identity().equals( serviceId ) )
+                {
+                    service = reference.get();
+                    break;
+                }
+            }
+        }
+
+        if( service == null )
+        {
+            throw new ServiceImporterException( "No service importer with id '" + serviceId + "' was found" );
+        }
+
+        return service;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/importer/ServiceSelectorImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/ServiceSelectorImporter.java b/core/api/src/main/java/org/qi4j/api/service/importer/ServiceSelectorImporter.java
new file mode 100644
index 0000000..ad3c757
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/ServiceSelectorImporter.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.service.Availability;
+import org.qi4j.api.service.ImportedServiceDescriptor;
+import org.qi4j.api.service.ServiceFinder;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.ServiceImporterException;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.api.service.qualifier.ServiceQualifier;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+/**
+ * If several services are available with a given type, and you want to constrain
+ * the current module to use a specific one, then use this importer. Specify a
+ * Specification&lt;ServiceReference&lt;T&gt;&gt; criteria as meta-info for the service, which will be applied
+ * to the list of available services, and the first match will be chosen.
+ *
+ * This importer will avoid selecting itself, as could be possible if the ServiceQualifier.first()
+ * filter is used.
+ */
+public final class ServiceSelectorImporter<T>
+    implements ServiceImporter<T>
+{
+    @Structure
+    private ServiceFinder locator;
+
+    @Override
+    @SuppressWarnings( { "raw", "unchecked" } )
+    public T importService( ImportedServiceDescriptor serviceDescriptor )
+        throws ServiceImporterException
+    {
+        Specification<ServiceReference<?>> selector = serviceDescriptor.metaInfo( Specification.class );
+        Class serviceType = Iterables.first( serviceDescriptor.types() );
+        Iterable<ServiceReference<T>> services = locator.findServices( serviceType );
+        List<ServiceReference<T>> filteredServices = new ArrayList<>();
+        for( ServiceReference<T> service : services )
+        {
+            Specification selector1 = service.metaInfo( Specification.class );
+            if( selector1 != null && selector1 == selector )
+            {
+                continue;
+            }
+
+            filteredServices.add( service );
+        }
+        T service = ServiceQualifier.firstService( selector, filteredServices );
+        if( service == null )
+        {
+            throw new ServiceImporterException( "Could not find any service to import that matches the given specification for " + serviceDescriptor
+                .identity() );
+        }
+        return service;
+    }
+
+    @Override
+    public boolean isAvailable( T instance )
+    {
+        return !( instance instanceof Availability ) || ( (Availability) instance ).isAvailable();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/importer/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/package.html b/core/api/src/main/java/org/qi4j/api/service/importer/package.html
new file mode 100644
index 0000000..d960b3d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Service Importers.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/package.html b/core/api/src/main/java/org/qi4j/api/service/package.html
new file mode 100644
index 0000000..587937c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Service API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/Active.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/Active.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/Active.java
new file mode 100644
index 0000000..d06a749
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/Active.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Filter services based on whether they are active or not.
+ * <p>
+ * At an injection point you can do this:
+ * </p>
+ * <pre><code>
+ * &#64;Service &#64;Active MyService service;
+ * </code></pre>
+ * <p>
+ * to get only a service that is currently active.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Qualifier( Active.ActiveQualifier.class )
+public @interface Active
+{
+    /**
+     * Active Annotation Qualifier.
+     * See {@link Active}.
+     */
+    public final class ActiveQualifier
+        implements AnnotationQualifier<Active>
+    {
+        @Override
+        public <T> Specification<ServiceReference<?>> qualifier( Active active )
+        {
+            return ServiceQualifier.whereActive();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/AnnotationQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/AnnotationQualifier.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/AnnotationQualifier.java
new file mode 100644
index 0000000..7187ed1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/AnnotationQualifier.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Annotation;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Constructs a Specification for a given qualifier annotation
+ */
+public interface AnnotationQualifier<QUALIFIER extends Annotation>
+{
+    public <T> Specification<ServiceReference<?>> qualifier( QUALIFIER qualifier );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/Available.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/Available.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/Available.java
new file mode 100644
index 0000000..894451d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/Available.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Filter services based on whether they are available or not.
+ *
+ * At an injection point you can do this:
+ *
+ * <pre><code>
+ * &#64;Service &#64;Available MyService service;
+ * </code></pre>
+ * to get only a service that is currently available.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Qualifier( Available.AvailableQualifier.class )
+public @interface Available
+{
+    /**
+     * Available Annotation Qualifier.
+     * See {@link Available}.
+     */
+    public final class AvailableQualifier
+        implements AnnotationQualifier<Available>
+    {
+        @Override
+        public <T> Specification<ServiceReference<?>> qualifier( Available active )
+        {
+            return ServiceQualifier.whereAvailable();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/HasMetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/HasMetaInfo.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/HasMetaInfo.java
new file mode 100644
index 0000000..aac0702
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/HasMetaInfo.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2009, Niclas Hedhman. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Filter services based on Meta Info being declared on the Service.
+ * <p>
+ * Meta Info of any type can be set on the service during assembly, e.g.;
+ * </p>
+ * <pre><code>
+ * module.addService( MyService.class ).setMetaInfo( new MyCustomInfo(someData) );
+ * </code></pre>
+ * <p>
+ * and then at an injection point you can do this:
+ * </p>
+ * <pre><code>
+ * &#64;Service &#64;HasMetaInfo(MyCustomInfo.class) MyService service;
+ * </code></pre>
+ * <p>
+ * to get only a service that has a MyCustomInfo instance set as meta info.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Qualifier( HasMetaInfo.HasMetaInfoQualifier.class )
+@Documented
+public @interface HasMetaInfo
+{
+    /**
+     * The Class(es) needed to have been defined in the Service meta info for a qualifier to evaluate true.
+     *
+     * @return One or more classes that should be defined in the service's meta info for the service to be considered
+     *         qualified. If more than one class is defined, the {@code anded()} parameter will define if they must be
+     *         AND'ed or OR'ed together.
+     */
+    Class[] value();
+
+    /**
+     * True if the Classes defined in the value() field should be AND'ed instead of OR'ed.
+     *
+     * @return If true, all the Class types defined in {@code value()} must be defined for the service for it to be
+     *         qualified. If false, if any of the Class types defined in {@code value()} is defined for the service
+     *         the service is qualified.
+     */
+    boolean anded() default false;
+
+    /**
+     * HasMetaInfo Annotation Qualifier.
+     * See {@link HasMetaInfo}.
+     */
+    public static class HasMetaInfoQualifier
+        implements AnnotationQualifier<HasMetaInfo>
+    {
+        @Override
+        public <T> Specification<ServiceReference<?>> qualifier( final HasMetaInfo hasMetaInfo )
+        {
+            return new Specification<ServiceReference<?>>()
+            {
+                @Override
+                @SuppressWarnings( {"raw", "unchecked"} )
+                public boolean satisfiedBy( ServiceReference<?> service )
+                {
+                    for( Class metaInfoType : hasMetaInfo.value() )
+                    {
+                        Object metaInfo = service.metaInfo( metaInfoType );
+                        if( hasMetaInfo.anded() )
+                        {
+                            if( metaInfo == null )
+                            {
+                                return false;
+                            }
+                        }
+                        else
+                        {
+                            if( metaInfo != null )
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                    return false;
+                }
+            };
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/IdentifiedBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/IdentifiedBy.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/IdentifiedBy.java
new file mode 100644
index 0000000..2c715d7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/IdentifiedBy.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Filter services based on identity. Identity can be set during assembly, like so:
+ * <pre><code>
+ * module.addService(MyService.class).identifiedBy("myservice1");
+ * </code></pre>
+ *
+ * and then at an injection point you can do this:
+ * <pre><code>
+ * &#64;Service @IdentifiedBy("myservice1") MyService service;
+ * </code></pre>
+ * to get only a service identified "myservice1".
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Qualifier( IdentifiedBy.IdentifiedByQualifier.class )
+public @interface IdentifiedBy
+{
+    public abstract String value();
+
+    /**
+     * IdentifiedBy Annotation Qualifier.
+     * See {@link IdentifiedBy}.
+     */
+    public final class IdentifiedByQualifier
+        implements AnnotationQualifier<IdentifiedBy>
+    {
+        @Override
+        public <T> Specification<ServiceReference<?>> qualifier( IdentifiedBy identifiedBy )
+        {
+            return ServiceQualifier.withId( identifiedBy.value() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/Qualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/Qualifier.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/Qualifier.java
new file mode 100644
index 0000000..50efb1c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/Qualifier.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Annotation used to declare Qualifiers annotations.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+public @interface Qualifier
+{
+    public abstract Class<? extends AnnotationQualifier> value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceQualifier.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceQualifier.java
new file mode 100644
index 0000000..75410d6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceQualifier.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * This class helps you select a particular service
+ * from a list.
+ * <p>
+ * Provide a Selector which does the actual
+ * selection from the list. A common case is to select
+ * based on identity of the service, which you can do this way:
+ * </p>
+ *
+ * <pre><code>
+ * new ServiceQualifier&lt;MyService&gt;(services, ServiceQualifier.withId("someId"))
+ * </code></pre>
+ * <p>
+ * Many selectors can be combined by using firstOf. Example:
+ * </p>
+ * <pre><code>
+ * new ServiceQualifier&lt;MyService&gt;(services, firstOf(withTags("sometag"), firstActive(), first()))
+ * </code></pre>
+ * <p>
+ * This will pick a service that has the tag "sometag", or if none is found take the first active one. If no
+ * service is active, then the first service will be picked.
+ * </p>
+ */
+public abstract class ServiceQualifier
+{
+    public static <T> T firstService( Specification<ServiceReference<?>> qualifier,
+                                      Iterable<ServiceReference<T>> services
+    )
+    {
+        for( ServiceReference<T> service : services )
+        {
+            if( qualifier.satisfiedBy( service ) )
+            {
+                return service.get();
+            }
+        }
+        return null;
+    }
+
+    public static Specification<ServiceReference<?>> withId( final String anId )
+    {
+        return new Specification<ServiceReference<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( ServiceReference<?> service )
+            {
+                return service.identity().equals( anId );
+            }
+        };
+    }
+
+    public static Specification<ServiceReference<?>> whereMetaInfoIs( final Object metaInfo )
+    {
+        return new Specification<ServiceReference<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( ServiceReference<?> service )
+            {
+                Object metaObject = service.metaInfo( metaInfo.getClass() );
+                return metaObject != null && metaInfo.equals( metaObject );
+            }
+        };
+    }
+
+    public static Specification<ServiceReference<?>> whereActive()
+    {
+        return new Specification<ServiceReference<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( ServiceReference<?> service )
+            {
+                return service.isActive();
+            }
+        };
+    }
+
+    public static Specification<ServiceReference<?>> whereAvailable()
+    {
+        return new Specification<ServiceReference<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( ServiceReference<?> service )
+            {
+                return service.isAvailable();
+            }
+        };
+    }
+
+    public static Specification<ServiceReference<?>> withTags( final String... tags )
+    {
+        return new Specification<ServiceReference<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( ServiceReference<?> service )
+            {
+                ServiceTags serviceTags = service.metaInfo( ServiceTags.class );
+
+                return serviceTags != null && serviceTags.hasTags( tags );
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceTags.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceTags.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceTags.java
new file mode 100644
index 0000000..5ee8cb5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/ServiceTags.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.io.Serializable;
+
+/**
+ * Use this as metainfo about a Service to specify tags. Easiest way to set them on a service
+ * is to use the <code>ServiceDeclaration.taggedWith(String...)</code> method.
+ *
+ * These can be used in conjunction with the withTags() Service
+ * Selector.
+ */
+public final class ServiceTags
+    implements Serializable
+{
+    private String[] tags;
+
+    public ServiceTags( String... tags )
+    {
+        this.tags = tags;
+    }
+
+    public String[] tags()
+    {
+        return tags;
+    }
+
+    public boolean hasTag( String tag )
+    {
+        for( String serviceTag : tags )
+        {
+            if( serviceTag.equals( tag ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean hasTags( String... aTags )
+    {
+        for( String tag : aTags )
+        {
+            if( !hasTag( tag ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/Tagged.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/Tagged.java b/core/api/src/main/java/org/qi4j/api/service/qualifier/Tagged.java
new file mode 100644
index 0000000..3c8c0b7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/Tagged.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.service.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.functional.Specification;
+
+/**
+ * Filter services based on tags. Tags can be set using the ServiceTags meta-info, like so:
+ * <pre><code>
+ * module.addService(MyService.class).taggedWith(new ServiceTags("onetag","twotag"));
+ * </code></pre>
+ *
+ * and then at an injection point you can do this:
+ *
+ * <pre><code>
+ * &#64;Service &#64;Tagged("onetag") MyService service;
+ * </code></pre>
+ * to get only a service tagged with MyService. If several match only the first match is used.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Qualifier( Tagged.TaggedQualifier.class )
+public @interface Tagged
+{
+    public abstract String[] value();
+
+    /**
+     * Tagged Annotation Qualifier.
+     * See {@link Tagged}.
+     */
+    public final class TaggedQualifier
+        implements AnnotationQualifier<Tagged>
+    {
+        @Override
+        public Specification<ServiceReference<?>> qualifier( Tagged tagged )
+        {
+            return ServiceQualifier.withTags( tagged.value() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/service/qualifier/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/qualifier/package.html b/core/api/src/main/java/org/qi4j/api/service/qualifier/package.html
new file mode 100644
index 0000000..ec0edd3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/service/qualifier/package.html
@@ -0,0 +1,59 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Service Qualifiers.</h2>
+        <p>
+            The @Service injection is only able to specify the type of the service to be injected. If any other type of
+            qualification has to be done it has to be done manually but for common cases it's more convenient to use
+            annotations to do this filtering. This package contains annotations to perform this qualification.
+        </p>
+        <p>Example:</p>
+        <blockquote>
+            <pre>@Service @Tagged( "sometag" ) MyService service;</pre>
+        </blockquote>
+        <p>
+            This will only inject instances of MyService that have been tagged with "sometag". If none exist an
+            exception will occur at injection time since it is not optional.
+        </p>
+        <p>It also works with iterables:</p>
+        <blockquote>
+            <pre>@Service @Tagged( "sometag" ) Iterable&lt;MyService&gt; services;</pre>
+        </blockquote>
+        <p>
+            The qualification will be evaluated upon each call to iterator(), and since the qualifier has access to a
+            ServiceReference, which contains the isActive() method, it can even provide some dynamicity.
+        </p>
+        <blockquote>
+            <pre>@Service @Active Iterable&lt;SomeImportedService&gt; importedServices;</pre>
+        </blockquote>
+        <p>
+            Let's say these SomeImportedService are only sometimes available. Then whenever iterator() is called the
+            {@link org.qi4j.api.service.qualifier.Active} tag can kick in and filter out those whose
+            ServiceReference.isActive() returns false.
+        </p>
+        <p>Standard ones defined in the API are:</p>
+        <ul>
+            <li>{@link org.qi4j.api.service.qualifier.Active}</li>
+            <li>{@link org.qi4j.api.service.qualifier.Available}</li>
+            <li>{@link org.qi4j.api.service.qualifier.HasMetaInfo}</li>
+            <li>{@link org.qi4j.api.service.qualifier.IdentifiedBy}</li>
+            <li>{@link org.qi4j.api.service.qualifier.Tagged}</li>
+        </ul>
+        <p>See tests and API for more examples, and how to implement your own qualifiers.</p>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/GenericSideEffect.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/GenericSideEffect.java b/core/api/src/main/java/org/qi4j/api/sideeffect/GenericSideEffect.java
new file mode 100644
index 0000000..167c1ef
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/GenericSideEffect.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.sideeffect;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * Base class for generic SideEffects.
+ */
+public abstract class GenericSideEffect
+    extends SideEffectOf<InvocationHandler>
+    implements InvocationHandler
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object invoke( final Object proxy, final Method method, final Object[] args )
+        throws Throwable
+    {
+        invoke( method, args );
+        return null;
+    }
+
+    /**
+     * Convenience method to be overridden by subclasses in order to avoid returning null, as returned value from side
+     * effects is not taken in consideration.
+     *
+     * @param method the method that was invoked
+     * @param args   the arguments of the method invocation
+     *
+     * @throws Throwable - the exception to throw from the method invocation on the proxy instance. The exception's type
+     *                   must be assignable either to any of the exception types declared in the throws clause of the
+     *                   interface method or to the unchecked exception types {code}java.lang.RuntimeException{code}
+     *                   or {code}java.lang.Error{code}. If a checked exception is thrown by this method that is not
+     *                   assignable to any of the exception types declared in the throws clause of the interface method,
+     *                   then an UndeclaredThrowableException containing the exception that was thrown by this method
+     *                   will be thrown by the method invocation on the proxy instance.
+     */
+    protected void invoke( final Method method, final Object[] args )
+        throws Throwable
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java
new file mode 100644
index 0000000..85e8610
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.sideeffect;
+
+/**
+ * SideEffect Descriptor.
+ */
+public interface SideEffectDescriptor
+{
+    Class<?> modifierClass();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectOf.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectOf.java b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectOf.java
new file mode 100644
index 0000000..39113cc
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectOf.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.sideeffect;
+
+import org.qi4j.api.sideeffect.internal.SideEffectFor;
+
+/**
+ * Base class for SideEffects. It introduces a typed "next" pointer
+ * that SideEffects can use to get the result of the original invocation.
+ * <p>
+ * Generic SideEffects should subclass {@link GenericSideEffect} instead.
+ * </p>
+ * <p>
+ * SideEffects implementations must be thread-safe in their implementation,
+ * as multiple threads may share instances.
+ * </p>
+ */
+public abstract class SideEffectOf<T>
+{
+    final
+    @SideEffectFor
+    protected T result = null;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffects.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffects.java b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffects.java
new file mode 100644
index 0000000..bd2e525
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffects.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.sideeffect;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used by composites and mixins to declare what SideEffects
+ * should apply to the type or specific method.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface SideEffects
+{
+    Class<?>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectsDescriptor.java b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectsDescriptor.java
new file mode 100644
index 0000000..9f569ea
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectsDescriptor.java
@@ -0,0 +1,24 @@
+/*  Copyright 2008 Edward Yakop.
+*
+* 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.qi4j.api.sideeffect;
+
+/**
+ * SideEffects Descriptor.
+ */
+public interface SideEffectsDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/internal/SideEffectFor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/internal/SideEffectFor.java b/core/api/src/main/java/org/qi4j/api/sideeffect/internal/SideEffectFor.java
new file mode 100644
index 0000000..1ab3383
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/internal/SideEffectFor.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.sideeffect.internal;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * This annotation is required once in each SideEffect, to mark the
+ * field where the element providing the invocation result should be
+ * injected.
+ * <p>
+ * The type of the field must be of the same type as the SideEffect
+ * itself, or an InvocationHandler.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ * public interface MyStuff
+ * {
+ *     SomeResult doSomething();
+ * }
+ *
+ * public class MyStuffSideEffect
+ *     implements MyStuff
+ * {
+ *     &#64;SideEffectFor MyStuff next;
+ *
+ *     public SomeResult doSomething()
+ *     {
+ *          SomeResult result = next.doSomething();
+ *
+ *         // HERE DO THE SIDEEFFECT STUFF.
+ *
+ *          return result; // Result value is ignored, null would work too.
+ *     }
+ * }
+ * </code></pre>
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.FIELD, ElementType.PARAMETER })
+@Documented
+@InjectionScope
+public @interface SideEffectFor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/internal/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/internal/package.html b/core/api/src/main/java/org/qi4j/api/sideeffect/internal/package.html
new file mode 100644
index 0000000..269774e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/internal/package.html
@@ -0,0 +1,25 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h1>Internal/Private package for the API.</h1>
+        <p>
+            This is an internal package, and no classes in this package is part of the API and compatibility
+            with these classes will not be attempted.
+        </p>
+    </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/sideeffect/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/sideeffect/package.html b/core/api/src/main/java/org/qi4j/api/sideeffect/package.html
new file mode 100644
index 0000000..a658adb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/sideeffect/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>SideEffect API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/Application.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/Application.java b/core/api/src/main/java/org/qi4j/api/structure/Application.java
new file mode 100644
index 0000000..6023942
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/Application.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2008, Niclas Hedhman.
+ *
+ * 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.qi4j.api.structure;
+
+import org.qi4j.api.activation.Activation;
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+
+/**
+ * The Application represents a whole Zest application.
+ */
+public interface Application
+    extends ActivationEventListenerRegistration, Activation, MetaInfoHolder
+{
+    /**
+     * Application modes.
+     */
+    public enum Mode
+    {
+        /**
+         * Should be used for unit test runs. Created files etc. should be cleaned up between runs.
+         */
+        test,
+        /**
+         * Should be used during development. Typically create in-memory databases etc.
+         */
+        development,
+        /**
+         * Should be used in QA environments, and other production-like settings where different set of external
+         * resources are utilized.
+         */
+        staging,
+        /**
+         * Should be used in production. All databases are persistent on disk etc.
+         */
+        production
+    }
+
+    /**
+     * @return Application name
+     */
+    String name();
+
+    /**
+     * The version of the application. This can be in any format, but
+     * most likely will follow the Dewey format, i.e. x.y.z.
+     *
+     * @return the version of the application
+     */
+    String version();
+
+    /**
+     * @return Application Mode
+     */
+    Mode mode();
+
+    /**
+     * Find a Layer.
+     *
+     * @param layerName Layer name
+     * @return Found Layer, never returns null
+     * @throws IllegalArgumentException if there's no such Layer
+     */
+    Layer findLayer( String layerName )
+        throws IllegalArgumentException;
+
+    /**
+     * Find a Module.
+     *
+     * @param layerName Layer name
+     * @param moduleName Module name
+     * @return Found Module, never returns null
+     * @throws IllegalArgumentException if there's no such Module
+     */
+    Module findModule( String layerName, String moduleName )
+        throws IllegalArgumentException;
+
+    /**
+     * @return Application Descriptor
+     */
+    ApplicationDescriptor descriptor();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java b/core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java
new file mode 100644
index 0000000..b33f134
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.structure;
+
+import org.qi4j.api.Qi4j;
+import org.qi4j.functional.VisitableHierarchy;
+
+/**
+ * Application Descriptor.
+ */
+public interface ApplicationDescriptor
+    extends VisitableHierarchy<Object, Object>
+{
+    /**
+     * Create a new instance of the Application.
+     * @param runtime Zest Runtime
+     * @param importedServiceInstances Imported Services instances
+     * @return a new instance of the Application.
+     */
+    Application newInstance( Qi4j runtime, Object... importedServiceInstances );
+
+    /**
+     * @return the Application's name
+     */
+    String name();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/Layer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/Layer.java b/core/api/src/main/java/org/qi4j/api/structure/Layer.java
new file mode 100644
index 0000000..4268764
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/Layer.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2008, Niclas Hedhman.
+ *
+ * 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.qi4j.api.structure;
+
+import org.qi4j.api.activation.Activation;
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+
+/**
+ * The Layer represents a single layer in a Zest application.
+ */
+public interface Layer
+    extends ActivationEventListenerRegistration, Activation, MetaInfoHolder
+{
+    /**
+     * @return the Layer's name
+     */
+    String name();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java b/core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java
new file mode 100644
index 0000000..db0c56a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.structure;
+
+/**
+ * Layer Descriptor.
+ */
+public interface LayerDescriptor
+{
+
+    /**
+     * @return the Layer's name
+     */
+    String name();
+
+    /**
+     * @return Layers used by this Layer
+     */
+    UsedLayersDescriptor usedLayers();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/MetaInfoHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/MetaInfoHolder.java b/core/api/src/main/java/org/qi4j/api/structure/MetaInfoHolder.java
new file mode 100644
index 0000000..f497a75
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/MetaInfoHolder.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.structure;
+
+/**
+ * MetaInfo holder.
+ */
+public interface MetaInfoHolder
+{
+
+    /**
+     * Get metadata that implements the given type.
+     * The info is registered during assembly of the application.
+     *
+     * @param infoType the type of metadata to be returned
+     *
+     * @return the metadata for the given type, or <code>null</code> if
+     *         no such metadata has been registered
+     */
+    <T> T metaInfo( Class<T> infoType );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/Module.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/Module.java b/core/api/src/main/java/org/qi4j/api/structure/Module.java
new file mode 100644
index 0000000..47ffab8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/Module.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2008, Niclas Hedhman.
+ *
+ * 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.qi4j.api.structure;
+
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+import org.qi4j.api.composite.TransientBuilderFactory;
+import org.qi4j.api.composite.TransientDescriptor;
+import org.qi4j.api.entity.EntityDescriptor;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.object.ObjectDescriptor;
+import org.qi4j.api.object.ObjectFactory;
+import org.qi4j.api.query.QueryBuilderFactory;
+import org.qi4j.api.service.ServiceFinder;
+import org.qi4j.api.unitofwork.UnitOfWorkFactory;
+import org.qi4j.api.value.ValueBuilderFactory;
+import org.qi4j.api.value.ValueDescriptor;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Visitable;
+import org.qi4j.functional.Visitor;
+
+/**
+ * API for interacting with a Module. Instances
+ * of this can be accessed by using the {@link Structure}
+ * injection scope.
+ */
+public interface Module
+    extends ActivationEventListenerRegistration,
+            MetaInfoHolder,
+            ObjectFactory,
+            TransientBuilderFactory,
+            ValueBuilderFactory,
+            UnitOfWorkFactory,
+            QueryBuilderFactory,
+            ServiceFinder
+{
+
+    /**
+     * @return the Module's name
+     */
+    String name();
+
+    /**
+     * @return the Module's ClassLoader
+     */
+    ClassLoader classLoader();
+
+    /**
+     * @param typeName name of a transient composite type
+     * @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
+     */
+    TransientDescriptor transientDescriptor( String typeName );
+
+    /**
+     * @param typeName name of an entity composite type
+     * @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
+     */
+    EntityDescriptor entityDescriptor( String typeName );
+
+    /**
+     * @param typeName name of an object type
+     * @return the descriptor for an object or null if the class could not be found or the object is not visible
+     */
+    ObjectDescriptor objectDescriptor( String typeName );
+
+    /**
+     * @param typeName name of a value composite type
+     * @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
+     */
+    ValueDescriptor valueDescriptor( String typeName );
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/ModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/ModuleDescriptor.java b/core/api/src/main/java/org/qi4j/api/structure/ModuleDescriptor.java
new file mode 100644
index 0000000..ffb7b9b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/ModuleDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.structure;
+
+/**
+ * Module Descriptor.
+ */
+public interface ModuleDescriptor
+{
+    String name();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/UsedLayersDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/UsedLayersDescriptor.java b/core/api/src/main/java/org/qi4j/api/structure/UsedLayersDescriptor.java
new file mode 100644
index 0000000..ee530b7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/UsedLayersDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.structure;
+
+/**
+ * Used Layers Descriptor.
+ */
+public interface UsedLayersDescriptor
+{
+    Iterable<? extends LayerDescriptor> layers();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/structure/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/structure/package.html b/core/api/src/main/java/org/qi4j/api/structure/package.html
new file mode 100644
index 0000000..3134a90
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/structure/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Application Structure API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/CollectionType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/CollectionType.java b/core/api/src/main/java/org/qi4j/api/type/CollectionType.java
new file mode 100644
index 0000000..1b85b5f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/CollectionType.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.type;
+
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.util.Classes;
+
+/**
+ * Collection ValueType.
+ * <p>This handles Collection, List and Set types.</p>
+ */
+public final class CollectionType
+    extends ValueType
+{
+
+    public static boolean isCollection( Type type )
+    {
+        Class<?> cl = Classes.RAW_CLASS.map( type );
+        return cl.equals( Collection.class ) || cl.equals( List.class ) || cl.equals( Set.class );
+    }
+
+    public static CollectionType collectionOf( Class<?> collectedType )
+    {
+        return new CollectionType( Collection.class, ValueType.of( collectedType ) );
+    }
+
+    public static CollectionType listOf( Class<?> collectedType )
+    {
+        return new CollectionType( List.class, ValueType.of( collectedType ) );
+    }
+
+    public static CollectionType setOf( Class<?> collectedType )
+    {
+        return new CollectionType( Set.class, ValueType.of( collectedType ) );
+    }
+    private ValueType collectedType;
+
+    public CollectionType( Class<?> type, ValueType collectedType )
+    {
+        super( type );
+        this.collectedType = collectedType;
+        if( !isCollection( type ) )
+        {
+            throw new IllegalArgumentException( type + " is not a Collection, List or Set." );
+        }
+    }
+
+    public ValueType collectedType()
+    {
+        return collectedType;
+    }
+
+    @Override
+    public String toString()
+    {
+        return super.toString() + "<" + collectedType + ">";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/EnumType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/EnumType.java b/core/api/src/main/java/org/qi4j/api/type/EnumType.java
new file mode 100644
index 0000000..aa4ff31
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/EnumType.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.type;
+
+import java.lang.reflect.Type;
+
+/**
+ * Enum ValueType.
+ */
+public final class EnumType
+    extends ValueType
+{
+
+    public static boolean isEnum( Type type )
+    {
+        if( type instanceof Class )
+        {
+            Class<?> typeClass = (Class) type;
+            return ( typeClass.isEnum() );
+        }
+        return false;
+    }
+
+    public static EnumType of( Class<?> type )
+    {
+        return new EnumType( type );
+    }
+
+    public EnumType( Class<?> type )
+    {
+        super( type );
+        if( !isEnum( type ) )
+        {
+            throw new IllegalArgumentException( type + " is not an Enum." );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/HasTypes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/HasTypes.java b/core/api/src/main/java/org/qi4j/api/type/HasTypes.java
new file mode 100644
index 0000000..0ad36a4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/HasTypes.java
@@ -0,0 +1,27 @@
+/*
+ * 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.qi4j.api.type;
+
+/**
+ * Has types.
+ */
+public interface HasTypes
+{
+    Iterable<Class<?>> types();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/type/MapType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/MapType.java b/core/api/src/main/java/org/qi4j/api/type/MapType.java
new file mode 100644
index 0000000..1cb1700
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/MapType.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.type;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import org.qi4j.api.util.Classes;
+
+/**
+ * Map ValueType.
+ * <p>This handles instances of Map.</p>
+ */
+public final class MapType
+    extends ValueType
+{
+
+    private ValueType keyType;
+    private ValueType valueType;
+    private final Serialization.Variant variant;
+
+    public static boolean isMap( Type type )
+    {
+        Class<?> cl = Classes.RAW_CLASS.map( type );
+        return Map.class.isAssignableFrom( cl );
+    }
+
+    public static MapType of( Class<?> keyType, Class<?> valueType )
+    {
+        return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ) );
+    }
+
+    public static MapType of( Class<?> keyType, Class<?> valueType, Serialization.Variant variant )
+    {
+        return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ), variant );
+    }
+
+    public MapType( Class<?> type, ValueType keyType, ValueType valueType )
+    {
+        this( type, keyType, valueType, Serialization.Variant.entry );
+    }
+
+    public MapType( Class<?> type, ValueType keyType, ValueType valueType, Serialization.Variant variant )
+    {
+        super( type );
+        this.keyType = keyType;
+        this.valueType = valueType;
+        this.variant = variant;
+        if( !isMap( type ) )
+        {
+            throw new IllegalArgumentException( type + " is not a Map." );
+        }
+    }
+
+    public ValueType keyType()
+    {
+        return keyType;
+    }
+
+    public ValueType valueType()
+    {
+        return valueType;
+    }
+
+    public Serialization.Variant variant()
+    {
+        return variant;
+    }
+
+    @Override
+    public String toString()
+    {
+        return super.toString() + "<" + keyType + "," + valueType + ">";
+    }
+}


[25/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembler.java
new file mode 100644
index 0000000..cb5dfda
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembler.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Implement this interface to create the root class that
+ * is responsible for assembling your entire application.
+ *
+ * Model introspectors will instantiate this class and call assemble
+ * to create the application, which will then be visited to get
+ * information about its structure.
+ *
+ * Application deployment servers will instantiate this, call assemble,
+ * and then activate the created application, which will be the runtime
+ * instance that forms your application.
+ */
+public interface ApplicationAssembler
+{
+    ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblerAdapter.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblerAdapter.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblerAdapter.java
new file mode 100644
index 0000000..1025f7a
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblerAdapter.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Helper base class for application assemblers that
+ * want to either create applications using only one layer/module,
+ * or that wants to create pancake-layered applications.
+ */
+public class ApplicationAssemblerAdapter
+    implements ApplicationAssembler
+{
+    private final Assembler[][][] assemblers;
+
+    protected ApplicationAssemblerAdapter( Assembler assembler )
+    {
+        this.assemblers = new Assembler[][][]{ { { assembler } } };
+    }
+
+    protected ApplicationAssemblerAdapter( Assembler[][][] assemblers )
+    {
+        this.assemblers = assemblers;
+    }
+
+    @Override
+    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+        throws AssemblyException
+    {
+        return applicationFactory.newApplicationAssembly( assemblers );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembly.java
new file mode 100644
index 0000000..b14d554
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssembly.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2008 Niclas Hedhman. All rights Reserved.
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.structure.Application;
+
+/**
+ * An application assembly. This can be used by Assemblers to programmatically
+ * set the name of the application and create new layers.
+ */
+public interface ApplicationAssembly
+{
+    /**
+     * Create a new layer assembly
+     *
+     * @param name of the new layer
+     *
+     * @return a LayerAssembly instance
+     */
+    LayerAssembly layer( String name );
+
+    /**
+     * Get an assembly for a particular Module. If this is called many times with the same names, then the same module
+     * is affected.
+     *
+     * @param layerName The name of the Layer
+     * @param moduleName The name of the Module to retrieve or create.
+     * @return The ModuleAssembly for the Module.
+     */
+    ModuleAssembly module( String layerName, String moduleName );
+    
+    /**
+     * Get the currently set name of the application
+     *
+     * @return the name of the application
+     */
+    String name();
+
+    /**
+     * Get the currently set mode of the application
+     *
+     * @return the application mode
+     */
+    Application.Mode mode();
+
+    /**
+     * Set the name of the application
+     *
+     * @param name of the application
+     *
+     * @return the assembly
+     */
+    ApplicationAssembly setName( String name );
+
+    /**
+     * Set the version of the application. This can be in any format, but
+     * most likely will follow the Dewey format, i.e. x.y.z.
+     *
+     * @param version of the application
+     *
+     * @return the assembly
+     */
+    ApplicationAssembly setVersion( String version );
+
+    /**
+     * Set the application mode. This will be set to "production" by default. You can
+     * set the system property "mode" to either "development", "satisfiedBy" or "production"
+     * to explicitly set the mode. If that is not an option, then call this method
+     * during assembly to set the mode. The mode may then be queried by assemblers,
+     * and they may assemble the application differentlly depending on this setting.
+     *
+     * @param mode the application mode
+     *
+     * @return the assembly
+     */
+    ApplicationAssembly setMode( Application.Mode mode );
+
+    ApplicationAssembly setMetaInfo( Object info );
+
+    /**
+     * Set the application activators. Activators are executed in order around the
+     * Application activation and passivation.
+     *
+     * @param activators the application activators
+     * @return the assembly
+     */
+    @SuppressWarnings( { "unchecked","varargs" } )
+    ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators );
+
+    <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblyFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblyFactory.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblyFactory.java
new file mode 100644
index 0000000..5d86bf9
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationAssemblyFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+/**
+ * Factory for creating new Zest application assemblies. Typically
+ * you will implement one or more Assemblers, wrap them in an ApplicationAssembler,
+ * which then uses this factory to assemble and create applications.
+ */
+public interface ApplicationAssemblyFactory
+{
+    /**
+     * Create a new application with one layer and one module.
+     *
+     * @param assembler the assembler for the single module
+     *
+     * @return the application instance
+     *
+     * @throws AssemblyException if the application could not be assembled
+     */
+    ApplicationAssembly newApplicationAssembly( Assembler assembler )
+        throws AssemblyException;
+
+    /**
+     * Create a new application with the same amount of layers
+     * as the first array size, with modules according to the second array size,
+     * and then use the third array for assemblers of each module. This gives you
+     * a simple way to create "pancake" layered applications.
+     *
+     * @param assemblers the set of assemblers for the application
+     *
+     * @return the application instance
+     *
+     * @throws AssemblyException if the application could not be assembled
+     */
+    ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers )
+        throws AssemblyException;
+
+    /**
+     * Create a new ApplicationAssembly that can be used for the above method.
+     *
+     * @return a new ApplicationAssembly
+     */
+    ApplicationAssembly newApplicationAssembly();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationModelFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationModelFactory.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationModelFactory.java
new file mode 100644
index 0000000..c8ea46f
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationModelFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+import org.qi4j.api.structure.ApplicationDescriptor;
+
+/**
+ * Factory for ApplicationModelSPI's. Takes an ApplicationAssembly, executes it,
+ * and builds an application model from it, which can then be instantiated and activated.
+ */
+public interface ApplicationModelFactory
+{
+    ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationName.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationName.java
new file mode 100644
index 0000000..d2ca628
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ApplicationName.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Set the name of the application
+ */
+public final class ApplicationName
+    implements Assembler
+{
+    private String name;
+
+    public ApplicationName( String name )
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.layer().application().setName( name );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assembler.java
new file mode 100644
index 0000000..b2ffe34
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assembler.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * ModuleAssemblies are configured by Assemblers. This
+ * is the interface you would implement in order to provide
+ * all configuration and additional metainfo that is needed
+ * to instantiate a Zest application.
+ */
+public interface Assembler
+{
+    /**
+     * Assemblers receive a callback to the ModuleAssembly
+     * they are supposed to configure. They can use this
+     * to register objects, composites, services etc. and
+     * the additional metadata that may exist for these
+     * artifacts.
+     * <p>
+     * An Assembler may create new Modules by calling
+     * {@link org.qi4j.bootstrap.ModuleAssembly#layer()} and
+     * then {@link LayerAssembly#module(String)} (String)}.
+     * This allows an Assembler to bootstrap an entire Layer with
+     * more Modules.
+     * </p>
+     * @param module the Module to assemble
+     *
+     * @throws AssemblyException thrown if the assembler tries to do something illegal
+     */
+    void assemble( ModuleAssembly module )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblerCollection.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblerCollection.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblerCollection.java
new file mode 100644
index 0000000..670d88b
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblerCollection.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.bootstrap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * Assembler that delegates to a collection of Assemblers.
+ * <p>
+ * Makes it easy to collect and compose assemblers into bigger assemblers.
+ * </p>
+ */
+public final class AssemblerCollection
+    implements Assembler
+{
+    Collection<Assembler> assemblers;
+
+    public AssemblerCollection( Assembler... assemblers )
+    {
+        this.assemblers = Arrays.asList( assemblers );
+    }
+
+    @SafeVarargs
+    public AssemblerCollection( Class<? extends Assembler>... assemblyClasses )
+        throws AssemblyException
+    {
+        assemblers = new ArrayList<>();
+        for( Class<? extends Assembler> assemblyClass : assemblyClasses )
+        {
+            try
+            {
+                Assembler assembler = assemblyClass.newInstance();
+                assemblers.add( assembler );
+            }
+            catch( Exception e )
+            {
+                throw new AssemblyException( "Could not instantiate assembly with class " + assemblyClass.getName(), e );
+            }
+        }
+    }
+
+    public AssemblerCollection( Collection<Assembler> assemblers )
+    {
+        this.assemblers = assemblers;
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        for( Assembler assembler : assemblers )
+        {
+            assembler.assemble( module );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assemblers.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assemblers.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assemblers.java
new file mode 100644
index 0000000..6fdcd80
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Assemblers.java
@@ -0,0 +1,446 @@
+/*
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+/**
+ * Assembler adapters for common use cases (visibility, identity, configuration).
+ */
+public class Assemblers
+{
+    private Assemblers()
+    {
+    }
+
+    /**
+     * Assembler with Visibility interface.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public interface Visible<AssemblerType>
+        extends Assembler
+    {
+        /**
+         * Set Visibility.
+         * @param visibility Visibility
+         * @return This Assembler instance
+         */
+        AssemblerType visibleIn( org.qi4j.api.common.Visibility visibility );
+
+        /**
+         * Get Visibility.
+         * <p>Default to {@link org.qi4j.api.common.Visibility#module}.</p>
+         * @return Visibility
+         */
+        org.qi4j.api.common.Visibility visibility();
+    }
+
+    /**
+     * Assembler with Identity interface.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public interface Identifiable<AssemblerType>
+        extends Assembler
+    {
+        /**
+         * Set Identity.
+         * @param identity Identity
+         * @return This Assembler instance
+         */
+        AssemblerType identifiedBy( String identity );
+
+        /**
+         * @return {@literal true} if {@link #identity()} do not return null, {@literal false} otherwise
+         */
+        boolean hasIdentity();
+
+        /**
+         * Get Identity.
+         * <p>Default to {@literal null}.</p>
+         * @return Identity
+         */
+        String identity();
+    }
+
+    /**
+     * Assembler with Configuration interface.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public interface Configurable<AssemblerType>
+        extends Assembler
+    {
+        /**
+         * Set Configuration Module and Visibility.
+         * @param configModule Configuration Module
+         * @param configVisibility Configuration Visiblity
+         * @return This Assembler instance
+         */
+        AssemblerType withConfig( ModuleAssembly configModule,
+                                  org.qi4j.api.common.Visibility configVisibility );
+
+        /**
+         * @return {@literal true} if {@link #configModule() ()} do not return null, {@literal false} otherwise
+         */
+        boolean hasConfig();
+
+        /**
+         * Get Configuration Module.
+         * <p>Default to {@literal null}.</p>
+         * @return Configuration Module
+         */
+        ModuleAssembly configModule();
+
+        /**
+         * Get Configuration Visibility.
+         * <p>Default to {@link org.qi4j.api.common.Visibility#module}.</p>
+         * @return Configuration Visibility
+         */
+        org.qi4j.api.common.Visibility configVisibility();
+    }
+
+    /**
+     * Assembler with Visibility adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class Visibility<AssemblerType>
+        implements Visible<AssemblerType>
+    {
+        private org.qi4j.api.common.Visibility visibility = org.qi4j.api.common.Visibility.module;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType visibleIn( org.qi4j.api.common.Visibility visibility )
+        {
+            this.visibility = visibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility visibility()
+        {
+            return visibility;
+        }
+    }
+
+    /**
+     * Assembler with Identity adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class Identity<AssemblerType>
+        implements Identifiable<AssemblerType>
+    {
+        private String identity;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType identifiedBy( String identity )
+        {
+            this.identity = identity;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasIdentity()
+        {
+            return identity != null;
+        }
+
+        @Override
+        public final String identity()
+        {
+            return identity;
+        }
+    }
+
+    /**
+     * Assembler with Configuration adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class Config<AssemblerType>
+        implements Configurable<AssemblerType>
+    {
+        private ModuleAssembly configModule = null;
+        private org.qi4j.api.common.Visibility configVisibility = org.qi4j.api.common.Visibility.module;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType withConfig( ModuleAssembly configModule,
+                                               org.qi4j.api.common.Visibility configVisibility )
+        {
+            this.configModule = configModule;
+            this.configVisibility = configVisibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasConfig()
+        {
+            return configModule != null;
+        }
+
+        @Override
+        public final ModuleAssembly configModule()
+        {
+            return configModule;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility configVisibility()
+        {
+            return configVisibility;
+        }
+    }
+
+    /**
+     * Assembler with Visibility and Identity adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class VisibilityIdentity<AssemblerType>
+        implements Visible<AssemblerType>,
+                   Identifiable<AssemblerType>
+    {
+        private org.qi4j.api.common.Visibility visibility = org.qi4j.api.common.Visibility.module;
+        private String identity;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType visibleIn( org.qi4j.api.common.Visibility visibility )
+        {
+            this.visibility = visibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility visibility()
+        {
+            return visibility;
+        }
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType identifiedBy( String identity )
+        {
+            this.identity = identity;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasIdentity()
+        {
+            return identity != null;
+        }
+
+        @Override
+        public final String identity()
+        {
+            return identity;
+        }
+    }
+
+    /**
+     * Assembler with Visibility and Configuration adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class VisibilityConfig<AssemblerType>
+        implements Visible<AssemblerType>,
+                   Configurable<AssemblerType>
+    {
+        private org.qi4j.api.common.Visibility visibility = org.qi4j.api.common.Visibility.module;
+        private ModuleAssembly configModule = null;
+        private org.qi4j.api.common.Visibility configVisibility = org.qi4j.api.common.Visibility.module;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType visibleIn( org.qi4j.api.common.Visibility visibility )
+        {
+            this.visibility = visibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility visibility()
+        {
+            return visibility;
+        }
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType withConfig( ModuleAssembly configModule,
+                                               org.qi4j.api.common.Visibility configVisibility )
+        {
+            this.configModule = configModule;
+            this.configVisibility = configVisibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasConfig()
+        {
+            return configModule != null;
+        }
+
+        @Override
+        public final ModuleAssembly configModule()
+        {
+            return configModule;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility configVisibility()
+        {
+            return configVisibility;
+        }
+    }
+
+    /**
+     * Assembler with Identity and Configuration adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class IdentityConfig<AssemblerType>
+        implements Identifiable<AssemblerType>,
+                   Configurable<AssemblerType>
+    {
+        private String identity;
+        private ModuleAssembly configModule = null;
+        private org.qi4j.api.common.Visibility configVisibility = org.qi4j.api.common.Visibility.module;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType identifiedBy( String identity )
+        {
+            this.identity = identity;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasIdentity()
+        {
+            return identity != null;
+        }
+
+        @Override
+        public final String identity()
+        {
+            return identity;
+        }
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType withConfig( ModuleAssembly configModule,
+                                               org.qi4j.api.common.Visibility configVisibility )
+        {
+            this.configModule = configModule;
+            this.configVisibility = configVisibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasConfig()
+        {
+            return configModule != null;
+        }
+
+        @Override
+        public final ModuleAssembly configModule()
+        {
+            return configModule;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility configVisibility()
+        {
+            return configVisibility;
+        }
+    }
+
+    /**
+     * Assembler with Visibility, Identity and Configuation adapter.
+     * @param <AssemblerType> Parameterized type of Assembler
+     */
+    public static abstract class VisibilityIdentityConfig<AssemblerType>
+        implements Visible<AssemblerType>,
+                   Identifiable<AssemblerType>,
+                   Configurable<AssemblerType>
+    {
+        private org.qi4j.api.common.Visibility visibility = org.qi4j.api.common.Visibility.module;
+        private String identity;
+        private ModuleAssembly configModule = null;
+        private org.qi4j.api.common.Visibility configVisibility = org.qi4j.api.common.Visibility.module;
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType visibleIn( org.qi4j.api.common.Visibility visibility )
+        {
+            this.visibility = visibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility visibility()
+        {
+            return visibility;
+        }
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType identifiedBy( String identity )
+        {
+            this.identity = identity;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasIdentity()
+        {
+            return identity != null;
+        }
+
+        @Override
+        public final String identity()
+        {
+            return identity;
+        }
+
+        @Override
+        @SuppressWarnings( "unchecked" )
+        public final AssemblerType withConfig( ModuleAssembly configModule,
+                                               org.qi4j.api.common.Visibility configVisibility )
+        {
+            this.configModule = configModule;
+            this.configVisibility = configVisibility;
+            return (AssemblerType) this;
+        }
+
+        @Override
+        public final boolean hasConfig()
+        {
+            return configModule != null;
+        }
+
+        @Override
+        public final ModuleAssembly configModule()
+        {
+            return configModule;
+        }
+
+        @Override
+        public final org.qi4j.api.common.Visibility configVisibility()
+        {
+            return configVisibility;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyException.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyException.java
new file mode 100644
index 0000000..1c75cd9
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyException.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Thrown by ModuleAssembly if the Assembler tries to make an invalid assembly.
+ */
+public class AssemblyException
+    extends Exception
+{
+    public AssemblyException()
+    {
+    }
+
+    public AssemblyException( String string )
+    {
+        super( string );
+    }
+
+    public AssemblyException( String string, Throwable throwable )
+    {
+        super( string, throwable );
+    }
+
+    public AssemblyException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblySpecifications.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblySpecifications.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblySpecifications.java
new file mode 100644
index 0000000..66fafc7
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblySpecifications.java
@@ -0,0 +1,49 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+
+/**
+ * Utility specifications for Assemblies.
+ */
+public class AssemblySpecifications
+{
+    public static Specification<HasTypes> types( final Class... types )
+    {
+        return new Specification<HasTypes>()
+        {
+            @Override
+            public boolean satisfiedBy( HasTypes item )
+            {
+
+                for( Class<?> type : item.types() )
+                {
+                    if( Specifications.in( types ).satisfiedBy( type ) )
+                    {
+                        return true;
+                    }
+                }
+                return false;
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitor.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitor.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitor.java
new file mode 100644
index 0000000..c1afb59
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitor.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Visitor interface to visit the whole or parts of an assembly.
+ * <p>
+ * Implement this interface and call visit() on ApplicationAssembly, LayerAssembly or ModuleAssembly.
+ * </p>
+ * <p>
+ * This can be used to, for example, add metadata to all entities, add concerns on composites, or similar.
+ * </p>
+ */
+public interface AssemblyVisitor<ThrowableType extends Throwable>
+{
+    public void visitApplication( ApplicationAssembly assembly )
+        throws ThrowableType;
+
+    public void visitLayer( LayerAssembly assembly )
+        throws ThrowableType;
+
+    public void visitModule( ModuleAssembly assembly )
+        throws ThrowableType;
+
+    public void visitComposite( TransientDeclaration declaration )
+        throws ThrowableType;
+
+    public void visitEntity( EntityDeclaration declaration )
+        throws ThrowableType;
+
+    public void visitService( ServiceDeclaration declaration )
+        throws ThrowableType;
+
+    public void visitImportedService( ImportedServiceDeclaration declaration )
+        throws ThrowableType;
+
+    public void visitValue( ValueDeclaration declaration )
+        throws ThrowableType;
+
+    public void visitObject( ObjectDeclaration declaration )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitorAdapter.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitorAdapter.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitorAdapter.java
new file mode 100644
index 0000000..904bb5e
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssemblyVisitorAdapter.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Base class for assembly visitors. Subclass and override
+ * the particular methods you are interested in.
+ */
+public class AssemblyVisitorAdapter<ThrowableType extends Throwable>
+    implements AssemblyVisitor<ThrowableType>
+{
+    @Override
+    public void visitApplication( ApplicationAssembly assembly )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitLayer( LayerAssembly assembly )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitModule( ModuleAssembly assembly )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitComposite( TransientDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitEntity( EntityDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitService( ServiceDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitImportedService( ImportedServiceDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitValue( ValueDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+
+    @Override
+    public void visitObject( ObjectDeclaration declaration )
+        throws ThrowableType
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssociationDeclarations.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssociationDeclarations.java
new file mode 100644
index 0000000..59724ca
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/AssociationDeclarations.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.common.MetaInfo;
+
+/**
+ * This provides declared {@link org.qi4j.api.association.Association} information that the runtime can use.
+ */
+public interface AssociationDeclarations
+{
+    MetaInfo metaInfoFor( AccessibleObject accessor );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/BindingException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/BindingException.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/BindingException.java
new file mode 100644
index 0000000..dbadbfd
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/BindingException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Thrown by the Zest runtime if a dependency can not be bound.
+ */
+public class BindingException
+    extends Exception
+{
+    public BindingException( String s )
+    {
+        super( s );
+    }
+
+    public BindingException( String s, InvalidInjectionException ex )
+    {
+        super( s, ex );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/BootstrapException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/BootstrapException.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/BootstrapException.java
new file mode 100644
index 0000000..f1f1cfd
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/BootstrapException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+/**
+ * This exception is thrown if no ApplicationFactory provider can be found
+ */
+public class BootstrapException
+    extends RuntimeException
+{
+    public BootstrapException( String message )
+    {
+        super( message );
+    }
+
+    public BootstrapException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ClassScanner.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ClassScanner.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ClassScanner.java
new file mode 100644
index 0000000..70c2946
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ClassScanner.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2008-2011 Rickard Öberg. 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.qi4j.bootstrap;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.CodeSource;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.flatten;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.map;
+
+/**
+ * Scan classpath for classes that matches given criteria. Useful for automated assemblies with lots of similar classes.
+ */
+public class ClassScanner
+{
+    /**
+     * Get all classes from the same package of the given class, and recursively in all subpackages.
+     * <p>
+     * This only works if the seed class is loaded from a file: URL. Jar files are possible as well. Abstract classes
+     * are not included in the results. For further filtering use e.g. Iterables.filter.
+     * </p>
+     * @param seedClass starting point for classpath scanning
+     *
+     * @return iterable of all concrete classes in the same package as the seedclass, and also all classes in subpackages.
+     */
+    public static Iterable<Class<?>> findClasses( final Class<?> seedClass )
+    {
+        CodeSource codeSource = seedClass.getProtectionDomain().getCodeSource();
+        if( codeSource == null )
+        {
+            return Iterables.empty();
+        }
+
+        URL location = codeSource.getLocation();
+
+        if( !location.getProtocol().equals( "file" ) )
+        {
+            throw new IllegalArgumentException( "Can only enumerate classes from file system locations. URL is:" + location );
+        }
+
+        final File file;
+        try
+        {
+            file = new File( location.toURI().getPath() );
+        }
+        catch( URISyntaxException e )
+        {
+            throw new IllegalArgumentException( "The file location of codebase is invalid. Can not convert to URI. URL is:" + location );
+        }
+
+        if( file.getName().endsWith( ".jar" ) )
+        {
+            try
+            {
+                final String packageName = seedClass.getPackage().getName().replace( '.', '/' );
+
+                JarFile jarFile = new JarFile( file );
+                Iterable<JarEntry> entries = Iterables.iterable( jarFile.entries() );
+                try
+                {
+                    return Iterables.toList( filter( new ValidClass(),
+                                                     map( new Function<JarEntry, Class<?>>()
+                                                     {
+                                                         @Override
+                                                         public Class map( JarEntry jarEntry )
+                                                         {
+                                                             String name = jarEntry.getName();
+                                                             name = name.substring( 0, name.length() - 6 );
+                                                             name = name.replace( '/', '.' );
+                                                             try
+                                                             {
+                                                                 return seedClass.getClassLoader().loadClass( name );
+                                                             }
+                                                             catch( ClassNotFoundException e )
+                                                             {
+                                                                 return null;
+                                                             }
+                                                         }
+                                                     }
+                                                         , filter( new Specification<JarEntry>()
+                                                     {
+                                                         @Override
+                                                         public boolean satisfiedBy( JarEntry jarEntry )
+                                                         {
+                                                             return jarEntry.getName()
+                                                                        .startsWith( packageName ) && jarEntry.getName()
+                                                                 .endsWith( ".class" );
+                                                         }
+                                                     }, entries ) ) ) );
+                }
+                finally
+                {
+                    jarFile.close();
+                }
+            }
+            catch( IOException e )
+            {
+                throw new IllegalArgumentException( "Could not open jar file " + file, e );
+            }
+        }
+        else
+        {
+            final File path = new File( file, seedClass.getPackage().getName().replace( '.', File.separatorChar ) );
+            Iterable<File> files = findFiles( path, new Specification<File>()
+            {
+                @Override
+                public boolean satisfiedBy( File file )
+                {
+                    return file.getName().endsWith( ".class" );
+                }
+            } );
+
+            return filter( new ValidClass(),
+                           map( new Function<File, Class<?>>()
+                           {
+                               @Override
+                               public Class<?> map( File f )
+                               {
+                                   String fileName = f.getAbsolutePath().substring( file.toString().length() + 1 );
+                                   fileName = fileName.replace( File.separatorChar, '.' )
+                                       .substring( 0, fileName.length() - 6 );
+                                   try
+                                   {
+                                       return seedClass.getClassLoader().loadClass( fileName );
+                                   }
+                                   catch( ClassNotFoundException e )
+                                   {
+                                       return null;
+                                   }
+                               }
+                           }, files ) );
+        }
+    }
+
+    /**
+     * Useful specification for filtering classes based on a regular expression matching the class names.
+     * <p>
+     * Example: matches(".*Model") -&gt; match only class names that end with Model
+     * </p>
+     *
+     * @param regex The regular expression to be matched.
+     *
+     * @return regex class name specification
+     */
+    public static Specification<Class<?>> matches( String regex )
+    {
+        final Pattern pattern = Pattern.compile( regex );
+
+        return new Specification<Class<?>>()
+        {
+            @Override
+            public boolean satisfiedBy( Class<?> aClass )
+            {
+                return pattern.matcher( aClass.getName() ).matches();
+            }
+        };
+    }
+
+    private static Iterable<File> findFiles( File directory, final Specification<File> filter )
+    {
+        return flatten( filter( filter, iterable( directory.listFiles() ) ),
+                        flattenIterables( map( new Function<File, Iterable<File>>()
+                        {
+                            @Override
+                            public Iterable<File> map( File file )
+                            {
+                                return findFiles( file, filter );
+                            }
+                        }, filter( new Specification<File>()
+                        {
+                            @Override
+                            public boolean satisfiedBy( File file )
+                            {
+                                return file.isDirectory();
+                            }
+                        }, iterable( directory.listFiles() ) ) ) ) );
+    }
+
+    private static class ValidClass
+        implements Specification<Class<?>>
+    {
+        @Override
+        public boolean satisfiedBy( Class<?> item )
+        {
+            return ( item.isInterface() || !Modifier.isAbstract( item.getModifiers() ) ) && ( !item.isEnum() && !item.isAnonymousClass() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationAssembly.java
new file mode 100644
index 0000000..8f45332
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationAssembly.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single ConfigurationComposite in a Module.
+ */
+public interface ConfigurationAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationDeclaration.java
new file mode 100644
index 0000000..ef10c35
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ConfigurationDeclaration.java
@@ -0,0 +1,87 @@
+/*
+ *  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.qi4j.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring configurations. Instances
+ * of this API are acquired by calling {@link ModuleAssembly#configurations(Class[])}.
+ */
+public interface ConfigurationDeclaration
+{
+    /**
+     * Set additional metainfo for this configuration declaration.
+     *
+     * @param info metainfo that can be retrieved from the CompositeDescriptor.
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration setMetaInfo( Object info );
+
+    /**
+     * Set visibility for declared entities.
+     *
+     * @param visibility The {@link Visibility} that this ConfigurationComposite will have.
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration visibleIn( Visibility visibility );
+
+    /**
+     * Declare additional concerns for these configurations.
+     *
+     * @param concerns The concerns that are to be added to the ConfigurationComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration withConcerns( Class<?>... concerns );
+
+    /**
+     * Declare additional side-effects for these configurations.
+     *
+     * @param sideEffects The sideeffects that are to be added to the ConfigurationComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration withSideEffects( Class<?>... sideEffects );
+
+    /**
+     * Declare additional mixins for these configurations.
+     * <p>
+     * This can be useful to override any default mixins from the configuration interface.
+     * </p>
+     * @param mixins The mixins that are to be added to the ConfigurationComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration withMixins( Class<?>... mixins );
+
+    /**
+     * Declare additional interfaces for these declared interfaces.
+     * <p>
+     * This can be useful to add types that the Configuration should implement, but
+     * which you do not want to include in the entity interface itself.
+     * </p>
+     * @param types list of interfaces to add
+     *
+     * @return This instance for a fluid DSL
+     */
+    ConfigurationDeclaration withTypes( Class<?>... types );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/Energy4Java.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/Energy4Java.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Energy4Java.java
new file mode 100644
index 0000000..d9cdc18
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Energy4Java.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2008-2011 Niclas Hedhman. 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.qi4j.bootstrap;
+
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.spi.Qi4jSPI;
+
+/**
+ * Main bootstrap class for starting Zest and creating new applications.
+ * <p>
+ * Instantiate this and call one of the factory methods to get started.
+ * </p>
+ * <p>
+ * This class will use the Service Loader mechanism in Java to try to locate a runtime that implements
+ * the Qi4jRuntime interface. This avoids a direct dependency from the bootstrap to the runtime.
+ * </p>
+ */
+public final class Energy4Java
+{
+    private Qi4jRuntime runtime;
+
+    public Energy4Java( RuntimeFactory runtimeFactory )
+    {
+        this( runtimeFactory.createRuntime() );
+    }
+
+    public Energy4Java()
+    {
+        this( new RuntimeFactory.StandaloneApplicationRuntimeFactory().createRuntime() );
+    }
+
+    public Energy4Java( Qi4jRuntime runtime )
+    {
+        if( runtime == null )
+        {
+            throw new BootstrapException( "Can not create Zest without a Zest Runtime." );
+        }
+        this.runtime = runtime;
+    }
+
+    public ApplicationDescriptor newApplicationModel( ApplicationAssembler assembler )
+        throws AssemblyException
+    {
+        ApplicationAssembly assembly = assembler.assemble( runtime.applicationAssemblyFactory() );
+
+        if( assembly == null )
+        {
+            throw new AssemblyException( "Application assembler did not return any ApplicationAssembly" );
+        }
+
+        try
+        {
+            ApplicationModelFactory modelFactory = runtime.applicationModelFactory();
+            return modelFactory.newApplicationModel( assembly );
+        }
+        catch( RuntimeException e )
+        {
+            throw new AssemblyException( "Unable to create Application Model.", e );
+        }
+    }
+
+    public Application newApplication( ApplicationAssembler assembler, Object... importedServiceInstances )
+        throws AssemblyException
+    {
+        ApplicationDescriptor model = newApplicationModel( assembler );
+        return model.newInstance( runtime.spi(), importedServiceInstances );
+    }
+
+    public Qi4jSPI spi()
+    {
+        return runtime.spi();
+    }
+
+    public Qi4j api()
+    {
+        return runtime.spi();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityAssembly.java
new file mode 100644
index 0000000..ef608ed
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single EntityComposite in a Module.
+ */
+public interface EntityAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityDeclaration.java
new file mode 100644
index 0000000..fb00745
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/EntityDeclaration.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring entities. Instances
+ * of this API are acquired by calling {@link ModuleAssembly#entities(Class[])}.
+ */
+public interface EntityDeclaration
+{
+    /**
+     * Set additional metainfo for this entity declaration.
+     *
+     * @param info metainfo that can be retrieved from the EntityDescriptor.
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration setMetaInfo( Object info );
+
+    /**
+     * Set visibility for declared entities.
+     *
+     * @param visibility The {@link Visibility} that this EntityComposite will have.
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration visibleIn( Visibility visibility );
+
+    /**
+     * Declare additional concerns for these entities.
+     *
+     * @param concerns The concerns that are to be added to the EntityComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration withConcerns( Class<?>... concerns );
+
+    /**
+     * Declare additional side-effects for these entitites.
+     *
+     * @param sideEffects The sideeffects that are to be added to the EntityComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration withSideEffects( Class<?>... sideEffects );
+
+    /**
+     * Declare additional mixins for these entities.
+     * <p>
+     * This can be useful to override any default mixins from the entity interface.
+     * </p>
+     * @param mixins The mixins that are to be added to the EntityComposite beyond the statically declared ones.
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration withMixins( Class<?>... mixins );
+
+    /**
+     * Declare additional interfaces for these declared interfaces.
+     * <p>
+     * This can be useful to add types that the entities should implement, but
+     * which you do not want to include in the entity interface itself.
+     * </p>
+     * @param types list of interfaces to add
+     *
+     * @return This instance for a fluid DSL
+     */
+    EntityDeclaration withTypes( Class<?>... types );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceAssembly.java
new file mode 100644
index 0000000..2d9320e
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single imported service in a Module.
+ */
+public interface ImportedServiceAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceDeclaration.java
new file mode 100644
index 0000000..2d4b0a9
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ImportedServiceDeclaration.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2008 Niclas Hedhman. All rights Reserved.
+ * Copyright 2012, Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.service.ServiceImporter;
+import org.qi4j.api.service.importer.InstanceImporter;
+import org.qi4j.api.service.importer.NewObjectImporter;
+import org.qi4j.api.service.importer.ServiceInstanceImporter;
+import org.qi4j.api.service.importer.ServiceSelectorImporter;
+
+/**
+ * Fluent API for declaring imported services. Instances
+ * of this API are acquired by calling {@link ModuleAssembly#importedServices(Class[])}.
+ */
+public interface ImportedServiceDeclaration
+{
+    // Convenience constants for common service importers
+    public static final Class<? extends ServiceImporter> INSTANCE = InstanceImporter.class;
+    public static final Class<? extends ServiceImporter> NEW_OBJECT = NewObjectImporter.class;
+    public static final Class<? extends ServiceImporter> SERVICE_SELECTOR = ServiceSelectorImporter.class;
+    public static final Class<? extends ServiceImporter> SERVICE_IMPORTER = ServiceInstanceImporter.class;
+
+    ImportedServiceDeclaration visibleIn( Visibility visibility );
+
+    ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass );
+
+    ImportedServiceDeclaration identifiedBy( String identity );
+
+    ImportedServiceDeclaration taggedWith( String... tags );
+
+    ImportedServiceDeclaration setMetaInfo( Object serviceAttribute );
+    
+    ImportedServiceDeclaration importOnStartup();
+
+    /**
+     * Set the imported service activators. Activators are executed in order around
+     * the ServiceReference activation and passivation.
+     *
+     * @param activators the imported service activators
+     * @return the assembly
+     */    
+    @SuppressWarnings( { "unchecked","varargs" } )
+    ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/InjectionException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/InjectionException.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/InjectionException.java
new file mode 100644
index 0000000..bb0d782
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/InjectionException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Thrown by the Zest runtime if a dependency can not be injected.
+ */
+public class InjectionException
+    extends RuntimeException
+{
+    public InjectionException( String s )
+    {
+        super( s );
+    }
+
+    public InjectionException( String s, Throwable throwable )
+    {
+        super( s, throwable );
+    }
+
+    public InjectionException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/InvalidInjectionException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/InvalidInjectionException.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/InvalidInjectionException.java
new file mode 100644
index 0000000..d3f18d9
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/InvalidInjectionException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.bootstrap;
+
+/**
+ * Thrown by the Zest runtime if a dependency injection declaration is invalid.
+ */
+public class InvalidInjectionException
+    extends Exception
+{
+    public InvalidInjectionException( String s )
+    {
+        super( s );
+    }
+
+    public InvalidInjectionException( String s, Throwable throwable )
+    {
+        super( s, throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerAssembly.java
new file mode 100644
index 0000000..5880b3e
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerAssembly.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2008 Niclas Hedhman. All rights Reserved.
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.structure.Layer;
+import org.qi4j.functional.Specification;
+
+/**
+ * Fluid API for declaring a layer in an application. This is obtained by calling {@link ApplicationAssembly#layer(String)}.
+ */
+public interface LayerAssembly
+{
+    /**
+     * Get an assembly for a particular Module. If this is called many times with the same name, then the same module
+     * is affected.
+     *
+     * @param name The name of the Module to retrieve or create.
+     *
+     * @return The ModuleAssembly for the Module.
+     */
+    ModuleAssembly module( String name );
+
+    ApplicationAssembly application();
+
+    String name();
+
+    LayerAssembly setName( String name );
+
+    LayerAssembly setMetaInfo( Object info );
+
+    LayerAssembly uses( LayerAssembly... layerAssembly );
+
+    /**
+     * Set the layer activators. Activators are executed in order around the
+     * Layer activation and passivation.
+     *
+     * @param activators the layer activators
+     * @return the assembly
+     */    
+    @SuppressWarnings( { "unchecked","varargs" } )
+    LayerAssembly withActivators( Class<? extends Activator<Layer>>... activators );
+
+    <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType;
+
+    /**
+     * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the EntityComposite types of interest.
+     *
+     * @return An EntityDeclaration for the specified EntityComposite types.
+     */
+    EntityDeclaration entities( Specification<? super EntityAssembly> specification );
+
+    /**
+     * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the ServiceComposite types of interest.
+     *
+     * @return An ServiceDeclaration for the specified ServiceComposite types.
+     */
+    ServiceDeclaration services( Specification<? super ServiceAssembly> specification );
+
+    /**
+     * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the TransientComposite types of interest.
+     *
+     * @return An TransientDeclaration for the specified TransientComposite types.
+     */
+    TransientDeclaration transients( Specification<? super TransientAssembly> specification );
+
+    /**
+     * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the ValueComposite types of interest.
+     *
+     * @return An ValueDeclaration for the specified ValueComposite types.
+     */
+    ValueDeclaration values( Specification<? super ValueAssembly> specification );
+
+    /**
+     * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the Object types of interest.
+     *
+     * @return An ObjectDeclaration for the specified Object types.
+     */
+    ObjectDeclaration objects( Specification<? super ObjectAssembly> specification );
+
+    /**
+     * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can
+     * be used to work with all of the assemblies in this Layer matched by the specification.
+     *
+     * @param specification The Specification that specifies the Imported Service types of interest.
+     *
+     * @return An ImportedServiceDeclaration for the specified Imported Service types.
+     */
+    ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerName.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerName.java
new file mode 100644
index 0000000..8d1b8bf
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/LayerName.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Set the name of the layer
+ */
+public final class LayerName
+    implements Assembler
+{
+    private final String name;
+
+    public LayerName( String name )
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.layer().setName( name );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ManyAssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ManyAssociationDeclarations.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ManyAssociationDeclarations.java
new file mode 100644
index 0000000..f95a6ac
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ManyAssociationDeclarations.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.common.MetaInfo;
+
+/**
+ * This provides declared {@link org.qi4j.api.association.ManyAssociation} information that the runtime can use.
+ */
+public interface ManyAssociationDeclarations
+{
+    MetaInfo metaInfoFor( AccessibleObject accessor );
+}
\ No newline at end of file


[24/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/MetaInfoDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/MetaInfoDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/MetaInfoDeclaration.java
new file mode 100644
index 0000000..0e55aba
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/MetaInfoDeclaration.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2008, Michael Hunger 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.qi4j.bootstrap;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.property.Property;
+
+/**
+ * Declaration of a Property or Association.
+ */
+public final class MetaInfoDeclaration
+    implements StateDeclarations, AssociationDeclarations, ManyAssociationDeclarations, NamedAssociationDeclarations
+{
+    Map<Class<?>, InfoHolder<?>> mixinPropertyDeclarations = new HashMap<>();
+
+    public MetaInfoDeclaration()
+    {
+    }
+
+    public <T> MixinDeclaration<T> on( Class<T> mixinType )
+    {
+        @SuppressWarnings( "unchecked" )
+        InfoHolder<T> propertyDeclarationHolder = (InfoHolder<T>) mixinPropertyDeclarations.get( mixinType );
+        if( propertyDeclarationHolder == null )
+        {
+            propertyDeclarationHolder = new InfoHolder<>( mixinType );
+            mixinPropertyDeclarations.put( mixinType, propertyDeclarationHolder );
+        }
+        return propertyDeclarationHolder;
+    }
+
+    @Override
+    public MetaInfo metaInfoFor( AccessibleObject accessor )
+    {
+        for( Map.Entry<Class<?>, InfoHolder<?>> entry : mixinPropertyDeclarations.entrySet() )
+        {
+            InfoHolder<?> holder = entry.getValue();
+            MetaInfo metaInfo = holder.metaInfoFor( accessor );
+            if( metaInfo != null )
+            {
+                Class<?> mixinType = entry.getKey();
+                return metaInfo.withAnnotations( mixinType )
+                    .withAnnotations( accessor )
+                    .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor )
+                        .getType() );
+            }
+        }
+        // TODO is this code reached at all??
+        Class<?> declaringType = ( (Member) accessor ).getDeclaringClass();
+        return new MetaInfo().withAnnotations( declaringType )
+            .withAnnotations( accessor )
+            .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor ).getType() );
+    }
+
+    @Override
+    public Object initialValueOf( AccessibleObject accessor )
+    {
+        for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() )
+        {
+            final Object initialValue = propertyDeclarationHolder.initialValueOf( accessor );
+            if( initialValue != null )
+            {
+                return initialValue;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public boolean useDefaults( AccessibleObject accessor )
+    {
+        for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() )
+        {
+            final boolean useDefaults = propertyDeclarationHolder.useDefaults( accessor );
+            if( useDefaults )
+            {
+                return useDefaults;
+            }
+        }
+        return false;
+    }
+
+    private static class InfoHolder<T>
+        implements InvocationHandler, StateDeclarations, MixinDeclaration<T>
+    {
+        private final static class MethodInfo
+        {
+            Object initialValue;
+            boolean useDefaults;
+            MetaInfo metaInfo;
+
+            private MethodInfo( MetaInfo metaInfo )
+            {
+                this.metaInfo = metaInfo;
+            }
+        }
+
+        private final Class<T> mixinType;
+        private final Map<AccessibleObject, MethodInfo> methodInfos = new HashMap<>();
+        // temporary holder
+        private MetaInfo metaInfo = null;
+
+        private InfoHolder( Class<T> mixinType )
+        {
+            this.mixinType = mixinType;
+        }
+
+        @Override
+        @SuppressWarnings( "raw" )
+        public Object invoke( Object o, Method method, Object[] objects )
+            throws Throwable
+        {
+            final MethodInfo methodInfo = new MethodInfo( metaInfo );
+            methodInfo.useDefaults = true;
+            methodInfos.put( method, methodInfo );
+            metaInfo = null; // reset
+            final Class<?> returnType = method.getReturnType();
+            try
+            {
+                return Proxy.newProxyInstance( returnType.getClassLoader(), new Class[]{ returnType },
+                                               new InvocationHandler()
+                                               {
+                                                   @Override
+                                                   public Object invoke( Object o, Method method, Object[] objects )
+                                                       throws Throwable
+                                                   {
+                                                       if( method.getName().equals( "set" ) )
+                                                       {
+                                                           methodInfo.initialValue = objects[ 0 ];
+                                                       }
+                                                       return null;
+                                                   }
+                                               } );
+            }
+            catch( IllegalArgumentException e )
+            {
+                throw new IllegalArgumentException(
+                    "Only methods with " + Property.class.getName() + " as return type can have declareDefaults()" );
+            }
+        }
+
+        public MethodInfo matches( AccessibleObject accessor )
+        {
+            return methodInfos.get( accessor );
+        }
+
+        @Override
+        public MetaInfo metaInfoFor( AccessibleObject accessor )
+        {
+            final MethodInfo methodInfo = matches( accessor );
+            if( methodInfo == null )
+            {
+                return null;
+            }
+            return methodInfo.metaInfo;
+        }
+
+        @Override
+        public Object initialValueOf( AccessibleObject accessor )
+        {
+            final MethodInfo methodInfo = matches( accessor );
+            if( methodInfo == null )
+            {
+                return null;
+            }
+            return methodInfo.initialValue;
+        }
+
+        @Override
+        public boolean useDefaults( AccessibleObject accessor )
+        {
+            final MethodInfo methodInfo = matches( accessor );
+            if( methodInfo == null )
+            {
+                return false;
+            }
+            return methodInfo.useDefaults;
+        }
+
+        // DSL Interface
+
+        @Override
+        @SuppressWarnings( "raw" )
+        public T declareDefaults()
+        {
+            return mixinType.cast(
+                Proxy.newProxyInstance( mixinType.getClassLoader(), new Class[]{ mixinType }, this ) );
+        }
+
+        @Override
+        public MixinDeclaration<T> setMetaInfo( Object info )
+        {
+            if( metaInfo == null )
+            {
+                metaInfo = new MetaInfo();
+            }
+            metaInfo.set( info );
+            return this;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/MixinDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/MixinDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/MixinDeclaration.java
new file mode 100644
index 0000000..719600a
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/MixinDeclaration.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2008, Michael Hunger. 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.qi4j.bootstrap;
+
+/**
+ * Fluent API for declaring information about properties
+ *
+ * @param <T>
+ */
+public interface MixinDeclaration<T>
+{
+    T declareDefaults();
+
+    MixinDeclaration<T> setMetaInfo( Object info );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleAssembly.java
new file mode 100644
index 0000000..4e473b4
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleAssembly.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2008 Niclas Hedhman. All rights Reserved.
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.HasTypes;
+import org.qi4j.functional.Specification;
+
+/**
+ * The ModuleAssembly is used to register any information about * what the module should contain, such as composites,
+ * entities and services.
+ * <p>
+ * Use the methods and the fluent API's to declare how the module should be constructed.
+ * </p>
+ */
+public interface ModuleAssembly
+{
+    /**
+     * Access the layer assembly for this module.
+     *
+     * @return The Layer containing this Module.
+     */
+    LayerAssembly layer();
+
+    /**
+     * Get an assembly for a particular Module. If this is called many times with the same names, then the same module
+     * is affected.
+     *
+     * @param layerName  The name of the Layer
+     * @param moduleName The name of the Module to retrieve or create.
+     *
+     * @return The ModuleAssembly for the Module.
+     */
+    ModuleAssembly module( String layerName, String moduleName );
+
+    /**
+     * Set the name of this module.
+     *
+     * @param name The name that this Module should have.
+     *
+     * @return This instance to support the fluid DSL of bootstrap.
+     */
+    ModuleAssembly setName( String name );
+
+    /**
+     * Access the currently set name for this module.
+     *
+     * @return The name of this Module.
+     */
+    String name();
+
+    ModuleAssembly setMetaInfo( Object info );
+
+    /**
+     * Set the module activators. Activators are executed in order around the
+     * Module activation and passivation.
+     *
+     * @param activators the module activators
+     *
+     * @return the assembly
+     */
+    @SuppressWarnings({ "unchecked", "varargs" })
+    ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators );
+
+    /**
+     * Declare a list of TransientComposites for this Module. Use the TransientDeclaration that is returned to
+     * declare further settings. Note that the TransientDeclaration works on all of the types specified.
+     *
+     * @param transientTypes The types that specifies the Transient types.
+     *
+     * @return An TransientDeclaration for the specified Transient types.
+     */
+    TransientDeclaration transients( Class<?>... transientTypes );
+
+    /**
+     * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the TransientComposite types of interest.
+     *
+     * @return An TransientDeclaration for the specified TransientComposite types.
+     */
+    TransientDeclaration transients( Specification<? super TransientAssembly> specification );
+
+    /**
+     * Declare a list of ValueComposites for this Module. Use the ValueDeclaration that is returned to
+     * declare further settings. Note that the ValueDeclaration works on all of the types specified.
+     *
+     * @param valueTypes The types that specifies the Value types.
+     *
+     * @return An ValueDeclaration for the specified Value types.
+     */
+    ValueDeclaration values( Class<?>... valueTypes );
+
+    /**
+     * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the ValueComposite types of interest.
+     *
+     * @return An ValueDeclaration for the specified ValueComposite types.
+     */
+    ValueDeclaration values( Specification<? super ValueAssembly> specification );
+
+    /**
+     * Declare a list of EntityComposites for this Module. Use the EntityDeclaration that is returned to
+     * declare further settings. Note that the EntityDeclaration works on all of the types specified.
+     *
+     * @param entityTypes The types that specifies the Entity types.
+     *
+     * @return An EntityDeclaration for the specified Entity types.
+     */
+    EntityDeclaration entities( Class<?>... entityTypes );
+
+    /**
+     * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the EntityComposite types of interest.
+     *
+     * @return An EntityDeclaration for the specified EntityComposite types.
+     */
+    EntityDeclaration entities( Specification<? super EntityAssembly> specification );
+
+    /**
+     * Declare a list of Configuration Composites for this Module. Use the ConfigurationDeclaration that is returned to
+     * declare further settings. Note that the ConfigurationDeclaration works on all of the types specified.
+     *
+     * @param configurationTypes The types that specifies the Configuration types.
+     *
+     * @return An ConfigurationDeclaration for the specified Configuration types.
+     */
+    ConfigurationDeclaration configurations( Class<?>... configurationTypes );
+
+    /**
+     * Given a Specification for ConfigurationAssembly's, returns a ConfigurationDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the ConfigurationComposite types of interest.
+     *
+     * @return An ConfigurationDeclaration for the specified EntityComposite types.
+     */
+    ConfigurationDeclaration configurations( Specification<HasTypes> specification );
+
+
+    /**
+     * Declare a list of object classes for this Module. Use the ObjectDeclaration that is returned to
+     * declare further settings. Note that the ObjectDeclaration works on all of the types specified.
+     *
+     * @param objectTypes The types that specifies the Object types.
+     *
+     * @return An ObjectDeclaration for the specified Object types.
+     */
+    ObjectDeclaration objects( Class<?>... objectTypes )
+        throws AssemblyException;
+
+    /**
+     * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the Object types of interest.
+     *
+     * @return An ObjectDeclaration for the specified Object types.
+     */
+    ObjectDeclaration objects( Specification<? super ObjectAssembly> specification );
+
+    /**
+     * Create a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
+     * declare further settings. This will always create new assemblies for the specified types, instead
+     * of potentially working on already declared types like the services(...) method.
+     *
+     * @param serviceTypes The types that specifies the Service types.
+     *
+     * @return An ServiceDeclaration for the specified Service types.
+     */
+    ServiceDeclaration addServices( Class<?>... serviceTypes );
+
+    /**
+     * Declare a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
+     * declare further settings. Note that the ServiceDeclaration works on all of the types specified.
+     *
+     * @param serviceTypes The types that specifies the Service types.
+     *
+     * @return An ServiceDeclaration for the specified Service types.
+     */
+    ServiceDeclaration services( Class<?>... serviceTypes );
+
+    /**
+     * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the ServiceComposite types of interest.
+     *
+     * @return An ServiceDeclaration for the specified ServiceComposite types.
+     */
+    ServiceDeclaration services( Specification<? super ServiceAssembly> specification );
+
+    /**
+     * Declare a list of imported services for this Module. Use the ImportedServiceDeclaration that is returned to
+     * declare further settings. Note that the ImportedServiceDeclaration works on all of the types specified.
+     *
+     * @param serviceTypes The types that specifies the Imported Service types.
+     *
+     * @return An ImportedServiceDeclaration for the specified Imported Service types.
+     */
+    ImportedServiceDeclaration importedServices( Class<?>... serviceTypes );
+
+    /**
+     * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can
+     * be used to work with all of the assemblies matched by the specification.
+     *
+     * @param specification The Specification that specifies the Imported Service types of interest.
+     *
+     * @return An ImportedServiceDeclaration for the specified Imported Service types.
+     */
+    ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification );
+
+    <T> MixinDeclaration<T> forMixin( Class<T> mixinType );
+
+    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleName.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleName.java
new file mode 100644
index 0000000..e8a9a20
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ModuleName.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+/**
+ * Set the name of the module
+ */
+public final class ModuleName
+    implements Assembler
+{
+    private final String name;
+
+    public ModuleName( String name )
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.setName( name );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/NamedAssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/NamedAssociationDeclarations.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/NamedAssociationDeclarations.java
new file mode 100644
index 0000000..54a4257
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/NamedAssociationDeclarations.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.bootstrap;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.common.MetaInfo;
+
+/**
+ * This provides declared {@link org.qi4j.api.association.NamedAssociation} information that the runtime can use.
+ */
+public interface NamedAssociationDeclarations
+{
+    MetaInfo metaInfoFor( AccessibleObject accessor );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectAssembly.java
new file mode 100644
index 0000000..e424cf6
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single object type in a Module.
+ */
+public interface ObjectAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectDeclaration.java
new file mode 100644
index 0000000..278d6ff
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ObjectDeclaration.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring objects.Instances
+ * of this API are acquired by calling {@link ModuleAssembly#objects(Class[])}.
+ */
+public interface ObjectDeclaration
+{
+    ObjectDeclaration setMetaInfo( Object info );
+
+    ObjectDeclaration visibleIn( Visibility visibility )
+        throws IllegalStateException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/Qi4jRuntime.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/Qi4jRuntime.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Qi4jRuntime.java
new file mode 100644
index 0000000..76e6130
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/Qi4jRuntime.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.bootstrap;
+
+import org.qi4j.api.Qi4j;
+import org.qi4j.spi.Qi4jSPI;
+
+/**
+ * This interface has to be implemented by Zest runtimes.
+ */
+public interface Qi4jRuntime
+{
+    ApplicationAssemblyFactory applicationAssemblyFactory();
+
+    ApplicationModelFactory applicationModelFactory();
+
+    Qi4j api();
+
+    Qi4jSPI spi();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/RuntimeFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/RuntimeFactory.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/RuntimeFactory.java
new file mode 100644
index 0000000..b4efd24
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/RuntimeFactory.java
@@ -0,0 +1,62 @@
+/*
+ * 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.qi4j.bootstrap;
+
+/**
+ * Zest runtime factory.
+ */
+public interface RuntimeFactory
+{
+    Qi4jRuntime createRuntime();
+
+    /**
+     * Standalone application Zest runtime factory.
+     */
+    public final class StandaloneApplicationRuntimeFactory
+        implements RuntimeFactory
+    {
+        @Override
+        public Qi4jRuntime createRuntime()
+        {
+            ClassLoader loader = getClass().getClassLoader();
+            try
+            {
+                Class<? extends Qi4jRuntime> runtimeClass = loadRuntimeClass( loader );
+                return runtimeClass.newInstance();
+            }
+            catch( ClassNotFoundException e )
+            {
+                System.err.println( "Zest Runtime jar is not present in the classpath." );
+            }
+            catch( InstantiationException | IllegalAccessException e )
+            {
+                System.err.println( "Invalid Zest Runtime class. If you are providing your own Zest Runtime, please " +
+                                    "contact qi4j-dev at Google Groups for assistance." );
+            }
+            return null;
+        }
+
+        @SuppressWarnings( { "unchecked" } )
+        private Class<? extends Qi4jRuntime> loadRuntimeClass( ClassLoader loader )
+            throws ClassNotFoundException
+        {
+            return (Class<? extends Qi4jRuntime>) loader.loadClass( "org.qi4j.runtime.Qi4jRuntimeImpl" );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceAssembly.java
new file mode 100644
index 0000000..27ce698
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single ServiceComposite in a Module.
+ */
+public interface ServiceAssembly extends HasTypes
+{
+    String identity();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceDeclaration.java
new file mode 100644
index 0000000..c566c59
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ServiceDeclaration.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Niclas Hedhman. All rights Reserved.
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring services hosted in Zest. Instances
+ * of this API are acquired by calling {@link ModuleAssembly#services(Class[])}.
+ */
+public interface ServiceDeclaration
+{
+    ServiceDeclaration setMetaInfo( Object serviceAttribute );
+
+    ServiceDeclaration visibleIn( Visibility visibility );
+
+    ServiceDeclaration withConcerns( Class<?>... concerns );
+
+    ServiceDeclaration withSideEffects( Class<?>... sideEffects );
+
+    ServiceDeclaration withMixins( Class<?>... mixins );
+
+    ServiceDeclaration withTypes( Class<?>... types );
+
+    ServiceDeclaration identifiedBy( String identity );
+
+    ServiceDeclaration taggedWith( String... tags );
+
+    ServiceDeclaration instantiateOnStartup();
+
+    /**
+     * Set the service activators. Activators are executed in order around the
+     * ServiceReference activation and passivation.
+     *
+     * @param activators the service activators
+     * @return the assembly
+     */    
+    @SuppressWarnings( { "unchecked","varargs" } )
+    ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/SingletonAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/SingletonAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/SingletonAssembler.java
new file mode 100644
index 0000000..7d2542d
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/SingletonAssembler.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.bootstrap;
+
+import org.qi4j.api.Qi4j;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Module;
+
+/**
+ * Base class for Assembler that creates an Application
+ * with one Layer and one Module. Create a subclass of this
+ * and implement the {@link Assembler#assemble(ModuleAssembly)} method.
+ * Once the SingletonAssembler is instantiated it will have created and activated
+ * an Application which can be accessed from {@link org.qi4j.bootstrap.SingletonAssembler#application()}.
+ * You can also easily access any resources specific for the single Module, such as the TransientBuilderFactory.
+ */
+public abstract class SingletonAssembler
+    implements Assembler
+{
+    private Energy4Java qi4j;
+    private Application applicationInstance;
+    private final Module moduleInstance;
+
+    /**
+     * Creates a Zest Runtime instance containing one Layer with one Module.
+     * The Layer will be named "Layer 1" and the Module will be named "Module 1". It is possible to add
+     * additional layers and modules via the Assembler interface that must be implemented in the subclass of this
+     * class.
+     *
+     * @throws AssemblyException Either if the model can not be created from the disk, or some inconsistency in
+     *                           the programming model makes it impossible to create it.
+     * @throws ActivationException If the automatic {@code activate()} method is throwing this Exception..
+     */
+    public SingletonAssembler()
+        throws AssemblyException, ActivationException
+    {
+// START SNIPPET: actual
+        qi4j = new Energy4Java();
+        applicationInstance = qi4j.newApplication( new ApplicationAssembler()
+        {
+            @Override
+            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+                throws AssemblyException
+            {
+                return applicationFactory.newApplicationAssembly( SingletonAssembler.this );
+            }
+        } );
+
+        try
+        {
+            beforeActivation( applicationInstance );
+            applicationInstance.activate();
+        }
+        catch( Exception e )
+        {
+            if( e instanceof ActivationException )
+            {
+                throw ( (ActivationException) e );
+            }
+            throw new ActivationException( "Could not activate application", e );
+        }
+// START SNIPPET: actual
+
+        moduleInstance = applicationInstance.findModule( "Layer 1", "Module 1" );
+    }
+
+    public final Qi4j runtime()
+    {
+        return qi4j.spi();
+    }
+
+    public final Application application()
+    {
+        return applicationInstance;
+    }
+
+    public final Module module()
+    {
+        return moduleInstance;
+    }
+
+    protected void beforeActivation( Application application )
+        throws Exception
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/StateDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/StateDeclarations.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/StateDeclarations.java
new file mode 100644
index 0000000..39a69b8
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/StateDeclarations.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.bootstrap;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.common.MetaInfo;
+
+/**
+ * This provides declared {@link org.qi4j.api.property.Property} information that the runtime can use.
+ */
+public interface StateDeclarations
+{
+    MetaInfo metaInfoFor( AccessibleObject accessor );
+
+    Object initialValueOf( AccessibleObject accessor );
+
+    boolean useDefaults( AccessibleObject accessor );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientAssembly.java
new file mode 100644
index 0000000..f3e2a58
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single TransientComposite in a Module.
+ */
+public interface TransientAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientDeclaration.java
new file mode 100644
index 0000000..a974f73
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/TransientDeclaration.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring TransientComposites. Instances
+ * of this API are acquired by calling {@link ModuleAssembly#transients(Class[])}.
+ */
+public interface TransientDeclaration
+{
+    TransientDeclaration setMetaInfo( Object info );
+
+    TransientDeclaration visibleIn( Visibility visibility );
+
+    TransientDeclaration withConcerns( Class<?>... concerns );
+
+    TransientDeclaration withSideEffects( Class<?>... sideEffects );
+
+    TransientDeclaration withMixins( Class<?>... mixins );
+
+    TransientDeclaration withTypes( Class<?>... roles );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueAssembly.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueAssembly.java
new file mode 100644
index 0000000..9f98406
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueAssembly.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.type.HasTypes;
+
+/**
+ * This represents the assembly information of a single ValueComposite in a Module.
+ */
+public interface ValueAssembly
+    extends HasTypes
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueDeclaration.java
new file mode 100644
index 0000000..490ae87
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/ValueDeclaration.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.bootstrap;
+
+import org.qi4j.api.common.Visibility;
+
+/**
+ * Fluent API for declaring values
+ */
+public interface ValueDeclaration
+{
+    ValueDeclaration setMetaInfo( Object info );
+
+    ValueDeclaration visibleIn( Visibility visibility );
+
+    ValueDeclaration withConcerns( Class<?>... concerns );
+
+    ValueDeclaration withSideEffects( Class<?>... sideEffects );
+
+    ValueDeclaration withMixins( Class<?>... mixins );
+
+    ValueDeclaration withTypes( Class<?>... roles );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ApplicationBuilder.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ApplicationBuilder.java
new file mode 100644
index 0000000..d68a3d5
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ApplicationBuilder.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright 2014 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap.builder;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.qi4j.api.activation.ActivationEventListener;
+import org.qi4j.api.activation.ActivationEventListenerRegistration;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.activation.ApplicationPassivationThread;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.bootstrap.ApplicationAssembler;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.Energy4Java;
+import org.qi4j.bootstrap.LayerAssembly;
+
+/**
+ * Application Builder.
+ */
+public class ApplicationBuilder
+    implements ActivationEventListenerRegistration
+{
+    private final String applicationName;
+    private final Map<String, LayerDeclaration> layers = new HashMap<>();
+    private final List<ActivationEventListener> activationListeners = new ArrayList<>();
+
+    public ApplicationBuilder( String applicationName )
+    {
+        this.applicationName = applicationName;
+    }
+
+    /**
+     * Create and activate a new Application.
+     * @return Activated Application
+     * @throws AssemblyException if the assembly failed
+     * @throws ActivationException if the activation failed
+     */
+    public Application newApplication()
+        throws AssemblyException, ActivationException
+    {
+        Energy4Java qi4j = new Energy4Java();
+        ApplicationDescriptor model = qi4j.newApplicationModel( new ApplicationAssembler()
+        {
+            @Override
+            public ApplicationAssembly assemble( ApplicationAssemblyFactory factory )
+                throws AssemblyException
+            {
+                ApplicationAssembly assembly = factory.newApplicationAssembly();
+                assembly.setName( applicationName );
+                HashMap<String, LayerAssembly> createdLayers = new HashMap<>();
+                for( Map.Entry<String, LayerDeclaration> entry : layers.entrySet() )
+                {
+                    LayerAssembly layer = entry.getValue().createLayer( assembly );
+                    createdLayers.put( entry.getKey(), layer );
+                }
+                for( LayerDeclaration layer : layers.values() )
+                {
+                    layer.initialize( createdLayers );
+                }
+                return assembly;
+            }
+        } );
+        Application application = model.newInstance( qi4j.api() );
+        for( ActivationEventListener activationListener : activationListeners )
+        {
+            application.registerActivationEventListener( activationListener );
+        }
+        beforeActivation();
+        application.activate();
+        afterActivation();
+        return application;
+    }
+
+    /**
+     * Called before application activation.
+     */
+    protected void beforeActivation()
+    {
+    }
+
+    /**
+     * Called after application activation.
+     */
+    protected void afterActivation()
+    {
+    }
+
+    @Override
+    public void registerActivationEventListener( ActivationEventListener listener )
+    {
+        activationListeners.add( listener );
+    }
+
+    @Override
+    public void deregisterActivationEventListener( ActivationEventListener listener )
+    {
+        activationListeners.remove( listener );
+    }
+
+    /**
+     * Declare Layer.
+     * @param layerName Name of the Layer
+     * @return Layer declaration for the given name, new if did not already exists
+     */
+    public LayerDeclaration withLayer( String layerName )
+    {
+        LayerDeclaration layerDeclaration = layers.get( layerName );
+        if( layerDeclaration != null )
+        {
+            return layerDeclaration;
+        }
+        layerDeclaration = new LayerDeclaration( layerName );
+        layers.put( layerName, layerDeclaration );
+        return layerDeclaration;
+    }
+
+    /**
+     * Load an ApplicationBuilder from a JSON String.
+     * @param json JSON String
+     * @return Application Builder loaded from JSON
+     * @throws JSONException if unable to read JSON
+     * @throws AssemblyException if unable to declare the assembly
+     */
+    public static ApplicationBuilder fromJson( String json )
+        throws JSONException, AssemblyException
+    {
+        JSONObject root = new JSONObject( json );
+        return fromJson( root );
+    }
+
+    /**
+     * Load an ApplicationBuilder from a JSON InputStream.
+     * @param json JSON input
+     * @return Application Builder loaded from JSON
+     * @throws JSONException if unable to read JSON
+     * @throws AssemblyException if unable to declare the assembly
+     */
+    public static ApplicationBuilder fromJson( InputStream json )
+        throws JSONException, AssemblyException
+    {
+        String jsonString = new Scanner( json, "UTF-8" ).useDelimiter( "\\A" ).next();
+        return fromJson( jsonString );
+    }
+
+    /**
+     * Load an ApplicationBuilder from a JSONObject.
+     * @param root JSON object
+     * @return Application Builder loaded from JSON
+     * @throws JSONException if unable to read JSON
+     * @throws AssemblyException if unable to declare the assembly
+     */
+    public static ApplicationBuilder fromJson( JSONObject root )
+        throws JSONException, AssemblyException
+    {
+        String applicationName = root.getString( "name" );
+        ApplicationBuilder builder = new ApplicationBuilder( applicationName );
+        builder.configureWithJson( root );
+        return builder;
+    }
+
+    /** Configures the application struucture from a JSON document.
+     *
+     * @param root The JSON document root.
+     * @throws JSONException if the JSON document isn't valid.
+     * @throws AssemblyException if probelms in the Assemblers provided in the JSON document.
+     */
+    protected void configureWithJson( JSONObject root )
+        throws JSONException, AssemblyException
+    {
+        JSONArray layers = root.optJSONArray( "layers" );
+        if( layers != null )
+        {
+            for( int i = 0; i < layers.length(); i++ )
+            {
+                JSONObject layerObject = layers.getJSONObject( i );
+                String layerName = layerObject.getString( "name" );
+                LayerDeclaration layerDeclaration = withLayer( layerName );
+                JSONArray using = layerObject.optJSONArray( "uses" );
+                if( using != null )
+                {
+                    for( int j = 0; j < using.length(); j++ )
+                    {
+                        layerDeclaration.using( using.getString( j ) );
+                    }
+                }
+                JSONArray modules = layerObject.optJSONArray( "modules" );
+                if( modules != null )
+                {
+                    for( int k = 0; k < modules.length(); k++ )
+                    {
+                        JSONObject moduleObject = modules.getJSONObject( k );
+                        String moduleName = moduleObject.getString( "name" );
+                        ModuleDeclaration moduleDeclaration = layerDeclaration.withModule( moduleName );
+                        JSONArray assemblers = moduleObject.optJSONArray( "assemblers" );
+                        if( assemblers != null )
+                        {
+                            for( int m = 0; m < assemblers.length(); m++ )
+                            {
+                                String string = assemblers.getString( m );
+                                moduleDeclaration.withAssembler( string );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * {@literal main} method that read JSON from STDIN.
+     * <p>Passivation exceptions are written to STDERR if any.</p>
+     * @param args Unused
+     * @throws JSONException if unable to read JSON
+     * @throws AssemblyException if the assembly failed
+     * @throws ActivationException if the activation failed
+     */
+    public static void main( String[] args )
+        throws JSONException, ActivationException, AssemblyException
+    {
+        ApplicationBuilder builder = fromJson( System.in );
+        Application application = builder.newApplication();
+        Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application, System.err ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/LayerDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/LayerDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/LayerDeclaration.java
new file mode 100644
index 0000000..0a30bbe
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/LayerDeclaration.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2014 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap.builder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.functional.Iterables;
+
+/**
+ * Provides declared {@link org.qi4j.api.structure.Layer} information that the {@link ApplicationBuilder} can use.
+ */
+public class LayerDeclaration
+{
+    private final String layerName;
+    private final List<String> using = new ArrayList<>();
+    private final Map<String, ModuleDeclaration> modules = new HashMap<>();
+    private LayerAssembly layer;
+
+    LayerDeclaration( String layerName )
+    {
+        this.layerName = layerName;
+    }
+
+    /**
+     * Declare using layer.
+     * @param layerName Used layer name
+     * @return This Layer declaration
+     */
+    public LayerDeclaration using( String layerName )
+    {
+        this.using.add( layerName );
+        return this;
+    }
+
+    /**
+     * Declare using layers.
+     * @param layerNames Used layers names
+     * @return This Layer declaration
+     */
+    public LayerDeclaration using( Iterable<String> layerNames )
+    {
+        Iterables.addAll( using, layerNames );
+        return this;
+    }
+
+    /**
+     * Declare Module.
+     * @param moduleName Name of the Module
+     * @return Module declaration for the given name, new if did not already exists
+     */
+    public ModuleDeclaration withModule( String moduleName )
+    {
+        ModuleDeclaration module = modules.get( moduleName );
+        if( module != null )
+        {
+            return module;
+        }
+        module = new ModuleDeclaration( moduleName );
+        modules.put( moduleName, module );
+        return module;
+    }
+
+    LayerAssembly createLayer( ApplicationAssembly application )
+    {
+        layer = application.layer( layerName );
+        layer.setName( layerName );
+        for( ModuleDeclaration module : modules.values() )
+        {
+            ModuleAssembly assembly = module.createModule( layer );
+        }
+        return layer;
+    }
+
+    void initialize( HashMap<String, LayerAssembly> createdLayers )
+        throws AssemblyException
+    {
+        for( String uses : using )
+        {
+            LayerAssembly usedLayer = createdLayers.get( uses );
+            layer.uses( usedLayer );
+        }
+        for( ModuleDeclaration module : modules.values() )
+        {
+            module.initialize();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ModuleDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ModuleDeclaration.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ModuleDeclaration.java
new file mode 100644
index 0000000..6ac63d9
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/ModuleDeclaration.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2014 Niclas Hedhman.
+ * Copyright 2014 Paul Merlin.
+ *
+ * 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.qi4j.bootstrap.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+import static org.qi4j.api.util.Classes.isAssignableFrom;
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.toList;
+import static org.qi4j.functional.Specifications.not;
+
+/**
+ * Provides declared {@link org.qi4j.api.structure.Module} information that the {@link ApplicationBuilder} can use.
+ */
+public class ModuleDeclaration
+{
+    private final String moduleName;
+    private final List<Assembler> assemblers = new ArrayList<>();
+    private ModuleAssembly module;
+
+    public ModuleDeclaration( String moduleName )
+    {
+        this.moduleName = moduleName;
+    }
+
+    /**
+     * Declare Assembler.
+     * @param assembler Assembler instance
+     * @return This Module declaration
+     */
+    public ModuleDeclaration withAssembler( Assembler assembler )
+    {
+        assemblers.add( assembler );
+        return this;
+    }
+
+    /**
+     * Declare Assembler.
+     * @param classname Assembler class name
+     * @return This Module declaration
+     * @throws AssemblyException if unable to load class, not an Assembler or unable to instanciate
+     */
+    public ModuleDeclaration withAssembler( String classname )
+        throws AssemblyException
+    {
+        Class<? extends Assembler> clazz = loadClass( classname );
+        return withAssembler( clazz );
+    }
+
+    /**
+     * Declare Assembler.
+     * @param assemblerClass Assembler class
+     * @return This Module declaration
+     * @throws AssemblyException not an Assembler or if unable to instanciate
+     */
+    public ModuleDeclaration withAssembler( Class<?> assemblerClass )
+        throws AssemblyException
+    {
+        Assembler assembler = createAssemblerInstance( assemblerClass );
+        assemblers.add( assembler );
+        return this;
+    }
+
+    /**
+     * Declare Assemblers.
+     * <p>Declare several Assemblers from an Iterable of Class objects.</p>
+     * <p>Typically used along {@link org.qi4j.bootstrap.ClassScanner}.</p>
+     * @param assemblerClasses Assembler classes
+     * @return This Module declaration
+     * @throws AssemblyException if one of the Class is not an Assembler or unable to instanciate
+     */
+    public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses )
+        throws AssemblyException
+    {
+        List<Class<?>> notAssemblers = toList(
+            filter( not( isAssignableFrom( Assembler.class ) ),
+                    assemblerClasses )
+        );
+        if( !notAssemblers.isEmpty() )
+        {
+            throw new AssemblyException(
+                "Classes " + notAssemblers + " are not implementing " + Assembler.class.getName()
+            );
+        }
+        for( Class<?> assemblerClass : assemblerClasses )
+        {
+            withAssembler( assemblerClass );
+        }
+        return this;
+    }
+
+    ModuleAssembly createModule( LayerAssembly layer )
+    {
+        module = layer.module( moduleName );
+        return module;
+    }
+
+    void initialize()
+        throws AssemblyException
+    {
+        for( Assembler assembler : assemblers )
+        {
+            assembler.assemble( module );
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Class<? extends Assembler> loadClass( String classname )
+        throws AssemblyException
+    {
+        Class<?> clazz;
+        try
+        {
+            clazz = getClass().getClassLoader().loadClass( classname );
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to load class " + classname, e );
+        }
+        if( !Assembler.class.isAssignableFrom( clazz ) )
+        {
+            throw new AssemblyException(
+                "Class " + classname + " is not implementing " + Assembler.class.getName()
+            );
+        }
+        //noinspection unchecked
+        return (Class<? extends Assembler>) clazz;
+    }
+
+    private Assembler createAssemblerInstance( Class<?> assemblerClass )
+        throws AssemblyException
+    {
+        if( !Assembler.class.isAssignableFrom( assemblerClass ) )
+        {
+            throw new AssemblyException(
+                "Class " + assemblerClass + " is not implementing " + Assembler.class.getName()
+            );
+        }
+        try
+        {
+            return (Assembler) assemblerClass.newInstance();
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to instantiate " + assemblerClass, e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/package.html b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/package.html
new file mode 100644
index 0000000..663b016
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/builder/package.html
@@ -0,0 +1,25 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Application Builder.</h2>
+        <p>
+            Generic ApplicationBuilder, which simplifies the creation of Application Structure, either by a fluid DSL
+            or from a JSON file.
+        </p>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayerAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayerAssembler.java
new file mode 100644
index 0000000..c8a7b88
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayerAssembler.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap.layered;
+
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+
+public interface LayerAssembler
+{
+    LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredApplicationAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredApplicationAssembler.java
new file mode 100644
index 0000000..b399711
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredApplicationAssembler.java
@@ -0,0 +1,212 @@
+/*
+ * 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.qi4j.bootstrap.layered;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.activation.PassivationException;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.bootstrap.ApplicationAssembler;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.Energy4Java;
+import org.qi4j.bootstrap.LayerAssembly;
+
+public abstract class LayeredApplicationAssembler
+    implements ApplicationAssembler
+{
+    protected Application application;
+    protected String name;
+    protected String version;
+    private final Application.Mode mode;
+    private ApplicationAssembly assembly;
+
+    private HashMap<Class<? extends LayerAssembler>, LayerAssembler> assemblers = new HashMap<>();
+
+    public LayeredApplicationAssembler( String name, String version, Application.Mode mode )
+        throws AssemblyException
+    {
+        this.name = name;
+        this.version = version;
+        this.mode = mode;
+        Energy4Java qi4j = new Energy4Java();
+        ApplicationDescriptor model = qi4j.newApplicationModel( this );
+        onModelCreated( model );
+        instantiateApplication( qi4j, model );
+    }
+
+    public ApplicationAssembly assembly()
+    {
+        return assembly;
+    }
+
+    /**
+     * This method is called from the constructor to instantiate the Zest application from the application model.
+     *
+     * <p>
+     * The default implementation simply calls;
+     * </p>
+     * <pre><code>
+     *   application = model.newInstance( qi4j.spi() );
+     * </code></pre>
+     *
+     * @param qi4j  The Zest runtime engine.
+     * @param model The application model descriptor.
+     */
+    protected void instantiateApplication( Energy4Java qi4j, ApplicationDescriptor model )
+    {
+        application = model.newInstance( qi4j.spi() );
+    }
+
+    /**
+     * This method is called after the Application Model has been created, before the instantiation of the Zest
+     * application.
+     *
+     * <p>
+     * The default implementation does nothing. Applications may have advanced features to inspect or
+     * modify the model prior to instantiation, and this is the place where such advanced manipulation is
+     * expected to take place.
+     * </p>
+     *
+     * @param model
+     */
+    protected void onModelCreated( ApplicationDescriptor model )
+    {
+    }
+
+    public Application application()
+    {
+        return application;
+    }
+
+    public void start()
+        throws ActivationException
+    {
+        application.activate();
+    }
+
+    public void stop()
+        throws PassivationException
+    {
+        application.passivate();
+    }
+
+    @Override
+    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+        throws AssemblyException
+    {
+        assembly = applicationFactory.newApplicationAssembly();
+        assembly.setName( name );
+        assembly.setVersion( version );
+        assembly.setMode( mode );
+        assembleLayers( assembly );
+        return assembly;
+    }
+
+    protected LayerAssembly createLayer( Class<? extends LayerAssembler> layerAssemblerClass )
+        throws IllegalArgumentException
+    {
+        try
+        {
+            String classname = layerAssemblerClass.getSimpleName();
+            if( classname.endsWith( "Layer" ) )
+            {
+                classname = classname.substring( 0, classname.length() - 5 ) + " Layer";
+            }
+            setNameIfPresent( layerAssemblerClass, classname );
+            LayerAssembly layer = assembly.layer( classname );
+
+            LayerAssembler layerAssembler = instantiateAssembler( layerAssemblerClass, layer );
+            assemblers.put( layerAssemblerClass, layerAssembler );
+            LayerAssembly assembly = layerAssembler.assemble( layer );
+            if( assembly == null )
+            {
+                // Assume that people forgot, and let's not require a "return layer", since we can do that ourselves.
+                return layer;
+            }
+            return assembly;
+        }
+        catch( Exception e )
+        {
+            throw new IllegalArgumentException( "Unable to instantiate layer with " + layerAssemblerClass.getSimpleName(), e );
+        }
+    }
+
+    private LayerAssembler instantiateAssembler( Class<? extends LayerAssembler> layerAssemblerClass,
+                                                 LayerAssembly layer
+    )
+        throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException
+    {
+        LayerAssembler layerAssembler;
+        try
+        {
+            Constructor<? extends LayerAssembler> assemblyConstructor = layerAssemblerClass.getConstructor( LayerAssembly.class );
+            layerAssembler = assemblyConstructor.newInstance( layer );
+        }
+        catch( NoSuchMethodException e )
+        {
+            // Use default constructor then.
+            layerAssembler = layerAssemblerClass.newInstance();
+        }
+        return layerAssembler;
+    }
+
+    static void setNameIfPresent( Class<?> clazz, String classname )
+        throws IllegalAccessException
+    {
+        try
+        {
+            Field field = clazz.getDeclaredField( "NAME" );
+            if( Modifier.isStatic( field.getModifiers() ) )
+            {
+                field.setAccessible( true );
+                field.set( null, classname );
+            }
+        }
+        catch( Exception e )
+        {
+            // Ignore and consider normal.
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected <T extends LayerAssembler> T assemblerOf( Class<T> layerAssemblerClass )
+    {
+        return (T) assemblers.get( layerAssemblerClass );
+    }
+
+    /**
+     * Called from the constructor to assemble the layers in the applcation.
+     *
+     * <p>
+     * This method must be implemented, and is typically a list of LayerAssmebler instantitations, followed
+     * by {@link LayerAssembly#uses(LayerAssembly...)} declarations.
+     * </p>
+     * <pre><code>
+     *
+     * </code></pre>
+     */
+    protected abstract void assembleLayers( ApplicationAssembly assembly )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredLayerAssembler.java
new file mode 100644
index 0000000..def4a46
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/LayeredLayerAssembler.java
@@ -0,0 +1,86 @@
+/*
+ * 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.qi4j.bootstrap.layered;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+public abstract class LayeredLayerAssembler
+    implements LayerAssembler
+{
+    private HashMap<Class<? extends ModuleAssembler>, ModuleAssembler> assemblers = new HashMap<>();
+
+    protected ModuleAssembly createModule( LayerAssembly layer, Class<? extends ModuleAssembler> modulerAssemblerClass )
+    {
+        try
+        {
+            ModuleAssembler moduleAssembler = instantiateAssembler( layer, modulerAssemblerClass );
+            String moduleName = createModuleName( modulerAssemblerClass );
+            LayeredApplicationAssembler.setNameIfPresent( modulerAssemblerClass, moduleName );
+            ModuleAssembly module = layer.module( moduleName );
+            assemblers.put( modulerAssemblerClass, moduleAssembler );
+            ModuleAssembly assembly = moduleAssembler.assemble( layer, module );
+            if( assembly == null )
+            {
+                return module;
+            }
+            return assembly;
+        }
+        catch( Exception e )
+        {
+            throw new IllegalArgumentException( "Unable to instantiate module with " + modulerAssemblerClass.getSimpleName(), e );
+        }
+    }
+
+    protected String createModuleName( Class<? extends ModuleAssembler> modulerAssemblerClass )
+    {
+        String moduleName = modulerAssemblerClass.getSimpleName();
+        if( moduleName.endsWith( "Module" ) )
+        {
+            moduleName = moduleName.substring( 0, moduleName.length() - 6 ) + " Module";
+        }
+        return moduleName;
+    }
+
+    private ModuleAssembler instantiateAssembler( LayerAssembly layer,
+                                                  Class<? extends ModuleAssembler> modulerAssemblerClass
+    )
+        throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException
+    {
+        ModuleAssembler moduleAssembler;
+        try
+        {
+            Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getConstructor( ModuleAssembly.class );
+            moduleAssembler = assemblyConstructor.newInstance( layer );
+        }
+        catch( NoSuchMethodException e )
+        {
+            moduleAssembler = modulerAssemblerClass.newInstance();
+        }
+        return moduleAssembler;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected <T extends ModuleAssembler> T assemblerOf( Class<T> moduleAssemblerType )
+    {
+        return (T) assemblers.get( moduleAssemblerType );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/ModuleAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/ModuleAssembler.java b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/ModuleAssembler.java
new file mode 100644
index 0000000..17c8765
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/ModuleAssembler.java
@@ -0,0 +1,29 @@
+/*
+ * 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.qi4j.bootstrap.layered;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+public interface ModuleAssembler
+{
+    ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/package.html b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/package.html
new file mode 100644
index 0000000..60cdec2
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/layered/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Layered Assembly.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/qi4j/bootstrap/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/qi4j/bootstrap/package.html b/core/bootstrap/src/main/java/org/qi4j/bootstrap/package.html
new file mode 100644
index 0000000..0458761
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/qi4j/bootstrap/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Assembly and Bootstrap API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
deleted file mode 100644
index fc7147b..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
+++ /dev/null
@@ -1,64 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.bootstrap.somepackage.Test2Value;
-import org.apache.zest.functional.Iterables;
-
-import static org.apache.zest.bootstrap.ClassScanner.findClasses;
-import static org.apache.zest.bootstrap.ClassScanner.matches;
-import static org.apache.zest.functional.Iterables.filter;
-
-/**
- * Test and showcase of the ClassScanner assembly utility.
- */
-public class ClassScannerTest
-{
-    @Test
-    public void testClassScannerFiles()
-        throws ActivationException, AssemblyException
-    {
-        SingletonAssembler singleton = new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module )
-                throws AssemblyException
-            {
-                // Find all classes starting from TestValue, but include only the ones that are named *Value
-
-                for( Class aClass : filter( matches( ".*Value" ), findClasses( TestValue.class ) ) )
-                {
-                    module.values( aClass );
-                }
-            }
-        };
-
-        singleton.module().newValueBuilder( TestValue.class );
-        singleton.module().newValueBuilder( Test2Value.class );
-    }
-
-    @Test
-    public void testClassScannerJar()
-    {
-        Assert.assertEquals( 138, Iterables.count( findClasses( Test.class ) ) );
-    }
-}


[45/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java b/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java
deleted file mode 100644
index a109310..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- * Copyright 2008 Alin Dreghiciu.
- * Copyright 2012 Stanislav Muhametsin.
- * Copyright 2012-2014 Paul Merlin.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.grammar.AndSpecification;
-import org.apache.zest.api.query.grammar.AssociationFunction;
-import org.apache.zest.api.query.grammar.AssociationNotNullSpecification;
-import org.apache.zest.api.query.grammar.AssociationNullSpecification;
-import org.apache.zest.api.query.grammar.ContainsAllSpecification;
-import org.apache.zest.api.query.grammar.ContainsSpecification;
-import org.apache.zest.api.query.grammar.EqSpecification;
-import org.apache.zest.api.query.grammar.GeSpecification;
-import org.apache.zest.api.query.grammar.GtSpecification;
-import org.apache.zest.api.query.grammar.LeSpecification;
-import org.apache.zest.api.query.grammar.LtSpecification;
-import org.apache.zest.api.query.grammar.ManyAssociationContainsSpecification;
-import org.apache.zest.api.query.grammar.ManyAssociationFunction;
-import org.apache.zest.api.query.grammar.MatchesSpecification;
-import org.apache.zest.api.query.grammar.NamedAssociationContainsNameSpecification;
-import org.apache.zest.api.query.grammar.NamedAssociationContainsSpecification;
-import org.apache.zest.api.query.grammar.NamedAssociationFunction;
-import org.apache.zest.api.query.grammar.NeSpecification;
-import org.apache.zest.api.query.grammar.NotSpecification;
-import org.apache.zest.api.query.grammar.OrSpecification;
-import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.api.query.grammar.PropertyFunction;
-import org.apache.zest.api.query.grammar.PropertyNotNullSpecification;
-import org.apache.zest.api.query.grammar.PropertyNullSpecification;
-import org.apache.zest.api.query.grammar.PropertyReference;
-import org.apache.zest.api.query.grammar.Variable;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.prepend;
-
-/**
- * Static factory methods for query expressions and operators.
- */
-public final class QueryExpressions
-{
-    // This is used for eq(Association,Composite)
-    private static final Method IDENTITY_METHOD;
-
-    static
-    {
-        try
-        {
-            IDENTITY_METHOD = Identity.class.getMethod( "identity" );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core API codebase is corrupted. Contact Zest team: QueryExpressions" );
-        }
-    }
-
-    // Templates and variables -----------------------------------------------|
-
-    /**
-     * Create a Query Template using the given type.
-     *
-     * @param <T> the type of the template
-     * @param clazz a class declaring the type of the template
-     *
-     * @return a new Query Template
-     */
-    public static <T> T templateFor( Class<T> clazz )
-    {
-        NullArgumentException.validateNotNull( "Template class", clazz );
-
-        if( clazz.isInterface() )
-        {
-            return clazz.cast( Proxy.newProxyInstance( clazz.getClassLoader(),
-                                                       array( clazz ),
-                                                       new TemplateHandler<T>( null, null, null, null ) ) );
-        }
-        else
-        {
-            try
-            {
-                T mixin = clazz.newInstance();
-                for( Field field : clazz.getFields() )
-                {
-                    if( field.getAnnotation( State.class ) != null )
-                    {
-                        if( field.getType().equals( Property.class ) )
-                        {
-                            field.set( mixin,
-                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
-                                                               array( field.getType() ),
-                                                               new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ) );
-                        }
-                        else if( field.getType().equals( Association.class ) )
-                        {
-                            field.set( mixin,
-                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
-                                                               array( field.getType() ),
-                                                               new AssociationReferenceHandler<>( new AssociationFunction<T>( null, null, null, field ) ) ) );
-                        }
-                        else if( field.getType().equals( ManyAssociation.class ) )
-                        {
-                            field.set( mixin,
-                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
-                                                               array( field.getType() ),
-                                                               new ManyAssociationReferenceHandler<>( new ManyAssociationFunction<T>( null, null, null, field ) ) ) );
-                        }
-                        else if( field.getType().equals( NamedAssociation.class ) )
-                        {
-                            field.set( mixin,
-                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
-                                                               array( field.getType() ),
-                                                               new NamedAssociationReferenceHandler<>( new NamedAssociationFunction<T>( null, null, null, field ) ) ) );
-                        }
-                    }
-                }
-                return mixin;
-            }
-            catch( IllegalAccessException | IllegalArgumentException | InstantiationException | SecurityException e )
-            {
-                throw new IllegalArgumentException( "Cannot use class as template", e );
-            }
-        }
-    }
-
-    /**
-     * Create a Query Template using the given mixin class and association.
-     *
-     * @param <T> the type of the template
-     * @param mixinType  a class declaring the type of the template
-     * @param association an association
-     *
-     * @return a new Query Template
-     */
-    public static <T> T templateFor( final Class<T> mixinType, Association<?> association )
-    {
-        NullArgumentException.validateNotNull( "Mixin class", mixinType );
-        NullArgumentException.validateNotNull( "Association", association );
-        return mixinType.cast( Proxy.newProxyInstance( mixinType.getClassLoader(),
-                                                       array( mixinType ),
-                                                       new TemplateHandler<T>( null,
-                                                                               association( association ),
-                                                                               null,
-                                                                               null ) ) );
-    }
-
-    public static <T> T oneOf( final ManyAssociation<T> association )
-    {
-        NullArgumentException.validateNotNull( "Association", association );
-        return association.get( 0 );
-    }
-
-    public static <T> T oneOf( final NamedAssociation<T> association )
-    {
-        NullArgumentException.validateNotNull( "Association", association );
-        return association.get( first( association ) );
-    }
-
-    /**
-     * Create a new Query Variable.
-     *
-     * @param name a name for the Variable
-     *
-     * @return a new Query Variable.
-     */
-    public static Variable variable( String name )
-    {
-        NullArgumentException.validateNotNull( "Variable name", name );
-        return new Variable( name );
-    }
-
-    /**
-     * Create a new Query Template PropertyFunction.
-     *
-     * @param <T> type of the Property
-     * @param property a Property
-     *
-     * @return a new Query Template PropertyFunction
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> PropertyFunction<T> property( Property<T> property )
-    {
-        return ( (PropertyReferenceHandler<T>) Proxy.getInvocationHandler( property ) ).property();
-    }
-
-    /**
-     * Create a new Query Property instance.
-     *
-     * @param <T> type of the Property
-     * @param mixinClass mixin of the Property
-     * @param fieldName name of the Property field
-     *
-     * @return a new Query Property instance for the given mixin and property name.
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> Property<T> property( Class<?> mixinClass, String fieldName )
-    {
-        try
-        {
-            Field field = mixinClass.getField( fieldName );
-            if( !Property.class.isAssignableFrom( field.getType() ) )
-            {
-                throw new IllegalArgumentException( "Field must be of type Property<?>" );
-            }
-            return (Property<T>) Proxy.newProxyInstance(
-                mixinClass.getClassLoader(),
-                array( field.getType() ),
-                new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) );
-        }
-        catch( NoSuchFieldException e )
-        {
-            throw new IllegalArgumentException( "No such field '" + fieldName + "' in mixin " + mixinClass.getName() );
-        }
-    }
-
-    /**
-     * Create a new Query Template AssociationFunction.
-     *
-     * @param <T> type of the Association
-     * @param association an Association
-     *
-     * @return a new Query Template AssociationFunction
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> AssociationFunction<T> association( Association<T> association )
-    {
-        return ( (AssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).association();
-    }
-
-    /**
-     * Create a new Query Template ManyAssociationFunction.
-     *
-     * @param <T> type of the ManyAssociation
-     * @param association a ManyAssociation
-     *
-     * @return a new Query Template ManyAssociationFunction
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> ManyAssociationFunction<T> manyAssociation( ManyAssociation<T> association )
-    {
-        return ( (ManyAssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).manyAssociation();
-    }
-
-    /**
-     * Create a new Query Template NamedAssociationFunction.
-     *
-     * @param <T> type of the NamedAssociation
-     * @param association a NamedAssociation
-     *
-     * @return a new Query Template NamedAssociationFunction
-     */
-    @SuppressWarnings( "unchecked" )
-    public static <T> NamedAssociationFunction<T> namedAssociation( NamedAssociation<T> association )
-    {
-        return ( (NamedAssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).namedAssociation();
-    }
-
-    // And/Or/Not ------------------------------------------------------------|
-    /**
-     * Create a new AND specification.
-     *
-     * @param left first operand
-     * @param right second operand
-     * @param optionalRight optional operands
-     *
-     * @return a new AND specification
-     */
-    @SafeVarargs
-    public static AndSpecification and( Specification<Composite> left,
-                                        Specification<Composite> right,
-                                        Specification<Composite>... optionalRight
-    )
-    {
-        return new AndSpecification( prepend( left, prepend( right, Arrays.asList( optionalRight ) ) ) );
-    }
-
-    /**
-     * Create a new OR specification.
-     *
-     * @param specs operands
-     *
-     * @return a new OR specification
-     */
-    @SafeVarargs
-    public static OrSpecification or( Specification<Composite>... specs )
-    {
-        return new OrSpecification( Arrays.asList( specs ) );
-    }
-
-    /**
-     * Create a new NOT specification.
-     *
-     * @param operand specification to be negated
-     *
-     * @return a new NOT specification
-     */
-    public static NotSpecification not( Specification<Composite> operand )
-    {
-        return new NotSpecification( operand );
-    }
-
-    // Comparisons -----------------------------------------------------------|
-
-    /**
-     * Create a new EQUALS specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new EQUALS specification for a Property.
-     */
-    public static <T> EqSpecification<T> eq( Property<T> property, T value )
-    {
-        return new EqSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new EQUALS specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new EQUALS specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> EqSpecification<T> eq( Property<T> property, Variable variable )
-    {
-        return new EqSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new EQUALS specification for an Association.
-     *
-     * @param association an Association
-     * @param value its value
-     *
-     * @return a new EQUALS specification for an Association.
-     */
-    public static <T> EqSpecification<String> eq( Association<T> association, T value )
-    {
-        return new EqSpecification<>( new PropertyFunction<String>( null,
-                                                                    association( association ),
-                                                                    null,
-                                                                    null,
-                                                                    IDENTITY_METHOD ),
-                                      value.toString() );
-    }
-
-    /**
-     * Create a new GREATER OR EQUALS specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new GREATER OR EQUALS specification for a Property.
-     */
-    public static <T> GeSpecification<T> ge( Property<T> property, T value )
-    {
-        return new GeSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new GREATER OR EQUALS specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new GREATER OR EQUALS specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> GeSpecification<T> ge( Property<T> property, Variable variable )
-    {
-        return new GeSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new GREATER THAN specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new GREATER THAN specification for a Property.
-     */
-    public static <T> GtSpecification<T> gt( Property<T> property, T value )
-    {
-        return new GtSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new GREATER THAN specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new GREATER THAN specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> GtSpecification<T> gt( Property<T> property, Variable variable )
-    {
-        return new GtSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new LESS OR EQUALS specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new LESS OR EQUALS specification for a Property.
-     */
-    public static <T> LeSpecification<T> le( Property<T> property, T value )
-    {
-        return new LeSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new LESS OR EQUALS specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new LESS OR EQUALS specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> LeSpecification<T> le( Property<T> property, Variable variable )
-    {
-        return new LeSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new LESSER THAN specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new LESSER THAN specification for a Property.
-     */
-    public static <T> LtSpecification<T> lt( Property<T> property, T value )
-    {
-        return new LtSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new LESSER THAN specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new LESSER THAN specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> LtSpecification<T> lt( Property<T> property, Variable variable )
-    {
-        return new LtSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new NOT EQUALS specification for a Property.
-     *
-     * @param property a Property
-     * @param value its value
-     *
-     * @return a new NOT EQUALS specification for a Property.
-     */
-    public static <T> NeSpecification<T> ne( Property<T> property, T value )
-    {
-        return new NeSpecification<>( property( property ), value );
-    }
-
-    /**
-     * Create a new NOT EQUALS specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new NOT EQUALS specification for a Property using a named Variable.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> NeSpecification<T> ne( Property<T> property, Variable variable )
-    {
-        return new NeSpecification( property( property ), variable );
-    }
-
-    /**
-     * Create a new REGULAR EXPRESSION specification for a Property.
-     *
-     * @param property a Property
-     * @param regexp its value
-     *
-     * @return a new REGULAR EXPRESSION specification for a Property.
-     */
-    public static MatchesSpecification matches( Property<String> property, String regexp )
-    {
-        return new MatchesSpecification( property( property ), regexp );
-    }
-
-    /**
-     * Create a new REGULAR EXPRESSION specification for a Property using a named Variable.
-     *
-     * @param property a Property
-     * @param variable a Query Variable
-     *
-     * @return a new REGULAR EXPRESSION specification for a Property using a named Variable.
-     */
-    public static MatchesSpecification matches( Property<String> property, Variable variable )
-    {
-        return new MatchesSpecification( property( property ), variable );
-    }
-
-    // Null checks -----------------------------------------------------------|
-
-    /**
-     * Create a new NOT NULL specification for a Property.
-     *
-     * @param property a Property
-     *
-     * @return a new NOT NULL specification for a Property.
-     */
-    public static <T> PropertyNotNullSpecification<T> isNotNull( Property<T> property )
-    {
-        return new PropertyNotNullSpecification<>( property( property ) );
-    }
-
-    /**
-     * Create a new NULL specification for a Property.
-     *
-     * @param property a Property
-     *
-     * @return a new NULL specification for a Property.
-     */
-    public static <T> PropertyNullSpecification<T> isNull( Property<T> property )
-    {
-        return new PropertyNullSpecification<>( property( property ) );
-    }
-
-    /**
-     * Create a new NOT NULL specification for an Association.
-     *
-     * @param association an Association
-     *
-     * @return a new NOT NULL specification for an Association.
-     */
-    public static <T> AssociationNotNullSpecification<T> isNotNull( Association<T> association )
-    {
-        return new AssociationNotNullSpecification<>( association( association ) );
-    }
-
-    /**
-     * Create a new NULL specification for an Association.
-     *
-     * @param association an Association
-     *
-     * @return a new NULL specification for an Association.
-     */
-    public static <T> AssociationNullSpecification<T> isNull( Association<T> association )
-    {
-        return new AssociationNullSpecification<>( association( association ) );
-    }
-
-    // Collections -----------------------------------------------------------|
-
-    /**
-     * Create a new CONTAINS ALL specification for a Collection Property.
-     *
-     * @param collectionProperty a Collection Property
-     * @param values its values
-     *
-     * @return a new CONTAINS ALL specification for a Collection Property.
-     */
-    public static <T> ContainsAllSpecification<T> containsAll( Property<? extends Collection<T>> collectionProperty,
-                                                               Iterable<T> values )
-    {
-        NullArgumentException.validateNotNull( "Values", values );
-        return new ContainsAllSpecification<>( property( collectionProperty ), values );
-    }
-
-    /**
-     * Create a new CONTAINS ALL specification for a Collection Property using named Variables.
-     *
-     * @param collectionProperty a Collection Property
-     * @param variables named Variables
-     *
-     * @return a new CONTAINS ALL specification for a Collection Property using named Variables.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> ContainsAllSpecification<T> containsAllVariables(
-        Property<? extends Collection<T>> collectionProperty,
-        Iterable<Variable> variables )
-    {
-        NullArgumentException.validateNotNull( "Variables", variables );
-        return new ContainsAllSpecification( property( collectionProperty ), variables );
-    }
-
-    /**
-     * Create a new CONTAINS specification for a Collection Property.
-     *
-     * @param collectionProperty a Collection Property
-     * @param value the value
-     *
-     * @return a new CONTAINS specification for a Collection Property.
-     */
-    public static <T> ContainsSpecification<T> contains( Property<? extends Collection<T>> collectionProperty,
-                                                         T value )
-    {
-        NullArgumentException.validateNotNull( "Value", value );
-        return new ContainsSpecification<>( property( collectionProperty ), value );
-    }
-
-    /**
-     * Create a new CONTAINS specification for a Collection Property using named Variables.
-     *
-     * @param collectionProperty a Collection Property
-     * @param variable named Variable
-     *
-     * @return a new CONTAINS specification for a Collection Property using named Variables.
-     */
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public static <T> ContainsSpecification<T> contains( Property<? extends Collection<T>> collectionProperty,
-                                                         Variable variable )
-    {
-        NullArgumentException.validateNotNull( "Variable", variable );
-        return new ContainsSpecification( property( collectionProperty ), variable );
-    }
-
-    /**
-     * Create a new CONTAINS specification for a ManyAssociation.
-     *
-     * @param manyAssoc  a ManyAssociation
-     * @param value the value
-     *
-     * @return a new CONTAINS specification for a ManyAssociation.
-     */
-    public static <T> ManyAssociationContainsSpecification<T> contains( ManyAssociation<T> manyAssoc, T value )
-    {
-        return new ManyAssociationContainsSpecification<>( manyAssociation( manyAssoc ), value );
-    }
-
-    /**
-     * Create a new CONTAINS specification for a NamedAssociation.
-     *
-     * @param namedAssoc  a NamedAssociation
-     * @param value the value
-     *
-     * @return a new CONTAINS specification for a NamedAssociation.
-     */
-    public static <T> NamedAssociationContainsSpecification<T> contains( NamedAssociation<T> namedAssoc, T value )
-    {
-        return new NamedAssociationContainsSpecification<>( namedAssociation( namedAssoc ), value );
-    }
-
-    /**
-     * Create a new CONTAINS NAME specification for a NamedAssociation.
-     *
-     * @param namedAssoc  a NamedAssociation
-     * @param name the name
-     *
-     * @return a new CONTAINS NAME specification for a NamedAssociation.
-     */
-    public static <T> NamedAssociationContainsNameSpecification<T> containsName( NamedAssociation<T> namedAssoc,
-                                                                                 String name )
-    {
-        return new NamedAssociationContainsNameSpecification<>( namedAssociation( namedAssoc ), name );
-    }
-
-    // Ordering --------------------------------------------------------------|
-    /**
-     * Create a new Query ascending order segment for a Property.
-     *
-     * @param <T> type of the Property
-     * @param property a Property
-     *
-     * @return a new Query ascending order segment for a Property.
-     */
-    public static <T> OrderBy orderBy( final Property<T> property )
-    {
-        return orderBy( property, OrderBy.Order.ASCENDING );
-    }
-
-    /**
-     * Create a new Query ordering segment for a Property.
-     *
-     * @param <T> type of the Property
-     * @param property a Property
-     * @param order ascending or descending
-     *
-     * @return a new Query ordering segment for a Property.
-     */
-    public static <T> OrderBy orderBy( final Property<T> property, final OrderBy.Order order )
-    {
-        return new OrderBy( property( property ), order );
-    }
-
-    // Query Templates InvocationHandlers ------------------------------------|
-
-    private static class TemplateHandler<T>
-        implements InvocationHandler
-    {
-        private final PropertyFunction<?> compositeProperty;
-        private final AssociationFunction<?> compositeAssociation;
-        private final ManyAssociationFunction<?> compositeManyAssociation;
-        private final NamedAssociationFunction<?> compositeNamedAssociation;
-
-        private TemplateHandler( PropertyFunction<?> compositeProperty,
-                                 AssociationFunction<?> compositeAssociation,
-                                 ManyAssociationFunction<?> compositeManyAssociation,
-                                 NamedAssociationFunction<?> compositeNamedAssociation
-        )
-        {
-            this.compositeProperty = compositeProperty;
-            this.compositeAssociation = compositeAssociation;
-            this.compositeManyAssociation = compositeManyAssociation;
-            this.compositeNamedAssociation = compositeNamedAssociation;
-        }
-
-        @Override
-        public Object invoke( Object o, Method method, Object[] objects )
-            throws Throwable
-        {
-            if( Property.class.isAssignableFrom( method.getReturnType() ) )
-            {
-                return Proxy.newProxyInstance(
-                    method.getReturnType().getClassLoader(),
-                    array( method.getReturnType() ),
-                    new PropertyReferenceHandler<>( new PropertyFunction<T>( compositeProperty,
-                                                                             compositeAssociation,
-                                                                             compositeManyAssociation,
-                                                                             compositeNamedAssociation,
-                                                                             method ) ) );
-            }
-            else if( Association.class.isAssignableFrom( method.getReturnType() ) )
-            {
-                return Proxy.newProxyInstance(
-                    method.getReturnType().getClassLoader(),
-                    array( method.getReturnType() ),
-                    new AssociationReferenceHandler<>( new AssociationFunction<T>( compositeAssociation,
-                                                                                   compositeManyAssociation,
-                                                                                   compositeNamedAssociation,
-                                                                                   method ) ) );
-            }
-            else if( ManyAssociation.class.isAssignableFrom( method.getReturnType() ) )
-            {
-                return Proxy.newProxyInstance(
-                    method.getReturnType().getClassLoader(),
-                    array( method.getReturnType() ),
-                    new ManyAssociationReferenceHandler<>( new ManyAssociationFunction<T>( compositeAssociation,
-                                                                                           compositeManyAssociation,
-                                                                                           compositeNamedAssociation,
-                                                                                           method ) ) );
-            }
-            else if( NamedAssociation.class.isAssignableFrom( method.getReturnType() ) )
-            {
-                return Proxy.newProxyInstance(
-                    method.getReturnType().getClassLoader(),
-                    array( method.getReturnType() ),
-                    new NamedAssociationReferenceHandler<>( new NamedAssociationFunction<T>( compositeAssociation,
-                                                                                             compositeManyAssociation,
-                                                                                             compositeNamedAssociation,
-                                                                                             method ) ) );
-            }
-
-            return null;
-        }
-    }
-
-    private static class PropertyReferenceHandler<T>
-        implements InvocationHandler
-    {
-        private final PropertyFunction<T> property;
-
-        private PropertyReferenceHandler( PropertyFunction<T> property )
-        {
-            this.property = property;
-        }
-
-        private PropertyFunction<T> property()
-        {
-            return property;
-        }
-
-        @Override
-        public Object invoke( Object o, final Method method, Object[] objects )
-            throws Throwable
-        {
-            if( method.equals( Property.class.getMethod( "get" ) ) )
-            {
-                Type propertyType = GenericPropertyInfo.propertyTypeOf( property.accessor() );
-                if( propertyType.getClass().equals( Class.class ) )
-                {
-                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
-                                                   array( (Class<?>) propertyType, PropertyReference.class ),
-                                                   new TemplateHandler<T>( property, null, null, null ) );
-                }
-            }
-
-            return null;
-        }
-    }
-
-    private static class AssociationReferenceHandler<T>
-        implements InvocationHandler
-    {
-        private final AssociationFunction<T> association;
-
-        private AssociationReferenceHandler( AssociationFunction<T> association )
-        {
-            this.association = association;
-        }
-
-        private AssociationFunction<T> association()
-        {
-            return association;
-        }
-
-        @Override
-        public Object invoke( Object o, final Method method, Object[] objects )
-            throws Throwable
-        {
-            if( method.equals( Association.class.getMethod( "get" ) ) )
-            {
-                Type associationType = GenericAssociationInfo.associationTypeOf( association.accessor() );
-                if( associationType.getClass().equals( Class.class ) )
-                {
-                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
-                                                   array( (Class) associationType, PropertyReference.class ),
-                                                   new TemplateHandler<T>( null, association, null, null ) );
-                }
-            }
-
-            return null;
-        }
-    }
-
-    private static class ManyAssociationReferenceHandler<T>
-        implements InvocationHandler
-    {
-        private final ManyAssociationFunction<T> manyAssociation;
-
-        private ManyAssociationReferenceHandler( ManyAssociationFunction<T> manyAssociation )
-        {
-            this.manyAssociation = manyAssociation;
-        }
-
-        public ManyAssociationFunction<T> manyAssociation()
-        {
-            return manyAssociation;
-        }
-
-        @Override
-        public Object invoke( Object o, final Method method, Object[] objects )
-            throws Throwable
-        {
-            if( method.equals( ManyAssociation.class.getMethod( "get", Integer.TYPE ) ) )
-            {
-                Type manyAssociationType = GenericAssociationInfo.associationTypeOf( manyAssociation.accessor() );
-                if( manyAssociationType.getClass().equals( Class.class ) )
-                {
-                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
-                                                   array( (Class) manyAssociationType, PropertyReference.class ),
-                                                   new TemplateHandler<T>( null, null, manyAssociation, null ) );
-                }
-            }
-
-            return null;
-        }
-    }
-
-    private static class NamedAssociationReferenceHandler<T>
-        implements InvocationHandler
-    {
-        private final NamedAssociationFunction<T> namedAssociation;
-
-        private NamedAssociationReferenceHandler( NamedAssociationFunction<T> namedAssociation )
-        {
-            this.namedAssociation = namedAssociation;
-        }
-
-        public NamedAssociationFunction<T> namedAssociation()
-        {
-            return namedAssociation;
-        }
-
-        @Override
-        public Object invoke( Object o, final Method method, Object[] objects )
-            throws Throwable
-        {
-            if( method.equals( NamedAssociation.class.getMethod( "get", String.class ) ) )
-            {
-                Type namedAssociationType = GenericAssociationInfo.associationTypeOf( namedAssociation.accessor() );
-                if( namedAssociationType.getClass().equals( Class.class ) )
-                {
-                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
-                                                   array( (Class) namedAssociationType, PropertyReference.class ),
-                                                   new TemplateHandler<T>( null, null, null, namedAssociation ) );
-                }
-            }
-
-            return null;
-        }
-    }
-
-    @SafeVarargs
-    private static <T> T[] array( T... array )
-    {
-        return array;
-    }
-
-    private QueryExpressions()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/AndSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AndSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AndSpecification.java
deleted file mode 100644
index 3d710ad..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AndSpecification.java
+++ /dev/null
@@ -1,56 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * AND Specification.
- */
-public class AndSpecification
-    extends BinarySpecification
-{
-
-    public AndSpecification( Iterable<Specification<Composite>> operands )
-    {
-        super( operands );
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        return Specifications.and( operands ).satisfiedBy( item );
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder( "(" );
-        String and = "";
-        for( Specification<Composite> operand : operands )
-        {
-            sb.append( and ).append( operand );
-            and = " and ";
-        }
-        return sb.append( ")" ).toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationFunction.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationFunction.java
deleted file mode 100644
index 8355114..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationFunction.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.query.QueryExpressionException;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.Function;
-
-import static org.apache.zest.api.util.Classes.typeOf;
-
-/**
- * Function to get Entity Associations
- */
-public class AssociationFunction<T>
-    implements Function<Composite, Association<T>>
-{
-    private final AssociationFunction<?> traversedAssociation;
-    private final ManyAssociationFunction<?> traversedManyAssociation;
-    private final NamedAssociationFunction<?> traversedNamedAssociation;
-    private final AccessibleObject accessor;
-
-    public AssociationFunction( AssociationFunction<?> traversedAssociation,
-                                ManyAssociationFunction<?> traversedManyAssociation,
-                                NamedAssociationFunction<?> traversedNamedAssociation,
-                                AccessibleObject accessor
-    )
-    {
-        this.traversedAssociation = traversedAssociation;
-        this.traversedManyAssociation = traversedManyAssociation;
-        this.traversedNamedAssociation = traversedNamedAssociation;
-        this.accessor = accessor;
-
-        Type returnType = typeOf( accessor );
-        if( !Association.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) )
-            && !ManyAssociation.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) )
-            && !NamedAssociation.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) ) )
-        {
-            throw new QueryExpressionException( "Unsupported association type:" + returnType );
-        }
-        Type associationTypeAsType = GenericAssociationInfo.toAssociationType( returnType );
-        if( !( associationTypeAsType instanceof Class ) )
-        {
-            throw new QueryExpressionException( "Unsupported association type:" + associationTypeAsType );
-        }
-    }
-
-    public AssociationFunction<?> traversedAssociation()
-    {
-        return traversedAssociation;
-    }
-
-    public ManyAssociationFunction<?> traversedManyAssociation()
-    {
-        return traversedManyAssociation;
-    }
-
-    public NamedAssociationFunction<?> traversedNamedAssociation()
-    {
-        return traversedNamedAssociation;
-    }
-
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public Association<T> map( Composite entity )
-    {
-        try
-        {
-            Object target = entity;
-            if( traversedAssociation != null )
-            {
-                Association<?> association = traversedAssociation.map( entity );
-                if( association == null )
-                {
-                    return null;
-                }
-                target = association.get();
-            }
-            else if( traversedManyAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );
-            }
-            else if( traversedNamedAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot evaluate a NamedAssociation" );
-            }
-
-            if( target == null )
-            {
-                return null;
-            }
-
-            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
-            return ( (AssociationStateHolder) handler.state() ).associationFor( accessor );
-        }
-        catch( IllegalArgumentException e )
-        {
-            throw e;
-        }
-        catch( Throwable e )
-        {
-            throw new IllegalArgumentException( e );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        if( traversedAssociation != null )
-        {
-            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
-        }
-        else
-        {
-            return ( (Member) accessor ).getName();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullSpecification.java
deleted file mode 100644
index 1376029..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullSpecification.java
+++ /dev/null
@@ -1,67 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * Association not null Specification.
- */
-public class AssociationNotNullSpecification<T>
-    extends ExpressionSpecification
-{
-    private AssociationFunction<T> association;
-
-    public AssociationNotNullSpecification( AssociationFunction<T> association )
-    {
-        this.association = association;
-    }
-
-    public AssociationFunction<T> association()
-    {
-        return association;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        try
-        {
-            Association<T> assoc = association.map( item );
-
-            if( assoc == null )
-            {
-                return false;
-            }
-
-            return assoc.get() != null;
-        }
-        catch( IllegalArgumentException e )
-        {
-            return false;
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return association.toString() + "is not null";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullSpecification.java
deleted file mode 100644
index 7dd72b2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullSpecification.java
+++ /dev/null
@@ -1,67 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * Association null Specification.
- */
-public class AssociationNullSpecification<T>
-    extends ExpressionSpecification
-{
-    private AssociationFunction<T> association;
-
-    public AssociationNullSpecification( AssociationFunction<T> association )
-    {
-        this.association = association;
-    }
-
-    public AssociationFunction<T> association()
-    {
-        return association;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        try
-        {
-            Association<T> assoc = association.map( item );
-
-            if( assoc == null )
-            {
-                return true;
-            }
-
-            return assoc.get() == null;
-        }
-        catch( IllegalArgumentException e )
-        {
-            return true;
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return association.toString() + "is null";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/BinarySpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/BinarySpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/BinarySpecification.java
deleted file mode 100644
index 177caf0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/BinarySpecification.java
+++ /dev/null
@@ -1,41 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-
-/**
- * Base binary Specification, used for AND and OR Specifications..
- */
-public abstract class BinarySpecification
-    extends ExpressionSpecification
-{
-    protected final Iterable<Specification<Composite>> operands;
-
-    protected BinarySpecification( Iterable<Specification<Composite>> operands )
-    {
-        this.operands = operands;
-    }
-
-    public Iterable<Specification<Composite>> operands()
-    {
-        return operands;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ComparisonSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ComparisonSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ComparisonSpecification.java
deleted file mode 100644
index c53fe00..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ComparisonSpecification.java
+++ /dev/null
@@ -1,76 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Base comparison Specification.
- */
-public abstract class ComparisonSpecification<T>
-    extends ExpressionSpecification
-{
-    protected final PropertyFunction<T> property;
-    protected final T value;
-
-    public ComparisonSpecification( PropertyFunction<T> property, T value )
-    {
-        this.property = property;
-        this.value = value;
-    }
-
-    public PropertyFunction<T> property()
-    {
-        return property;
-    }
-
-    @Override
-    public final boolean satisfiedBy( Composite item )
-    {
-        try
-        {
-            Property<T> prop = property.map( item );
-
-            if( prop == null )
-            {
-                return false;
-            }
-
-            T propValue = prop.get();
-            if( propValue == null )
-            {
-                return false;
-            }
-
-            return compare( propValue );
-        }
-        catch( IllegalArgumentException e )
-        {
-            return false;
-        }
-    }
-
-    protected abstract boolean compare( T value );
-
-    public T value()
-    {
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsAllSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsAllSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsAllSpecification.java
deleted file mode 100644
index c5221d2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsAllSpecification.java
+++ /dev/null
@@ -1,78 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.util.Collection;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Iterables;
-
-/**
- * Contains All Specification.
- */
-public class ContainsAllSpecification<T>
-    extends ExpressionSpecification
-{
-    private PropertyFunction<? extends Collection<T>> collectionProperty;
-    private Iterable<T> valueCollection;
-
-    public ContainsAllSpecification( PropertyFunction<? extends Collection<T>> collectionProperty,
-                                     Iterable<T> valueCollection
-    )
-    {
-        this.collectionProperty = collectionProperty;
-        this.valueCollection = valueCollection;
-    }
-
-    public PropertyFunction<? extends Collection<T>> collectionProperty()
-    {
-        return collectionProperty;
-    }
-
-    public Iterable<T> containedValues()
-    {
-        return valueCollection;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        Collection<T> collection = collectionProperty.map( item ).get();
-
-        if( collection == null )
-        {
-            return false;
-        }
-
-        for( T value : valueCollection )
-        {
-            if( !collection.contains( value ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    @Override
-    public String toString()
-    {
-        return collectionProperty + " contains " + Iterables.toList( valueCollection );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsSpecification.java
deleted file mode 100644
index 4f05aac..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ContainsSpecification.java
+++ /dev/null
@@ -1,67 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.util.Collection;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * Contains Specification.
- */
-public class ContainsSpecification<T>
-    extends ExpressionSpecification
-{
-    private PropertyFunction<? extends Collection<T>> collectionProperty;
-    private T value;
-
-    public ContainsSpecification( PropertyFunction<? extends Collection<T>> collectionProperty, T value )
-    {
-        this.collectionProperty = collectionProperty;
-        this.value = value;
-    }
-
-    public PropertyFunction<? extends Collection<T>> collectionProperty()
-    {
-        return collectionProperty;
-    }
-
-    public T value()
-    {
-        return value;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        Collection<T> collection = collectionProperty.map( item ).get();
-
-        if( collection == null )
-        {
-            return false;
-        }
-
-        return collection.contains( value );
-    }
-
-    @Override
-    public String toString()
-    {
-        return collectionProperty + " contains " + value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/EqSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/EqSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/EqSpecification.java
deleted file mode 100644
index b7ed03c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/EqSpecification.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Equals Specification.
- */
-public class EqSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public EqSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    protected boolean compare( T value )
-    {
-        return value.equals( this.value );
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "=" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ExpressionSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ExpressionSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ExpressionSpecification.java
deleted file mode 100644
index f0dd6b2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ExpressionSpecification.java
+++ /dev/null
@@ -1,60 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.functional.Iterables.append;
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * Base expression Specification.
- */
-public abstract class ExpressionSpecification
-    implements Specification<Composite>
-{
-
-    @SuppressWarnings( "unchecked" )
-    public AndSpecification and( Specification<Composite> specification )
-    {
-        if( this instanceof AndSpecification )
-        {
-            return new AndSpecification( append( specification, ( (AndSpecification) this ).operands() ) );
-        }
-        else
-        {
-            return new AndSpecification( iterable( this, specification ) );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public OrSpecification or( Specification<Composite> specification )
-    {
-        if( this instanceof OrSpecification )
-        {
-            return new OrSpecification( append( specification, ( (OrSpecification) this ).operands() ) );
-        }
-        else
-        {
-            return new OrSpecification( iterable( this, specification ) );
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/GeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/GeSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/GeSpecification.java
deleted file mode 100644
index f012293..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/GeSpecification.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Greater or equals Specification.
- */
-public class GeSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public GeSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    protected boolean compare( T value )
-    {
-        return ( (Comparable) value ).compareTo( this.value ) >= 0;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + ">=" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/GtSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/GtSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/GtSpecification.java
deleted file mode 100644
index 880fb67..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/GtSpecification.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Greater than Specification.
- */
-public class GtSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public GtSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    protected boolean compare( T value )
-    {
-        return ( (Comparable) value ).compareTo( this.value ) > 0;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + ">" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
deleted file mode 100644
index 3a28f16..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/LeSpecification.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Less or equals Specification.
- */
-public class LeSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public LeSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    protected boolean compare( T value )
-    {
-        return ( (Comparable) value ).compareTo( this.value ) <= 0;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "<=" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
deleted file mode 100644
index 8f476c3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/LtSpecification.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-/**
- * Lesser than Specification.
- */
-public class LtSpecification<T>
-    extends ComparisonSpecification<T>
-{
-    public LtSpecification( PropertyFunction<T> property, T value )
-    {
-        super( property, value );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    protected boolean compare( T value )
-    {
-        return ( (Comparable) value ).compareTo( this.value ) < 0;
-    }
-
-    @Override
-    public String toString()
-    {
-        return property.toString() + "<" + value.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
deleted file mode 100644
index a15bdb0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationContainsSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * ManyAssociation Contains Specification.
- */
-public class ManyAssociationContainsSpecification<T>
-    extends ExpressionSpecification
-{
-    private final ManyAssociationFunction<T> manyAssociationFunction;
-    private final T value;
-
-    public ManyAssociationContainsSpecification( ManyAssociationFunction<T> manyAssociationFunction, T value )
-    {
-        this.manyAssociationFunction = manyAssociationFunction;
-        this.value = value;
-    }
-
-    public ManyAssociationFunction<T> manyAssociation()
-    {
-        return manyAssociationFunction;
-    }
-
-    public T value()
-    {
-        return value;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        ManyAssociation<T> collection = manyAssociationFunction.map( item );
-        if( collection == null )
-        {
-            return false;
-        }
-        return collection.contains( value );
-    }
-
-    @Override
-    public String toString()
-    {
-        return manyAssociationFunction + " contains:" + value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationFunction.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationFunction.java
deleted file mode 100644
index 540a901..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/ManyAssociationFunction.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2007-2011 Rickard Öberg.
- * Copyright 2007-2010 Niclas Hedhman.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.lang.reflect.Proxy;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.functional.Function;
-
-/**
- * Function to get Entity ManyAssociations.
- */
-public class ManyAssociationFunction<T>
-    implements Function<Composite, ManyAssociation<T>>
-{
-    private final AssociationFunction<?> traversedAssociation;
-    private final ManyAssociationFunction<?> traversedManyAssociation;
-    private final NamedAssociationFunction<?> traversedNamedAssociation;
-    private final AccessibleObject accessor;
-
-    public ManyAssociationFunction( AssociationFunction<?> traversedAssociation,
-                                    ManyAssociationFunction<?> traversedManyAssociation,
-                                    NamedAssociationFunction<?> traversedNamedAssociation,
-                                    AccessibleObject accessor
-    )
-    {
-        this.traversedAssociation = traversedAssociation;
-        this.traversedManyAssociation = traversedManyAssociation;
-        this.traversedNamedAssociation = traversedNamedAssociation;
-        this.accessor = accessor;
-    }
-
-    public AssociationFunction<?> traversedAssociation()
-    {
-        return traversedAssociation;
-    }
-
-    public ManyAssociationFunction<?> traversedManyAssociation()
-    {
-        return traversedManyAssociation;
-    }
-
-    public NamedAssociationFunction<?> traversedNamedAssociation()
-    {
-        return traversedNamedAssociation;
-    }
-
-    public AccessibleObject accessor()
-    {
-        return accessor;
-    }
-
-    @Override
-    public ManyAssociation<T> map( Composite entity )
-    {
-        try
-        {
-            Object target = entity;
-            if( traversedAssociation != null )
-            {
-                target = traversedAssociation.map( entity ).get();
-            }
-            if( traversedManyAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot traverse ManyAssociations" );
-            }
-            if( traversedNamedAssociation != null )
-            {
-                throw new IllegalArgumentException( "Cannot traverse NamedAssociations" );
-            }
-
-            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
-            return ( (AssociationStateHolder) handler.state() ).manyAssociationFor( accessor );
-        }
-        catch( IllegalArgumentException e )
-        {
-            throw e;
-        }
-        catch( Throwable e )
-        {
-            throw new IllegalArgumentException( e );
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        if( traversedAssociation != null )
-        {
-            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
-        }
-        else
-        {
-            return ( (Member) accessor ).getName();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
deleted file mode 100644
index 4f54a47..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesSpecification.java
+++ /dev/null
@@ -1,93 +0,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.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.property.Property;
-
-/**
- * Regular expression match Specification.
- */
-public class MatchesSpecification
-    extends ExpressionSpecification
-{
-    private PropertyFunction<String> property;
-    private Object value;
-
-    public MatchesSpecification( PropertyFunction<String> property, String regexp )
-    {
-        this.property = property;
-        this.value = regexp;
-    }
-
-    public MatchesSpecification( PropertyFunction<String> property, Variable variable )
-    {
-        this.property = property;
-        this.value = variable;
-    }
-
-    public PropertyFunction<String> property()
-    {
-        return property;
-    }
-
-    public Object value()
-    {
-        return value;
-    }
-
-    public String regexp()
-    {
-        return ( String ) value;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        Property<String> prop = property.map( item );
-
-        if( prop == null )
-        {
-            return false;
-        }
-
-        String val = prop.get();
-
-        if( val == null )
-        {
-            return false;
-        }
-
-        return val.matches( ( String ) value );
-    }
-
-    @Override
-    public String toString()
-    {
-        return new StringBuilder()
-            .append( "( " )
-            .append( property )
-            .append( " matches " )
-            .append( "\"" )
-            .append( value )
-            .append( "\"" )
-            .append( " )" )
-            .toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
deleted file mode 100644
index 5af9a51..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsNameSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2011-2012 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * NamedAssociation Contains Specification.
- */
-public class NamedAssociationContainsNameSpecification<T>
-    extends ExpressionSpecification
-{
-    private final NamedAssociationFunction<T> namedAssociationFunction;
-    private final String name;
-
-    public NamedAssociationContainsNameSpecification( NamedAssociationFunction<T> namedAssociationFunction, String name )
-    {
-        this.namedAssociationFunction = namedAssociationFunction;
-        this.name = name;
-    }
-
-    public NamedAssociationFunction<T> namedAssociation()
-    {
-        return namedAssociationFunction;
-    }
-
-    public String name()
-    {
-        return name;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        NamedAssociation<T> collection = namedAssociationFunction.map( item );
-        if( collection == null )
-        {
-            return false;
-        }
-        return collection.containsName( name );
-    }
-
-    @Override
-    public String toString()
-    {
-        return namedAssociationFunction + " contains name:" + name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
deleted file mode 100644
index e4e4f7b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/query/grammar/NamedAssociationContainsSpecification.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2011-2012 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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
- * ied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.api.query.grammar;
-
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.Composite;
-
-/**
- * NamedAssociation Contains Specification.
- */
-public class NamedAssociationContainsSpecification<T>
-    extends ExpressionSpecification
-{
-    private final NamedAssociationFunction<T> namedAssociationFunction;
-    private final T value;
-
-    public NamedAssociationContainsSpecification( NamedAssociationFunction<T> namedAssociationFunction, T value )
-    {
-        this.namedAssociationFunction = namedAssociationFunction;
-        this.value = value;
-    }
-
-    public NamedAssociationFunction<T> namedAssociation()
-    {
-        return namedAssociationFunction;
-    }
-
-    public T value()
-    {
-        return value;
-    }
-
-    @Override
-    public boolean satisfiedBy( Composite item )
-    {
-        NamedAssociation<T> collection = namedAssociationFunction.map( item );
-        if( collection == null )
-        {
-            return false;
-        }
-        return collection.nameOf( value ) != null;
-    }
-
-    @Override
-    public String toString()
-    {
-        return namedAssociationFunction + " contains:" + value;
-    }
-}


[26/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java
deleted file mode 100644
index 8cee5f1..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2008, Michael Hunger 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.zest.bootstrap;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.property.Property;
-
-/**
- * Declaration of a Property or Association.
- */
-public final class MetaInfoDeclaration
-    implements StateDeclarations, AssociationDeclarations, ManyAssociationDeclarations, NamedAssociationDeclarations
-{
-    Map<Class<?>, InfoHolder<?>> mixinPropertyDeclarations = new HashMap<>();
-
-    public MetaInfoDeclaration()
-    {
-    }
-
-    public <T> MixinDeclaration<T> on( Class<T> mixinType )
-    {
-        @SuppressWarnings( "unchecked" )
-        InfoHolder<T> propertyDeclarationHolder = (InfoHolder<T>) mixinPropertyDeclarations.get( mixinType );
-        if( propertyDeclarationHolder == null )
-        {
-            propertyDeclarationHolder = new InfoHolder<>( mixinType );
-            mixinPropertyDeclarations.put( mixinType, propertyDeclarationHolder );
-        }
-        return propertyDeclarationHolder;
-    }
-
-    @Override
-    public MetaInfo metaInfoFor( AccessibleObject accessor )
-    {
-        for( Map.Entry<Class<?>, InfoHolder<?>> entry : mixinPropertyDeclarations.entrySet() )
-        {
-            InfoHolder<?> holder = entry.getValue();
-            MetaInfo metaInfo = holder.metaInfoFor( accessor );
-            if( metaInfo != null )
-            {
-                Class<?> mixinType = entry.getKey();
-                return metaInfo.withAnnotations( mixinType )
-                    .withAnnotations( accessor )
-                    .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor )
-                        .getType() );
-            }
-        }
-        // TODO is this code reached at all??
-        Class<?> declaringType = ( (Member) accessor ).getDeclaringClass();
-        return new MetaInfo().withAnnotations( declaringType )
-            .withAnnotations( accessor )
-            .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor ).getType() );
-    }
-
-    @Override
-    public Object initialValueOf( AccessibleObject accessor )
-    {
-        for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() )
-        {
-            final Object initialValue = propertyDeclarationHolder.initialValueOf( accessor );
-            if( initialValue != null )
-            {
-                return initialValue;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public boolean useDefaults( AccessibleObject accessor )
-    {
-        for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() )
-        {
-            final boolean useDefaults = propertyDeclarationHolder.useDefaults( accessor );
-            if( useDefaults )
-            {
-                return useDefaults;
-            }
-        }
-        return false;
-    }
-
-    private static class InfoHolder<T>
-        implements InvocationHandler, StateDeclarations, MixinDeclaration<T>
-    {
-        private final static class MethodInfo
-        {
-            Object initialValue;
-            boolean useDefaults;
-            MetaInfo metaInfo;
-
-            private MethodInfo( MetaInfo metaInfo )
-            {
-                this.metaInfo = metaInfo;
-            }
-        }
-
-        private final Class<T> mixinType;
-        private final Map<AccessibleObject, MethodInfo> methodInfos = new HashMap<>();
-        // temporary holder
-        private MetaInfo metaInfo = null;
-
-        private InfoHolder( Class<T> mixinType )
-        {
-            this.mixinType = mixinType;
-        }
-
-        @Override
-        @SuppressWarnings( "raw" )
-        public Object invoke( Object o, Method method, Object[] objects )
-            throws Throwable
-        {
-            final MethodInfo methodInfo = new MethodInfo( metaInfo );
-            methodInfo.useDefaults = true;
-            methodInfos.put( method, methodInfo );
-            metaInfo = null; // reset
-            final Class<?> returnType = method.getReturnType();
-            try
-            {
-                return Proxy.newProxyInstance( returnType.getClassLoader(), new Class[]{ returnType },
-                                               new InvocationHandler()
-                                               {
-                                                   @Override
-                                                   public Object invoke( Object o, Method method, Object[] objects )
-                                                       throws Throwable
-                                                   {
-                                                       if( method.getName().equals( "set" ) )
-                                                       {
-                                                           methodInfo.initialValue = objects[ 0 ];
-                                                       }
-                                                       return null;
-                                                   }
-                                               } );
-            }
-            catch( IllegalArgumentException e )
-            {
-                throw new IllegalArgumentException(
-                    "Only methods with " + Property.class.getName() + " as return type can have declareDefaults()" );
-            }
-        }
-
-        public MethodInfo matches( AccessibleObject accessor )
-        {
-            return methodInfos.get( accessor );
-        }
-
-        @Override
-        public MetaInfo metaInfoFor( AccessibleObject accessor )
-        {
-            final MethodInfo methodInfo = matches( accessor );
-            if( methodInfo == null )
-            {
-                return null;
-            }
-            return methodInfo.metaInfo;
-        }
-
-        @Override
-        public Object initialValueOf( AccessibleObject accessor )
-        {
-            final MethodInfo methodInfo = matches( accessor );
-            if( methodInfo == null )
-            {
-                return null;
-            }
-            return methodInfo.initialValue;
-        }
-
-        @Override
-        public boolean useDefaults( AccessibleObject accessor )
-        {
-            final MethodInfo methodInfo = matches( accessor );
-            if( methodInfo == null )
-            {
-                return false;
-            }
-            return methodInfo.useDefaults;
-        }
-
-        // DSL Interface
-
-        @Override
-        @SuppressWarnings( "raw" )
-        public T declareDefaults()
-        {
-            return mixinType.cast(
-                Proxy.newProxyInstance( mixinType.getClassLoader(), new Class[]{ mixinType }, this ) );
-        }
-
-        @Override
-        public MixinDeclaration<T> setMetaInfo( Object info )
-        {
-            if( metaInfo == null )
-            {
-                metaInfo = new MetaInfo();
-            }
-            metaInfo.set( info );
-            return this;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java
deleted file mode 100644
index 629c9df..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2008, Michael Hunger. 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.zest.bootstrap;
-
-/**
- * Fluent API for declaring information about properties
- *
- * @param <T>
- */
-public interface MixinDeclaration<T>
-{
-    T declareDefaults();
-
-    MixinDeclaration<T> setMetaInfo( Object info );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
deleted file mode 100644
index 6bf4437..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. All rights Reserved.
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.functional.Specification;
-
-/**
- * The ModuleAssembly is used to register any information about * what the module should contain, such as composites,
- * entities and services.
- * <p>
- * Use the methods and the fluent API's to declare how the module should be constructed.
- * </p>
- */
-public interface ModuleAssembly
-{
-    /**
-     * Access the layer assembly for this module.
-     *
-     * @return The Layer containing this Module.
-     */
-    LayerAssembly layer();
-
-    /**
-     * Get an assembly for a particular Module. If this is called many times with the same names, then the same module
-     * is affected.
-     *
-     * @param layerName  The name of the Layer
-     * @param moduleName The name of the Module to retrieve or create.
-     *
-     * @return The ModuleAssembly for the Module.
-     */
-    ModuleAssembly module( String layerName, String moduleName );
-
-    /**
-     * Set the name of this module.
-     *
-     * @param name The name that this Module should have.
-     *
-     * @return This instance to support the fluid DSL of bootstrap.
-     */
-    ModuleAssembly setName( String name );
-
-    /**
-     * Access the currently set name for this module.
-     *
-     * @return The name of this Module.
-     */
-    String name();
-
-    ModuleAssembly setMetaInfo( Object info );
-
-    /**
-     * Set the module activators. Activators are executed in order around the
-     * Module activation and passivation.
-     *
-     * @param activators the module activators
-     *
-     * @return the assembly
-     */
-    @SuppressWarnings({ "unchecked", "varargs" })
-    ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators );
-
-    /**
-     * Declare a list of TransientComposites for this Module. Use the TransientDeclaration that is returned to
-     * declare further settings. Note that the TransientDeclaration works on all of the types specified.
-     *
-     * @param transientTypes The types that specifies the Transient types.
-     *
-     * @return An TransientDeclaration for the specified Transient types.
-     */
-    TransientDeclaration transients( Class<?>... transientTypes );
-
-    /**
-     * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the TransientComposite types of interest.
-     *
-     * @return An TransientDeclaration for the specified TransientComposite types.
-     */
-    TransientDeclaration transients( Specification<? super TransientAssembly> specification );
-
-    /**
-     * Declare a list of ValueComposites for this Module. Use the ValueDeclaration that is returned to
-     * declare further settings. Note that the ValueDeclaration works on all of the types specified.
-     *
-     * @param valueTypes The types that specifies the Value types.
-     *
-     * @return An ValueDeclaration for the specified Value types.
-     */
-    ValueDeclaration values( Class<?>... valueTypes );
-
-    /**
-     * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the ValueComposite types of interest.
-     *
-     * @return An ValueDeclaration for the specified ValueComposite types.
-     */
-    ValueDeclaration values( Specification<? super ValueAssembly> specification );
-
-    /**
-     * Declare a list of EntityComposites for this Module. Use the EntityDeclaration that is returned to
-     * declare further settings. Note that the EntityDeclaration works on all of the types specified.
-     *
-     * @param entityTypes The types that specifies the Entity types.
-     *
-     * @return An EntityDeclaration for the specified Entity types.
-     */
-    EntityDeclaration entities( Class<?>... entityTypes );
-
-    /**
-     * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the EntityComposite types of interest.
-     *
-     * @return An EntityDeclaration for the specified EntityComposite types.
-     */
-    EntityDeclaration entities( Specification<? super EntityAssembly> specification );
-
-    /**
-     * Declare a list of Configuration Composites for this Module. Use the ConfigurationDeclaration that is returned to
-     * declare further settings. Note that the ConfigurationDeclaration works on all of the types specified.
-     *
-     * @param configurationTypes The types that specifies the Configuration types.
-     *
-     * @return An ConfigurationDeclaration for the specified Configuration types.
-     */
-    ConfigurationDeclaration configurations( Class<?>... configurationTypes );
-
-    /**
-     * Given a Specification for ConfigurationAssembly's, returns a ConfigurationDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the ConfigurationComposite types of interest.
-     *
-     * @return An ConfigurationDeclaration for the specified EntityComposite types.
-     */
-    ConfigurationDeclaration configurations( Specification<HasTypes> specification );
-
-
-    /**
-     * Declare a list of object classes for this Module. Use the ObjectDeclaration that is returned to
-     * declare further settings. Note that the ObjectDeclaration works on all of the types specified.
-     *
-     * @param objectTypes The types that specifies the Object types.
-     *
-     * @return An ObjectDeclaration for the specified Object types.
-     */
-    ObjectDeclaration objects( Class<?>... objectTypes )
-        throws AssemblyException;
-
-    /**
-     * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the Object types of interest.
-     *
-     * @return An ObjectDeclaration for the specified Object types.
-     */
-    ObjectDeclaration objects( Specification<? super ObjectAssembly> specification );
-
-    /**
-     * Create a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
-     * declare further settings. This will always create new assemblies for the specified types, instead
-     * of potentially working on already declared types like the services(...) method.
-     *
-     * @param serviceTypes The types that specifies the Service types.
-     *
-     * @return An ServiceDeclaration for the specified Service types.
-     */
-    ServiceDeclaration addServices( Class<?>... serviceTypes );
-
-    /**
-     * Declare a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
-     * declare further settings. Note that the ServiceDeclaration works on all of the types specified.
-     *
-     * @param serviceTypes The types that specifies the Service types.
-     *
-     * @return An ServiceDeclaration for the specified Service types.
-     */
-    ServiceDeclaration services( Class<?>... serviceTypes );
-
-    /**
-     * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the ServiceComposite types of interest.
-     *
-     * @return An ServiceDeclaration for the specified ServiceComposite types.
-     */
-    ServiceDeclaration services( Specification<? super ServiceAssembly> specification );
-
-    /**
-     * Declare a list of imported services for this Module. Use the ImportedServiceDeclaration that is returned to
-     * declare further settings. Note that the ImportedServiceDeclaration works on all of the types specified.
-     *
-     * @param serviceTypes The types that specifies the Imported Service types.
-     *
-     * @return An ImportedServiceDeclaration for the specified Imported Service types.
-     */
-    ImportedServiceDeclaration importedServices( Class<?>... serviceTypes );
-
-    /**
-     * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can
-     * be used to work with all of the assemblies matched by the specification.
-     *
-     * @param specification The Specification that specifies the Imported Service types of interest.
-     *
-     * @return An ImportedServiceDeclaration for the specified Imported Service types.
-     */
-    ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification );
-
-    <T> MixinDeclaration<T> forMixin( Class<T> mixinType );
-
-    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java
deleted file mode 100644
index 122dfa5..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Set the name of the module
- */
-public final class ModuleName
-    implements Assembler
-{
-    private final String name;
-
-    public ModuleName( String name )
-    {
-        this.name = name;
-    }
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.setName( name );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
deleted file mode 100644
index b5c8e46..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.bootstrap;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.MetaInfo;
-
-/**
- * This provides declared {@link org.apache.zest.api.association.NamedAssociation} information that the runtime can use.
- */
-public interface NamedAssociationDeclarations
-{
-    MetaInfo metaInfoFor( AccessibleObject accessor );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java
deleted file mode 100644
index f26225c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single object type in a Module.
- */
-public interface ObjectAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java
deleted file mode 100644
index af4c1c9..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring objects.Instances
- * of this API are acquired by calling {@link ModuleAssembly#objects(Class[])}.
- */
-public interface ObjectDeclaration
-{
-    ObjectDeclaration setMetaInfo( Object info );
-
-    ObjectDeclaration visibleIn( Visibility visibility )
-        throws IllegalStateException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Qi4jRuntime.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Qi4jRuntime.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Qi4jRuntime.java
deleted file mode 100644
index d0914bc..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Qi4jRuntime.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.spi.Qi4jSPI;
-
-/**
- * This interface has to be implemented by Zest runtimes.
- */
-public interface Qi4jRuntime
-{
-    ApplicationAssemblyFactory applicationAssemblyFactory();
-
-    ApplicationModelFactory applicationModelFactory();
-
-    Qi4j api();
-
-    Qi4jSPI spi();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
deleted file mode 100644
index e9631af..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
+++ /dev/null
@@ -1,62 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-/**
- * Zest runtime factory.
- */
-public interface RuntimeFactory
-{
-    Qi4jRuntime createRuntime();
-
-    /**
-     * Standalone application Zest runtime factory.
-     */
-    public final class StandaloneApplicationRuntimeFactory
-        implements RuntimeFactory
-    {
-        @Override
-        public Qi4jRuntime createRuntime()
-        {
-            ClassLoader loader = getClass().getClassLoader();
-            try
-            {
-                Class<? extends Qi4jRuntime> runtimeClass = loadRuntimeClass( loader );
-                return runtimeClass.newInstance();
-            }
-            catch( ClassNotFoundException e )
-            {
-                System.err.println( "Zest Runtime jar is not present in the classpath." );
-            }
-            catch( InstantiationException | IllegalAccessException e )
-            {
-                System.err.println( "Invalid Zest Runtime class. If you are providing your own Zest Runtime, please " +
-                                    "contact qi4j-dev at Google Groups for assistance." );
-            }
-            return null;
-        }
-
-        @SuppressWarnings( { "unchecked" } )
-        private Class<? extends Qi4jRuntime> loadRuntimeClass( ClassLoader loader )
-            throws ClassNotFoundException
-        {
-            return (Class<? extends Qi4jRuntime>) loader.loadClass( "org.qi4j.runtime.Qi4jRuntimeImpl" );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java
deleted file mode 100644
index 095c67b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single ServiceComposite in a Module.
- */
-public interface ServiceAssembly extends HasTypes
-{
-    String identity();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
deleted file mode 100644
index dc820d5..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. All rights Reserved.
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring services hosted in Zest. Instances
- * of this API are acquired by calling {@link ModuleAssembly#services(Class[])}.
- */
-public interface ServiceDeclaration
-{
-    ServiceDeclaration setMetaInfo( Object serviceAttribute );
-
-    ServiceDeclaration visibleIn( Visibility visibility );
-
-    ServiceDeclaration withConcerns( Class<?>... concerns );
-
-    ServiceDeclaration withSideEffects( Class<?>... sideEffects );
-
-    ServiceDeclaration withMixins( Class<?>... mixins );
-
-    ServiceDeclaration withTypes( Class<?>... types );
-
-    ServiceDeclaration identifiedBy( String identity );
-
-    ServiceDeclaration taggedWith( String... tags );
-
-    ServiceDeclaration instantiateOnStartup();
-
-    /**
-     * Set the service activators. Activators are executed in order around the
-     * ServiceReference activation and passivation.
-     *
-     * @param activators the service activators
-     * @return the assembly
-     */    
-    @SuppressWarnings( { "unchecked","varargs" } )
-    ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
deleted file mode 100644
index 1666f7a..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.bootstrap;
-
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-
-/**
- * Base class for Assembler that creates an Application
- * with one Layer and one Module. Create a subclass of this
- * and implement the {@link Assembler#assemble(ModuleAssembly)} method.
- * Once the SingletonAssembler is instantiated it will have created and activated
- * an Application which can be accessed from {@link org.apache.zest.bootstrap.SingletonAssembler#application()}.
- * You can also easily access any resources specific for the single Module, such as the TransientBuilderFactory.
- */
-public abstract class SingletonAssembler
-    implements Assembler
-{
-    private Energy4Java qi4j;
-    private Application applicationInstance;
-    private final Module moduleInstance;
-
-    /**
-     * Creates a Zest Runtime instance containing one Layer with one Module.
-     * The Layer will be named "Layer 1" and the Module will be named "Module 1". It is possible to add
-     * additional layers and modules via the Assembler interface that must be implemented in the subclass of this
-     * class.
-     *
-     * @throws AssemblyException Either if the model can not be created from the disk, or some inconsistency in
-     *                           the programming model makes it impossible to create it.
-     * @throws ActivationException If the automatic {@code activate()} method is throwing this Exception..
-     */
-    public SingletonAssembler()
-        throws AssemblyException, ActivationException
-    {
-// START SNIPPET: actual
-        qi4j = new Energy4Java();
-        applicationInstance = qi4j.newApplication( new ApplicationAssembler()
-        {
-            @Override
-            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-                throws AssemblyException
-            {
-                return applicationFactory.newApplicationAssembly( SingletonAssembler.this );
-            }
-        } );
-
-        try
-        {
-            beforeActivation( applicationInstance );
-            applicationInstance.activate();
-        }
-        catch( Exception e )
-        {
-            if( e instanceof ActivationException )
-            {
-                throw ( (ActivationException) e );
-            }
-            throw new ActivationException( "Could not activate application", e );
-        }
-// START SNIPPET: actual
-
-        moduleInstance = applicationInstance.findModule( "Layer 1", "Module 1" );
-    }
-
-    public final Qi4j runtime()
-    {
-        return qi4j.spi();
-    }
-
-    public final Application application()
-    {
-        return applicationInstance;
-    }
-
-    public final Module module()
-    {
-        return moduleInstance;
-    }
-
-    protected void beforeActivation( Application application )
-        throws Exception
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
deleted file mode 100644
index ad060b2..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.MetaInfo;
-
-/**
- * This provides declared {@link org.apache.zest.api.property.Property} information that the runtime can use.
- */
-public interface StateDeclarations
-{
-    MetaInfo metaInfoFor( AccessibleObject accessor );
-
-    Object initialValueOf( AccessibleObject accessor );
-
-    boolean useDefaults( AccessibleObject accessor );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java
deleted file mode 100644
index 7d8db10..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single TransientComposite in a Module.
- */
-public interface TransientAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java
deleted file mode 100644
index 2709595..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring TransientComposites. Instances
- * of this API are acquired by calling {@link ModuleAssembly#transients(Class[])}.
- */
-public interface TransientDeclaration
-{
-    TransientDeclaration setMetaInfo( Object info );
-
-    TransientDeclaration visibleIn( Visibility visibility );
-
-    TransientDeclaration withConcerns( Class<?>... concerns );
-
-    TransientDeclaration withSideEffects( Class<?>... sideEffects );
-
-    TransientDeclaration withMixins( Class<?>... mixins );
-
-    TransientDeclaration withTypes( Class<?>... roles );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java
deleted file mode 100644
index 98a242a..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single ValueComposite in a Module.
- */
-public interface ValueAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
deleted file mode 100644
index 5392d2c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring values
- */
-public interface ValueDeclaration
-{
-    ValueDeclaration setMetaInfo( Object info );
-
-    ValueDeclaration visibleIn( Visibility visibility );
-
-    ValueDeclaration withConcerns( Class<?>... concerns );
-
-    ValueDeclaration withSideEffects( Class<?>... sideEffects );
-
-    ValueDeclaration withMixins( Class<?>... mixins );
-
-    ValueDeclaration withTypes( Class<?>... roles );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
deleted file mode 100644
index 5532ae7..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2014 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.bootstrap.builder;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.ApplicationPassivationThread;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-/**
- * Application Builder.
- */
-public class ApplicationBuilder
-    implements ActivationEventListenerRegistration
-{
-    private final String applicationName;
-    private final Map<String, LayerDeclaration> layers = new HashMap<>();
-    private final List<ActivationEventListener> activationListeners = new ArrayList<>();
-
-    public ApplicationBuilder( String applicationName )
-    {
-        this.applicationName = applicationName;
-    }
-
-    /**
-     * Create and activate a new Application.
-     * @return Activated Application
-     * @throws AssemblyException if the assembly failed
-     * @throws ActivationException if the activation failed
-     */
-    public Application newApplication()
-        throws AssemblyException, ActivationException
-    {
-        Energy4Java qi4j = new Energy4Java();
-        ApplicationDescriptor model = qi4j.newApplicationModel( new ApplicationAssembler()
-        {
-            @Override
-            public ApplicationAssembly assemble( ApplicationAssemblyFactory factory )
-                throws AssemblyException
-            {
-                ApplicationAssembly assembly = factory.newApplicationAssembly();
-                assembly.setName( applicationName );
-                HashMap<String, LayerAssembly> createdLayers = new HashMap<>();
-                for( Map.Entry<String, LayerDeclaration> entry : layers.entrySet() )
-                {
-                    LayerAssembly layer = entry.getValue().createLayer( assembly );
-                    createdLayers.put( entry.getKey(), layer );
-                }
-                for( LayerDeclaration layer : layers.values() )
-                {
-                    layer.initialize( createdLayers );
-                }
-                return assembly;
-            }
-        } );
-        Application application = model.newInstance( qi4j.api() );
-        for( ActivationEventListener activationListener : activationListeners )
-        {
-            application.registerActivationEventListener( activationListener );
-        }
-        beforeActivation();
-        application.activate();
-        afterActivation();
-        return application;
-    }
-
-    /**
-     * Called before application activation.
-     */
-    protected void beforeActivation()
-    {
-    }
-
-    /**
-     * Called after application activation.
-     */
-    protected void afterActivation()
-    {
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activationListeners.add( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activationListeners.remove( listener );
-    }
-
-    /**
-     * Declare Layer.
-     * @param layerName Name of the Layer
-     * @return Layer declaration for the given name, new if did not already exists
-     */
-    public LayerDeclaration withLayer( String layerName )
-    {
-        LayerDeclaration layerDeclaration = layers.get( layerName );
-        if( layerDeclaration != null )
-        {
-            return layerDeclaration;
-        }
-        layerDeclaration = new LayerDeclaration( layerName );
-        layers.put( layerName, layerDeclaration );
-        return layerDeclaration;
-    }
-
-    /**
-     * Load an ApplicationBuilder from a JSON String.
-     * @param json JSON String
-     * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
-     * @throws AssemblyException if unable to declare the assembly
-     */
-    public static ApplicationBuilder fromJson( String json )
-        throws JSONException, AssemblyException
-    {
-        JSONObject root = new JSONObject( json );
-        return fromJson( root );
-    }
-
-    /**
-     * Load an ApplicationBuilder from a JSON InputStream.
-     * @param json JSON input
-     * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
-     * @throws AssemblyException if unable to declare the assembly
-     */
-    public static ApplicationBuilder fromJson( InputStream json )
-        throws JSONException, AssemblyException
-    {
-        String jsonString = new Scanner( json, "UTF-8" ).useDelimiter( "\\A" ).next();
-        return fromJson( jsonString );
-    }
-
-    /**
-     * Load an ApplicationBuilder from a JSONObject.
-     * @param root JSON object
-     * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
-     * @throws AssemblyException if unable to declare the assembly
-     */
-    public static ApplicationBuilder fromJson( JSONObject root )
-        throws JSONException, AssemblyException
-    {
-        String applicationName = root.getString( "name" );
-        ApplicationBuilder builder = new ApplicationBuilder( applicationName );
-        builder.configureWithJson( root );
-        return builder;
-    }
-
-    /** Configures the application struucture from a JSON document.
-     *
-     * @param root The JSON document root.
-     * @throws JSONException if the JSON document isn't valid.
-     * @throws AssemblyException if probelms in the Assemblers provided in the JSON document.
-     */
-    protected void configureWithJson( JSONObject root )
-        throws JSONException, AssemblyException
-    {
-        JSONArray layers = root.optJSONArray( "layers" );
-        if( layers != null )
-        {
-            for( int i = 0; i < layers.length(); i++ )
-            {
-                JSONObject layerObject = layers.getJSONObject( i );
-                String layerName = layerObject.getString( "name" );
-                LayerDeclaration layerDeclaration = withLayer( layerName );
-                JSONArray using = layerObject.optJSONArray( "uses" );
-                if( using != null )
-                {
-                    for( int j = 0; j < using.length(); j++ )
-                    {
-                        layerDeclaration.using( using.getString( j ) );
-                    }
-                }
-                JSONArray modules = layerObject.optJSONArray( "modules" );
-                if( modules != null )
-                {
-                    for( int k = 0; k < modules.length(); k++ )
-                    {
-                        JSONObject moduleObject = modules.getJSONObject( k );
-                        String moduleName = moduleObject.getString( "name" );
-                        ModuleDeclaration moduleDeclaration = layerDeclaration.withModule( moduleName );
-                        JSONArray assemblers = moduleObject.optJSONArray( "assemblers" );
-                        if( assemblers != null )
-                        {
-                            for( int m = 0; m < assemblers.length(); m++ )
-                            {
-                                String string = assemblers.getString( m );
-                                moduleDeclaration.withAssembler( string );
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * {@literal main} method that read JSON from STDIN.
-     * <p>Passivation exceptions are written to STDERR if any.</p>
-     * @param args Unused
-     * @throws JSONException if unable to read JSON
-     * @throws AssemblyException if the assembly failed
-     * @throws ActivationException if the activation failed
-     */
-    public static void main( String[] args )
-        throws JSONException, ActivationException, AssemblyException
-    {
-        ApplicationBuilder builder = fromJson( System.in );
-        Application application = builder.newApplication();
-        Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application, System.err ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
deleted file mode 100644
index cacd282..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.bootstrap.builder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Iterables;
-
-/**
- * Provides declared {@link org.apache.zest.api.structure.Layer} information that the {@link ApplicationBuilder} can use.
- */
-public class LayerDeclaration
-{
-    private final String layerName;
-    private final List<String> using = new ArrayList<>();
-    private final Map<String, ModuleDeclaration> modules = new HashMap<>();
-    private LayerAssembly layer;
-
-    LayerDeclaration( String layerName )
-    {
-        this.layerName = layerName;
-    }
-
-    /**
-     * Declare using layer.
-     * @param layerName Used layer name
-     * @return This Layer declaration
-     */
-    public LayerDeclaration using( String layerName )
-    {
-        this.using.add( layerName );
-        return this;
-    }
-
-    /**
-     * Declare using layers.
-     * @param layerNames Used layers names
-     * @return This Layer declaration
-     */
-    public LayerDeclaration using( Iterable<String> layerNames )
-    {
-        Iterables.addAll( using, layerNames );
-        return this;
-    }
-
-    /**
-     * Declare Module.
-     * @param moduleName Name of the Module
-     * @return Module declaration for the given name, new if did not already exists
-     */
-    public ModuleDeclaration withModule( String moduleName )
-    {
-        ModuleDeclaration module = modules.get( moduleName );
-        if( module != null )
-        {
-            return module;
-        }
-        module = new ModuleDeclaration( moduleName );
-        modules.put( moduleName, module );
-        return module;
-    }
-
-    LayerAssembly createLayer( ApplicationAssembly application )
-    {
-        layer = application.layer( layerName );
-        layer.setName( layerName );
-        for( ModuleDeclaration module : modules.values() )
-        {
-            ModuleAssembly assembly = module.createModule( layer );
-        }
-        return layer;
-    }
-
-    void initialize( HashMap<String, LayerAssembly> createdLayers )
-        throws AssemblyException
-    {
-        for( String uses : using )
-        {
-            LayerAssembly usedLayer = createdLayers.get( uses );
-            layer.uses( usedLayer );
-        }
-        for( ModuleDeclaration module : modules.values() )
-        {
-            module.initialize();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
deleted file mode 100644
index 065e9d8..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2014 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.bootstrap.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-import static org.apache.zest.api.util.Classes.isAssignableFrom;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.toList;
-import static org.apache.zest.functional.Specifications.not;
-
-/**
- * Provides declared {@link org.apache.zest.api.structure.Module} information that the {@link ApplicationBuilder} can use.
- */
-public class ModuleDeclaration
-{
-    private final String moduleName;
-    private final List<Assembler> assemblers = new ArrayList<>();
-    private ModuleAssembly module;
-
-    public ModuleDeclaration( String moduleName )
-    {
-        this.moduleName = moduleName;
-    }
-
-    /**
-     * Declare Assembler.
-     * @param assembler Assembler instance
-     * @return This Module declaration
-     */
-    public ModuleDeclaration withAssembler( Assembler assembler )
-    {
-        assemblers.add( assembler );
-        return this;
-    }
-
-    /**
-     * Declare Assembler.
-     * @param classname Assembler class name
-     * @return This Module declaration
-     * @throws AssemblyException if unable to load class, not an Assembler or unable to instanciate
-     */
-    public ModuleDeclaration withAssembler( String classname )
-        throws AssemblyException
-    {
-        Class<? extends Assembler> clazz = loadClass( classname );
-        return withAssembler( clazz );
-    }
-
-    /**
-     * Declare Assembler.
-     * @param assemblerClass Assembler class
-     * @return This Module declaration
-     * @throws AssemblyException not an Assembler or if unable to instanciate
-     */
-    public ModuleDeclaration withAssembler( Class<?> assemblerClass )
-        throws AssemblyException
-    {
-        Assembler assembler = createAssemblerInstance( assemblerClass );
-        assemblers.add( assembler );
-        return this;
-    }
-
-    /**
-     * Declare Assemblers.
-     * <p>Declare several Assemblers from an Iterable of Class objects.</p>
-     * <p>Typically used along {@link org.apache.zest.bootstrap.ClassScanner}.</p>
-     * @param assemblerClasses Assembler classes
-     * @return This Module declaration
-     * @throws AssemblyException if one of the Class is not an Assembler or unable to instanciate
-     */
-    public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses )
-        throws AssemblyException
-    {
-        List<Class<?>> notAssemblers = toList(
-            filter( not( isAssignableFrom( Assembler.class ) ),
-                    assemblerClasses )
-        );
-        if( !notAssemblers.isEmpty() )
-        {
-            throw new AssemblyException(
-                "Classes " + notAssemblers + " are not implementing " + Assembler.class.getName()
-            );
-        }
-        for( Class<?> assemblerClass : assemblerClasses )
-        {
-            withAssembler( assemblerClass );
-        }
-        return this;
-    }
-
-    ModuleAssembly createModule( LayerAssembly layer )
-    {
-        module = layer.module( moduleName );
-        return module;
-    }
-
-    void initialize()
-        throws AssemblyException
-    {
-        for( Assembler assembler : assemblers )
-        {
-            assembler.assemble( module );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Class<? extends Assembler> loadClass( String classname )
-        throws AssemblyException
-    {
-        Class<?> clazz;
-        try
-        {
-            clazz = getClass().getClassLoader().loadClass( classname );
-        }
-        catch( Exception e )
-        {
-            throw new AssemblyException( "Unable to load class " + classname, e );
-        }
-        if( !Assembler.class.isAssignableFrom( clazz ) )
-        {
-            throw new AssemblyException(
-                "Class " + classname + " is not implementing " + Assembler.class.getName()
-            );
-        }
-        //noinspection unchecked
-        return (Class<? extends Assembler>) clazz;
-    }
-
-    private Assembler createAssemblerInstance( Class<?> assemblerClass )
-        throws AssemblyException
-    {
-        if( !Assembler.class.isAssignableFrom( assemblerClass ) )
-        {
-            throw new AssemblyException(
-                "Class " + assemblerClass + " is not implementing " + Assembler.class.getName()
-            );
-        }
-        try
-        {
-            return (Assembler) assemblerClass.newInstance();
-        }
-        catch( Exception e )
-        {
-            throw new AssemblyException( "Unable to instantiate " + assemblerClass, e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
deleted file mode 100644
index 663b016..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
+++ /dev/null
@@ -1,25 +0,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.
--->
-<html>
-    <body>
-        <h2>Application Builder.</h2>
-        <p>
-            Generic ApplicationBuilder, which simplifies the creation of Application Structure, either by a fluid DSL
-            or from a JSON file.
-        </p>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
deleted file mode 100644
index 4522acd..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.bootstrap.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public interface LayerAssembler
-{
-    LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
deleted file mode 100644
index a55fb9c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
+++ /dev/null
@@ -1,212 +0,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.
- */
-package org.apache.zest.bootstrap.layered;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public abstract class LayeredApplicationAssembler
-    implements ApplicationAssembler
-{
-    protected Application application;
-    protected String name;
-    protected String version;
-    private final Application.Mode mode;
-    private ApplicationAssembly assembly;
-
-    private HashMap<Class<? extends LayerAssembler>, LayerAssembler> assemblers = new HashMap<>();
-
-    public LayeredApplicationAssembler( String name, String version, Application.Mode mode )
-        throws AssemblyException
-    {
-        this.name = name;
-        this.version = version;
-        this.mode = mode;
-        Energy4Java qi4j = new Energy4Java();
-        ApplicationDescriptor model = qi4j.newApplicationModel( this );
-        onModelCreated( model );
-        instantiateApplication( qi4j, model );
-    }
-
-    public ApplicationAssembly assembly()
-    {
-        return assembly;
-    }
-
-    /**
-     * This method is called from the constructor to instantiate the Zest application from the application model.
-     *
-     * <p>
-     * The default implementation simply calls;
-     * </p>
-     * <pre><code>
-     *   application = model.newInstance( qi4j.spi() );
-     * </code></pre>
-     *
-     * @param qi4j  The Zest runtime engine.
-     * @param model The application model descriptor.
-     */
-    protected void instantiateApplication( Energy4Java qi4j, ApplicationDescriptor model )
-    {
-        application = model.newInstance( qi4j.spi() );
-    }
-
-    /**
-     * This method is called after the Application Model has been created, before the instantiation of the Zest
-     * application.
-     *
-     * <p>
-     * The default implementation does nothing. Applications may have advanced features to inspect or
-     * modify the model prior to instantiation, and this is the place where such advanced manipulation is
-     * expected to take place.
-     * </p>
-     *
-     * @param model
-     */
-    protected void onModelCreated( ApplicationDescriptor model )
-    {
-    }
-
-    public Application application()
-    {
-        return application;
-    }
-
-    public void start()
-        throws ActivationException
-    {
-        application.activate();
-    }
-
-    public void stop()
-        throws PassivationException
-    {
-        application.passivate();
-    }
-
-    @Override
-    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-        throws AssemblyException
-    {
-        assembly = applicationFactory.newApplicationAssembly();
-        assembly.setName( name );
-        assembly.setVersion( version );
-        assembly.setMode( mode );
-        assembleLayers( assembly );
-        return assembly;
-    }
-
-    protected LayerAssembly createLayer( Class<? extends LayerAssembler> layerAssemblerClass )
-        throws IllegalArgumentException
-    {
-        try
-        {
-            String classname = layerAssemblerClass.getSimpleName();
-            if( classname.endsWith( "Layer" ) )
-            {
-                classname = classname.substring( 0, classname.length() - 5 ) + " Layer";
-            }
-            setNameIfPresent( layerAssemblerClass, classname );
-            LayerAssembly layer = assembly.layer( classname );
-
-            LayerAssembler layerAssembler = instantiateAssembler( layerAssemblerClass, layer );
-            assemblers.put( layerAssemblerClass, layerAssembler );
-            LayerAssembly assembly = layerAssembler.assemble( layer );
-            if( assembly == null )
-            {
-                // Assume that people forgot, and let's not require a "return layer", since we can do that ourselves.
-                return layer;
-            }
-            return assembly;
-        }
-        catch( Exception e )
-        {
-            throw new IllegalArgumentException( "Unable to instantiate layer with " + layerAssemblerClass.getSimpleName(), e );
-        }
-    }
-
-    private LayerAssembler instantiateAssembler( Class<? extends LayerAssembler> layerAssemblerClass,
-                                                 LayerAssembly layer
-    )
-        throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException
-    {
-        LayerAssembler layerAssembler;
-        try
-        {
-            Constructor<? extends LayerAssembler> assemblyConstructor = layerAssemblerClass.getConstructor( LayerAssembly.class );
-            layerAssembler = assemblyConstructor.newInstance( layer );
-        }
-        catch( NoSuchMethodException e )
-        {
-            // Use default constructor then.
-            layerAssembler = layerAssemblerClass.newInstance();
-        }
-        return layerAssembler;
-    }
-
-    static void setNameIfPresent( Class<?> clazz, String classname )
-        throws IllegalAccessException
-    {
-        try
-        {
-            Field field = clazz.getDeclaredField( "NAME" );
-            if( Modifier.isStatic( field.getModifiers() ) )
-            {
-                field.setAccessible( true );
-                field.set( null, classname );
-            }
-        }
-        catch( Exception e )
-        {
-            // Ignore and consider normal.
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected <T extends LayerAssembler> T assemblerOf( Class<T> layerAssemblerClass )
-    {
-        return (T) assemblers.get( layerAssemblerClass );
-    }
-
-    /**
-     * Called from the constructor to assemble the layers in the applcation.
-     *
-     * <p>
-     * This method must be implemented, and is typically a list of LayerAssmebler instantitations, followed
-     * by {@link LayerAssembly#uses(LayerAssembly...)} declarations.
-     * </p>
-     * <pre><code>
-     *
-     * </code></pre>
-     */
-    protected abstract void assembleLayers( ApplicationAssembly assembly )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
deleted file mode 100644
index 920ef54..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
+++ /dev/null
@@ -1,86 +0,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.
- */
-package org.apache.zest.bootstrap.layered;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public abstract class LayeredLayerAssembler
-    implements LayerAssembler
-{
-    private HashMap<Class<? extends ModuleAssembler>, ModuleAssembler> assemblers = new HashMap<>();
-
-    protected ModuleAssembly createModule( LayerAssembly layer, Class<? extends ModuleAssembler> modulerAssemblerClass )
-    {
-        try
-        {
-            ModuleAssembler moduleAssembler = instantiateAssembler( layer, modulerAssemblerClass );
-            String moduleName = createModuleName( modulerAssemblerClass );
-            LayeredApplicationAssembler.setNameIfPresent( modulerAssemblerClass, moduleName );
-            ModuleAssembly module = layer.module( moduleName );
-            assemblers.put( modulerAssemblerClass, moduleAssembler );
-            ModuleAssembly assembly = moduleAssembler.assemble( layer, module );
-            if( assembly == null )
-            {
-                return module;
-            }
-            return assembly;
-        }
-        catch( Exception e )
-        {
-            throw new IllegalArgumentException( "Unable to instantiate module with " + modulerAssemblerClass.getSimpleName(), e );
-        }
-    }
-
-    protected String createModuleName( Class<? extends ModuleAssembler> modulerAssemblerClass )
-    {
-        String moduleName = modulerAssemblerClass.getSimpleName();
-        if( moduleName.endsWith( "Module" ) )
-        {
-            moduleName = moduleName.substring( 0, moduleName.length() - 6 ) + " Module";
-        }
-        return moduleName;
-    }
-
-    private ModuleAssembler instantiateAssembler( LayerAssembly layer,
-                                                  Class<? extends ModuleAssembler> modulerAssemblerClass
-    )
-        throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException
-    {
-        ModuleAssembler moduleAssembler;
-        try
-        {
-            Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getConstructor( ModuleAssembly.class );
-            moduleAssembler = assemblyConstructor.newInstance( layer );
-        }
-        catch( NoSuchMethodException e )
-        {
-            moduleAssembler = modulerAssemblerClass.newInstance();
-        }
-        return moduleAssembler;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected <T extends ModuleAssembler> T assemblerOf( Class<T> moduleAssemblerType )
-    {
-        return (T) assemblers.get( moduleAssemblerType );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java
deleted file mode 100644
index b277c82..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public interface ModuleAssembler
-{
-    ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
deleted file mode 100644
index 60cdec2..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Layered Assembly.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
deleted file mode 100644
index 0458761..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Assembly and Bootstrap API.</h2>
-    </body>
-</html>


[27/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/resources/org/qi4j/api/configuration/MyService.properties
----------------------------------------------------------------------
diff --git a/core/api/src/test/resources/org/qi4j/api/configuration/MyService.properties b/core/api/src/test/resources/org/qi4j/api/configuration/MyService.properties
new file mode 100644
index 0000000..6ed5ff6
--- /dev/null
+++ b/core/api/src/test/resources/org/qi4j/api/configuration/MyService.properties
@@ -0,0 +1,16 @@
+# 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.
+
+me = { name : Niclas, address={ street1 : "Henan Lu 555", street2 : "Block 15", city : { cityName : "Shanghai", country : { countryName : "China" } } } }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembler.java
deleted file mode 100644
index 1e1e0e3..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembler.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Implement this interface to create the root class that
- * is responsible for assembling your entire application.
- *
- * Model introspectors will instantiate this class and call assemble
- * to create the application, which will then be visited to get
- * information about its structure.
- *
- * Application deployment servers will instantiate this, call assemble,
- * and then activate the created application, which will be the runtime
- * instance that forms your application.
- */
-public interface ApplicationAssembler
-{
-    ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblerAdapter.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblerAdapter.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblerAdapter.java
deleted file mode 100644
index 3b8cb80..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Helper base class for application assemblers that
- * want to either create applications using only one layer/module,
- * or that wants to create pancake-layered applications.
- */
-public class ApplicationAssemblerAdapter
-    implements ApplicationAssembler
-{
-    private final Assembler[][][] assemblers;
-
-    protected ApplicationAssemblerAdapter( Assembler assembler )
-    {
-        this.assemblers = new Assembler[][][]{ { { assembler } } };
-    }
-
-    protected ApplicationAssemblerAdapter( Assembler[][][] assemblers )
-    {
-        this.assemblers = assemblers;
-    }
-
-    @Override
-    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-        throws AssemblyException
-    {
-        return applicationFactory.newApplicationAssembly( assemblers );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembly.java
deleted file mode 100644
index 849f397..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssembly.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. All rights Reserved.
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.structure.Application;
-
-/**
- * An application assembly. This can be used by Assemblers to programmatically
- * set the name of the application and create new layers.
- */
-public interface ApplicationAssembly
-{
-    /**
-     * Create a new layer assembly
-     *
-     * @param name of the new layer
-     *
-     * @return a LayerAssembly instance
-     */
-    LayerAssembly layer( String name );
-
-    /**
-     * Get an assembly for a particular Module. If this is called many times with the same names, then the same module
-     * is affected.
-     *
-     * @param layerName The name of the Layer
-     * @param moduleName The name of the Module to retrieve or create.
-     * @return The ModuleAssembly for the Module.
-     */
-    ModuleAssembly module( String layerName, String moduleName );
-    
-    /**
-     * Get the currently set name of the application
-     *
-     * @return the name of the application
-     */
-    String name();
-
-    /**
-     * Get the currently set mode of the application
-     *
-     * @return the application mode
-     */
-    Application.Mode mode();
-
-    /**
-     * Set the name of the application
-     *
-     * @param name of the application
-     *
-     * @return the assembly
-     */
-    ApplicationAssembly setName( String name );
-
-    /**
-     * Set the version of the application. This can be in any format, but
-     * most likely will follow the Dewey format, i.e. x.y.z.
-     *
-     * @param version of the application
-     *
-     * @return the assembly
-     */
-    ApplicationAssembly setVersion( String version );
-
-    /**
-     * Set the application mode. This will be set to "production" by default. You can
-     * set the system property "mode" to either "development", "satisfiedBy" or "production"
-     * to explicitly set the mode. If that is not an option, then call this method
-     * during assembly to set the mode. The mode may then be queried by assemblers,
-     * and they may assemble the application differentlly depending on this setting.
-     *
-     * @param mode the application mode
-     *
-     * @return the assembly
-     */
-    ApplicationAssembly setMode( Application.Mode mode );
-
-    ApplicationAssembly setMetaInfo( Object info );
-
-    /**
-     * Set the application activators. Activators are executed in order around the
-     * Application activation and passivation.
-     *
-     * @param activators the application activators
-     * @return the assembly
-     */
-    @SuppressWarnings( { "unchecked","varargs" } )
-    ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators );
-
-    <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblyFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblyFactory.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblyFactory.java
deleted file mode 100644
index 264fa65..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationAssemblyFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-/**
- * Factory for creating new Zest application assemblies. Typically
- * you will implement one or more Assemblers, wrap them in an ApplicationAssembler,
- * which then uses this factory to assemble and create applications.
- */
-public interface ApplicationAssemblyFactory
-{
-    /**
-     * Create a new application with one layer and one module.
-     *
-     * @param assembler the assembler for the single module
-     *
-     * @return the application instance
-     *
-     * @throws AssemblyException if the application could not be assembled
-     */
-    ApplicationAssembly newApplicationAssembly( Assembler assembler )
-        throws AssemblyException;
-
-    /**
-     * Create a new application with the same amount of layers
-     * as the first array size, with modules according to the second array size,
-     * and then use the third array for assemblers of each module. This gives you
-     * a simple way to create "pancake" layered applications.
-     *
-     * @param assemblers the set of assemblers for the application
-     *
-     * @return the application instance
-     *
-     * @throws AssemblyException if the application could not be assembled
-     */
-    ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers )
-        throws AssemblyException;
-
-    /**
-     * Create a new ApplicationAssembly that can be used for the above method.
-     *
-     * @return a new ApplicationAssembly
-     */
-    ApplicationAssembly newApplicationAssembly();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationModelFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationModelFactory.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationModelFactory.java
deleted file mode 100644
index 471410d..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationModelFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-import org.apache.zest.api.structure.ApplicationDescriptor;
-
-/**
- * Factory for ApplicationModelSPI's. Takes an ApplicationAssembly, executes it,
- * and builds an application model from it, which can then be instantiated and activated.
- */
-public interface ApplicationModelFactory
-{
-    ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationName.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationName.java
deleted file mode 100644
index 3a4ffa2..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ApplicationName.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Set the name of the application
- */
-public final class ApplicationName
-    implements Assembler
-{
-    private String name;
-
-    public ApplicationName( String name )
-    {
-        this.name = name;
-    }
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.layer().application().setName( name );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assembler.java
deleted file mode 100644
index be8126c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assembler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * ModuleAssemblies are configured by Assemblers. This
- * is the interface you would implement in order to provide
- * all configuration and additional metainfo that is needed
- * to instantiate a Zest application.
- */
-public interface Assembler
-{
-    /**
-     * Assemblers receive a callback to the ModuleAssembly
-     * they are supposed to configure. They can use this
-     * to register objects, composites, services etc. and
-     * the additional metadata that may exist for these
-     * artifacts.
-     * <p>
-     * An Assembler may create new Modules by calling
-     * {@link org.apache.zest.bootstrap.ModuleAssembly#layer()} and
-     * then {@link LayerAssembly#module(String)} (String)}.
-     * This allows an Assembler to bootstrap an entire Layer with
-     * more Modules.
-     * </p>
-     * @param module the Module to assemble
-     *
-     * @throws AssemblyException thrown if the assembler tries to do something illegal
-     */
-    void assemble( ModuleAssembly module )
-        throws AssemblyException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblerCollection.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblerCollection.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblerCollection.java
deleted file mode 100644
index 63e96ed..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblerCollection.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * Assembler that delegates to a collection of Assemblers.
- * <p>
- * Makes it easy to collect and compose assemblers into bigger assemblers.
- * </p>
- */
-public final class AssemblerCollection
-    implements Assembler
-{
-    Collection<Assembler> assemblers;
-
-    public AssemblerCollection( Assembler... assemblers )
-    {
-        this.assemblers = Arrays.asList( assemblers );
-    }
-
-    @SafeVarargs
-    public AssemblerCollection( Class<? extends Assembler>... assemblyClasses )
-        throws AssemblyException
-    {
-        assemblers = new ArrayList<>();
-        for( Class<? extends Assembler> assemblyClass : assemblyClasses )
-        {
-            try
-            {
-                Assembler assembler = assemblyClass.newInstance();
-                assemblers.add( assembler );
-            }
-            catch( Exception e )
-            {
-                throw new AssemblyException( "Could not instantiate assembly with class " + assemblyClass.getName(), e );
-            }
-        }
-    }
-
-    public AssemblerCollection( Collection<Assembler> assemblers )
-    {
-        this.assemblers = assemblers;
-    }
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        for( Assembler assembler : assemblers )
-        {
-            assembler.assemble( module );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java
deleted file mode 100644
index d123132..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-/**
- * Assembler adapters for common use cases (visibility, identity, configuration).
- */
-public class Assemblers
-{
-    private Assemblers()
-    {
-    }
-
-    /**
-     * Assembler with Visibility interface.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public interface Visible<AssemblerType>
-        extends Assembler
-    {
-        /**
-         * Set Visibility.
-         * @param visibility Visibility
-         * @return This Assembler instance
-         */
-        AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility );
-
-        /**
-         * Get Visibility.
-         * <p>Default to {@link org.apache.zest.api.common.Visibility#module}.</p>
-         * @return Visibility
-         */
-        org.apache.zest.api.common.Visibility visibility();
-    }
-
-    /**
-     * Assembler with Identity interface.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public interface Identifiable<AssemblerType>
-        extends Assembler
-    {
-        /**
-         * Set Identity.
-         * @param identity Identity
-         * @return This Assembler instance
-         */
-        AssemblerType identifiedBy( String identity );
-
-        /**
-         * @return {@literal true} if {@link #identity()} do not return null, {@literal false} otherwise
-         */
-        boolean hasIdentity();
-
-        /**
-         * Get Identity.
-         * <p>Default to {@literal null}.</p>
-         * @return Identity
-         */
-        String identity();
-    }
-
-    /**
-     * Assembler with Configuration interface.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public interface Configurable<AssemblerType>
-        extends Assembler
-    {
-        /**
-         * Set Configuration Module and Visibility.
-         * @param configModule Configuration Module
-         * @param configVisibility Configuration Visiblity
-         * @return This Assembler instance
-         */
-        AssemblerType withConfig( ModuleAssembly configModule,
-                                  org.apache.zest.api.common.Visibility configVisibility );
-
-        /**
-         * @return {@literal true} if {@link #configModule() ()} do not return null, {@literal false} otherwise
-         */
-        boolean hasConfig();
-
-        /**
-         * Get Configuration Module.
-         * <p>Default to {@literal null}.</p>
-         * @return Configuration Module
-         */
-        ModuleAssembly configModule();
-
-        /**
-         * Get Configuration Visibility.
-         * <p>Default to {@link org.apache.zest.api.common.Visibility#module}.</p>
-         * @return Configuration Visibility
-         */
-        org.apache.zest.api.common.Visibility configVisibility();
-    }
-
-    /**
-     * Assembler with Visibility adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class Visibility<AssemblerType>
-        implements Visible<AssemblerType>
-    {
-        private org.apache.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility )
-        {
-            this.visibility = visibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility visibility()
-        {
-            return visibility;
-        }
-    }
-
-    /**
-     * Assembler with Identity adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class Identity<AssemblerType>
-        implements Identifiable<AssemblerType>
-    {
-        private String identity;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType identifiedBy( String identity )
-        {
-            this.identity = identity;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasIdentity()
-        {
-            return identity != null;
-        }
-
-        @Override
-        public final String identity()
-        {
-            return identity;
-        }
-    }
-
-    /**
-     * Assembler with Configuration adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class Config<AssemblerType>
-        implements Configurable<AssemblerType>
-    {
-        private ModuleAssembly configModule = null;
-        private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType withConfig( ModuleAssembly configModule,
-                                               org.apache.zest.api.common.Visibility configVisibility )
-        {
-            this.configModule = configModule;
-            this.configVisibility = configVisibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasConfig()
-        {
-            return configModule != null;
-        }
-
-        @Override
-        public final ModuleAssembly configModule()
-        {
-            return configModule;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility configVisibility()
-        {
-            return configVisibility;
-        }
-    }
-
-    /**
-     * Assembler with Visibility and Identity adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class VisibilityIdentity<AssemblerType>
-        implements Visible<AssemblerType>,
-                   Identifiable<AssemblerType>
-    {
-        private org.apache.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module;
-        private String identity;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility )
-        {
-            this.visibility = visibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility visibility()
-        {
-            return visibility;
-        }
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType identifiedBy( String identity )
-        {
-            this.identity = identity;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasIdentity()
-        {
-            return identity != null;
-        }
-
-        @Override
-        public final String identity()
-        {
-            return identity;
-        }
-    }
-
-    /**
-     * Assembler with Visibility and Configuration adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class VisibilityConfig<AssemblerType>
-        implements Visible<AssemblerType>,
-                   Configurable<AssemblerType>
-    {
-        private org.apache.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module;
-        private ModuleAssembly configModule = null;
-        private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility )
-        {
-            this.visibility = visibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility visibility()
-        {
-            return visibility;
-        }
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType withConfig( ModuleAssembly configModule,
-                                               org.apache.zest.api.common.Visibility configVisibility )
-        {
-            this.configModule = configModule;
-            this.configVisibility = configVisibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasConfig()
-        {
-            return configModule != null;
-        }
-
-        @Override
-        public final ModuleAssembly configModule()
-        {
-            return configModule;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility configVisibility()
-        {
-            return configVisibility;
-        }
-    }
-
-    /**
-     * Assembler with Identity and Configuration adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class IdentityConfig<AssemblerType>
-        implements Identifiable<AssemblerType>,
-                   Configurable<AssemblerType>
-    {
-        private String identity;
-        private ModuleAssembly configModule = null;
-        private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType identifiedBy( String identity )
-        {
-            this.identity = identity;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasIdentity()
-        {
-            return identity != null;
-        }
-
-        @Override
-        public final String identity()
-        {
-            return identity;
-        }
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType withConfig( ModuleAssembly configModule,
-                                               org.apache.zest.api.common.Visibility configVisibility )
-        {
-            this.configModule = configModule;
-            this.configVisibility = configVisibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasConfig()
-        {
-            return configModule != null;
-        }
-
-        @Override
-        public final ModuleAssembly configModule()
-        {
-            return configModule;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility configVisibility()
-        {
-            return configVisibility;
-        }
-    }
-
-    /**
-     * Assembler with Visibility, Identity and Configuation adapter.
-     * @param <AssemblerType> Parameterized type of Assembler
-     */
-    public static abstract class VisibilityIdentityConfig<AssemblerType>
-        implements Visible<AssemblerType>,
-                   Identifiable<AssemblerType>,
-                   Configurable<AssemblerType>
-    {
-        private org.apache.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module;
-        private String identity;
-        private ModuleAssembly configModule = null;
-        private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module;
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility )
-        {
-            this.visibility = visibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility visibility()
-        {
-            return visibility;
-        }
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType identifiedBy( String identity )
-        {
-            this.identity = identity;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasIdentity()
-        {
-            return identity != null;
-        }
-
-        @Override
-        public final String identity()
-        {
-            return identity;
-        }
-
-        @Override
-        @SuppressWarnings( "unchecked" )
-        public final AssemblerType withConfig( ModuleAssembly configModule,
-                                               org.apache.zest.api.common.Visibility configVisibility )
-        {
-            this.configModule = configModule;
-            this.configVisibility = configVisibility;
-            return (AssemblerType) this;
-        }
-
-        @Override
-        public final boolean hasConfig()
-        {
-            return configModule != null;
-        }
-
-        @Override
-        public final ModuleAssembly configModule()
-        {
-            return configModule;
-        }
-
-        @Override
-        public final org.apache.zest.api.common.Visibility configVisibility()
-        {
-            return configVisibility;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java
deleted file mode 100644
index aaaac20..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Thrown by ModuleAssembly if the Assembler tries to make an invalid assembly.
- */
-public class AssemblyException
-    extends Exception
-{
-    public AssemblyException()
-    {
-    }
-
-    public AssemblyException( String string )
-    {
-        super( string );
-    }
-
-    public AssemblyException( String string, Throwable throwable )
-    {
-        super( string, throwable );
-    }
-
-    public AssemblyException( Throwable throwable )
-    {
-        super( throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
deleted file mode 100644
index 69b82e3..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java
+++ /dev/null
@@ -1,49 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-/**
- * Utility specifications for Assemblies.
- */
-public class AssemblySpecifications
-{
-    public static Specification<HasTypes> types( final Class... types )
-    {
-        return new Specification<HasTypes>()
-        {
-            @Override
-            public boolean satisfiedBy( HasTypes item )
-            {
-
-                for( Class<?> type : item.types() )
-                {
-                    if( Specifications.in( types ).satisfiedBy( type ) )
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java
deleted file mode 100644
index cd5a4da..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Visitor interface to visit the whole or parts of an assembly.
- * <p>
- * Implement this interface and call visit() on ApplicationAssembly, LayerAssembly or ModuleAssembly.
- * </p>
- * <p>
- * This can be used to, for example, add metadata to all entities, add concerns on composites, or similar.
- * </p>
- */
-public interface AssemblyVisitor<ThrowableType extends Throwable>
-{
-    public void visitApplication( ApplicationAssembly assembly )
-        throws ThrowableType;
-
-    public void visitLayer( LayerAssembly assembly )
-        throws ThrowableType;
-
-    public void visitModule( ModuleAssembly assembly )
-        throws ThrowableType;
-
-    public void visitComposite( TransientDeclaration declaration )
-        throws ThrowableType;
-
-    public void visitEntity( EntityDeclaration declaration )
-        throws ThrowableType;
-
-    public void visitService( ServiceDeclaration declaration )
-        throws ThrowableType;
-
-    public void visitImportedService( ImportedServiceDeclaration declaration )
-        throws ThrowableType;
-
-    public void visitValue( ValueDeclaration declaration )
-        throws ThrowableType;
-
-    public void visitObject( ObjectDeclaration declaration )
-        throws ThrowableType;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java
deleted file mode 100644
index 69c6d32..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Base class for assembly visitors. Subclass and override
- * the particular methods you are interested in.
- */
-public class AssemblyVisitorAdapter<ThrowableType extends Throwable>
-    implements AssemblyVisitor<ThrowableType>
-{
-    @Override
-    public void visitApplication( ApplicationAssembly assembly )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitLayer( LayerAssembly assembly )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitModule( ModuleAssembly assembly )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitComposite( TransientDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitEntity( EntityDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitService( ServiceDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitImportedService( ImportedServiceDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitValue( ValueDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-
-    @Override
-    public void visitObject( ObjectDeclaration declaration )
-        throws ThrowableType
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java
deleted file mode 100644
index 5857194..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.MetaInfo;
-
-/**
- * This provides declared {@link org.apache.zest.api.association.Association} information that the runtime can use.
- */
-public interface AssociationDeclarations
-{
-    MetaInfo metaInfoFor( AccessibleObject accessor );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java
deleted file mode 100644
index 018d824..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Thrown by the Zest runtime if a dependency can not be bound.
- */
-public class BindingException
-    extends Exception
-{
-    public BindingException( String s )
-    {
-        super( s );
-    }
-
-    public BindingException( String s, InvalidInjectionException ex )
-    {
-        super( s, ex );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java
deleted file mode 100644
index 12da989..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-/**
- * This exception is thrown if no ApplicationFactory provider can be found
- */
-public class BootstrapException
-    extends RuntimeException
-{
-    public BootstrapException( String message )
-    {
-        super( message );
-    }
-
-    public BootstrapException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
deleted file mode 100644
index d8fb7b7..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2008-2011 Rickard Öberg. 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.zest.bootstrap;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Modifier;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.security.CodeSource;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.regex.Pattern;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * Scan classpath for classes that matches given criteria. Useful for automated assemblies with lots of similar classes.
- */
-public class ClassScanner
-{
-    /**
-     * Get all classes from the same package of the given class, and recursively in all subpackages.
-     * <p>
-     * This only works if the seed class is loaded from a file: URL. Jar files are possible as well. Abstract classes
-     * are not included in the results. For further filtering use e.g. Iterables.filter.
-     * </p>
-     * @param seedClass starting point for classpath scanning
-     *
-     * @return iterable of all concrete classes in the same package as the seedclass, and also all classes in subpackages.
-     */
-    public static Iterable<Class<?>> findClasses( final Class<?> seedClass )
-    {
-        CodeSource codeSource = seedClass.getProtectionDomain().getCodeSource();
-        if( codeSource == null )
-        {
-            return Iterables.empty();
-        }
-
-        URL location = codeSource.getLocation();
-
-        if( !location.getProtocol().equals( "file" ) )
-        {
-            throw new IllegalArgumentException( "Can only enumerate classes from file system locations. URL is:" + location );
-        }
-
-        final File file;
-        try
-        {
-            file = new File( location.toURI().getPath() );
-        }
-        catch( URISyntaxException e )
-        {
-            throw new IllegalArgumentException( "The file location of codebase is invalid. Can not convert to URI. URL is:" + location );
-        }
-
-        if( file.getName().endsWith( ".jar" ) )
-        {
-            try
-            {
-                final String packageName = seedClass.getPackage().getName().replace( '.', '/' );
-
-                JarFile jarFile = new JarFile( file );
-                Iterable<JarEntry> entries = Iterables.iterable( jarFile.entries() );
-                try
-                {
-                    return Iterables.toList( filter( new ValidClass(),
-                                                     map( new Function<JarEntry, Class<?>>()
-                                                     {
-                                                         @Override
-                                                         public Class map( JarEntry jarEntry )
-                                                         {
-                                                             String name = jarEntry.getName();
-                                                             name = name.substring( 0, name.length() - 6 );
-                                                             name = name.replace( '/', '.' );
-                                                             try
-                                                             {
-                                                                 return seedClass.getClassLoader().loadClass( name );
-                                                             }
-                                                             catch( ClassNotFoundException e )
-                                                             {
-                                                                 return null;
-                                                             }
-                                                         }
-                                                     }
-                                                         , filter( new Specification<JarEntry>()
-                                                     {
-                                                         @Override
-                                                         public boolean satisfiedBy( JarEntry jarEntry )
-                                                         {
-                                                             return jarEntry.getName()
-                                                                        .startsWith( packageName ) && jarEntry.getName()
-                                                                 .endsWith( ".class" );
-                                                         }
-                                                     }, entries ) ) ) );
-                }
-                finally
-                {
-                    jarFile.close();
-                }
-            }
-            catch( IOException e )
-            {
-                throw new IllegalArgumentException( "Could not open jar file " + file, e );
-            }
-        }
-        else
-        {
-            final File path = new File( file, seedClass.getPackage().getName().replace( '.', File.separatorChar ) );
-            Iterable<File> files = findFiles( path, new Specification<File>()
-            {
-                @Override
-                public boolean satisfiedBy( File file )
-                {
-                    return file.getName().endsWith( ".class" );
-                }
-            } );
-
-            return filter( new ValidClass(),
-                           map( new Function<File, Class<?>>()
-                           {
-                               @Override
-                               public Class<?> map( File f )
-                               {
-                                   String fileName = f.getAbsolutePath().substring( file.toString().length() + 1 );
-                                   fileName = fileName.replace( File.separatorChar, '.' )
-                                       .substring( 0, fileName.length() - 6 );
-                                   try
-                                   {
-                                       return seedClass.getClassLoader().loadClass( fileName );
-                                   }
-                                   catch( ClassNotFoundException e )
-                                   {
-                                       return null;
-                                   }
-                               }
-                           }, files ) );
-        }
-    }
-
-    /**
-     * Useful specification for filtering classes based on a regular expression matching the class names.
-     * <p>
-     * Example: matches(".*Model") -&gt; match only class names that end with Model
-     * </p>
-     *
-     * @param regex The regular expression to be matched.
-     *
-     * @return regex class name specification
-     */
-    public static Specification<Class<?>> matches( String regex )
-    {
-        final Pattern pattern = Pattern.compile( regex );
-
-        return new Specification<Class<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( Class<?> aClass )
-            {
-                return pattern.matcher( aClass.getName() ).matches();
-            }
-        };
-    }
-
-    private static Iterable<File> findFiles( File directory, final Specification<File> filter )
-    {
-        return flatten( filter( filter, iterable( directory.listFiles() ) ),
-                        flattenIterables( map( new Function<File, Iterable<File>>()
-                        {
-                            @Override
-                            public Iterable<File> map( File file )
-                            {
-                                return findFiles( file, filter );
-                            }
-                        }, filter( new Specification<File>()
-                        {
-                            @Override
-                            public boolean satisfiedBy( File file )
-                            {
-                                return file.isDirectory();
-                            }
-                        }, iterable( directory.listFiles() ) ) ) ) );
-    }
-
-    private static class ValidClass
-        implements Specification<Class<?>>
-    {
-        @Override
-        public boolean satisfiedBy( Class<?> item )
-        {
-            return ( item.isInterface() || !Modifier.isAbstract( item.getModifiers() ) ) && ( !item.isEnum() && !item.isAnonymousClass() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java
deleted file mode 100644
index 24ec6e4..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java
+++ /dev/null
@@ -1,28 +0,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.
- *
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single ConfigurationComposite in a Module.
- */
-public interface ConfigurationAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java
deleted file mode 100644
index 6ca6949..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java
+++ /dev/null
@@ -1,87 +0,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.
- *
- */
-
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring configurations. Instances
- * of this API are acquired by calling {@link ModuleAssembly#configurations(Class[])}.
- */
-public interface ConfigurationDeclaration
-{
-    /**
-     * Set additional metainfo for this configuration declaration.
-     *
-     * @param info metainfo that can be retrieved from the CompositeDescriptor.
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration setMetaInfo( Object info );
-
-    /**
-     * Set visibility for declared entities.
-     *
-     * @param visibility The {@link Visibility} that this ConfigurationComposite will have.
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration visibleIn( Visibility visibility );
-
-    /**
-     * Declare additional concerns for these configurations.
-     *
-     * @param concerns The concerns that are to be added to the ConfigurationComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration withConcerns( Class<?>... concerns );
-
-    /**
-     * Declare additional side-effects for these configurations.
-     *
-     * @param sideEffects The sideeffects that are to be added to the ConfigurationComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration withSideEffects( Class<?>... sideEffects );
-
-    /**
-     * Declare additional mixins for these configurations.
-     * <p>
-     * This can be useful to override any default mixins from the configuration interface.
-     * </p>
-     * @param mixins The mixins that are to be added to the ConfigurationComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration withMixins( Class<?>... mixins );
-
-    /**
-     * Declare additional interfaces for these declared interfaces.
-     * <p>
-     * This can be useful to add types that the Configuration should implement, but
-     * which you do not want to include in the entity interface itself.
-     * </p>
-     * @param types list of interfaces to add
-     *
-     * @return This instance for a fluid DSL
-     */
-    ConfigurationDeclaration withTypes( Class<?>... types );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java
deleted file mode 100644
index 4661417..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2008-2011 Niclas Hedhman. 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.zest.bootstrap;
-
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.spi.Qi4jSPI;
-
-/**
- * Main bootstrap class for starting Zest and creating new applications.
- * <p>
- * Instantiate this and call one of the factory methods to get started.
- * </p>
- * <p>
- * This class will use the Service Loader mechanism in Java to try to locate a runtime that implements
- * the Qi4jRuntime interface. This avoids a direct dependency from the bootstrap to the runtime.
- * </p>
- */
-public final class Energy4Java
-{
-    private Qi4jRuntime runtime;
-
-    public Energy4Java( RuntimeFactory runtimeFactory )
-    {
-        this( runtimeFactory.createRuntime() );
-    }
-
-    public Energy4Java()
-    {
-        this( new RuntimeFactory.StandaloneApplicationRuntimeFactory().createRuntime() );
-    }
-
-    public Energy4Java( Qi4jRuntime runtime )
-    {
-        if( runtime == null )
-        {
-            throw new BootstrapException( "Can not create Zest without a Zest Runtime." );
-        }
-        this.runtime = runtime;
-    }
-
-    public ApplicationDescriptor newApplicationModel( ApplicationAssembler assembler )
-        throws AssemblyException
-    {
-        ApplicationAssembly assembly = assembler.assemble( runtime.applicationAssemblyFactory() );
-
-        if( assembly == null )
-        {
-            throw new AssemblyException( "Application assembler did not return any ApplicationAssembly" );
-        }
-
-        try
-        {
-            ApplicationModelFactory modelFactory = runtime.applicationModelFactory();
-            return modelFactory.newApplicationModel( assembly );
-        }
-        catch( RuntimeException e )
-        {
-            throw new AssemblyException( "Unable to create Application Model.", e );
-        }
-    }
-
-    public Application newApplication( ApplicationAssembler assembler, Object... importedServiceInstances )
-        throws AssemblyException
-    {
-        ApplicationDescriptor model = newApplicationModel( assembler );
-        return model.newInstance( runtime.spi(), importedServiceInstances );
-    }
-
-    public Qi4jSPI spi()
-    {
-        return runtime.spi();
-    }
-
-    public Qi4j api()
-    {
-        return runtime.spi();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java
deleted file mode 100644
index a36d9bf..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single EntityComposite in a Module.
- */
-public interface EntityAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java
deleted file mode 100644
index 425d802..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring entities. Instances
- * of this API are acquired by calling {@link ModuleAssembly#entities(Class[])}.
- */
-public interface EntityDeclaration
-{
-    /**
-     * Set additional metainfo for this entity declaration.
-     *
-     * @param info metainfo that can be retrieved from the EntityDescriptor.
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration setMetaInfo( Object info );
-
-    /**
-     * Set visibility for declared entities.
-     *
-     * @param visibility The {@link Visibility} that this EntityComposite will have.
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration visibleIn( Visibility visibility );
-
-    /**
-     * Declare additional concerns for these entities.
-     *
-     * @param concerns The concerns that are to be added to the EntityComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration withConcerns( Class<?>... concerns );
-
-    /**
-     * Declare additional side-effects for these entitites.
-     *
-     * @param sideEffects The sideeffects that are to be added to the EntityComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration withSideEffects( Class<?>... sideEffects );
-
-    /**
-     * Declare additional mixins for these entities.
-     * <p>
-     * This can be useful to override any default mixins from the entity interface.
-     * </p>
-     * @param mixins The mixins that are to be added to the EntityComposite beyond the statically declared ones.
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration withMixins( Class<?>... mixins );
-
-    /**
-     * Declare additional interfaces for these declared interfaces.
-     * <p>
-     * This can be useful to add types that the entities should implement, but
-     * which you do not want to include in the entity interface itself.
-     * </p>
-     * @param types list of interfaces to add
-     *
-     * @return This instance for a fluid DSL
-     */
-    EntityDeclaration withTypes( Class<?>... types );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java
deleted file mode 100644
index 2dfa31b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java
+++ /dev/null
@@ -1,29 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single imported service in a Module.
- */
-public interface ImportedServiceAssembly
-    extends HasTypes
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java
deleted file mode 100644
index 41cb46c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. All rights Reserved.
- * Copyright 2012, Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.service.ServiceImporter;
-import org.apache.zest.api.service.importer.InstanceImporter;
-import org.apache.zest.api.service.importer.NewObjectImporter;
-import org.apache.zest.api.service.importer.ServiceInstanceImporter;
-import org.apache.zest.api.service.importer.ServiceSelectorImporter;
-
-/**
- * Fluent API for declaring imported services. Instances
- * of this API are acquired by calling {@link ModuleAssembly#importedServices(Class[])}.
- */
-public interface ImportedServiceDeclaration
-{
-    // Convenience constants for common service importers
-    public static final Class<? extends ServiceImporter> INSTANCE = InstanceImporter.class;
-    public static final Class<? extends ServiceImporter> NEW_OBJECT = NewObjectImporter.class;
-    public static final Class<? extends ServiceImporter> SERVICE_SELECTOR = ServiceSelectorImporter.class;
-    public static final Class<? extends ServiceImporter> SERVICE_IMPORTER = ServiceInstanceImporter.class;
-
-    ImportedServiceDeclaration visibleIn( Visibility visibility );
-
-    ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass );
-
-    ImportedServiceDeclaration identifiedBy( String identity );
-
-    ImportedServiceDeclaration taggedWith( String... tags );
-
-    ImportedServiceDeclaration setMetaInfo( Object serviceAttribute );
-    
-    ImportedServiceDeclaration importOnStartup();
-
-    /**
-     * Set the imported service activators. Activators are executed in order around
-     * the ServiceReference activation and passivation.
-     *
-     * @param activators the imported service activators
-     * @return the assembly
-     */    
-    @SuppressWarnings( { "unchecked","varargs" } )
-    ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators );
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java
deleted file mode 100644
index 65225a8..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Thrown by the Zest runtime if a dependency can not be injected.
- */
-public class InjectionException
-    extends RuntimeException
-{
-    public InjectionException( String s )
-    {
-        super( s );
-    }
-
-    public InjectionException( String s, Throwable throwable )
-    {
-        super( s, throwable );
-    }
-
-    public InjectionException( Throwable throwable )
-    {
-        super( throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java
deleted file mode 100644
index b0ad552..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-/**
- * Thrown by the Zest runtime if a dependency injection declaration is invalid.
- */
-public class InvalidInjectionException
-    extends Exception
-{
-    public InvalidInjectionException( String s )
-    {
-        super( s );
-    }
-
-    public InvalidInjectionException( String s, Throwable throwable )
-    {
-        super( s, throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java
deleted file mode 100644
index 9b320c3..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. All rights Reserved.
- * Copyright 2012 Paul Merlin.
- *
- * 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.zest.bootstrap;
-
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.functional.Specification;
-
-/**
- * Fluid API for declaring a layer in an application. This is obtained by calling {@link ApplicationAssembly#layer(String)}.
- */
-public interface LayerAssembly
-{
-    /**
-     * Get an assembly for a particular Module. If this is called many times with the same name, then the same module
-     * is affected.
-     *
-     * @param name The name of the Module to retrieve or create.
-     *
-     * @return The ModuleAssembly for the Module.
-     */
-    ModuleAssembly module( String name );
-
-    ApplicationAssembly application();
-
-    String name();
-
-    LayerAssembly setName( String name );
-
-    LayerAssembly setMetaInfo( Object info );
-
-    LayerAssembly uses( LayerAssembly... layerAssembly );
-
-    /**
-     * Set the layer activators. Activators are executed in order around the
-     * Layer activation and passivation.
-     *
-     * @param activators the layer activators
-     * @return the assembly
-     */    
-    @SuppressWarnings( { "unchecked","varargs" } )
-    LayerAssembly withActivators( Class<? extends Activator<Layer>>... activators );
-
-    <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
-        throws ThrowableType;
-
-    /**
-     * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the EntityComposite types of interest.
-     *
-     * @return An EntityDeclaration for the specified EntityComposite types.
-     */
-    EntityDeclaration entities( Specification<? super EntityAssembly> specification );
-
-    /**
-     * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the ServiceComposite types of interest.
-     *
-     * @return An ServiceDeclaration for the specified ServiceComposite types.
-     */
-    ServiceDeclaration services( Specification<? super ServiceAssembly> specification );
-
-    /**
-     * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the TransientComposite types of interest.
-     *
-     * @return An TransientDeclaration for the specified TransientComposite types.
-     */
-    TransientDeclaration transients( Specification<? super TransientAssembly> specification );
-
-    /**
-     * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the ValueComposite types of interest.
-     *
-     * @return An ValueDeclaration for the specified ValueComposite types.
-     */
-    ValueDeclaration values( Specification<? super ValueAssembly> specification );
-
-    /**
-     * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the Object types of interest.
-     *
-     * @return An ObjectDeclaration for the specified Object types.
-     */
-    ObjectDeclaration objects( Specification<? super ObjectAssembly> specification );
-
-    /**
-     * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can
-     * be used to work with all of the assemblies in this Layer matched by the specification.
-     *
-     * @param specification The Specification that specifies the Imported Service types of interest.
-     *
-     * @return An ImportedServiceDeclaration for the specified Imported Service types.
-     */
-    ImportedServiceDeclaration importedServices( Specification<? super ImportedServiceAssembly> specification );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java
deleted file mode 100644
index f2c6005..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-/**
- * Set the name of the layer
- */
-public final class LayerName
-    implements Assembler
-{
-    private final String name;
-
-    public LayerName( String name )
-    {
-        this.name = name;
-    }
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.layer().setName( name );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java
deleted file mode 100644
index 3b97b2f..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.bootstrap;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.common.MetaInfo;
-
-/**
- * This provides declared {@link org.apache.zest.api.association.ManyAssociation} information that the runtime can use.
- */
-public interface ManyAssociationDeclarations
-{
-    MetaInfo metaInfoFor( AccessibleObject accessor );
-}
\ No newline at end of file


[30/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/StartMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/StartMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/StartMixin.java
deleted file mode 100644
index b3f797f..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/StartMixin.java
+++ /dev/null
@@ -1,22 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-public abstract class StartMixin implements Startable
-{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/Startable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/Startable.java b/core/api/src/test/java/org/apache/zest/api/mixin/Startable.java
deleted file mode 100644
index 4150686..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/Startable.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-// START SNIPPET: mixins
-public interface Startable
-{
-    boolean start();
-    void stop();
-}
-
-// END SNIPPET: mixins
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/Vehicle.java b/core/api/src/test/java/org/apache/zest/api/mixin/Vehicle.java
deleted file mode 100644
index 18c82ec..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/Vehicle.java
+++ /dev/null
@@ -1,31 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-// START SNIPPET: mixins
-public interface Vehicle
-{
-    void turn(float angle);
-
-    void accelerate(float acceleration);
-
-    // more methods
-}
-
-// END SNIPPET: mixins
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/VehicleMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/VehicleMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/VehicleMixin.java
deleted file mode 100644
index 982e81d..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/VehicleMixin.java
+++ /dev/null
@@ -1,22 +0,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.
- */
-package org.apache.zest.api.mixin;
-
-public abstract class VehicleMixin
-{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
deleted file mode 100644
index 7361d2c..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
+++ /dev/null
@@ -1,91 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import org.junit.Test;
-import org.apache.zest.api.composite.TransientBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class DecoratorMixinTest extends AbstractQi4jTest
-{
-    // START SNIPPET: assembly
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.transients( View1.class );
-        module.transients( View2.class );
-        module.transients( FooModel.class );
-    }
-// END SNIPPET: assembly
-
-// START SNIPPET: test
-
-    @Test
-    public void testDecoration()
-    {
-        FooModelImpl model = new FooModelImpl( "Init" );
-        View1 view1 = createView1( model );
-        View2 view2 = createView2( model );
-        assertThat( view1.bar(), equalTo( "Init" ) );
-        assertThat( view2.bar(), equalTo( "Init" ) );
-        model.setBar( "New Value" );
-        assertThat( view1.bar(), equalTo( "New Value" ) );
-        assertThat( view2.bar(), equalTo( "New Value" ) );
-    }
-// END SNIPPET: test
-
-    @Test
-    public void testDecorationWithGenericMixin()
-    {
-        InvocationHandler handler = new FooModelInvocationHandler("Init");
-        ClassLoader cl = getClass().getClassLoader();
-        FooModel model = (FooModel) Proxy.newProxyInstance( cl, new Class[]{ FooModel.class }, handler );
-        View1 view1 = createView1( model );
-        View2 view2 = createView2( model );
-        assertThat( view1.bar(), equalTo( "Init" ) );
-        assertThat( view2.bar(), equalTo( "Init" ) );
-        model.setBar( "New Value" );
-        assertThat( view1.bar(), equalTo( "New Value" ) );
-        assertThat( view2.bar(), equalTo( "New Value" ) );
-    }
-
-    // START SNIPPET: create
-    public View1 createView1( FooModel model )
-    {
-        TransientBuilder<View1> builder = module.newTransientBuilder( View1.class );
-        builder.use( model );
-        return builder.newInstance();
-    }
-// END SNIPPET: create
-
-    public View2 createView2( FooModel model )
-    {
-        TransientBuilder<View2> builder = module.newTransientBuilder( View2.class );
-        builder.use( model );
-        return builder.newInstance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModel.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModel.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModel.java
deleted file mode 100644
index ae8236e..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModel.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-import org.apache.zest.api.composite.DecoratorMixin;
-import org.apache.zest.api.mixin.Mixins;
-
-// START SNIPPET: decorator
-@Mixins(DecoratorMixin.class)
-// START SNIPPET: plain
-public interface FooModel
-// END SNIPPET: decorator
-{
-    String getBar();
-    void setBar(String value);
-// END SNIPPET: plain
-
-// START SNIPPET: plain
-}
-// END SNIPPET: plain

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelImpl.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelImpl.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelImpl.java
deleted file mode 100644
index 1d7b495..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelImpl.java
+++ /dev/null
@@ -1,41 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-public class FooModelImpl
-    implements FooModel
-{
-    private String bar;
-
-    public FooModelImpl( String bar )
-    {
-        this.bar = bar;
-    }
-
-    @Override
-    public String getBar()
-    {
-        return bar;
-    }
-
-    public void setBar( String bar )
-    {
-        this.bar = bar;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelInvocationHandler.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelInvocationHandler.java
deleted file mode 100644
index f626113..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/FooModelInvocationHandler.java
+++ /dev/null
@@ -1,47 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-public class FooModelInvocationHandler
-    implements InvocationHandler
-{
-    private String value;
-
-    public FooModelInvocationHandler( String value )
-    {
-        this.value = value;
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        if(method.getName().equals( "hashCode" ))
-            return hashCode();
-        if(method.getName().equals( "equals" ))
-            return equals(args[0]);
-        if(args==null || args.length==0)
-            return value;
-        value = (String) args[0];
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View1.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View1.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View1.java
deleted file mode 100644
index 3da3aca..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View1.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-
-// START SNIPPET: decorator
-@Mixins(View1.Mixin.class)
-public interface View1
-{
-    String bar();
-
-    public class Mixin
-        implements View1
-    {
-        @This
-        FooModel model;
-
-        @Override
-        public String bar()
-        {
-            return model.getBar();
-        }
-    }
-}
-// END SNIPPET: decorator

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View2.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View2.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View2.java
deleted file mode 100644
index 75cec00..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/View2.java
+++ /dev/null
@@ -1,40 +0,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.
- */
-package org.apache.zest.api.mixin.decoratorMixin;
-
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-
-@Mixins(View2.Mixin.class)
-public interface View2
-{
-    String bar();
-    public class Mixin
-        implements View2
-    {
-        @This
-        FooModel model;
-
-        @Override
-        public String bar()
-        {
-            return model.getBar();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Car.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/Car.java
deleted file mode 100644
index d125e3a..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Car.java
+++ /dev/null
@@ -1,30 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.mixin.StartMixin;
-import org.apache.zest.api.mixin.Startable;
-
-// START SNIPPET: partial
-@Mixins( { StartMixin.class, SpeedMixin.class, CrashResultMixin.class } )
-public interface Car extends Startable, Vehicle
-{}
-
-// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/CrashResultMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/CrashResultMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/CrashResultMixin.java
deleted file mode 100644
index 0a6ffa7..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/CrashResultMixin.java
+++ /dev/null
@@ -1,23 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-public class CrashResultMixin implements Crashable
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/Crashable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Crashable.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/Crashable.java
deleted file mode 100644
index 86bcd59..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Crashable.java
+++ /dev/null
@@ -1,23 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-public interface Crashable
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedLocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedLocation.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedLocation.java
deleted file mode 100644
index 8129dc8..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedLocation.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-// START SNIPPET: partial
-public interface SpeedLocation
-{
-    void turn(float angle);
-
-    void accelerate(float acceleration);
-}
-// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedMixin.java
deleted file mode 100644
index 45a2eb6..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/SpeedMixin.java
+++ /dev/null
@@ -1,33 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-// START SNIPPET: partial
-public abstract class SpeedMixin
-        implements SpeedLocation
-{
-    // state for speed
-
-    public void accelerate( float acceleration )
-    {
-        // logic
-    }
-}
-
-// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/partial/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Vehicle.java b/core/api/src/test/java/org/apache/zest/api/mixin/partial/Vehicle.java
deleted file mode 100644
index 54725e9..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/partial/Vehicle.java
+++ /dev/null
@@ -1,26 +0,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.
- */
-package org.apache.zest.api.mixin.partial;
-
-// START SNIPPET: partial
-public interface Vehicle extends SpeedLocation, Crashable
-{
-}
-
-// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/Cargo.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/Cargo.java b/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/Cargo.java
deleted file mode 100644
index 53295ea..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/Cargo.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.api.mixin.privateMixin;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.mixin.Mixins;
-
-// START SNIPPET: private
-@Mixins( CargoMixin.class )
-public interface Cargo extends EntityComposite
-{
-    String origin();
-
-    String destination();
-
-    void changeDestination( String newDestination );
-
-}
-
-// END SNIPPET: private

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoMixin.java b/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoMixin.java
deleted file mode 100644
index e043b54..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoMixin.java
+++ /dev/null
@@ -1,46 +0,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.
- */
-package org.apache.zest.api.mixin.privateMixin;
-
-import org.apache.zest.api.injection.scope.This;
-
-// START SNIPPET: private
-public abstract class CargoMixin
-        implements Cargo
-{
-    @This
-    private CargoState state;
-
-    public String origin()
-    {
-        return state.origin().get();
-    }
-
-    public String destination()
-    {
-        return state.destination().get();
-    }
-
-    public void changeDestination( String newDestination )
-    {
-        state.destination().set( newDestination );
-    }
-}
-
-// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoState.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoState.java b/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoState.java
deleted file mode 100644
index 0895948..0000000
--- a/core/api/src/test/java/org/apache/zest/api/mixin/privateMixin/CargoState.java
+++ /dev/null
@@ -1,30 +0,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.
- */
-package org.apache.zest.api.mixin.privateMixin;
-
-import org.apache.zest.api.property.Property;
-
-// START SNIPPET: private
-public interface CargoState
-{
-    Property<String> origin();
-    Property<String> destination();
-}
-
-// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java b/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
deleted file mode 100644
index 018c521..0000000
--- a/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.api.object;
-
-import org.junit.Test;
-import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * JAVADOC
- */
-public class ObjectBuilderTest
-    extends AbstractQi4jTest
-{
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.objects( A.class, B.class, C.class, D.class );
-    }
-
-    @Test
-    public void testNotProvidedUses()
-    {
-        A a = module.newObject( A.class );
-        assertNotNull( a );
-        assertNotNull( a.b );
-        assertNotNull( a.b.c );
-        assertNotNull( a.b.c.d );
-    }
-
-    public static class A
-    {
-        @Uses
-        B b;
-    }
-
-    public static class B
-    {
-        @Uses
-        C c;
-    }
-
-    public static class C
-    {
-        @Uses
-        D d;
-    }
-
-    public static class D
-    {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java b/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
deleted file mode 100644
index ef22b06..0000000
--- a/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.property;
-
-import org.junit.Test;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-/**
- * Error messages for Properties
- */
-public class PropertyErrorTest
-    extends AbstractQi4jTest
-{
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        new EntityTestAssembler().assemble( module );
-        module.entities( PersonEntity.class );
-    }
-
-    @Test( expected = ConstraintViolationException.class )
-    public void givenEntityWithNonOptionPropertyWhenInstantiatedThenException()
-        throws Exception
-    {
-        UnitOfWork unitOfWork = module.newUnitOfWork();
-        try
-        {
-            PersonEntity person = unitOfWork.newEntity( PersonEntity.class );
-
-            unitOfWork.complete();
-        }
-        finally
-        {
-            unitOfWork.discard();
-        }
-    }
-
-    interface PersonEntity
-        extends EntityComposite
-    {
-        Property<String> foo();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/service/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/service/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/service/DocumentationSupport.java
deleted file mode 100644
index d5ca53a..0000000
--- a/core/api/src/test/java/org/apache/zest/api/service/DocumentationSupport.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.service;
-
-import java.util.List;
-import org.apache.zest.api.activation.Activators;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.qualifier.ServiceTags;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-
-public class DocumentationSupport
-    implements Assembler
-{
-    // START SNIPPET: tag
-    // START SNIPPET: instantiateOnStartup
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        ServiceDeclaration service = module.addServices( MyDemoService.class );
-        // END SNIPPET: tag
-        service.instantiateOnStartup();
-        // END SNIPPET: instantiateOnStartup
-        // START SNIPPET: tag
-        service.taggedWith( "Important", "Drain" );
-        // END SNIPPET: tag
-    }
-
-    private static class MyDemoService
-    {
-    }
-
-    private static class MyOtherDemoService
-    {
-        // START SNIPPET: UseTag
-        @Service
-        private List<ServiceReference<MyDemoService>> services;
-
-        public MyDemoService locateImportantService()
-        {
-            for( ServiceReference<MyDemoService> ref : services )
-            {
-                ServiceTags serviceTags = ref.metaInfo( ServiceTags.class );
-                if( serviceTags.hasTag( "Important" ) )
-                {
-                    return ref.get();
-                }
-            }
-            return null;
-        }
-        // END SNIPPET: UseTag
-    }
-
-    // START SNIPPET: activation1
-    @Mixins( MyActivationMixin.class )
-    public static interface MyActivationDemoService
-        extends ServiceComposite, ServiceActivation
-    {
-    }
-
-    public static class MyActivationMixin
-        implements ServiceActivation
-    {
-        @Override
-        public void activateService()
-            throws Exception
-        {
-            // Activation code
-        }
-
-        @Override
-        public void passivateService()
-            throws Exception
-        {
-            // Passivation code
-        }
-    }
-    // END SNIPPET: activation1
-
-    // START SNIPPET: activation2
-    @Activators( MyActivator.class )
-    public static interface MyOtherActivationDemoService
-        extends ServiceComposite
-    {
-    }
-
-    public static class MyActivator
-        extends ServiceActivatorAdapter<MyOtherActivationDemoService>
-    {
-        @Override
-        public void afterActivation( ServiceReference<MyOtherActivationDemoService> activated )
-            throws Exception
-        {
-            // Activation code
-        }
-
-        @Override
-        public void beforePassivation( ServiceReference<MyOtherActivationDemoService> passivating )
-            throws Exception
-        {
-            // Passivation code
-        }
-    }
-    // END SNIPPET: activation2
-
-    static class Activation3
-        implements Assembler
-    {
-        // START SNIPPET: activation3
-        @Override
-        public void assemble( ModuleAssembly module )
-        {
-            module.services( MyDemoService.class ).withActivators( MyActivator.class );
-        }
-        // END SNIPPET: activation3
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
deleted file mode 100644
index 7cfcc32..0000000
--- a/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.unitofwork;
-
-import org.junit.Test;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-public class RemovalTest
-    extends AbstractQi4jTest
-{
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.entities( TestEntity.class );
-        module.entities( PidRegulator.class );
-        new EntityTestAssembler().assemble( module );
-    }
-
-    @Test
-    public void givenEntityIsCreatedAndUnitOfWorkIsNotCompletedWhenEntityIsRemoveThenSuccessfulRemoval()
-        throws Exception
-    {
-        UnitOfWork uow = module.newUnitOfWork();
-        try
-        {
-            EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, "123" );
-            builder.instance().test().set( "habba" );
-            TestEntity test = builder.newInstance();
-            uow.remove( test );
-            uow.complete();
-        }
-        finally
-        {
-            uow.discard();
-        }
-    }
-
-    @Test
-    public void givenStandardPidRegulatorWhenNoChangeInInputExpectOutputToGoTowardsMinimum()
-        throws Exception
-    {
-        UnitOfWork uow = module.newUnitOfWork();
-        PidRegulator regulator = null;
-        try
-        {
-            regulator = createPidRegulator( uow );
-        }
-        finally
-        {
-            if( regulator != null )
-            {
-                uow.remove( regulator );
-            }
-            // TODO: This problem is related to that uow.remove() has a bug.
-            // If the Entity is both created and removed in the same session, then the remove() should simply remove
-            // the entity from the internal UoW holding area, and not set the REMOVED status.
-
-            // Probably that UnitOfWorkInstance.remove() should also call instanceCache.remove(), but the question is
-            // then what is an InstanceKey vs EntityReference
-            uow.complete();
-        }
-    }
-
-    public interface TestEntity
-        extends EntityComposite
-    {
-        @Optional
-        Property<String> test();
-    }
-
-    private PidRegulator createPidRegulator( UnitOfWork uow )
-        throws UnitOfWorkCompletionException
-    {
-        EntityBuilder<PidRegulator> builder = uow.newEntityBuilder( PidRegulator.class );
-        PidRegulator prototype = builder.instance();
-        prototype.p().set( 1.0f );
-        prototype.i().set( 10f );
-        prototype.d().set( 0.1f );
-        prototype.maxD().set( 10f );
-        prototype.maximum().set( 100f );
-        prototype.minimum().set( 0f );
-        PidRegulator regulator = builder.newInstance();
-
-        return regulator;
-    }
-
-    //    @Mixins( { PidRegulatorAlgorithmMixin.class } )
-    public interface PidRegulator
-        extends PidParameters, EntityComposite
-    {
-    }
-
-    public interface PidParameters
-    {
-        Property<Float> p();
-
-        Property<Float> i();
-
-        Property<Float> d();
-
-        Property<Float> maxD();
-
-        Property<Float> minimum();
-
-        Property<Float> maximum();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java b/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
deleted file mode 100644
index e32ac3b..0000000
--- a/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
+++ /dev/null
@@ -1,73 +0,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.
- */
-package org.apache.zest.api.unitofwork;
-
-import org.junit.Test;
-import org.apache.zest.api.entity.EntityBuilderTemplate;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-/**
- * TODO
- */
-public class UnitOfWorkTemplateTest
-    extends AbstractQi4jTest
-{
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        new EntityTestAssembler().assemble( module );
-        module.entities( TestEntity.class );
-    }
-
-    @Test
-    public void testTemplate()
-        throws UnitOfWorkCompletionException
-    {
-        new UnitOfWorkTemplate<Void, RuntimeException>()
-        {
-            @Override
-            protected Void withUnitOfWork( UnitOfWork uow )
-                throws RuntimeException
-            {
-                new EntityBuilderTemplate<TestEntity>( TestEntity.class )
-                {
-                    @Override
-                    protected void build( TestEntity prototype )
-                    {
-                        prototype.name().set( "Rickard" );
-                    }
-                }.newInstance( module );
-
-                return null;
-            }
-        }.withModule( module );
-    }
-
-    interface TestEntity
-        extends EntityComposite
-    {
-        Property<String> name();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java b/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
deleted file mode 100644
index 5499aa8..0000000
--- a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.api.util;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Test;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.api.util.Classes.interfacesWithMethods;
-import static org.apache.zest.functional.Iterables.count;
-
-/**
- * Tests for Classes
- */
-public class ClassesTest
-{
-
-    @Test
-    public void givenClassWithInterfacesWhenInterfacesOfThenGetCorrectSet()
-    {
-        assertThat( "one interface returned", count( interfacesOf( A.class ) ), equalTo( 1L ) );
-        assertThat( "two interface returned", count( interfacesOf( B.class ) ), equalTo( 2L ) );
-        assertThat( "tree interface returned", count( interfacesOf( C.class ) ), equalTo( 4L ) );
-    }
-
-    @Test
-    public void givenClassWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
-    {
-        HashSet<Class<?>> interfaces = new HashSet<Class<?>>();
-        interfaces.add( B.class );
-        Set<Class<?>> types = interfacesWithMethods( interfaces );
-        assertThat( "one interface returned", types.size(), equalTo( 1 ) );
-        assertThat( "correct interface returned", types.contains( B.class ), is( true ) );
-    }
-
-    @Test
-    public void givenClassesWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
-    {
-        Iterable<Type> types = Iterables.filter( Methods.HAS_METHODS, interfacesOf( C.class ) );
-        assertThat( "one interface returned", count( types ), equalTo( 1L ) );
-        assertThat( "correct interface returned", Iterables.matchesAny( (Specification) Specifications.in( B.class ), Iterables
-            .<Class<?>>cast( types ) ), is( true ) );
-    }
-
-    @Test
-    public void givenClassNameWhenToUriThenUriIsReturned()
-    {
-        assertThat( "URI is correct", Classes.toURI( A.class ), equalTo( "urn:qi4j:type:org.qi4j.api.util.ClassesTest-A" ) );
-    }
-
-    @Test
-    public void givenUriWhenToClassNameThenClassNameIsReturned()
-    {
-        assertThat( "Class name is correct", Classes.toClassName( "urn:qi4j:type:org.qi4j.api.util.ClassesTest-A" ), equalTo( "org.qi4j.api.util.ClassesTest$A" ) );
-    }
-
-    @Test
-    public void givenGenericTypeWithWildCardWhenGetRawClassThenCorrectTypeIsReturned()
-        throws NoSuchMethodException
-    {
-        Type returnType = Generics.class.getMethod( "wildcard" ).getGenericReturnType();
-        Type wildcardType = ( (ParameterizedType) returnType ).getActualTypeArguments()[ 0];
-        assertThat( "Return type is A", Classes.RAW_CLASS.map( wildcardType ), equalTo( (Class) A.class ) );
-    }
-
-    @Test
-    public void givenTypeVariableWhenResolveThenResolved()
-    {
-        for( Method method : Type1.class.getMethods() )
-        {
-            Type type = method.getGenericReturnType();
-            TypeVariable typeVariable = (TypeVariable) type;
-            Type resolvedType = Classes.resolveTypeVariable( typeVariable, method.getDeclaringClass(), Type1.class );
-            System.out.println( type + "=" + resolvedType );
-            switch( method.getName() )
-            {
-                case "type":
-                    assertThat( resolvedType, equalTo( (Type) String.class ) );
-                    break;
-                case "type1":
-                    assertThat( resolvedType, equalTo( (Type) String.class ) );
-                    break;
-                case "type2":
-                    assertThat( resolvedType, equalTo( (Type) Long.class ) );
-                    break;
-            }
-        }
-    }
-
-    @Test
-    public void givenGenericTypeWhenGetSimpleGenericNameThenCorrectStringIsReturned()
-        throws NoSuchMethodException
-    {
-        assertThat( "Simple Generic Name is 'A'",
-                    Classes.simpleGenericNameOf( A.class ),
-                    equalTo( "A" ) );
-        assertThat( "Simple Generic Name is 'B'",
-                    Classes.simpleGenericNameOf( B.class ),
-                    equalTo( "B" ) );
-        assertThat( "Simple Generic Name is 'C'",
-                    Classes.simpleGenericNameOf( C.class ),
-                    equalTo( "C" ) );
-
-        assertThat( "Simple Generic Name is 'Generics'",
-                    Classes.simpleGenericNameOf( Generics.class ),
-                    equalTo( "Generics" ) );
-        assertThat( "Simple Generic Name is 'Iterable<? extends A>'",
-                    Classes.simpleGenericNameOf( Generics.class.getMethod( "wildcard" ).getGenericReturnType() ),
-                    equalTo( "Iterable<? extends A>" ) );
-
-        assertThat( "Simple Generic Name is 'Type1'",
-                    Classes.simpleGenericNameOf( Type1.class ),
-                    equalTo( "Type1" ) );
-        assertThat( "Simple Generic Name is 'TYPE'",
-                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type" ).getGenericReturnType() ),
-                    equalTo( "TYPE" ) );
-        assertThat( "Simple Generic Name is 'TYPE1'",
-                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type1" ).getGenericReturnType() ),
-                    equalTo( "TYPE1" ) );
-        assertThat( "Simple Generic Name is 'TYPE2'",
-                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type2" ).getGenericReturnType() ),
-                    equalTo( "TYPE2" ) );
-
-        assertThat( "Simple Generic Name is 'Type2'",
-                    Classes.simpleGenericNameOf( Type2.class ),
-                    equalTo( "Type2" ) );
-        assertThat( "Simple Generic Name is 'TYPE'",
-                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type" ).getGenericReturnType() ),
-                    equalTo( "TYPE" ) );
-        assertThat( "Simple Generic Name is 'TYPE1'",
-                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type1" ).getGenericReturnType() ),
-                    equalTo( "TYPE1" ) );
-        assertThat( "Simple Generic Name is 'TYPE2'",
-                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type2" ).getGenericReturnType() ),
-                    equalTo( "TYPE2" ) );
-
-        assertThat( "Simple Generic Name is 'Type3'",
-                    Classes.simpleGenericNameOf( Type3.class ),
-                    equalTo( "Type3" ) );
-        assertThat( "Simple Generic Name is 'TYPE'",
-                    Classes.simpleGenericNameOf( Type3.class.getMethod( "type" ).getGenericReturnType() ),
-                    equalTo( "TYPE" ) );
-    }
-
-    interface A
-    {
-    }
-
-    interface B
-        extends A
-    {
-
-        public void doStuff();
-
-    }
-
-    interface C
-        extends A, B
-    {
-    }
-
-    interface Generics
-    {
-
-        Iterable<? extends A> wildcard();
-
-    }
-
-    interface Type1
-        extends Type2<String, Long>
-    {
-    }
-
-    interface Type2<TYPE1, TYPE2>
-        extends Type3<TYPE1>
-    {
-
-        TYPE1 type1();
-
-        TYPE2 type2();
-
-    }
-
-    interface Type3<TYPE>
-    {
-
-        TYPE type();
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
deleted file mode 100644
index 2c2b998..0000000
--- a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2013, Paul Merlin. 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.zest.api.value;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Function;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
-import org.apache.zest.io.Transforms;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-
-/**
- * Snippets:
- * - default : default ValueSerialization
- * - service : assembled service ValueSerialization
- * - lookup  : ValueSerialization values module finder
- */
-public class DocumentationSupport
-    extends AbstractQi4jTest
-{
-
-    @Before
-    public void injectToThis()
-    {
-        module.injectTo( this );
-    }
-
-    // START SNIPPET: default
-    // START SNIPPET: service
-    public interface SomeValue // (1)
-    {
-
-        Property<String> foo();
-    }
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.values( SomeValue.class ); // (2)
-        // END SNIPPET: default
-        new OrgJsonValueSerializationAssembler().assemble( module ); // (3)
-        // START SNIPPET: default
-    }
-    // END SNIPPET: default
-    // END SNIPPET: service
-
-    @Test
-    // START SNIPPET: default
-    public void defaultValueSerialization()
-    {
-        SomeValue someValue = someNewValueInstance( module ); // (3)
-        String json = someValue.toString(); // (4)
-        SomeValue someNewValue = module.newValueFromSerializedState( SomeValue.class, json ); // (5)
-        // END SNIPPET: default
-
-        assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
-        assertThat( someNewValue, equalTo( someValue ) );
-
-        // START SNIPPET: default
-    }
-    // END SNIPPET: default
-    // START SNIPPET: service
-    @Service
-    private ValueSerializer valueSerializer; // (4)
-    @Service
-    private ValueDeserializer valueDeserializer; // (4)
-
-    // END SNIPPET: service
-    @Test
-    // START SNIPPET: service
-    public void assembledDefaultServiceSerialization()
-    {
-        SomeValue someValue = someNewValueInstance( module ); // (5)
-        String json = valueSerializer.serialize( someValue ); // (6)
-        SomeValue someNewValue = valueDeserializer.deserialize( SomeValue.class, json ); // (7)
-        // END SNIPPET: service
-
-        assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
-        assertThat( someNewValue, equalTo( someValue ) );
-
-        // START SNIPPET: service
-    }
-    // END SNIPPET: service
-
-    static enum AcmeValue
-    {
-
-        foo, bar
-    }
-
-    @Test
-    // START SNIPPET: stream
-    public void assembledServiceStreamingSerialization()
-    {
-        // END SNIPPET: stream
-
-        List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
-        ByteArrayOutputStream targetStream = new ByteArrayOutputStream();
-
-        // START SNIPPET: stream
-        // (1)
-        Iterable<AcmeValue> data = dataSource; // Eg. Entities converted to Values
-        OutputStream output = targetStream; // Eg. streaming JSON over HTTP
-
-        // (2)
-        valueSerializer.serialize( data, output );
-        // END SNIPPET: stream
-
-        byte[] serialized = targetStream.toByteArray();
-        ByteArrayInputStream sourceStream = new ByteArrayInputStream( serialized );
-
-        // START SNIPPET: stream
-        // (3)
-        InputStream input = sourceStream; // Eg. reading incoming JSON
-
-        // (4)
-        List<AcmeValue> values = valueDeserializer.deserialize( CollectionType.listOf( AcmeValue.class ), input );
-        // END SNIPPET: stream
-
-        assertThat( values, equalTo( dataSource ) );
-
-        // START SNIPPET: stream
-    }
-    // END SNIPPET: stream
-
-    @Test
-    // START SNIPPET: io
-    public void assembledServiceIOSerialization()
-        throws IOException
-    {
-        // END SNIPPET: io
-
-        List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
-        StringWriter outputWriter = new StringWriter();
-
-        // START SNIPPET: io
-        // (1)
-        Iterable<AcmeValue> queryResult = dataSource; // Eg. Entities converted to Values
-        Writer writer = outputWriter; // Eg. to pipe data to another process or to a file
-
-        // (2)
-        Function<AcmeValue, String> serialize = valueSerializer.serialize();
-
-        // (3)
-        Inputs.iterable( queryResult ).transferTo( Transforms.map( serialize, Outputs.text( writer ) ) );
-        // END SNIPPET: io
-
-        String string = writer.toString();
-        StringReader inputReader = new StringReader( string );
-
-        // START SNIPPET: io
-        // (4)
-        Reader reader = inputReader;
-        List<AcmeValue> values = new ArrayList<AcmeValue>();
-
-        // (5)
-        Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( AcmeValue.class );
-
-        // Deserialization of a collection of AcmeValue from a String.
-        // One serialized AcmeValue per line.
-        // (6)
-        Inputs.text( reader ).transferTo( Transforms.map( deserialize, Outputs.collection( values ) ) );
-        // END SNIPPET: io
-
-        assertThat( dataSource, equalTo( values ) );
-
-        // START SNIPPET: io
-    }
-    // END SNIPPET: io
-
-    @Test
-    // TODO Move to SPI !
-    // TODO Include in each ValueSerialization extensions documentation
-    public void assembledWithValuesModuleSerialization()
-        throws Exception
-    {
-        Application app = new Energy4Java().newApplication( new ApplicationAssembler()
-        {
-            @Override
-            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-                throws AssemblyException
-            {
-                Assembler[][][] pancakes = new Assembler[][][]
-                {
-                    {
-                        {
-                            new Assembler()
-                            {
-                                @Override
-                                public void assemble( ModuleAssembly valuesModule )
-                                    throws AssemblyException
-                                {
-                                    valuesModule.layer().setName( "SINGLE-Layer" );
-                                    valuesModule.setName( "VALUES-Module" );
-
-                                    valuesModule.values( SomeValue.class );
-                                }
-                            }
-                        },
-                        {
-                            new Assembler()
-                            {
-                                @Override
-                                public void assemble( ModuleAssembly servicesModule )
-                                    throws AssemblyException
-                                {
-                                    servicesModule.setName( "SERVICES-Module" );
-
-                                    Function<Application, Module> valuesModuleFinder = new Function<Application, Module>()
-                                    {
-                                        @Override
-                                        public Module map( Application app )
-                                        {
-                                            return app.findModule( "SINGLE-Layer", "VALUES-Module" );
-                                        }
-                                    };
-                                    new OrgJsonValueSerializationAssembler().
-                                        withValuesModuleFinder( valuesModuleFinder ).
-                                        assemble( servicesModule );
-                                }
-                            }
-                        }
-                    }
-                };
-                return applicationFactory.newApplicationAssembly( pancakes );
-            }
-        } );
-        app.activate();
-        try
-        {
-            Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" );
-            SomeValue someValue = someNewValueInstance( valuesModule );
-
-            Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" );
-            ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get();
-
-            String json = valueSerialization.serialize( someValue );
-            assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
-
-            SomeValue someNewValue = valueSerialization.deserialize( SomeValue.class, json );
-            assertThat( someNewValue, equalTo( someValue ) );
-        }
-        finally
-        {
-            app.passivate();
-        }
-    }
-
-    private SomeValue someNewValueInstance( Module module )
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        builder.prototype().foo().set( "bar" );
-        return builder.newInstance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java
deleted file mode 100644
index 8da8dc9..0000000
--- a/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java
+++ /dev/null
@@ -1,84 +0,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.
- */
-package org.apache.zest.api.value;
-
-import org.junit.Test;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractQi4jTest;
-
-/**
- * TODO
- */
-public class ValueBuilderTemplateTest
-    extends AbstractQi4jTest
-{
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.values( TestValue.class );
-    }
-
-    @Test
-    public void testTemplate()
-    {
-        new TestBuilder( "Rickard" ).newInstance( module );
-    }
-
-    @Test
-    public void testAnonymousTemplate()
-    {
-        new ValueBuilderTemplate<TestValue>( TestValue.class )
-        {
-            @Override
-            protected void build( TestValue prototype )
-            {
-                prototype.name().set( "Rickard" );
-            }
-        }.newInstance( module );
-    }
-
-    interface TestValue
-        extends ValueComposite
-    {
-        Property<String> name();
-    }
-
-    class TestBuilder
-        extends ValueBuilderTemplate<TestValue>
-    {
-        String name;
-
-        TestBuilder( String name )
-        {
-            super( TestValue.class );
-            this.name = name;
-        }
-
-        @Override
-        protected void build( TestValue prototype )
-        {
-            prototype.name().set( name );
-        }
-    }
-
-    ;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
deleted file mode 100644
index 494c249..0000000
--- a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.value;
-
-import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.constraints.annotation.MaxLength;
-import org.apache.zest.test.AbstractQi4jTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-/**
- * Tests for ValueComposites
- */
-public class ValueCompositeTest
-    extends AbstractQi4jTest
-{
-
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.values( SomeValue.class, AnotherValue.class, AssociationValue.class );
-        module.entities( SomeEntity.class );
-        new EntityTestAssembler().assemble( module );
-    }
-
-    @Test( expected = IllegalStateException.class )
-    public void testImmutabilityOfValueComposite()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue some = builder.prototype();
-        some.other().set( "test" );
-        some = builder.newInstance();
-        some.other().set( "test2" );
-    }
-
-    @Test
-    public void testCreationOfValueComposite()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue some = builder.prototype();
-        some.other().set( "test" );
-        builder.newInstance();
-
-        // Check that @UseDefaults works for ValueComposites
-        assertEquals( "{\"val1\":\"\"}", some.another().get().toString() );
-    }
-
-    @Test
-    public void testEqualityOfValueComposite()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue prototype = builder.prototype();
-        prototype.other().set( "test" );
-        SomeValue instance = builder.newInstance();
-        SomeValue other = builder.newInstance();
-        Assert.assertFalse( "Instances should not be the same.", instance == other );
-        Assert.assertEquals( "Equal values.", instance, other );
-    }
-
-    @Test
-    public void testHashcodeOfValueComposite()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue prototype = builder.prototype();
-        prototype.other().set( "test" );
-        SomeValue instance = builder.newInstance();
-        SomeValue other = builder.newInstance();
-        Assert.assertFalse( "Instances should not be the same.", instance == other );
-        Assert.assertEquals( "Equal values.", instance.hashCode(), other.hashCode() );
-    }
-
-    @Test
-    public void testModifyValue()
-    {
-        ValueBuilder<AnotherValue> anotherBuilder = module.newValueBuilder( AnotherValue.class );
-        anotherBuilder.prototype().val1().set( "Val1" );
-        AnotherValue anotherValue = anotherBuilder.newInstance();
-
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue prototype = builder.prototype();
-        prototype.some().set( "foo" );
-        prototype.other().set( "test" );
-        prototype.xyzzyList().get().add( "blah" );
-        prototype.another().set( anotherValue );
-        SomeValue instance = builder.newInstance();
-
-        assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
-
-        // Modify value
-        builder = module.newValueBuilderWithPrototype( instance );
-        builder.prototype().some().set( "bar" );
-        instance = builder.newInstance();
-
-        assertThat( "Other is set to test", instance.other().get(), equalTo( "test" ) );
-        assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
-        assertThat( "AnotherValue.val1 has value Val1", instance.another().get().val1().get(), equalTo( "Val1" ) );
-
-        // Modify value again using method 2
-        builder = module.newValueBuilderWithPrototype( instance );
-        builder.prototype().other().set( "test2" );
-        instance = builder.newInstance();
-
-        assertThat( "Other is set to test2", instance.other().get(), equalTo( "test2" ) );
-        assertThat( "Some is set to bar", instance.some().get(), equalTo( "bar" ) );
-    }
-
-    @Test( expected = ConstraintViolationException.class )
-    public void givenValueWhenModifyToIncorrectValueThenThrowConstraintException()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        SomeValue prototype = builder.prototype();
-        prototype.some().set( "foo" );
-        SomeValue instance = builder.newInstance();
-
-        builder = module.newValueBuilderWithPrototype( instance );
-        builder.prototype().some().set( "123456" );
-    }
-
-    @Test
-    public void givenValueWithListOfValueWhenPrototypeThenListedValuesAreEditable()
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
-        SomeValue some = builder.newInstance();
-
-        builder = module.newValueBuilderWithPrototype( some );
-        builder.prototype().anotherList().get().get( 0 ).val1().set( "Foo" );
-        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
-        some = builder.newInstance();
-
-        assertThat( "Val1 has been set", some.anotherList().get().get( 0 ).val1().get(), equalTo( "Foo" ) );
-
-        try
-        {
-            some.anotherList().get().get( 0 ).val1().set( "Bar" );
-            Assert.fail( "Should not be allowed to modify value" );
-        }
-        catch( IllegalStateException e )
-        {
-            // Ok
-        }
-    }
-
-    @Test
-    public void givenEntityWhenUpdateValueThenValueIsSet()
-        throws UnitOfWorkCompletionException
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
-        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
-        valueBuilder.prototype().val1().set( "Foo" );
-        builder.prototype().another().set( valueBuilder.newInstance() );
-        builder.prototype().number().set( 42L );
-        SomeValue some = builder.newInstance();
-
-        UnitOfWork unitOfWork = module.newUnitOfWork();
-        try
-        {
-            EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
-            entityBuilder.instance().someValue().set( some );
-            SomeEntity entity = entityBuilder.newInstance();
-
-            assertThat( "Value has been set", entity.someValue().get().another().get().val1().get(), equalTo( "Foo" ) );
-
-            unitOfWork.complete();
-        }
-        finally
-        {
-            unitOfWork.discard();
-        }
-    }
-
-    @Test
-    public void givenValueWithAssociationsWhenNewUoWThenCanRead()
-        throws UnitOfWorkCompletionException
-    {
-        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
-        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
-        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
-        valueBuilder.prototype().val1().set( "Foo" );
-        builder.prototype().another().set( valueBuilder.newInstance() );
-        builder.prototype().number().set( 42L );
-        SomeValue some = builder.newInstance();
-
-        UnitOfWork unitOfWork = module.newUnitOfWork();
-        AssociationValue associationValue;
-        try
-        {
-            EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
-            entityBuilder.instance().someValue().set( some );
-            SomeEntity entity = entityBuilder.newInstance();
-
-            ValueBuilder<AssociationValue> associationBuilder = module.newValueBuilder( AssociationValue.class );
-            associationBuilder.prototype().some().set( entity );
-            associationValue = associationBuilder.newInstance();
-
-            String json = associationValue.toString();
-
-            unitOfWork.complete();
-
-            unitOfWork = module.newUnitOfWork();
-
-            AssociationValue newAssociationValue = module.newValueFromSerializedState( AssociationValue.class, json );
-
-            Assert.assertEquals( associationValue.some().get(), newAssociationValue.some().get() );
-        }
-        finally
-        {
-            unitOfWork.discard();
-        }
-
-        // Should allow the toString() to print the entityRefs.
-        System.out.println( associationValue.toString() );
-        try
-        {
-            associationValue.some().get();
-            fail( "Should have thrown an exception" );
-        }
-        catch( Exception e )
-        {
-            // Ok
-        }
-    }
-
-    public enum TestEnum
-    {
-        somevalue, anothervalue
-    }
-
-    public interface SomeValue
-        extends ValueComposite
-    {
-        @UseDefaults
-        @MaxLength( 5 )
-        Property<String> some();
-
-        @UseDefaults
-        Property<String> other();
-
-        @UseDefaults
-        Property<Long> number();
-
-        @UseDefaults
-        Property<List<String>> xyzzyList();
-
-        @UseDefaults
-        Property<AnotherValue> another();
-
-        @UseDefaults
-        Property<List<AnotherValue>> anotherList();
-
-        @UseDefaults
-        Property<TestEnum> testEnum();
-    }
-
-    public interface AnotherValue
-        extends ValueComposite
-    {
-        @UseDefaults
-        Property<String> val1();
-    }
-
-    public interface AssociationValue
-        extends ValueComposite
-    {
-        @Optional
-        Association<SomeEntity> some();
-
-        ManyAssociation<SomeEntity> manySome();
-    }
-
-    public interface SomeEntity
-        extends EntityComposite
-    {
-        Property<SomeValue> someValue();
-    }
-}
\ No newline at end of file


[36/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java b/core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java
new file mode 100644
index 0000000..6afee4d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.qi4j.api.property;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * Thrown when attempting to subclass Property.
+ */
+public class InvalidPropertyTypeException extends ConstructionException
+{
+    public InvalidPropertyTypeException( AccessibleObject accessor )
+    {
+        super( createMessage(accessor) );
+    }
+
+    private static String createMessage( AccessibleObject accessor )
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append( "Not allowed to subclass " + Property.class.getName() + ". Property accessor " + accessor + " is returning a Property subclass." );
+        return builder.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/Numbers.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/Numbers.java b/core/api/src/main/java/org/qi4j/api/property/Numbers.java
new file mode 100644
index 0000000..00c0e5f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/Numbers.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. 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.qi4j.api.property;
+
+import java.math.BigDecimal;
+
+/**
+ * Convenience class for mathematical operations on numerical properties.
+ * <pre>import static org.qi4j.api.property.Numbers.*;
+ * ...
+ * add( object.numberProperty(), 5 );</pre>
+ */
+public final class Numbers
+{
+    // Integer operations
+
+    public static Property<Integer> add( Property<Integer> property, int amount )
+    {
+        property.set( property.get() + amount );
+        return property;
+    }
+
+    public static Property<Integer> mult( Property<Integer> property, int amount )
+    {
+        property.set( property.get() * amount );
+        return property;
+    }
+
+    public static Property<Integer> sub( Property<Integer> property, int amount )
+    {
+        property.set( property.get() - amount );
+        return property;
+    }
+
+    public static Property<Integer> div( Property<Integer> property, int amount )
+    {
+        property.set( property.get() / amount );
+        return property;
+    }
+
+    // Long operations
+
+    public static Property<Long> add( Property<Long> property, long amount )
+    {
+        property.set( property.get() + amount );
+        return property;
+    }
+
+    public static Property<Long> mult( Property<Long> property, long amount )
+    {
+        property.set( property.get() * amount );
+        return property;
+    }
+
+    public static Property<Long> sub( Property<Long> property, long amount )
+    {
+        property.set( property.get() - amount );
+        return property;
+    }
+
+    public static Property<Long> div( Property<Long> property, long amount )
+    {
+        property.set( property.get() / amount );
+        return property;
+    }
+
+    // Double operations
+
+    public static Property<Double> add( Property<Double> property, double amount )
+    {
+        property.set( property.get() + amount );
+        return property;
+    }
+
+    public static Property<Double> mult( Property<Double> property, double amount )
+    {
+        property.set( property.get() * amount );
+        return property;
+    }
+
+    public static Property<Double> sub( Property<Double> property, double amount )
+    {
+        property.set( property.get() - amount );
+        return property;
+    }
+
+    public static Property<Double> div( Property<Double> property, double amount )
+    {
+        property.set( property.get() / amount );
+        return property;
+    }
+
+    // Float operations
+
+    public static Property<Float> add( Property<Float> property, float amount )
+    {
+        property.set( property.get() + amount );
+        return property;
+    }
+
+    public static Property<Float> mult( Property<Float> property, float amount )
+    {
+        property.set( property.get() * amount );
+        return property;
+    }
+
+    public static Property<Float> sub( Property<Float> property, float amount )
+    {
+        property.set( property.get() - amount );
+        return property;
+    }
+
+    public static Property<Float> div( Property<Float> property, float amount )
+    {
+        property.set( property.get() / amount );
+        return property;
+    }
+
+    // BigDecimal operations
+
+    public static Property<BigDecimal> add( Property<BigDecimal> property, BigDecimal amount )
+    {
+        property.set( property.get().add( amount ) );
+        return property;
+    }
+
+    public static Property<BigDecimal> mult( Property<BigDecimal> property, BigDecimal amount )
+    {
+        property.set( property.get().multiply( amount ) );
+        return property;
+    }
+
+    public static Property<BigDecimal> sub( Property<BigDecimal> property, BigDecimal amount )
+    {
+        property.set( property.get().subtract( amount ) );
+        return property;
+    }
+
+    public static Property<BigDecimal> div( Property<BigDecimal> property, BigDecimal amount )
+    {
+        property.set( property.get().divide( amount ) );
+        return property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/Property.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/Property.java b/core/api/src/main/java/org/qi4j/api/property/Property.java
new file mode 100644
index 0000000..9c9cfa8
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/Property.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007-2011, Rickard Öberg. 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.qi4j.api.property;
+
+/**
+ * Properties are declared in Composite interfaces by using this interface.
+ * <p>
+ * It creates a first-class object for the property from which you can get and set the value, and access any
+ * metadata about it.
+ * </p>
+ * <p>The type of the Property can be one of the following:</p>
+ * <ul>
+ * <li> A boxed primitive (Long,Integer,Boolean, etc.)</li>
+ * <li> String</li>
+ * <li> BigInteger</li>
+ * <li> BigDecimal</li>
+ * <li> Date</li>
+ * <li> DateTime (Joda Time)</li>
+ * <li> LocalDateTime (Joda Time)</li>
+ * <li> A serializable</li>
+ * <li> A ValueComposite</li>
+ * <li> A List, Set or Collection of any of the above</li>
+ * </ul>
+ *
+ * @param <T> Parameterized type of the Property
+ */
+public interface Property<T>
+{
+    /**
+     * Get the value of the property.
+     *
+     * @return the value
+     */
+    T get();
+
+    /**
+     * Set the value of the property
+     *
+     * @param newValue the new value
+     *
+     * @throws IllegalArgumentException if the value has an invalid value
+     * @throws IllegalStateException    if the property is immutable
+     */
+    void set( T newValue )
+        throws IllegalArgumentException, IllegalStateException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/PropertyDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/PropertyDescriptor.java b/core/api/src/main/java/org/qi4j/api/property/PropertyDescriptor.java
new file mode 100644
index 0000000..aa986b1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/PropertyDescriptor.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.property;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Type;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.structure.MetaInfoHolder;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.ValueType;
+
+/**
+ * Property Descriptor.
+ */
+public interface PropertyDescriptor extends MetaInfoHolder
+{
+    boolean isImmutable();
+
+    /**
+     * Get the qualified name of the property which is equal to:
+     * <pre><code>
+     * &lt;interface name&gt;:&lt;method name&gt;
+     * </code></pre>
+     *
+     * @return the qualified name of the property
+     */
+    QualifiedName qualifiedName();
+
+    /**
+     * Get the type of the property. If the property is declared
+     * as Property&lt;X&gt; then X is returned.
+     *
+     * @return the property type
+     */
+    Type type();
+
+    AccessibleObject accessor();
+
+    Object initialValue( Module module );
+
+    ValueType valueType();
+
+    boolean queryable();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/PropertyMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/PropertyMixin.java b/core/api/src/main/java/org/qi4j/api/property/PropertyMixin.java
new file mode 100644
index 0000000..26f8bd5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/PropertyMixin.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.property;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.injection.scope.State;
+
+/**
+ * Generic mixin for properties.
+ */
+// START SNIPPET: actual
+@AppliesTo( { PropertyMixin.PropertyFilter.class } )
+public final class PropertyMixin
+    implements InvocationHandler
+{
+    @State
+    private StateHolder state;
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        return state.propertyFor( method );
+    }
+
+    /**
+     * Filter Property methods to apply generic Property Mixin.
+     */
+    public static class PropertyFilter
+        implements AppliesToFilter
+    {
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
+        {
+            return Property.class.isAssignableFrom( method.getReturnType() );
+        }
+    }
+}
+// END SNIPPET: actual

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/PropertyWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/PropertyWrapper.java b/core/api/src/main/java/org/qi4j/api/property/PropertyWrapper.java
new file mode 100644
index 0000000..dc2259d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/PropertyWrapper.java
@@ -0,0 +1,71 @@
+/*
+ * 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.qi4j.api.property;
+
+/**
+ * If you want to catch getting and setting properties, then create a GenericConcern
+ * that wraps the Zest-supplied Property instance with PropertyWrappers. Override
+ * get() and/or set() to perform your custom code.
+ */
+public class PropertyWrapper
+    implements Property<Object>
+{
+    protected Property<Object> next;
+
+    public PropertyWrapper( Property<Object> next )
+    {
+        this.next = next;
+    }
+
+    public Property<Object> next()
+    {
+        return next;
+    }
+
+    @Override
+    public Object get()
+    {
+        return next.get();
+    }
+
+    @Override
+    public void set( Object newValue )
+        throws IllegalArgumentException, IllegalStateException
+    {
+        next.set( newValue );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return next.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        return next.equals( obj );
+    }
+
+    @Override
+    public String toString()
+    {
+        return next.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/StateHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/StateHolder.java b/core/api/src/main/java/org/qi4j/api/property/StateHolder.java
new file mode 100644
index 0000000..dfd0b29
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/StateHolder.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.property;
+
+import java.lang.reflect.AccessibleObject;
+
+/**
+ * This represents the state of a composite (properties).
+ */
+public interface StateHolder
+{
+    /**
+     * Get a property for a specific accessor
+     *
+     * @param accessor of the property
+     *
+     * @return the property
+     *
+     * @throws IllegalArgumentException if no property for given accessor exists
+     */
+    <T> Property<T> propertyFor( AccessibleObject accessor )
+        throws IllegalArgumentException;
+
+    Iterable<? extends Property<?>> properties();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/package.html b/core/api/src/main/java/org/qi4j/api/property/package.html
new file mode 100644
index 0000000..8fc2a93
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Property API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/MissingIndexingSystemException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/MissingIndexingSystemException.java b/core/api/src/main/java/org/qi4j/api/query/MissingIndexingSystemException.java
new file mode 100644
index 0000000..6bfd216
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/MissingIndexingSystemException.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.query;
+
+/**
+ * This Exception is thrown in <code>QueryBuilderFactory.newQueryBuilder()</code> method if
+ * no indexing subsystem has been declared in the assembly.
+ */
+public final class MissingIndexingSystemException
+    extends QueryException
+{
+    private static final long serialVersionUID = 5147421865890379209L;
+
+    public MissingIndexingSystemException()
+    {
+        super( "No EntityFinder has been declared in the assembly of the application." );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/NotQueryableException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/NotQueryableException.java b/core/api/src/main/java/org/qi4j/api/query/NotQueryableException.java
new file mode 100644
index 0000000..74737eb
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/NotQueryableException.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2009 Alin Dreghiciu.
+ *
+ * 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.qi4j.api.query;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import org.qi4j.api.entity.Queryable;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.util.Classes;
+
+/**
+ * Thrown in case that a non queryable type or accessor (marked with @Queriable(false)) is used during query building,
+ * or when non-Property, non-Associations are trying to be queried (possibly can not happen).
+ */
+public class NotQueryableException
+    extends QueryException
+{
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message
+     */
+    public NotQueryableException( final String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Verify that the provided accessor method has not been marked with a Queryable(false).
+     *
+     * @param accessor accessor method
+     *
+     * @throws NotQueryableException - If accessor method has been marked as not queryable
+     */
+    public static void throwIfNotQueryable( final AccessibleObject accessor )
+    {
+        Queryable queryable = accessor.getAnnotation( Queryable.class );
+        if( queryable != null && !queryable.value() )
+        {
+            throw new NotQueryableException(
+                String.format(
+                    "%1$s \"%2$s\" (%3$s) is not queryable as has been marked with @Queryable(false)",
+                    Classes.RAW_CLASS.map( GenericPropertyInfo.propertyTypeOf( accessor ) ).getSimpleName(),
+                    ( (Member) accessor ).getName(),
+                    ( (Member) accessor ).getDeclaringClass().getName()
+                )
+            );
+        }
+    }
+
+    /**
+     * Verify that the provided type has not been marked with a Queryable(false).
+     *
+     * @param type a type
+     *
+     * @throws NotQueryableException - If type has been marked as not queryable
+     */
+    public static void throwIfNotQueryable( final Class<?> type )
+    {
+        Queryable queryable = type.getAnnotation( Queryable.class );
+        if( queryable != null && !queryable.value() )
+        {
+            throw new NotQueryableException(
+                String.format(
+                    "Type \"%1$s\" is not queryable as has been marked with @Queryable(false)",
+                    type.getName()
+                )
+            );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/Query.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/Query.java b/core/api/src/main/java/org/qi4j/api/query/Query.java
new file mode 100644
index 0000000..504b2e2
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/Query.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2007 Rickard Öberg.
+ * Copyright 2007 Niclas Hedhman.
+ * Copyright 2008 Alin Dreghiciu.
+ *
+ * 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.qi4j.api.query;
+
+import java.io.Serializable;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.grammar.OrderBy;
+
+/**
+ * This represents a Query in an indexing system. It is created from a
+ * {@link QueryBuilder}, which decides the "where" clause in the query.
+ * <p>
+ * Additional limitations, such as paging, ordering, and variables, can be set on
+ * a Query before it is executed by calling one of find(), iterator(),
+ * or count().
+ * </p>
+ * <p>
+ * DDD tip: typically Queries are created in the Domain Model and passed to the UI,
+ * which sets the order and paging before executing it.
+ * </p>
+ */
+public interface Query<T>
+    extends Iterable<T>, Serializable
+{
+    /**
+     * Set the ordering rules. If many segments are used for ordering
+     * then they will be applied in order.
+     *
+     * @param segments the segments to order by
+     *
+     * @return the Query
+     */
+    Query<T> orderBy( OrderBy... segments );
+
+    /**
+     * Append an ordering rule to the existing segments.
+     *
+     * @param property the property to order by
+     * @param order the order to apply
+     *
+     * @return the Query
+     */
+    Query<T> orderBy( final Property<?> property, final OrderBy.Order order );
+
+    /**
+     * Append an ascending ordering rule to the existing segments.
+     *
+     * @param property the property to order by
+     *
+     * @return the Query
+     */
+    Query<T> orderBy( Property<?> property );
+
+    /**
+     * Set the index of the first result. Default is 0 (zero).
+     *
+     * @param firstResult which index to use as the first one
+     *
+     * @return the Query
+     */
+    Query<T> firstResult( int firstResult );
+
+    /**
+     * Set how many results should be returned. Default is that
+     * there is no limit set.
+     *
+     * @param maxResults that shouldbe returned
+     *
+     * @return the query
+     */
+    Query<T> maxResults( int maxResults );
+
+    /**
+     * Get the first Entity that matches the criteria. This
+     * executes the Query.
+     *
+     * @return the first found Entity or null if none were found
+     *
+     * @throws QueryExecutionException if the query fails
+     */
+    T find()
+        throws QueryExecutionException;
+
+    /**
+     * Set the value of a named variable.
+     *
+     * @param name  of the variable
+     * @param value of the variable
+     *
+     * @return the query
+     */
+    Query<T> setVariable( String name, Object value );
+
+    /**
+     * Get the value of a named variable.
+     *
+     * @param name of the variable
+     *
+     * @return value of the variable
+     */
+    <V> V getVariable( String name );
+
+    /**
+     * Get the result type of this Query
+     *
+     * @return the result type
+     */
+    Class<T> resultType();
+
+    /**
+     * Count how many results would be returned by this Query.
+     * This executes the Query.
+     *
+     * @return result count
+     *
+     * @throws QueryExecutionException if the query fails
+     */
+    long count()
+        throws QueryExecutionException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryBuilder.java b/core/api/src/main/java/org/qi4j/api/query/QueryBuilder.java
new file mode 100644
index 0000000..c07552c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryBuilder.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007 Rickard Öberg.
+ * Copyright 2008 Alin Dreghiciu.
+ *
+ * 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.qi4j.api.query;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+
+/**
+ * QueryBuilders are used to create {@link Query} instances.
+ * Iteratively add where() clauses to the query, and then use
+ * {@link org.qi4j.api.unitofwork.UnitOfWork#newQuery(QueryBuilder)}  to instantiate the Query.
+ * QueryBuilders are immutable, so when adding new where-clauses you get new instances. This
+ *
+ * DDD tip: Query objects are not executed immediately, so they
+ * should be constructed in the domain model and handed over to
+ * the UI, which can then further constrain it before actual
+ * execution.
+ */
+public interface QueryBuilder<T>
+{
+    /**
+     * Add a where-clause to the Query. Use {@link QueryExpressions}
+     * to create the expression.
+     *
+     * @param specification the where clause
+     *
+     * @return a new builder with the added where-clause
+     */
+    QueryBuilder<T> where( Specification<Composite> specification );
+
+    /**
+     * Create a new query with the declared where-clauses that will be evaluated against the iterable entries.
+     *
+     * @param iterable collection of objects (composites?)
+     *
+     * @return a new Query instance
+     */
+    Query<T> newQuery( Iterable<T> iterable );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryBuilderFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryBuilderFactory.java b/core/api/src/main/java/org/qi4j/api/query/QueryBuilderFactory.java
new file mode 100644
index 0000000..8841030
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryBuilderFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.query;
+
+/**
+ * This is used to create QueryBuilders.
+ *
+ * @see QueryBuilder
+ */
+public interface QueryBuilderFactory
+{
+    /**
+     * Create a new QueryBuilder.
+     *
+     * @param resultType the type of the result that you want
+     *
+     * @return a QueryBuilder
+     *
+     * @throws MissingIndexingSystemException if there is no EntityFinder service available
+     */
+    <T> QueryBuilder<T> newQueryBuilder( Class<T> resultType )
+        throws MissingIndexingSystemException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryException.java b/core/api/src/main/java/org/qi4j/api/query/QueryException.java
new file mode 100644
index 0000000..6caca4c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.query;
+
+/**
+ * Base class for Query exceptions.
+ */
+public abstract class QueryException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = -3602596752342902060L;
+
+    public QueryException()
+    {
+    }
+
+    public QueryException( final String message )
+    {
+        super( message );
+    }
+
+    public QueryException( final String message, final Throwable cause )
+    {
+        super( message, cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryExecutionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryExecutionException.java b/core/api/src/main/java/org/qi4j/api/query/QueryExecutionException.java
new file mode 100644
index 0000000..f8cad23
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryExecutionException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.query;
+
+/**
+ * Throw this exception if a query could not be executed
+ */
+public final class QueryExecutionException
+    extends QueryException
+{
+    private static final long serialVersionUID = 5147421865890379209L;
+
+    public QueryExecutionException( String message )
+    {
+        super( message );
+    }
+
+    public QueryExecutionException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryExpressionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryExpressionException.java b/core/api/src/main/java/org/qi4j/api/query/QueryExpressionException.java
new file mode 100644
index 0000000..f0a7f8e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryExpressionException.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.query;
+
+/**
+ * Throw this exception if a QueryExpression is invalid.
+ */
+public class QueryExpressionException
+    extends QueryException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public QueryExpressionException( String message )
+    {
+        super( message );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/QueryExpressions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/QueryExpressions.java b/core/api/src/main/java/org/qi4j/api/query/QueryExpressions.java
new file mode 100644
index 0000000..45501ee
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/QueryExpressions.java
@@ -0,0 +1,944 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ * Copyright 2008 Alin Dreghiciu.
+ * Copyright 2012 Stanislav Muhametsin.
+ * Copyright 2012-2014 Paul Merlin.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collection;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.injection.scope.State;
+import org.qi4j.api.property.GenericPropertyInfo;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.grammar.AndSpecification;
+import org.qi4j.api.query.grammar.AssociationFunction;
+import org.qi4j.api.query.grammar.AssociationNotNullSpecification;
+import org.qi4j.api.query.grammar.AssociationNullSpecification;
+import org.qi4j.api.query.grammar.ContainsAllSpecification;
+import org.qi4j.api.query.grammar.ContainsSpecification;
+import org.qi4j.api.query.grammar.EqSpecification;
+import org.qi4j.api.query.grammar.GeSpecification;
+import org.qi4j.api.query.grammar.GtSpecification;
+import org.qi4j.api.query.grammar.LeSpecification;
+import org.qi4j.api.query.grammar.LtSpecification;
+import org.qi4j.api.query.grammar.ManyAssociationContainsSpecification;
+import org.qi4j.api.query.grammar.ManyAssociationFunction;
+import org.qi4j.api.query.grammar.MatchesSpecification;
+import org.qi4j.api.query.grammar.NamedAssociationContainsNameSpecification;
+import org.qi4j.api.query.grammar.NamedAssociationContainsSpecification;
+import org.qi4j.api.query.grammar.NamedAssociationFunction;
+import org.qi4j.api.query.grammar.NeSpecification;
+import org.qi4j.api.query.grammar.NotSpecification;
+import org.qi4j.api.query.grammar.OrSpecification;
+import org.qi4j.api.query.grammar.OrderBy;
+import org.qi4j.api.query.grammar.PropertyFunction;
+import org.qi4j.api.query.grammar.PropertyNotNullSpecification;
+import org.qi4j.api.query.grammar.PropertyNullSpecification;
+import org.qi4j.api.query.grammar.PropertyReference;
+import org.qi4j.api.query.grammar.Variable;
+import org.qi4j.api.util.NullArgumentException;
+import org.qi4j.functional.Specification;
+
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.prepend;
+
+/**
+ * Static factory methods for query expressions and operators.
+ */
+public final class QueryExpressions
+{
+    // This is used for eq(Association,Composite)
+    private static final Method IDENTITY_METHOD;
+
+    static
+    {
+        try
+        {
+            IDENTITY_METHOD = Identity.class.getMethod( "identity" );
+        }
+        catch( NoSuchMethodException e )
+        {
+            throw new InternalError( "Zest Core API codebase is corrupted. Contact Zest team: QueryExpressions" );
+        }
+    }
+
+    // Templates and variables -----------------------------------------------|
+
+    /**
+     * Create a Query Template using the given type.
+     *
+     * @param <T> the type of the template
+     * @param clazz a class declaring the type of the template
+     *
+     * @return a new Query Template
+     */
+    public static <T> T templateFor( Class<T> clazz )
+    {
+        NullArgumentException.validateNotNull( "Template class", clazz );
+
+        if( clazz.isInterface() )
+        {
+            return clazz.cast( Proxy.newProxyInstance( clazz.getClassLoader(),
+                                                       array( clazz ),
+                                                       new TemplateHandler<T>( null, null, null, null ) ) );
+        }
+        else
+        {
+            try
+            {
+                T mixin = clazz.newInstance();
+                for( Field field : clazz.getFields() )
+                {
+                    if( field.getAnnotation( State.class ) != null )
+                    {
+                        if( field.getType().equals( Property.class ) )
+                        {
+                            field.set( mixin,
+                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
+                                                               array( field.getType() ),
+                                                               new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ) );
+                        }
+                        else if( field.getType().equals( Association.class ) )
+                        {
+                            field.set( mixin,
+                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
+                                                               array( field.getType() ),
+                                                               new AssociationReferenceHandler<>( new AssociationFunction<T>( null, null, null, field ) ) ) );
+                        }
+                        else if( field.getType().equals( ManyAssociation.class ) )
+                        {
+                            field.set( mixin,
+                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
+                                                               array( field.getType() ),
+                                                               new ManyAssociationReferenceHandler<>( new ManyAssociationFunction<T>( null, null, null, field ) ) ) );
+                        }
+                        else if( field.getType().equals( NamedAssociation.class ) )
+                        {
+                            field.set( mixin,
+                                       Proxy.newProxyInstance( field.getType().getClassLoader(),
+                                                               array( field.getType() ),
+                                                               new NamedAssociationReferenceHandler<>( new NamedAssociationFunction<T>( null, null, null, field ) ) ) );
+                        }
+                    }
+                }
+                return mixin;
+            }
+            catch( IllegalAccessException | IllegalArgumentException | InstantiationException | SecurityException e )
+            {
+                throw new IllegalArgumentException( "Cannot use class as template", e );
+            }
+        }
+    }
+
+    /**
+     * Create a Query Template using the given mixin class and association.
+     *
+     * @param <T> the type of the template
+     * @param mixinType  a class declaring the type of the template
+     * @param association an association
+     *
+     * @return a new Query Template
+     */
+    public static <T> T templateFor( final Class<T> mixinType, Association<?> association )
+    {
+        NullArgumentException.validateNotNull( "Mixin class", mixinType );
+        NullArgumentException.validateNotNull( "Association", association );
+        return mixinType.cast( Proxy.newProxyInstance( mixinType.getClassLoader(),
+                                                       array( mixinType ),
+                                                       new TemplateHandler<T>( null,
+                                                                               association( association ),
+                                                                               null,
+                                                                               null ) ) );
+    }
+
+    public static <T> T oneOf( final ManyAssociation<T> association )
+    {
+        NullArgumentException.validateNotNull( "Association", association );
+        return association.get( 0 );
+    }
+
+    public static <T> T oneOf( final NamedAssociation<T> association )
+    {
+        NullArgumentException.validateNotNull( "Association", association );
+        return association.get( first( association ) );
+    }
+
+    /**
+     * Create a new Query Variable.
+     *
+     * @param name a name for the Variable
+     *
+     * @return a new Query Variable.
+     */
+    public static Variable variable( String name )
+    {
+        NullArgumentException.validateNotNull( "Variable name", name );
+        return new Variable( name );
+    }
+
+    /**
+     * Create a new Query Template PropertyFunction.
+     *
+     * @param <T> type of the Property
+     * @param property a Property
+     *
+     * @return a new Query Template PropertyFunction
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> PropertyFunction<T> property( Property<T> property )
+    {
+        return ( (PropertyReferenceHandler<T>) Proxy.getInvocationHandler( property ) ).property();
+    }
+
+    /**
+     * Create a new Query Property instance.
+     *
+     * @param <T> type of the Property
+     * @param mixinClass mixin of the Property
+     * @param fieldName name of the Property field
+     *
+     * @return a new Query Property instance for the given mixin and property name.
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> Property<T> property( Class<?> mixinClass, String fieldName )
+    {
+        try
+        {
+            Field field = mixinClass.getField( fieldName );
+            if( !Property.class.isAssignableFrom( field.getType() ) )
+            {
+                throw new IllegalArgumentException( "Field must be of type Property<?>" );
+            }
+            return (Property<T>) Proxy.newProxyInstance(
+                mixinClass.getClassLoader(),
+                array( field.getType() ),
+                new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) );
+        }
+        catch( NoSuchFieldException e )
+        {
+            throw new IllegalArgumentException( "No such field '" + fieldName + "' in mixin " + mixinClass.getName() );
+        }
+    }
+
+    /**
+     * Create a new Query Template AssociationFunction.
+     *
+     * @param <T> type of the Association
+     * @param association an Association
+     *
+     * @return a new Query Template AssociationFunction
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> AssociationFunction<T> association( Association<T> association )
+    {
+        return ( (AssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).association();
+    }
+
+    /**
+     * Create a new Query Template ManyAssociationFunction.
+     *
+     * @param <T> type of the ManyAssociation
+     * @param association a ManyAssociation
+     *
+     * @return a new Query Template ManyAssociationFunction
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> ManyAssociationFunction<T> manyAssociation( ManyAssociation<T> association )
+    {
+        return ( (ManyAssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).manyAssociation();
+    }
+
+    /**
+     * Create a new Query Template NamedAssociationFunction.
+     *
+     * @param <T> type of the NamedAssociation
+     * @param association a NamedAssociation
+     *
+     * @return a new Query Template NamedAssociationFunction
+     */
+    @SuppressWarnings( "unchecked" )
+    public static <T> NamedAssociationFunction<T> namedAssociation( NamedAssociation<T> association )
+    {
+        return ( (NamedAssociationReferenceHandler<T>) Proxy.getInvocationHandler( association ) ).namedAssociation();
+    }
+
+    // And/Or/Not ------------------------------------------------------------|
+    /**
+     * Create a new AND specification.
+     *
+     * @param left first operand
+     * @param right second operand
+     * @param optionalRight optional operands
+     *
+     * @return a new AND specification
+     */
+    @SafeVarargs
+    public static AndSpecification and( Specification<Composite> left,
+                                        Specification<Composite> right,
+                                        Specification<Composite>... optionalRight
+    )
+    {
+        return new AndSpecification( prepend( left, prepend( right, Arrays.asList( optionalRight ) ) ) );
+    }
+
+    /**
+     * Create a new OR specification.
+     *
+     * @param specs operands
+     *
+     * @return a new OR specification
+     */
+    @SafeVarargs
+    public static OrSpecification or( Specification<Composite>... specs )
+    {
+        return new OrSpecification( Arrays.asList( specs ) );
+    }
+
+    /**
+     * Create a new NOT specification.
+     *
+     * @param operand specification to be negated
+     *
+     * @return a new NOT specification
+     */
+    public static NotSpecification not( Specification<Composite> operand )
+    {
+        return new NotSpecification( operand );
+    }
+
+    // Comparisons -----------------------------------------------------------|
+
+    /**
+     * Create a new EQUALS specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new EQUALS specification for a Property.
+     */
+    public static <T> EqSpecification<T> eq( Property<T> property, T value )
+    {
+        return new EqSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new EQUALS specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new EQUALS specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> EqSpecification<T> eq( Property<T> property, Variable variable )
+    {
+        return new EqSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new EQUALS specification for an Association.
+     *
+     * @param association an Association
+     * @param value its value
+     *
+     * @return a new EQUALS specification for an Association.
+     */
+    public static <T> EqSpecification<String> eq( Association<T> association, T value )
+    {
+        return new EqSpecification<>( new PropertyFunction<String>( null,
+                                                                    association( association ),
+                                                                    null,
+                                                                    null,
+                                                                    IDENTITY_METHOD ),
+                                      value.toString() );
+    }
+
+    /**
+     * Create a new GREATER OR EQUALS specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new GREATER OR EQUALS specification for a Property.
+     */
+    public static <T> GeSpecification<T> ge( Property<T> property, T value )
+    {
+        return new GeSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new GREATER OR EQUALS specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new GREATER OR EQUALS specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> GeSpecification<T> ge( Property<T> property, Variable variable )
+    {
+        return new GeSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new GREATER THAN specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new GREATER THAN specification for a Property.
+     */
+    public static <T> GtSpecification<T> gt( Property<T> property, T value )
+    {
+        return new GtSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new GREATER THAN specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new GREATER THAN specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> GtSpecification<T> gt( Property<T> property, Variable variable )
+    {
+        return new GtSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new LESS OR EQUALS specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new LESS OR EQUALS specification for a Property.
+     */
+    public static <T> LeSpecification<T> le( Property<T> property, T value )
+    {
+        return new LeSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new LESS OR EQUALS specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new LESS OR EQUALS specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> LeSpecification<T> le( Property<T> property, Variable variable )
+    {
+        return new LeSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new LESSER THAN specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new LESSER THAN specification for a Property.
+     */
+    public static <T> LtSpecification<T> lt( Property<T> property, T value )
+    {
+        return new LtSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new LESSER THAN specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new LESSER THAN specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> LtSpecification<T> lt( Property<T> property, Variable variable )
+    {
+        return new LtSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new NOT EQUALS specification for a Property.
+     *
+     * @param property a Property
+     * @param value its value
+     *
+     * @return a new NOT EQUALS specification for a Property.
+     */
+    public static <T> NeSpecification<T> ne( Property<T> property, T value )
+    {
+        return new NeSpecification<>( property( property ), value );
+    }
+
+    /**
+     * Create a new NOT EQUALS specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new NOT EQUALS specification for a Property using a named Variable.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> NeSpecification<T> ne( Property<T> property, Variable variable )
+    {
+        return new NeSpecification( property( property ), variable );
+    }
+
+    /**
+     * Create a new REGULAR EXPRESSION specification for a Property.
+     *
+     * @param property a Property
+     * @param regexp its value
+     *
+     * @return a new REGULAR EXPRESSION specification for a Property.
+     */
+    public static MatchesSpecification matches( Property<String> property, String regexp )
+    {
+        return new MatchesSpecification( property( property ), regexp );
+    }
+
+    /**
+     * Create a new REGULAR EXPRESSION specification for a Property using a named Variable.
+     *
+     * @param property a Property
+     * @param variable a Query Variable
+     *
+     * @return a new REGULAR EXPRESSION specification for a Property using a named Variable.
+     */
+    public static MatchesSpecification matches( Property<String> property, Variable variable )
+    {
+        return new MatchesSpecification( property( property ), variable );
+    }
+
+    // Null checks -----------------------------------------------------------|
+
+    /**
+     * Create a new NOT NULL specification for a Property.
+     *
+     * @param property a Property
+     *
+     * @return a new NOT NULL specification for a Property.
+     */
+    public static <T> PropertyNotNullSpecification<T> isNotNull( Property<T> property )
+    {
+        return new PropertyNotNullSpecification<>( property( property ) );
+    }
+
+    /**
+     * Create a new NULL specification for a Property.
+     *
+     * @param property a Property
+     *
+     * @return a new NULL specification for a Property.
+     */
+    public static <T> PropertyNullSpecification<T> isNull( Property<T> property )
+    {
+        return new PropertyNullSpecification<>( property( property ) );
+    }
+
+    /**
+     * Create a new NOT NULL specification for an Association.
+     *
+     * @param association an Association
+     *
+     * @return a new NOT NULL specification for an Association.
+     */
+    public static <T> AssociationNotNullSpecification<T> isNotNull( Association<T> association )
+    {
+        return new AssociationNotNullSpecification<>( association( association ) );
+    }
+
+    /**
+     * Create a new NULL specification for an Association.
+     *
+     * @param association an Association
+     *
+     * @return a new NULL specification for an Association.
+     */
+    public static <T> AssociationNullSpecification<T> isNull( Association<T> association )
+    {
+        return new AssociationNullSpecification<>( association( association ) );
+    }
+
+    // Collections -----------------------------------------------------------|
+
+    /**
+     * Create a new CONTAINS ALL specification for a Collection Property.
+     *
+     * @param collectionProperty a Collection Property
+     * @param values its values
+     *
+     * @return a new CONTAINS ALL specification for a Collection Property.
+     */
+    public static <T> ContainsAllSpecification<T> containsAll( Property<? extends Collection<T>> collectionProperty,
+                                                               Iterable<T> values )
+    {
+        NullArgumentException.validateNotNull( "Values", values );
+        return new ContainsAllSpecification<>( property( collectionProperty ), values );
+    }
+
+    /**
+     * Create a new CONTAINS ALL specification for a Collection Property using named Variables.
+     *
+     * @param collectionProperty a Collection Property
+     * @param variables named Variables
+     *
+     * @return a new CONTAINS ALL specification for a Collection Property using named Variables.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> ContainsAllSpecification<T> containsAllVariables(
+        Property<? extends Collection<T>> collectionProperty,
+        Iterable<Variable> variables )
+    {
+        NullArgumentException.validateNotNull( "Variables", variables );
+        return new ContainsAllSpecification( property( collectionProperty ), variables );
+    }
+
+    /**
+     * Create a new CONTAINS specification for a Collection Property.
+     *
+     * @param collectionProperty a Collection Property
+     * @param value the value
+     *
+     * @return a new CONTAINS specification for a Collection Property.
+     */
+    public static <T> ContainsSpecification<T> contains( Property<? extends Collection<T>> collectionProperty,
+                                                         T value )
+    {
+        NullArgumentException.validateNotNull( "Value", value );
+        return new ContainsSpecification<>( property( collectionProperty ), value );
+    }
+
+    /**
+     * Create a new CONTAINS specification for a Collection Property using named Variables.
+     *
+     * @param collectionProperty a Collection Property
+     * @param variable named Variable
+     *
+     * @return a new CONTAINS specification for a Collection Property using named Variables.
+     */
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public static <T> ContainsSpecification<T> contains( Property<? extends Collection<T>> collectionProperty,
+                                                         Variable variable )
+    {
+        NullArgumentException.validateNotNull( "Variable", variable );
+        return new ContainsSpecification( property( collectionProperty ), variable );
+    }
+
+    /**
+     * Create a new CONTAINS specification for a ManyAssociation.
+     *
+     * @param manyAssoc  a ManyAssociation
+     * @param value the value
+     *
+     * @return a new CONTAINS specification for a ManyAssociation.
+     */
+    public static <T> ManyAssociationContainsSpecification<T> contains( ManyAssociation<T> manyAssoc, T value )
+    {
+        return new ManyAssociationContainsSpecification<>( manyAssociation( manyAssoc ), value );
+    }
+
+    /**
+     * Create a new CONTAINS specification for a NamedAssociation.
+     *
+     * @param namedAssoc  a NamedAssociation
+     * @param value the value
+     *
+     * @return a new CONTAINS specification for a NamedAssociation.
+     */
+    public static <T> NamedAssociationContainsSpecification<T> contains( NamedAssociation<T> namedAssoc, T value )
+    {
+        return new NamedAssociationContainsSpecification<>( namedAssociation( namedAssoc ), value );
+    }
+
+    /**
+     * Create a new CONTAINS NAME specification for a NamedAssociation.
+     *
+     * @param namedAssoc  a NamedAssociation
+     * @param name the name
+     *
+     * @return a new CONTAINS NAME specification for a NamedAssociation.
+     */
+    public static <T> NamedAssociationContainsNameSpecification<T> containsName( NamedAssociation<T> namedAssoc,
+                                                                                 String name )
+    {
+        return new NamedAssociationContainsNameSpecification<>( namedAssociation( namedAssoc ), name );
+    }
+
+    // Ordering --------------------------------------------------------------|
+    /**
+     * Create a new Query ascending order segment for a Property.
+     *
+     * @param <T> type of the Property
+     * @param property a Property
+     *
+     * @return a new Query ascending order segment for a Property.
+     */
+    public static <T> OrderBy orderBy( final Property<T> property )
+    {
+        return orderBy( property, OrderBy.Order.ASCENDING );
+    }
+
+    /**
+     * Create a new Query ordering segment for a Property.
+     *
+     * @param <T> type of the Property
+     * @param property a Property
+     * @param order ascending or descending
+     *
+     * @return a new Query ordering segment for a Property.
+     */
+    public static <T> OrderBy orderBy( final Property<T> property, final OrderBy.Order order )
+    {
+        return new OrderBy( property( property ), order );
+    }
+
+    // Query Templates InvocationHandlers ------------------------------------|
+
+    private static class TemplateHandler<T>
+        implements InvocationHandler
+    {
+        private final PropertyFunction<?> compositeProperty;
+        private final AssociationFunction<?> compositeAssociation;
+        private final ManyAssociationFunction<?> compositeManyAssociation;
+        private final NamedAssociationFunction<?> compositeNamedAssociation;
+
+        private TemplateHandler( PropertyFunction<?> compositeProperty,
+                                 AssociationFunction<?> compositeAssociation,
+                                 ManyAssociationFunction<?> compositeManyAssociation,
+                                 NamedAssociationFunction<?> compositeNamedAssociation
+        )
+        {
+            this.compositeProperty = compositeProperty;
+            this.compositeAssociation = compositeAssociation;
+            this.compositeManyAssociation = compositeManyAssociation;
+            this.compositeNamedAssociation = compositeNamedAssociation;
+        }
+
+        @Override
+        public Object invoke( Object o, Method method, Object[] objects )
+            throws Throwable
+        {
+            if( Property.class.isAssignableFrom( method.getReturnType() ) )
+            {
+                return Proxy.newProxyInstance(
+                    method.getReturnType().getClassLoader(),
+                    array( method.getReturnType() ),
+                    new PropertyReferenceHandler<>( new PropertyFunction<T>( compositeProperty,
+                                                                             compositeAssociation,
+                                                                             compositeManyAssociation,
+                                                                             compositeNamedAssociation,
+                                                                             method ) ) );
+            }
+            else if( Association.class.isAssignableFrom( method.getReturnType() ) )
+            {
+                return Proxy.newProxyInstance(
+                    method.getReturnType().getClassLoader(),
+                    array( method.getReturnType() ),
+                    new AssociationReferenceHandler<>( new AssociationFunction<T>( compositeAssociation,
+                                                                                   compositeManyAssociation,
+                                                                                   compositeNamedAssociation,
+                                                                                   method ) ) );
+            }
+            else if( ManyAssociation.class.isAssignableFrom( method.getReturnType() ) )
+            {
+                return Proxy.newProxyInstance(
+                    method.getReturnType().getClassLoader(),
+                    array( method.getReturnType() ),
+                    new ManyAssociationReferenceHandler<>( new ManyAssociationFunction<T>( compositeAssociation,
+                                                                                           compositeManyAssociation,
+                                                                                           compositeNamedAssociation,
+                                                                                           method ) ) );
+            }
+            else if( NamedAssociation.class.isAssignableFrom( method.getReturnType() ) )
+            {
+                return Proxy.newProxyInstance(
+                    method.getReturnType().getClassLoader(),
+                    array( method.getReturnType() ),
+                    new NamedAssociationReferenceHandler<>( new NamedAssociationFunction<T>( compositeAssociation,
+                                                                                             compositeManyAssociation,
+                                                                                             compositeNamedAssociation,
+                                                                                             method ) ) );
+            }
+
+            return null;
+        }
+    }
+
+    private static class PropertyReferenceHandler<T>
+        implements InvocationHandler
+    {
+        private final PropertyFunction<T> property;
+
+        private PropertyReferenceHandler( PropertyFunction<T> property )
+        {
+            this.property = property;
+        }
+
+        private PropertyFunction<T> property()
+        {
+            return property;
+        }
+
+        @Override
+        public Object invoke( Object o, final Method method, Object[] objects )
+            throws Throwable
+        {
+            if( method.equals( Property.class.getMethod( "get" ) ) )
+            {
+                Type propertyType = GenericPropertyInfo.propertyTypeOf( property.accessor() );
+                if( propertyType.getClass().equals( Class.class ) )
+                {
+                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
+                                                   array( (Class<?>) propertyType, PropertyReference.class ),
+                                                   new TemplateHandler<T>( property, null, null, null ) );
+                }
+            }
+
+            return null;
+        }
+    }
+
+    private static class AssociationReferenceHandler<T>
+        implements InvocationHandler
+    {
+        private final AssociationFunction<T> association;
+
+        private AssociationReferenceHandler( AssociationFunction<T> association )
+        {
+            this.association = association;
+        }
+
+        private AssociationFunction<T> association()
+        {
+            return association;
+        }
+
+        @Override
+        public Object invoke( Object o, final Method method, Object[] objects )
+            throws Throwable
+        {
+            if( method.equals( Association.class.getMethod( "get" ) ) )
+            {
+                Type associationType = GenericAssociationInfo.associationTypeOf( association.accessor() );
+                if( associationType.getClass().equals( Class.class ) )
+                {
+                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
+                                                   array( (Class) associationType, PropertyReference.class ),
+                                                   new TemplateHandler<T>( null, association, null, null ) );
+                }
+            }
+
+            return null;
+        }
+    }
+
+    private static class ManyAssociationReferenceHandler<T>
+        implements InvocationHandler
+    {
+        private final ManyAssociationFunction<T> manyAssociation;
+
+        private ManyAssociationReferenceHandler( ManyAssociationFunction<T> manyAssociation )
+        {
+            this.manyAssociation = manyAssociation;
+        }
+
+        public ManyAssociationFunction<T> manyAssociation()
+        {
+            return manyAssociation;
+        }
+
+        @Override
+        public Object invoke( Object o, final Method method, Object[] objects )
+            throws Throwable
+        {
+            if( method.equals( ManyAssociation.class.getMethod( "get", Integer.TYPE ) ) )
+            {
+                Type manyAssociationType = GenericAssociationInfo.associationTypeOf( manyAssociation.accessor() );
+                if( manyAssociationType.getClass().equals( Class.class ) )
+                {
+                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
+                                                   array( (Class) manyAssociationType, PropertyReference.class ),
+                                                   new TemplateHandler<T>( null, null, manyAssociation, null ) );
+                }
+            }
+
+            return null;
+        }
+    }
+
+    private static class NamedAssociationReferenceHandler<T>
+        implements InvocationHandler
+    {
+        private final NamedAssociationFunction<T> namedAssociation;
+
+        private NamedAssociationReferenceHandler( NamedAssociationFunction<T> namedAssociation )
+        {
+            this.namedAssociation = namedAssociation;
+        }
+
+        public NamedAssociationFunction<T> namedAssociation()
+        {
+            return namedAssociation;
+        }
+
+        @Override
+        public Object invoke( Object o, final Method method, Object[] objects )
+            throws Throwable
+        {
+            if( method.equals( NamedAssociation.class.getMethod( "get", String.class ) ) )
+            {
+                Type namedAssociationType = GenericAssociationInfo.associationTypeOf( namedAssociation.accessor() );
+                if( namedAssociationType.getClass().equals( Class.class ) )
+                {
+                    return Proxy.newProxyInstance( method.getDeclaringClass().getClassLoader(),
+                                                   array( (Class) namedAssociationType, PropertyReference.class ),
+                                                   new TemplateHandler<T>( null, null, null, namedAssociation ) );
+                }
+            }
+
+            return null;
+        }
+    }
+
+    @SafeVarargs
+    private static <T> T[] array( T... array )
+    {
+        return array;
+    }
+
+    private QueryExpressions()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/AndSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/AndSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/AndSpecification.java
new file mode 100644
index 0000000..138ad00
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/AndSpecification.java
@@ -0,0 +1,56 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.composite.Composite;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+
+/**
+ * AND Specification.
+ */
+public class AndSpecification
+    extends BinarySpecification
+{
+
+    public AndSpecification( Iterable<Specification<Composite>> operands )
+    {
+        super( operands );
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        return Specifications.and( operands ).satisfiedBy( item );
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder( "(" );
+        String and = "";
+        for( Specification<Composite> operand : operands )
+        {
+            sb.append( and ).append( operand );
+            and = " and ";
+        }
+        return sb.append( ")" ).toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationFunction.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationFunction.java b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationFunction.java
new file mode 100644
index 0000000..ee423a0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationFunction.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2007-2011 Rickard Öberg.
+ * Copyright 2007-2010 Niclas Hedhman.
+ *
+ * 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
+ * ied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.qi4j.api.query.grammar;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.api.query.QueryExpressionException;
+import org.qi4j.api.util.Classes;
+import org.qi4j.functional.Function;
+
+import static org.qi4j.api.util.Classes.typeOf;
+
+/**
+ * Function to get Entity Associations
+ */
+public class AssociationFunction<T>
+    implements Function<Composite, Association<T>>
+{
+    private final AssociationFunction<?> traversedAssociation;
+    private final ManyAssociationFunction<?> traversedManyAssociation;
+    private final NamedAssociationFunction<?> traversedNamedAssociation;
+    private final AccessibleObject accessor;
+
+    public AssociationFunction( AssociationFunction<?> traversedAssociation,
+                                ManyAssociationFunction<?> traversedManyAssociation,
+                                NamedAssociationFunction<?> traversedNamedAssociation,
+                                AccessibleObject accessor
+    )
+    {
+        this.traversedAssociation = traversedAssociation;
+        this.traversedManyAssociation = traversedManyAssociation;
+        this.traversedNamedAssociation = traversedNamedAssociation;
+        this.accessor = accessor;
+
+        Type returnType = typeOf( accessor );
+        if( !Association.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) )
+            && !ManyAssociation.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) )
+            && !NamedAssociation.class.isAssignableFrom( Classes.RAW_CLASS.map( returnType ) ) )
+        {
+            throw new QueryExpressionException( "Unsupported association type:" + returnType );
+        }
+        Type associationTypeAsType = GenericAssociationInfo.toAssociationType( returnType );
+        if( !( associationTypeAsType instanceof Class ) )
+        {
+            throw new QueryExpressionException( "Unsupported association type:" + associationTypeAsType );
+        }
+    }
+
+    public AssociationFunction<?> traversedAssociation()
+    {
+        return traversedAssociation;
+    }
+
+    public ManyAssociationFunction<?> traversedManyAssociation()
+    {
+        return traversedManyAssociation;
+    }
+
+    public NamedAssociationFunction<?> traversedNamedAssociation()
+    {
+        return traversedNamedAssociation;
+    }
+
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public Association<T> map( Composite entity )
+    {
+        try
+        {
+            Object target = entity;
+            if( traversedAssociation != null )
+            {
+                Association<?> association = traversedAssociation.map( entity );
+                if( association == null )
+                {
+                    return null;
+                }
+                target = association.get();
+            }
+            else if( traversedManyAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );
+            }
+            else if( traversedNamedAssociation != null )
+            {
+                throw new IllegalArgumentException( "Cannot evaluate a NamedAssociation" );
+            }
+
+            if( target == null )
+            {
+                return null;
+            }
+
+            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
+            return ( (AssociationStateHolder) handler.state() ).associationFor( accessor );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw e;
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalArgumentException( e );
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        if( traversedAssociation != null )
+        {
+            return traversedAssociation.toString() + "." + ( (Member) accessor ).getName();
+        }
+        else
+        {
+            return ( (Member) accessor ).getName();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNotNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNotNullSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNotNullSpecification.java
new file mode 100644
index 0000000..64d6def
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNotNullSpecification.java
@@ -0,0 +1,67 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.association.Association;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * Association not null Specification.
+ */
+public class AssociationNotNullSpecification<T>
+    extends ExpressionSpecification
+{
+    private AssociationFunction<T> association;
+
+    public AssociationNotNullSpecification( AssociationFunction<T> association )
+    {
+        this.association = association;
+    }
+
+    public AssociationFunction<T> association()
+    {
+        return association;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        try
+        {
+            Association<T> assoc = association.map( item );
+
+            if( assoc == null )
+            {
+                return false;
+            }
+
+            return assoc.get() != null;
+        }
+        catch( IllegalArgumentException e )
+        {
+            return false;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return association.toString() + "is not null";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNullSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNullSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNullSpecification.java
new file mode 100644
index 0000000..9f06b98
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/AssociationNullSpecification.java
@@ -0,0 +1,67 @@
+/*
+ * 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.qi4j.api.query.grammar;
+
+import org.qi4j.api.association.Association;
+import org.qi4j.api.composite.Composite;
+
+/**
+ * Association null Specification.
+ */
+public class AssociationNullSpecification<T>
+    extends ExpressionSpecification
+{
+    private AssociationFunction<T> association;
+
+    public AssociationNullSpecification( AssociationFunction<T> association )
+    {
+        this.association = association;
+    }
+
+    public AssociationFunction<T> association()
+    {
+        return association;
+    }
+
+    @Override
+    public boolean satisfiedBy( Composite item )
+    {
+        try
+        {
+            Association<T> assoc = association.map( item );
+
+            if( assoc == null )
+            {
+                return true;
+            }
+
+            return assoc.get() == null;
+        }
+        catch( IllegalArgumentException e )
+        {
+            return true;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return association.toString() + "is null";
+    }
+}


[08/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
deleted file mode 100644
index 074dccb..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Paul Merlin.
- *
- * 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.zest.runtime.structure;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Function;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.spi.module.ModelModule;
-
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * Instance of a Zest application layer. Contains a list of modules which are managed by this layer.
- */
-public class LayerInstance
-    implements Layer
-{
-
-    // Constructor parameters
-    private final LayerModel layerModel;
-    private final ApplicationInstance applicationInstance;
-    private final UsedLayersInstance usedLayersInstance;
-    // Eager instance objects
-    private final ActivationDelegate activation;
-    private final List<ModuleInstance> moduleInstances;
-
-    public LayerInstance( LayerModel model,
-                          ApplicationInstance applicationInstance,
-                          UsedLayersInstance usedLayersInstance
-    )
-    {
-        // Constructor parameters
-        this.layerModel = model;
-        this.applicationInstance = applicationInstance;
-        this.usedLayersInstance = usedLayersInstance;
-
-        // Eager instance objects
-        activation = new ActivationDelegate( this );
-        moduleInstances = new ArrayList<>();
-    }
-
-    @Override
-    public String toString()
-    {
-        return layerModel.toString();
-    }
-
-    // Implementation of Layer
-    @Override
-    public String name()
-    {
-        return layerModel.name();
-    }
-
-    // Implementation of MetaInfoHolder
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return layerModel.metaInfo( infoType );
-    }
-
-    // Implementation of Activation
-    @Override
-    public void activate()
-        throws ActivationException
-    {
-        activation.activate( layerModel.newActivatorsInstance(), moduleInstances );
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        activation.passivate();
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-
-    // Other methods
-    /* package */ void addModule( ModuleInstance module )
-    {
-        module.registerActivationEventListener( activation );
-        moduleInstances.add( module );
-    }
-
-    /* package */ LayerModel model()
-    {
-        return layerModel;
-    }
-
-    public ApplicationInstance applicationInstance()
-    {
-        return applicationInstance;
-    }
-
-    /* package */ UsedLayersInstance usedLayersInstance()
-    {
-        return usedLayersInstance;
-    }
-
-    /* package */ Iterable<ModelModule<ObjectDescriptor>> visibleObjects( final Visibility visibility )
-    {
-        return flattenIterables( map( new Function<ModuleInstance, Iterable<ModelModule<ObjectDescriptor>>>()
-        {
-
-            @Override
-            public Iterable<ModelModule<ObjectDescriptor>> map( ModuleInstance moduleInstance )
-            {
-                return moduleInstance.visibleObjects( visibility );
-            }
-        }, moduleInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<TransientDescriptor>> visibleTransients( final Visibility visibility )
-    {
-        return flattenIterables( map( new Function<ModuleInstance, Iterable<ModelModule<TransientDescriptor>>>()
-        {
-
-            @Override
-            public Iterable<ModelModule<TransientDescriptor>> map( ModuleInstance moduleInstance )
-            {
-                return moduleInstance.visibleTransients( visibility );
-            }
-        }, moduleInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<EntityDescriptor>> visibleEntities( final Visibility visibility )
-    {
-        return flattenIterables( map( new Function<ModuleInstance, Iterable<ModelModule<EntityDescriptor>>>()
-        {
-
-            @Override
-            public Iterable<ModelModule<EntityDescriptor>> map( ModuleInstance moduleInstance )
-            {
-                return moduleInstance.visibleEntities( visibility );
-            }
-        }, moduleInstances ) );
-    }
-
-    /* package */ Iterable<ModelModule<ValueDescriptor>> visibleValues( final Visibility visibility )
-    {
-        return flattenIterables( map( new Function<ModuleInstance, Iterable<ModelModule<ValueDescriptor>>>()
-        {
-
-            @Override
-            public Iterable<ModelModule<ValueDescriptor>> map( ModuleInstance moduleInstance )
-            {
-                return moduleInstance.visibleValues( visibility );
-            }
-        }, moduleInstances ) );
-    }
-
-    /* package */ Iterable<ServiceReference<?>> visibleServices( final Visibility visibility )
-    {
-        return flattenIterables( map( new Function<ModuleInstance, Iterable<ServiceReference<?>>>()
-        {
-
-            @Override
-            public Iterable<ServiceReference<?>> map( ModuleInstance moduleInstance )
-            {
-                return moduleInstance.visibleServices( visibility );
-            }
-        }, moduleInstances ) );
-    }
-
-    /* package */ ModuleInstance findModule( String moduleName )
-    {
-        for( ModuleInstance moduleInstance : moduleInstances )
-        {
-            if( moduleInstance.model().name().equals( moduleName ) )
-            {
-                return moduleInstance;
-            }
-        }
-
-        throw new IllegalArgumentException( "No such module:" + moduleName );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
deleted file mode 100644
index 8592122..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.structure;
-
-import java.util.List;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.LayerDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-
-/**
- * JAVADOC
- */
-public final class LayerModel
-    implements LayerDescriptor, VisitableHierarchy<Object, Object>
-{
-    // Model
-    private final String name;
-    private final MetaInfo metaInfo;
-    private final UsedLayersModel usedLayersModel;
-    private final ActivatorsModel<Layer> activatorsModel;
-    private final List<ModuleModel> modules;
-
-    public LayerModel( String name,
-                       MetaInfo metaInfo,
-                       UsedLayersModel usedLayersModel,
-                       ActivatorsModel<Layer> activatorsModel,
-                       List<ModuleModel> modules
-    )
-    {
-        this.name = name;
-        this.metaInfo = metaInfo;
-        this.usedLayersModel = usedLayersModel;
-        this.activatorsModel = activatorsModel;
-        this.modules = modules;
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    public Iterable<ModuleModel> modules()
-    {
-        return modules;
-    }
-
-    @Override
-    public UsedLayersModel usedLayers()
-    {
-        return usedLayersModel;
-    }
-
-    public ActivatorsInstance<Layer> newActivatorsInstance()
-        throws ActivationException
-    {
-        return new ActivatorsInstance<>( activatorsModel.newInstances() );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            if( activatorsModel.accept( modelVisitor ) )
-            {
-                for( ModuleModel module : modules )
-                {
-                    if( !module.accept( modelVisitor ) )
-                    {
-                        break;
-                    }
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-
-    // Context
-    public LayerInstance newInstance( ApplicationInstance applicationInstance, UsedLayersInstance usedLayerInstance )
-    {
-        LayerInstance layerInstance = new LayerInstance( this, applicationInstance, usedLayerInstance );
-        for( ModuleModel module : modules )
-        {
-            ModuleInstance moduleInstance = module.newInstance( layerInstance );
-            layerInstance.addModule( moduleInstance );
-        }
-
-        return layerInstance;
-    }
-
-    @Override
-    public String toString()
-    {
-        return name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
deleted file mode 100644
index 0a110e4..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * Copyright (c) 2008-2012, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2012, Kent Sølvsten. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2015, Paul Merlin. 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.zest.runtime.structure;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.AmbiguousTypeException;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.composite.NoSuchTransientException;
-import org.apache.zest.api.composite.TransientBuilder;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.IdentityGenerator;
-import org.apache.zest.api.metrics.MetricsProvider;
-import org.apache.zest.api.object.NoSuchObjectException;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.api.value.NoSuchValueException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.api.value.ValueSerializationException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.runtime.composite.FunctionStateResolver;
-import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.runtime.composite.TransientBuilderInstance;
-import org.apache.zest.runtime.composite.TransientModel;
-import org.apache.zest.runtime.composite.TransientStateInstance;
-import org.apache.zest.runtime.composite.TransientsModel;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.entity.EntitiesModel;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.object.ObjectModel;
-import org.apache.zest.runtime.object.ObjectsModel;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.query.QueryBuilderFactoryImpl;
-import org.apache.zest.runtime.service.ImportedServicesInstance;
-import org.apache.zest.runtime.service.ImportedServicesModel;
-import org.apache.zest.runtime.service.ServicesInstance;
-import org.apache.zest.runtime.service.ServicesModel;
-import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
-import org.apache.zest.runtime.value.ValueBuilderInstance;
-import org.apache.zest.runtime.value.ValueBuilderWithPrototype;
-import org.apache.zest.runtime.value.ValueBuilderWithState;
-import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.runtime.value.ValueModel;
-import org.apache.zest.runtime.value.ValuesModel;
-import org.apache.zest.spi.entitystore.EntityStore;
-import org.apache.zest.spi.metrics.MetricsProviderAdapter;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerialization;
-
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
-import static org.apache.zest.api.util.Classes.modelTypeSpecification;
-import static org.apache.zest.functional.Iterables.cast;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-import static org.apache.zest.functional.Iterables.toList;
-
-/**
- * Instance of a Zest Module. Contains the various composites for this Module.
- */
-public class ModuleInstance
-    implements Module, ModuleSpi, Activation
-{
-    // Constructor parameters
-    private final ModuleModel model;
-    private final LayerInstance layer;
-    private final TransientsModel transients;
-    private final ValuesModel values;
-    private final ObjectsModel objects;
-    private final EntitiesModel entities;
-    private final ServicesInstance services;
-    private final ImportedServicesInstance importedServices;
-    // Eager instance objects
-    private final ActivationDelegate activation;
-    private final TypeLookup typeLookup;
-    private final QueryBuilderFactory queryBuilderFactory;
-    private final ClassLoader classLoader;
-    private final EntityFunction entityFunction;
-    // Lazy assigned on accessors
-    private EntityStore store;
-    private IdentityGenerator generator;
-    private ValueSerialization valueSerialization;
-    private MetricsProvider metrics;
-
-    @SuppressWarnings( "LeakingThisInConstructor" )
-    public ModuleInstance( ModuleModel moduleModel, LayerInstance layerInstance, TransientsModel transientsModel,
-                           EntitiesModel entitiesModel, ObjectsModel objectsModel, ValuesModel valuesModel,
-                           ServicesModel servicesModel, ImportedServicesModel importedServicesModel
-    )
-    {
-        // Constructor parameters
-        model = moduleModel;
-        layer = layerInstance;
-        transients = transientsModel;
-        values = valuesModel;
-        objects = objectsModel;
-        entities = entitiesModel;
-        services = servicesModel.newInstance( this );
-        importedServices = importedServicesModel.newInstance( this );
-
-        // Eager instance objects
-        activation = new ActivationDelegate( this );
-        typeLookup = new TypeLookup( this );
-        queryBuilderFactory = new QueryBuilderFactoryImpl( this );
-        classLoader = new ModuleClassLoader( this, Thread.currentThread().getContextClassLoader() );
-        entityFunction = new EntityFunction( this );
-
-        // Activation
-        services.registerActivationEventListener( activation );
-        importedServices.registerActivationEventListener( activation );
-    }
-
-    @Override
-    public String toString()
-    {
-        return model.toString();
-    }
-
-    // Implementation of Module
-    @Override
-    public String name()
-    {
-        return model.name();
-    }
-
-    @Override
-    public ClassLoader classLoader()
-    {
-        return classLoader;
-    }
-
-    @Override
-    public EntityDescriptor entityDescriptor( String name )
-    {
-        try
-        {
-            Class<?> type = classLoader().loadClass( name );
-            ModelModule<EntityModel> entityModel = typeLookup.lookupEntityModel( type );
-            if( entityModel == null )
-            {
-                return null;
-            }
-            return entityModel.model();
-        }
-        catch( ClassNotFoundException e )
-        {
-            return null;
-        }
-    }
-
-    @Override
-    public ObjectDescriptor objectDescriptor( String typeName )
-    {
-        try
-        {
-            Class<?> type = classLoader().loadClass( typeName );
-            ModelModule<ObjectModel> objectModel = typeLookup.lookupObjectModel( type );
-            if( objectModel == null )
-            {
-                return null;
-            }
-            return objectModel.model();
-        }
-        catch( ClassNotFoundException e )
-        {
-            return null;
-        }
-    }
-
-    @Override
-    public TransientDescriptor transientDescriptor( String name )
-    {
-        try
-        {
-            Class<?> type = classLoader().loadClass( name );
-            ModelModule<TransientModel> transientModel = typeLookup.lookupTransientModel( type );
-            if( transientModel == null )
-            {
-                return null;
-            }
-            return transientModel.model();
-        }
-        catch( ClassNotFoundException e )
-        {
-            return null;
-        }
-    }
-
-    @Override
-    public ValueDescriptor valueDescriptor( String name )
-    {
-        try
-        {
-            Class<?> type = classLoader().loadClass( name );
-            ModelModule<ValueModel> valueModel = typeLookup.lookupValueModel( type );
-            if( valueModel == null )
-            {
-                return null;
-            }
-            return valueModel.model();
-        }
-        catch( ClassNotFoundException e )
-        {
-            return null;
-        }
-    }
-
-    // Implementation of MetaInfoHolder
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return model.metaInfo( infoType );
-    }
-
-    // Implementation of ObjectFactory
-    @Override
-    public <T> T newObject( Class<T> mixinType, Object... uses )
-        throws NoSuchObjectException
-    {
-        NullArgumentException.validateNotNull( "mixinType", mixinType );
-        ModelModule<ObjectModel> modelModule = typeLookup.lookupObjectModel( mixinType );
-
-        if( modelModule == null )
-        {
-            throw new NoSuchObjectException( mixinType.getName(), name() );
-        }
-
-        InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
-        return mixinType.cast( modelModule.model().newInstance( injectionContext ) );
-    }
-
-    @Override
-    public void injectTo( Object instance, Object... uses )
-        throws ConstructionException
-    {
-        NullArgumentException.validateNotNull( "instance", instance );
-        ModelModule<ObjectModel> modelModule = typeLookup.lookupObjectModel( instance.getClass() );
-
-        if( modelModule == null )
-        {
-            throw new NoSuchObjectException( instance.getClass().getName(), name() );
-        }
-
-        InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
-        modelModule.model().inject( injectionContext, instance );
-    }
-
-    // Implementation of TransientBuilderFactory
-    @Override
-    public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
-        throws NoSuchTransientException
-    {
-        NullArgumentException.validateNotNull( "mixinType", mixinType );
-        ModelModule<TransientModel> modelModule = typeLookup.lookupTransientModel( mixinType );
-
-        if( modelModule == null )
-        {
-            throw new NoSuchTransientException( mixinType.getName(), name() );
-        }
-
-        Map<AccessibleObject, Property<?>> properties = new HashMap<>();
-        for( PropertyModel propertyModel : modelModule.model().state().properties() )
-        {
-            Property<?> property = new PropertyInstance<>( propertyModel.getBuilderInfo(),
-                                                           propertyModel.initialValue( modelModule.module() ) );
-            properties.put( propertyModel.accessor(), property );
-        }
-
-        TransientStateInstance state = new TransientStateInstance( properties );
-
-        return new TransientBuilderInstance<>( modelModule, state, UsesInstance.EMPTY_USES );
-    }
-
-    @Override
-    public <T> T newTransient( final Class<T> mixinType, Object... uses )
-        throws NoSuchTransientException, ConstructionException
-    {
-        return newTransientBuilder( mixinType ).use( uses ).newInstance();
-    }
-
-    // Implementation of ValueBuilderFactory
-    @Override
-    public <T> T newValue( Class<T> mixinType )
-        throws NoSuchValueException, ConstructionException
-    {
-        return newValueBuilder( mixinType ).newInstance();
-    }
-
-    @Override
-    public <T> ValueBuilder<T> newValueBuilder( Class<T> mixinType )
-        throws NoSuchValueException
-    {
-        NullArgumentException.validateNotNull( "mixinType", mixinType );
-        ModelModule<ValueModel> compositeModelModule = typeLookup.lookupValueModel( mixinType );
-
-        if( compositeModelModule == null )
-        {
-            throw new NoSuchValueException( mixinType.getName(), name() );
-        }
-
-        StateResolver stateResolver = new InitialStateResolver( compositeModelModule.module() );
-        return new ValueBuilderInstance<>( compositeModelModule, this, stateResolver );
-    }
-
-    @Override
-    public <T> ValueBuilder<T> newValueBuilderWithState( Class<T> mixinType,
-                                                         Function<PropertyDescriptor, Object> propertyFunction,
-                                                         Function<AssociationDescriptor, EntityReference> associationFunction,
-                                                         Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-                                                         Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
-    )
-    {
-        NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
-        NullArgumentException.validateNotNull( "associationFunction", associationFunction );
-        NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
-        NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
-
-        ModelModule<ValueModel> compositeModelModule = typeLookup.lookupValueModel( mixinType );
-
-        if( compositeModelModule == null )
-        {
-            throw new NoSuchValueException( mixinType.getName(), name() );
-        }
-
-        StateResolver stateResolver = new FunctionStateResolver(
-            propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction
-        );
-        return new ValueBuilderWithState<>( compositeModelModule, this, stateResolver );
-    }
-
-    private static class InitialStateResolver
-        implements StateResolver
-    {
-        private final Module module;
-
-        private InitialStateResolver( Module module )
-        {
-            this.module = module;
-        }
-
-        @Override
-        public Object getPropertyState( PropertyDescriptor propertyDescriptor )
-        {
-            return propertyDescriptor.initialValue( module );
-        }
-
-        @Override
-        public EntityReference getAssociationState( AssociationDescriptor associationDescriptor )
-        {
-            return null;
-        }
-
-        @Override
-        public List<EntityReference> getManyAssociationState( AssociationDescriptor associationDescriptor )
-        {
-            return new ArrayList<>();
-        }
-
-        @Override
-        public Map<String, EntityReference> getNamedAssociationState( AssociationDescriptor associationDescriptor )
-        {
-            return new HashMap<>();
-        }
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> ValueBuilder<T> newValueBuilderWithPrototype( T prototype )
-    {
-        NullArgumentException.validateNotNull( "prototype", prototype );
-
-        ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) prototype );
-        Class<Composite> valueType = (Class<Composite>) first( valueInstance.types() );
-
-        ModelModule<ValueModel> modelModule = typeLookup.lookupValueModel( valueType );
-
-        if( modelModule == null )
-        {
-            throw new NoSuchValueException( valueType.getName(), name() );
-        }
-
-        return new ValueBuilderWithPrototype<>( modelModule, this, prototype );
-    }
-
-    @Override
-    public <T> T newValueFromSerializedState( Class<T> mixinType, String serializedState )
-        throws NoSuchValueException, ConstructionException
-    {
-        NullArgumentException.validateNotNull( "mixinType", mixinType );
-        ModelModule<ValueModel> modelModule = typeLookup.lookupValueModel( mixinType );
-
-        if( modelModule == null )
-        {
-            throw new NoSuchValueException( mixinType.getName(), name() );
-        }
-
-        try
-        {
-            return valueSerialization().deserialize( modelModule.model().valueType(), serializedState );
-        }
-        catch( ValueSerializationException ex )
-        {
-            throw new ConstructionException( "Could not create value from serialized state", ex );
-        }
-    }
-
-    // Implementation of UnitOfWorkFactory
-    @Override
-    public UnitOfWork newUnitOfWork()
-    {
-        return newUnitOfWork( Usecase.DEFAULT );
-    }
-
-    @Override
-    public UnitOfWork newUnitOfWork( long currentTime )
-    {
-        return newUnitOfWork( Usecase.DEFAULT, currentTime );
-    }
-
-    @Override
-    public UnitOfWork newUnitOfWork( Usecase usecase )
-    {
-        return newUnitOfWork( usecase == null ? Usecase.DEFAULT : usecase, System.currentTimeMillis() );
-    }
-
-    @Override
-    public UnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
-    {
-        UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( usecase, currentTime, metricsProvider() );
-        return new ModuleUnitOfWork( ModuleInstance.this, unitOfWorkInstance );
-    }
-
-    @Override
-    public boolean isUnitOfWorkActive()
-    {
-        Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
-        return !stack.isEmpty();
-    }
-
-    @Override
-    public UnitOfWork currentUnitOfWork()
-    {
-        Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
-        if( stack.size() == 0 )
-        {
-            throw new IllegalStateException( "No current UnitOfWork active" );
-        }
-        return new ModuleUnitOfWork( ModuleInstance.this, stack.peek() );
-    }
-
-    @Override
-    public UnitOfWork getUnitOfWork( EntityComposite entity )
-    {
-        EntityInstance instance = EntityInstance.entityInstanceOf( entity );
-        return instance.unitOfWork();
-    }
-
-    // Implementation of QueryBuilderFactory
-    @Override
-    public <T> QueryBuilder<T> newQueryBuilder( final Class<T> resultType )
-    {
-        return queryBuilderFactory.newQueryBuilder( resultType );
-    }
-
-    // Implementation of ServiceFinder
-    @Override
-    public <T> ServiceReference<T> findService( Class<T> serviceType )
-    {
-        return typeLookup.lookupServiceReference( (Type) serviceType );
-    }
-
-    @Override
-    public <T> ServiceReference<T> findService( Type serviceType )
-    {
-        return typeLookup.lookupServiceReference( serviceType );
-    }
-
-    @Override
-    public <T> Iterable<ServiceReference<T>> findServices( Class<T> serviceType )
-    {
-        return typeLookup.lookupServiceReferences( (Type) serviceType );
-    }
-
-    @Override
-    public <T> Iterable<ServiceReference<T>> findServices( Type serviceType )
-    {
-        return typeLookup.lookupServiceReferences( serviceType );
-    }
-
-    // Implementation of Activation
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public void activate()
-        throws ActivationException
-    {
-        activation.activate( model.newActivatorsInstance(), iterable( services, importedServices ) );
-    }
-
-    @Override
-    public void passivate()
-        throws PassivationException
-    {
-        activation.passivate();
-    }
-
-    @Override
-    public void registerActivationEventListener( ActivationEventListener listener )
-    {
-        activation.registerActivationEventListener( listener );
-    }
-
-    @Override
-    public void deregisterActivationEventListener( ActivationEventListener listener )
-    {
-        activation.deregisterActivationEventListener( listener );
-    }
-
-    // Other methods
-    /* package */ ModuleModel model()
-    {
-        return model;
-    }
-
-    public LayerInstance layerInstance()
-    {
-        return layer;
-    }
-
-    public TypeLookup typeLookup()
-    {
-        return typeLookup;
-    }
-
-    public Function2<EntityReference, Type, Object> getEntityFunction()
-    {
-        return entityFunction;
-    }
-
-    private static class EntityFunction
-        implements Function2<EntityReference, Type, Object>
-    {
-
-        private final UnitOfWorkFactory uowf;
-
-        private EntityFunction( UnitOfWorkFactory uowf )
-        {
-            this.uowf = uowf;
-        }
-
-        @Override
-        public Object map( EntityReference entityReference, Type type )
-        {
-            return uowf.currentUnitOfWork().get( RAW_CLASS.map( type ), entityReference.identity() );
-        }
-    }
-
-    public EntityStore entityStore()
-    {
-        synchronized( this )
-        {
-            if( store == null )
-            {
-                ServiceReference<EntityStore> service = findService( EntityStore.class );
-                if( service == null )
-                {
-                    throw new UnitOfWorkException( "No EntityStore service available in module " + name() );
-                }
-                store = service.get();
-            }
-        }
-        return store;
-    }
-
-    public IdentityGenerator identityGenerator()
-    {
-        synchronized( this )
-        {
-            if( generator == null )
-            {
-                ServiceReference<IdentityGenerator> service = findService( IdentityGenerator.class );
-                generator = service.get();
-            }
-            return generator;
-        }
-    }
-
-    public ValueSerialization valueSerialization()
-    {
-        synchronized( this )
-        {
-            if( valueSerialization == null )
-            {
-                try
-                {
-                    ServiceReference<ValueSerialization> service = findService( ValueSerialization.class );
-                    valueSerialization = service.get();
-                }
-                catch( NoSuchServiceException e )
-                {
-                    valueSerialization = new OrgJsonValueSerialization( layer.applicationInstance(), this, this );
-                }
-            }
-        }
-        return valueSerialization;
-    }
-
-    /* package */ MetricsProvider metricsProvider()
-    {
-        synchronized( this )
-        {
-            if( metrics == null )
-            {
-                try
-                {
-                    ServiceReference<MetricsProvider> service = findService( MetricsProvider.class );
-                    metrics = service.get();
-                }
-                catch( NoSuchServiceException e )
-                {
-                    metrics = new MetricsProviderAdapter();
-                }
-            }
-        }
-        return metrics;
-    }
-
-    public Iterable<ModelModule<ObjectDescriptor>> visibleObjects( Visibility visibility )
-    {
-        return map( ModelModule.<ObjectDescriptor>modelModuleFunction( this ),
-                    filter( new VisibilitySpecification( visibility ), objects.models() ) );
-    }
-
-    public Iterable<ModelModule<TransientDescriptor>> visibleTransients( Visibility visibility )
-    {
-        return map( ModelModule.<TransientDescriptor>modelModuleFunction( this ),
-                    filter( new VisibilitySpecification( visibility ), transients.models() ) );
-    }
-
-    public Iterable<ModelModule<EntityDescriptor>> visibleEntities( Visibility visibility )
-    {
-        return map( ModelModule.<EntityDescriptor>modelModuleFunction( this ),
-                    filter( new VisibilitySpecification( visibility ), entities.models() ) );
-    }
-
-    public Iterable<ModelModule<ValueDescriptor>> visibleValues( Visibility visibility )
-    {
-        return map( ModelModule.<ValueDescriptor>modelModuleFunction( this ),
-                    filter( new VisibilitySpecification( visibility ), values.models() ) );
-    }
-
-    public Iterable<ServiceReference<?>> visibleServices( Visibility visibility )
-    {
-        return flatten( services.visibleServices( visibility ),
-                        importedServices.visibleServices( visibility ) );
-    }
-
-    // Module ClassLoader
-    private static class ModuleClassLoader
-        extends ClassLoader
-    {
-
-        private final ModuleInstance moduleInstance;
-        private final Map<String, Class<?>> classes = new ConcurrentHashMap<>();
-
-        private ModuleClassLoader( ModuleInstance moduleInstance, ClassLoader classLoader )
-        {
-            super( classLoader );
-            this.moduleInstance = moduleInstance;
-        }
-
-        @Override
-        protected Class<?> findClass( String name )
-            throws ClassNotFoundException
-        {
-            Class<?> clazz = classes.get( name );
-            if( clazz == null )
-            {
-                Specification<ModelDescriptor> modelTypeSpecification = modelTypeSpecification( name );
-                Specification<ModelModule<ModelDescriptor>> translate = Specifications.translate( ModelModule.modelFunction(), modelTypeSpecification );
-                // Check module
-                {
-                    Iterable<ModelModule<ModelDescriptor>> i = cast( flatten(
-                        cast( moduleInstance.visibleObjects( Visibility.module ) ),
-                        cast( moduleInstance.visibleEntities( Visibility.module ) ),
-                        cast( moduleInstance.visibleTransients( Visibility.module ) ),
-                        cast( moduleInstance.visibleValues( Visibility.module ) ) ) );
-
-                    Iterable<ModelModule<ModelDescriptor>> moduleModels = filter( translate, i );
-                    Iterator<ModelModule<ModelDescriptor>> iter = moduleModels.iterator();
-                    if( iter.hasNext() )
-                    {
-                        clazz = first( iter.next().model().types() );
-
-                        if( iter.hasNext() )
-                        {
-                            // Ambiguous exception
-                            throw new ClassNotFoundException(
-                                name,
-                                new AmbiguousTypeException(
-                                    "More than one model matches the classname " + name + ":" + toList( moduleModels )
-                                )
-                            );
-                        }
-                    }
-                }
-
-                // Check layer
-                if( clazz == null )
-                {
-                    Iterable<ModelModule<ModelDescriptor>> flatten = cast( flatten(
-                        cast( moduleInstance.layerInstance().visibleObjects( Visibility.layer ) ),
-                        cast( moduleInstance.layerInstance().visibleTransients( Visibility.layer ) ),
-                        cast( moduleInstance.layerInstance().visibleEntities( Visibility.layer ) ),
-                        cast( moduleInstance.layerInstance().visibleValues( Visibility.layer ) ),
-                        cast( moduleInstance.layerInstance().visibleObjects( Visibility.application ) ),
-                        cast( moduleInstance.layerInstance().visibleTransients( Visibility.application ) ),
-                        cast( moduleInstance.layerInstance().visibleEntities( Visibility.application ) ),
-                        cast( moduleInstance.layerInstance().visibleValues( Visibility.application ) ) ) );
-                    Iterable<ModelModule<ModelDescriptor>> layerModels = filter( translate, flatten );
-                    Iterator<ModelModule<ModelDescriptor>> iter = layerModels.iterator();
-                    if( iter.hasNext() )
-                    {
-                        clazz = first( iter.next().model().types() );
-
-                        if( iter.hasNext() )
-                        {
-                            // Ambiguous exception
-                            throw new ClassNotFoundException(
-                                name,
-                                new AmbiguousTypeException(
-                                    "More than one model matches the classname " + name + ":" + toList( layerModels ) )
-                            );
-                        }
-                    }
-                }
-
-                // Check used layers
-                if( clazz == null )
-                {
-                    Iterable<ModelModule<ModelDescriptor>> flatten = cast( flatten(
-                        cast( moduleInstance.layerInstance().usedLayersInstance().visibleObjects() ),
-                        cast( moduleInstance.layerInstance().usedLayersInstance().visibleTransients() ),
-                        cast( moduleInstance.layerInstance().usedLayersInstance().visibleEntities() ),
-                        cast( moduleInstance.layerInstance().usedLayersInstance().visibleValues() ) ) );
-                    Iterable<ModelModule<ModelDescriptor>> usedLayersModels = filter( translate, flatten );
-                    Iterator<ModelModule<ModelDescriptor>> iter = usedLayersModels.iterator();
-                    if( iter.hasNext() )
-                    {
-                        clazz = first( iter.next().model().types() );
-
-                        if( iter.hasNext() )
-                        {
-                            // Ambiguous exception
-                            throw new ClassNotFoundException(
-                                name,
-                                new AmbiguousTypeException(
-                                    "More than one model matches the classname " + name + ":" + toList( usedLayersModels )
-                                )
-                            );
-                        }
-                    }
-                }
-
-                if( clazz == null )
-                {
-                    throw new ClassNotFoundException( name );
-                }
-                classes.put( name, clazz );
-            }
-
-            return clazz;
-        }
-    }
-
-    public Iterable<ModelModule<ValueDescriptor>> findVisibleValueTypes()
-    {
-        return flatten( visibleValues( Visibility.module ),
-            layerInstance().visibleValues( Visibility.layer ),
-            layerInstance().visibleValues( Visibility.application ),
-            layerInstance().usedLayersInstance().visibleValues()
-        );
-    }
-
-    public Iterable<ModelModule<EntityDescriptor>> findVisibleEntityTypes()
-    {
-        return flatten( visibleEntities( Visibility.module ),
-            layerInstance().visibleEntities( Visibility.layer ),
-            layerInstance().visibleEntities( Visibility.application ),
-            layerInstance().usedLayersInstance().visibleEntities()
-        );
-    }
-    public Iterable<ModelModule<TransientDescriptor>> findVisibleTransientTypes()
-    {
-        return flatten( visibleTransients( Visibility.module ),
-            layerInstance().visibleTransients( Visibility.layer ),
-            layerInstance().visibleTransients( Visibility.application ),
-            layerInstance().usedLayersInstance().visibleTransients()
-        );
-    }
-    public Iterable<ModelModule<ServiceDescriptor>> findVisibleServiceTypes()
-    {
-        return flatten( visibleServices( Visibility.module ),
-            layerInstance().visibleServices( Visibility.layer ),
-            layerInstance().visibleServices( Visibility.application ),
-            layerInstance().usedLayersInstance().visibleServices()
-        );
-    }
-    public Iterable<ModelModule<ObjectDescriptor>> findVisibleObjectTypes()
-    {
-        return flatten( visibleObjects( Visibility.module ),
-            layerInstance().visibleObjects( Visibility.layer ),
-            layerInstance().visibleObjects( Visibility.application ),
-            layerInstance().usedLayersInstance().visibleObjects()
-        );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
deleted file mode 100644
index 49e3670..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2012-2014, Paul Merlin. 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.zest.runtime.structure;
-
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.activation.ActivatorsInstance;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.composite.TransientsModel;
-import org.apache.zest.runtime.entity.EntitiesModel;
-import org.apache.zest.runtime.object.ObjectsModel;
-import org.apache.zest.runtime.service.ImportedServicesModel;
-import org.apache.zest.runtime.service.ServicesModel;
-import org.apache.zest.runtime.value.ValuesModel;
-
-/**
- * JAVADOC
- */
-public class ModuleModel
-    implements ModuleDescriptor, VisitableHierarchy<Object, Object>
-{
-    private final ActivatorsModel<Module> activatorsModel;
-    private final TransientsModel transientsModel;
-    private final EntitiesModel entitiesModel;
-    private final ObjectsModel objectsModel;
-    private final ValuesModel valuesModel;
-    private final ServicesModel servicesModel;
-    private final ImportedServicesModel importedServicesModel;
-
-    private final String name;
-    private final MetaInfo metaInfo;
-
-    public ModuleModel( String name,
-                        MetaInfo metaInfo,
-                        ActivatorsModel<Module> activatorsModel,
-                        TransientsModel transientsModel,
-                        EntitiesModel entitiesModel,
-                        ObjectsModel objectsModel,
-                        ValuesModel valuesModel,
-                        ServicesModel servicesModel,
-                        ImportedServicesModel importedServicesModel
-    )
-    {
-        this.name = name;
-        this.metaInfo = metaInfo;
-        this.activatorsModel = activatorsModel;
-        this.transientsModel = transientsModel;
-        this.entitiesModel = entitiesModel;
-        this.objectsModel = objectsModel;
-        this.valuesModel = valuesModel;
-        this.servicesModel = servicesModel;
-        this.importedServicesModel = importedServicesModel;
-    }
-
-    @Override
-    public String name()
-    {
-        return name;
-    }
-
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    public ActivatorsInstance<Module> newActivatorsInstance()
-        throws ActivationException
-    {
-        return new ActivatorsInstance<>( activatorsModel.newInstances() );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            if( activatorsModel.accept( modelVisitor ) )
-            {
-                if( transientsModel.accept( modelVisitor ) )
-                {
-                    if( entitiesModel.accept( modelVisitor ) )
-                    {
-                        if( servicesModel.accept( modelVisitor ) )
-                        {
-                            if( importedServicesModel.accept( modelVisitor ) )
-                            {
-                                if( objectsModel.accept( modelVisitor ) )
-                                {
-                                    valuesModel.accept( modelVisitor );
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-
-    // Context
-
-    public ModuleInstance newInstance( LayerInstance layerInstance )
-    {
-        return new ModuleInstance( this, layerInstance, transientsModel, entitiesModel, objectsModel, valuesModel, servicesModel, importedServicesModel );
-    }
-
-    @Override
-    public String toString()
-    {
-        return name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
deleted file mode 100644
index f052de2..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
+++ /dev/null
@@ -1,773 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2013-2015, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2013-2015, Paul Merlin. 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.zest.runtime.structure;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.IdentityGenerator;
-import org.apache.zest.api.entity.LifecycleException;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryExecutionException;
-import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
-import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.runtime.association.AssociationInstance;
-import org.apache.zest.runtime.association.ManyAssociationInstance;
-import org.apache.zest.runtime.association.NamedAssociationInstance;
-import org.apache.zest.runtime.composite.FunctionStateResolver;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.unitofwork.EntityBuilderInstance;
-import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
-import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.entity.NamedAssociationState;
-import org.apache.zest.spi.entitystore.EntityStore;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.spi.query.EntityFinder;
-import org.apache.zest.spi.query.EntityFinderException;
-import org.apache.zest.spi.query.QueryBuilderSPI;
-import org.apache.zest.spi.query.QuerySource;
-
-import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * JAVADOC
- */
-public class ModuleUnitOfWork
-    implements UnitOfWork
-{
-    private static final QualifiedName IDENTITY_STATE_NAME;
-
-    static
-    {
-        try
-        {
-            IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
-        }
-    }
-
-    private final UnitOfWorkInstance uow;
-    private final ModuleInstance module;
-
-    ModuleUnitOfWork( ModuleInstance module, UnitOfWorkInstance uow )
-    {
-        this.module = module;
-        this.uow = uow;
-    }
-
-    public ModuleInstance module()
-    {
-        return module;
-    }
-
-    public UnitOfWorkInstance instance()
-    {
-        return uow;
-    }
-
-    @Override
-    public UnitOfWorkFactory unitOfWorkFactory()
-    {
-        return module;
-    }
-
-    @Override
-    public long currentTime()
-    {
-        return uow.currentTime();
-    }
-
-    @Override
-    public Usecase usecase()
-    {
-        return uow.usecase();
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return uow.metaInfo().get( infoType );
-    }
-
-    @Override
-    public void setMetaInfo( Object metaInfo )
-    {
-        uow.metaInfo().set( metaInfo );
-    }
-
-    @Override
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public <T> Query<T> newQuery( QueryBuilder<T> queryBuilder )
-    {
-        QueryBuilderSPI queryBuilderSPI = (QueryBuilderSPI) queryBuilder;
-
-        return queryBuilderSPI.newQuery( new UoWQuerySource( this ) );
-    }
-
-    @Override
-    public <T> T newEntity( Class<T> type )
-        throws EntityTypeNotFoundException, LifecycleException
-    {
-        return newEntity( type, null );
-    }
-
-    @Override
-    public <T> T newEntity( Class<T> type, String identity )
-        throws EntityTypeNotFoundException, LifecycleException
-    {
-        return newEntityBuilder( type, identity ).newInstance();
-    }
-
-    @Override
-    public <T> EntityBuilder<T> newEntityBuilder( Class<T> type )
-        throws EntityTypeNotFoundException
-    {
-        return newEntityBuilder( type, null );
-    }
-
-    @Override
-    public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
-        throws EntityTypeNotFoundException
-    {
-        ModelModule<EntityModel> model = module.typeLookup().lookupEntityModel( type );
-
-        if( model == null )
-        {
-            throw new EntityTypeNotFoundException( type.getName(),
-                                                   module.name(),
-                                                   map( ModelModule.toStringFunction,
-                                                        module.findVisibleEntityTypes()
-                                                   ) );
-        }
-
-        EntityStore entityStore = model.module().entityStore();
-
-        // Generate id if necessary
-        if( identity == null )
-        {
-            IdentityGenerator idGen = model.module().identityGenerator();
-            if( idGen == null )
-            {
-                throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
-            }
-            identity = idGen.generate( first( model.model().types() ) );
-        }
-        EntityBuilder<T> builder;
-
-        builder = new EntityBuilderInstance<>( model,
-                                               this,
-                                               uow.getEntityStoreUnitOfWork( entityStore, module ),
-                                               identity );
-        return builder;
-    }
-
-    @Override
-    public <T> EntityBuilder<T> newEntityBuilderWithState(
-        Class<T> type,
-        Function<PropertyDescriptor, Object> propertyFunction,
-        Function<AssociationDescriptor, EntityReference> associationFunction,
-        Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-        Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
-    )
-        throws EntityTypeNotFoundException
-    {
-        return newEntityBuilderWithState( type, null,
-                                          propertyFunction,
-                                          associationFunction,
-                                          manyAssociationFunction,
-                                          namedAssociationFunction );
-    }
-
-    @Override
-    public <T> EntityBuilder<T> newEntityBuilderWithState(
-        Class<T> type, String identity,
-        Function<PropertyDescriptor, Object> propertyFunction,
-        Function<AssociationDescriptor, EntityReference> associationFunction,
-        Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-        Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
-    )
-        throws EntityTypeNotFoundException
-    {
-        NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
-        NullArgumentException.validateNotNull( "associationFunction", associationFunction );
-        NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
-        NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
-
-        ModelModule<EntityModel> model = module.typeLookup().lookupEntityModel( type );
-
-        if( model == null )
-        {
-            throw new EntityTypeNotFoundException( type.getName(),
-                                                   module.name(),
-                                                   map( ModelModule.toStringFunction,
-                                                        module.findVisibleEntityTypes()
-                                                   ) );
-        }
-
-        EntityStore entityStore = model.module().entityStore();
-
-        FunctionStateResolver stateResolver = new FunctionStateResolver(
-            propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction
-        );
-
-        if( identity == null )
-        {
-            // Use identity from StateResolver if available
-            PropertyModel identityModel = model.model().state().findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
-            identity = (String) stateResolver.getPropertyState( identityModel );
-            if( identity == null )
-            {
-                // Generate identity
-                IdentityGenerator idGen = model.module().identityGenerator();
-                if( idGen == null )
-                {
-                    throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
-                }
-                identity = idGen.generate( first( model.model().types() ) );
-            }
-        }
-
-        return new EntityBuilderInstance<>( model,
-                                            this,
-                                            uow.getEntityStoreUnitOfWork( entityStore, module ),
-                                            identity,
-                                            stateResolver );
-    }
-
-    @Override
-    public <T> T get( Class<T> type, String identity )
-        throws EntityTypeNotFoundException, NoSuchEntityException
-    {
-        Iterable<ModelModule<EntityModel>> models = module.typeLookup().lookupEntityModels( type );
-
-        if( !models.iterator().hasNext() )
-        {
-            throw new EntityTypeNotFoundException( type.getName(),
-                                                   module.name(),
-                                                   map( ModelModule.toStringFunction,
-                                                        module.findVisibleEntityTypes()
-                                                   ) );
-        }
-
-        return uow.get( parseEntityReference( identity ), this, models, type );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> T get( T entity )
-        throws EntityTypeNotFoundException
-    {
-        EntityComposite entityComposite = (EntityComposite) entity;
-        EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
-        ModelModule<EntityModel> model = new ModelModule<>( compositeInstance.module(), compositeInstance.entityModel() );
-        Class<T> type = (Class<T>) first( compositeInstance.types() );
-        return uow.get( compositeInstance.identity(), this, Collections.singletonList( model ), type );
-    }
-
-    @Override
-    public void remove( Object entity )
-        throws LifecycleException
-    {
-        uow.checkOpen();
-
-        EntityComposite entityComposite = (EntityComposite) entity;
-
-        EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
-
-        if( compositeInstance.status() == EntityStatus.NEW )
-        {
-            compositeInstance.remove( this );
-            uow.remove( compositeInstance.identity() );
-        }
-        else if( compositeInstance.status() == EntityStatus.LOADED || compositeInstance.status() == EntityStatus.UPDATED )
-        {
-            compositeInstance.remove( this );
-        }
-        else
-        {
-            throw new NoSuchEntityException( compositeInstance.identity(), compositeInstance.types(), usecase() );
-        }
-    }
-
-    @SuppressWarnings( "DuplicateThrows" )
-    @Override
-    public void complete()
-        throws UnitOfWorkCompletionException, ConcurrentEntityModificationException
-    {
-        uow.complete();
-    }
-
-    @Override
-    public void discard()
-    {
-        uow.discard();
-    }
-
-    @Override
-    public void close()
-    {
-        discard();
-    }
-
-    @Override
-    public boolean isOpen()
-    {
-        return uow.isOpen();
-    }
-
-    @Override
-    public boolean isPaused()
-    {
-        return uow.isPaused();
-    }
-
-    @Override
-    public void pause()
-    {
-        uow.pause();
-    }
-
-    @Override
-    public void resume()
-    {
-        uow.resume();
-    }
-
-    @Override
-    public void addUnitOfWorkCallback( UnitOfWorkCallback callback )
-    {
-        uow.addUnitOfWorkCallback( callback );
-    }
-
-    @Override
-    public void removeUnitOfWorkCallback( UnitOfWorkCallback callback )
-    {
-        uow.removeUnitOfWorkCallback( callback );
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        ModuleUnitOfWork that = (ModuleUnitOfWork) o;
-
-        return uow.equals( that.uow );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return uow.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        return uow.toString();
-    }
-
-    public void addEntity( EntityInstance instance )
-    {
-        uow.addEntity( instance );
-    }
-
-    @Override
-    public <T extends Identity> T toValue( Class<T> primaryType, T entityComposite )
-    {
-        Function<PropertyDescriptor, Object> propertyFunction = new ToValuePropertyMappingFunction( entityComposite );
-        Function<AssociationDescriptor, EntityReference> assocationFunction = new ToValueAssociationMappingFunction<>( entityComposite );
-        Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToValueManyAssociationMappingFunction<>( entityComposite );
-        Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToValueNameAssociationMappingFunction<>( entityComposite );
-
-        @SuppressWarnings( "unchecked" )
-        ValueBuilder<T> builder = module().newValueBuilderWithState(
-            primaryType, propertyFunction, assocationFunction, manyAssocFunction, namedAssocFunction );
-        return builder.newInstance();
-    }
-
-    @Override
-    public <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite )
-    {
-        Function<PropertyDescriptor, Object> propertyFunction = new ToEntityPropertyMappingFunction<>( valueComposite );
-        Function<AssociationDescriptor, EntityReference> assocationFunction = new ToEntityAssociationMappingFunction<>( valueComposite );
-        Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToEntityManyAssociationMappingFunction<>( valueComposite );
-        Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToEntityNameAssociationMappingFunction<>( valueComposite );
-
-        String identity = valueComposite.identity().get();
-        try
-        {
-            T entity = get( primaryType, identity );
-            // If successful, then this entity is to by modified.
-            EntityInstance instance = EntityInstance.entityInstanceOf( (EntityComposite) entity );
-            EntityState state = instance.entityState();
-            FunctionStateResolver stateResolver = new FunctionStateResolver( propertyFunction,
-                                                                             assocationFunction,
-                                                                             manyAssocFunction,
-                                                                             namedAssocFunction );
-            EntityModel model = (EntityModel) EntityInstance.entityInstanceOf( (EntityComposite) entity ).descriptor();
-            stateResolver.populateState( model, state );
-            return entity;
-        }
-        catch( NoSuchEntityException e )
-        {
-            EntityBuilder<T> entityBuilder = newEntityBuilderWithState( primaryType,
-                                                                        identity,
-                                                                        propertyFunction,
-                                                                        assocationFunction,
-                                                                        manyAssocFunction,
-                                                                        namedAssocFunction );
-            return entityBuilder.newInstance();
-        }
-    }
-
-    private static class UoWQuerySource implements QuerySource
-    {
-        private final ModuleUnitOfWork moduleUnitOfWork;
-
-        private UoWQuerySource( ModuleUnitOfWork moduleUnitOfWork )
-        {
-            this.moduleUnitOfWork = moduleUnitOfWork;
-        }
-
-        @Override
-        public <T> T find( Class<T> resultType,
-                           Specification<Composite> whereClause,
-                           Iterable<OrderBy> orderBySegments,
-                           Integer firstResult,
-                           Integer maxResults,
-                           Map<String, Object> variables
-        )
-        {
-            final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
-            try
-            {
-                final EntityReference foundEntity = entityFinder.findEntity( resultType, whereClause, variables == null ? Collections
-                    .<String, Object>emptyMap() : variables );
-                if( foundEntity != null )
-                {
-                    try
-                    {
-                        return moduleUnitOfWork.get( resultType, foundEntity.identity() );
-                    }
-                    catch( NoSuchEntityException e )
-                    {
-                        return null; // Index is out of sync - entity has been removed
-                    }
-                }
-                // No entity was found
-                return null;
-            }
-            catch( EntityFinderException e )
-            {
-                throw new QueryExecutionException( "Finder caused exception", e );
-            }
-        }
-
-        @Override
-        public <T> long count( Class<T> resultType,
-                               Specification<Composite> whereClause,
-                               Iterable<OrderBy> orderBySegments,
-                               Integer firstResult,
-                               Integer maxResults,
-                               Map<String, Object> variables
-        )
-        {
-            final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
-            try
-            {
-                return entityFinder.countEntities( resultType, whereClause, variables == null ? Collections.<String, Object>emptyMap() : variables );
-            }
-            catch( EntityFinderException e )
-            {
-                e.printStackTrace();
-                return 0;
-            }
-        }
-
-        @Override
-        public <T> Iterator<T> iterator( final Class<T> resultType,
-                                         Specification<Composite> whereClause,
-                                         Iterable<OrderBy> orderBySegments,
-                                         Integer firstResult,
-                                         Integer maxResults,
-                                         Map<String, Object> variables
-        )
-        {
-            final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
-            try
-            {
-                final Iterator<EntityReference> foundEntities = entityFinder.findEntities( resultType,
-                                                                                           whereClause,
-                                                                                           Iterables.toArray( OrderBy.class, orderBySegments ),
-                                                                                           firstResult,
-                                                                                           maxResults,
-                                                                                           variables == null ? Collections
-                                                                                               .<String, Object>emptyMap() : variables )
-                    .iterator();
-
-                return new Iterator<T>()
-                {
-                    @Override
-                    public boolean hasNext()
-                    {
-                        return foundEntities.hasNext();
-                    }
-
-                    @Override
-                    public T next()
-                    {
-                        final EntityReference foundEntity = foundEntities.next();
-                        try
-                        {
-                            return moduleUnitOfWork.get( resultType, foundEntity.identity() );
-                        }
-                        catch( NoSuchEntityException e )
-                        {
-                            // Index is out of sync - entity has been removed
-                            return null;
-                        }
-                    }
-
-                    @Override
-                    public void remove()
-                    {
-                        throw new UnsupportedOperationException();
-                    }
-                };
-            }
-            catch( EntityFinderException e )
-            {
-                throw new QueryExecutionException( "Query '" + toString() + "' could not be executed", e );
-            }
-        }
-
-        @Override
-        public String toString()
-        {
-            return "UnitOfWork( " + moduleUnitOfWork.usecase().name() + " )";
-        }
-    }
-
-    private class ToValuePropertyMappingFunction
-        implements Function<PropertyDescriptor, Object>
-    {
-        private Object entity;
-
-        public ToValuePropertyMappingFunction( Object entity )
-        {
-            this.entity = entity;
-        }
-
-        @Override
-        public Object map( PropertyDescriptor propertyDescriptor )
-        {
-            EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
-            return entityState.propertyValueOf( propertyDescriptor.qualifiedName() );
-        }
-    }
-
-    private class ToValueAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, EntityReference>
-    {
-        private final T entity;
-
-        public ToValueAssociationMappingFunction( T entity )
-        {
-            this.entity = entity;
-        }
-
-        @Override
-        public EntityReference map( AssociationDescriptor associationDescriptor )
-        {
-            EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
-            return entityState.associationValueOf( associationDescriptor.qualifiedName() );
-        }
-    }
-
-    private class ToValueManyAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, Iterable<EntityReference>>
-    {
-        private final T entity;
-
-        public ToValueManyAssociationMappingFunction( T entity )
-        {
-            this.entity = entity;
-        }
-
-        @Override
-        public Iterable<EntityReference> map( AssociationDescriptor associationDescriptor )
-        {
-            EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
-            return entityState.manyAssociationValueOf( associationDescriptor.qualifiedName() );
-        }
-    }
-
-    private class ToValueNameAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, Map<String, EntityReference>>
-    {
-        private final T entity;
-
-        public ToValueNameAssociationMappingFunction( T entity )
-        {
-            this.entity = entity;
-        }
-
-        @Override
-        public Map<String, EntityReference> map( AssociationDescriptor associationDescriptor )
-        {
-            Map<String, EntityReference> result = new HashMap<>();
-            EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
-            final NamedAssociationState state = entityState.namedAssociationValueOf( associationDescriptor.qualifiedName() );
-            for( String name : state )
-            {
-                result.put( name, state.get( name ) );
-            }
-            return result;
-        }
-    }
-
-    private class ToEntityPropertyMappingFunction<T>
-        implements Function<PropertyDescriptor, Object>
-    {
-        private final T value;
-
-        public ToEntityPropertyMappingFunction( T value )
-        {
-            this.value = value;
-        }
-
-        @Override
-        public Object map( PropertyDescriptor propertyDescriptor )
-        {
-            StateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
-            Property<Object> property = state.propertyFor( propertyDescriptor.accessor() );
-            return property.get();
-        }
-    }
-
-    private class ToEntityAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, EntityReference>
-    {
-
-        private final T value;
-
-        public ToEntityAssociationMappingFunction( T value )
-        {
-            this.value = value;
-        }
-
-        @Override
-        public EntityReference map( AssociationDescriptor associationDescriptor )
-        {
-            AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
-            AssociationInstance<T> association = (AssociationInstance<T>) state.associationFor( associationDescriptor.accessor() );
-            return association.getAssociationState().get();
-        }
-    }
-
-    private class ToEntityManyAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, Iterable<EntityReference>>
-    {
-
-        private final T value;
-
-        public ToEntityManyAssociationMappingFunction( T valueComposite )
-        {
-            this.value = valueComposite;
-        }
-
-        @Override
-        public Iterable<EntityReference> map( AssociationDescriptor associationDescriptor )
-        {
-            AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
-            ManyAssociationInstance<T> association =
-                (ManyAssociationInstance<T>) state.manyAssociationFor( associationDescriptor.accessor() );
-            return association.getManyAssociationState();
-        }
-    }
-
-    private class ToEntityNameAssociationMappingFunction<T>
-        implements Function<AssociationDescriptor, Map<String, EntityReference>>
-    {
-        private final T value;
-
-        public ToEntityNameAssociationMappingFunction( T valueComposite )
-        {
-            this.value = valueComposite;
-        }
-
-        @Override
-        public Map<String, EntityReference> map( AssociationDescriptor associationDescriptor )
-        {
-            AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
-            NamedAssociationInstance<T> association =
-                (NamedAssociationInstance<T>) state.namedAssociationFor( associationDescriptor.accessor() );
-            HashMap<String, EntityReference> result = new HashMap<>();
-            for( Map.Entry<String, EntityReference> entry : association.getEntityReferences() )
-            {
-                result.put( entry.getKey(), entry.getValue() );
-            }
-            return result;
-        }
-    }
-}


[47/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java b/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java
deleted file mode 100644
index f7828b5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.constraint;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used by composites and mixins to declare what Constraints
- * can be applied in the Composite.
- * <p>
- * Constraints implement the {@link Constraint} interface
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE } )
-@Documented
-public @interface Constraints
-{
-    Class<? extends Constraint<?, ?>>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java
deleted file mode 100644
index 1aa6824..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.constraint;
-
-/**
- * Constraints Descriptor.
- */
-public interface ConstraintsDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/Name.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Name.java b/core/api/src/main/java/org/apache/zest/api/constraint/Name.java
deleted file mode 100644
index 281efcc..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/Name.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.constraint;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation for parameter names. This is used to add extra information for constraint exception.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.PARAMETER } )
-@Documented
-public @interface Name
-{
-    String value();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/constraint/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/package.html b/core/api/src/main/java/org/apache/zest/api/constraint/package.html
deleted file mode 100644
index 2e4d340..0000000
--- a/core/api/src/main/java/org/apache/zest/api/constraint/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Constraint API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/DataSet.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/DataSet.java b/core/api/src/main/java/org/apache/zest/api/dataset/DataSet.java
deleted file mode 100644
index f52a563..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/DataSet.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.api.dataset;
-
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Specification;
-
-/**
- * definition.constrain(entity(Person.class))
- * builder.from(path(Person.class,Movie.))
- * TODO
- */
-public interface DataSet<T>
-{
-    DataSet<T> constrain( Specification<T> selection );
-
-    <U> DataSet<U> project( Function<T, U> conversion );
-
-    Query<T> newQuery();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/DataSetSource.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/DataSetSource.java b/core/api/src/main/java/org/apache/zest/api/dataset/DataSetSource.java
deleted file mode 100644
index ef99c08..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/DataSetSource.java
+++ /dev/null
@@ -1,27 +0,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.
- */
-package org.apache.zest.api.dataset;
-
-/**
- * TODO
- */
-public interface DataSetSource
-{
-    <T> DataSet<T> newDataSet( Class<T> type );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/Query.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/Query.java b/core/api/src/main/java/org/apache/zest/api/dataset/Query.java
deleted file mode 100644
index 53244ac..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/Query.java
+++ /dev/null
@@ -1,64 +0,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.
- */
-package org.apache.zest.api.dataset;
-
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.QueryException;
-import org.apache.zest.api.query.QueryExecutionException;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Visitor;
-
-/**
- * TODO
- */
-public interface Query<T>
-{
-    public enum Order
-    {
-        ASCENDING, DESCENDING
-    }
-
-    Query filter( Specification<T> filter );
-
-    Query orderBy( final Property<?> property, final Order order );
-
-    Query skip( int skipNrOfResults );
-
-    Query limit( int maxNrOfResults );
-
-    // Variables
-    Query<T> setVariable( String name, Object value );
-
-    Object getVariable( String name );
-
-    long count()
-        throws QueryExecutionException;
-
-    T first()
-        throws QueryExecutionException;
-
-    T single()
-        throws QueryException;
-
-    <ThrowableType extends Throwable> boolean execute( Visitor<T, ThrowableType> resultVisitor )
-        throws ThrowableType, QueryExecutionException;
-
-    Iterable<T> toIterable()
-        throws QueryExecutionException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableDataSet.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableDataSet.java b/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableDataSet.java
deleted file mode 100644
index e0d8614..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableDataSet.java
+++ /dev/null
@@ -1,57 +0,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.
- */
-package org.apache.zest.api.dataset.iterable;
-
-import org.apache.zest.api.dataset.DataSet;
-import org.apache.zest.api.dataset.Query;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-/**
- * TODO
- */
-public class IterableDataSet<T>
-    implements DataSet<T>
-{
-    private Iterable<T> iterable;
-
-    public IterableDataSet( Iterable<T> iterable )
-    {
-        this.iterable = iterable;
-    }
-
-    @Override
-    public DataSet<T> constrain( Specification<T> selection )
-    {
-        return new IterableDataSet<T>( Iterables.filter( selection, iterable ) );
-    }
-
-    @Override
-    public <U> DataSet<U> project( Function<T, U> conversion )
-    {
-        return new IterableDataSet<U>( Iterables.map( conversion, iterable ) );
-    }
-
-    @Override
-    public Query<T> newQuery()
-    {
-        return new IterableQuery<T>( iterable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableQuery.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableQuery.java b/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableQuery.java
deleted file mode 100644
index 4c4952a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/IterableQuery.java
+++ /dev/null
@@ -1,127 +0,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.
- */
-package org.apache.zest.api.dataset.iterable;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.dataset.Query;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.query.QueryException;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Visitor;
-
-/**
- * TODO
- */
-public class IterableQuery<T> implements Query<T>
-{
-    private Iterable<T> iterable;
-    private int skip;
-    private int limit;
-    private Map<String, Object> variables = new HashMap<String, Object>();
-
-    public IterableQuery( Iterable<T> iterable )
-    {
-        this.iterable = iterable;
-    }
-
-    @Override
-    public Query filter( Specification<T> filter )
-    {
-        iterable = Iterables.filter( filter, iterable );
-
-        return this;
-    }
-
-    @Override
-    public Query orderBy( Property<?> property, Order order )
-    {
-        return this;
-    }
-
-    @Override
-    public Query skip( int skipNrOfResults )
-    {
-        this.skip = skipNrOfResults;
-
-        return this;
-    }
-
-    @Override
-    public Query limit( int maxNrOfResults )
-    {
-        this.limit = maxNrOfResults;
-        return this;
-    }
-
-    @Override
-    public Query<T> setVariable( String name, Object value )
-    {
-        variables.put( name, value );
-        return this;
-    }
-
-    @Override
-    public Object getVariable( String name )
-    {
-        return variables.get( name );
-    }
-
-    @Override
-    public long count()
-    {
-        return Iterables.count( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
-    }
-
-    @Override
-    public T first()
-    {
-        return Iterables.first( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
-    }
-
-    @Override
-    public T single()
-        throws QueryException
-    {
-        return Iterables.single( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean execute( Visitor<T, ThrowableType> resultVisitor )
-        throws ThrowableType
-    {
-        for( T t : toIterable() )
-        {
-            if( !resultVisitor.visit( t ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    @Override
-    public Iterable<T> toIterable()
-        throws QueryException
-    {
-        return Iterables.limit( limit, Iterables.skip( skip, iterable ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/iterable/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/package.html b/core/api/src/main/java/org/apache/zest/api/dataset/iterable/package.html
deleted file mode 100644
index 9874cb5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/iterable/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Iterable DataSets.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/dataset/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/dataset/package.html b/core/api/src/main/java/org/apache/zest/api/dataset/package.html
deleted file mode 100644
index f324682..0000000
--- a/core/api/src/main/java/org/apache/zest/api/dataset/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>DataSet API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java b/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java
deleted file mode 100644
index 96672b7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.entity;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks an association as aggregating the referenced Entities
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.METHOD } )
-@Documented
-public @interface Aggregated
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java
deleted file mode 100644
index e403d47..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.entity;
-
-import org.apache.zest.api.common.ConstructionException;
-
-/**
- * EntityBuilders are used to instantiate EntityComposites. They can be acquired from
- * {@link org.apache.zest.api.unitofwork.UnitOfWork#newEntityBuilder(Class)} and allows the client
- * to provide additional settings before instantiating the Composite.
- *
- * After calling newInstance() the builder becomes invalid, and may not be called again.
- */
-public interface EntityBuilder<T>
-{
-    /**
-     * Get a representation of the state for the new Composite.
-     * It is possible to access and update properties and associations,
-     * even immutable ones since the builder represents the initial state.
-     *
-     * @return a proxy implementing the Composite type
-     */
-    T instance();
-
-    /**
-     * Get a representation of the state of the given type for the new Composite.
-     * This is primarily used if you want to provide state for a private mixin type.
-     *
-     * @param mixinType the mixin which you want to provide state for
-     *
-     * @return a proxy implementing the given mixin type
-     */
-    <K> K instanceFor( Class<K> mixinType );
-
-    /**
-     * Create a new Entity instance.
-     *
-     * @return a new Entity instance
-     *
-     * @throws org.apache.zest.api.common.ConstructionException
-     *                            thrown if it was not possible to instantiate the Composite
-     * @throws LifecycleException if the entity could not be created
-     */
-    T newInstance()
-        throws ConstructionException, LifecycleException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
deleted file mode 100644
index 56afa2c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.entity;
-
-import org.apache.zest.api.structure.Module;
-
-/**
- * EntityBuilderTemplate.
- */
-public abstract class EntityBuilderTemplate<T>
-{
-    Class<T> type;
-
-    protected EntityBuilderTemplate( Class<T> type )
-    {
-        this.type = type;
-    }
-
-    protected abstract void build( T prototype );
-
-    public T newInstance( Module module )
-    {
-        EntityBuilder<T> builder = module.currentUnitOfWork().newEntityBuilder( type );
-        build( builder.instance() );
-        return builder.newInstance();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java
deleted file mode 100644
index 43492c1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.entity;
-
-import org.apache.zest.api.association.AssociationMixin;
-import org.apache.zest.api.association.ManyAssociationMixin;
-import org.apache.zest.api.association.NamedAssociationMixin;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.mixin.Mixins;
-
-/**
- * EntityComposites are Composites that has mutable state persisted in EntityStores and equality defined from its
- * identity.
- */
-@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } )
-public interface EntityComposite
-    extends Identity, Composite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java
deleted file mode 100644
index c0f0d9c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.entity;
-
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.StatefulCompositeDescriptor;
-
-/**
- * Entity Descriptor.
- */
-public interface EntityDescriptor
-    extends CompositeDescriptor, StatefulCompositeDescriptor
-{
-    @Override
-    AssociationStateDescriptor state();
-
-    boolean queryable();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java
deleted file mode 100644
index 19d9f72..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.entity;
-
-import java.io.Serializable;
-import org.apache.zest.api.util.NullArgumentException;
-
-/**
- * An EntityReference is identity of a specific Entity instance.
- * <p>When stringified, the identity is used as-is. Example:</p>
- * <pre>123456-abcde</pre>
- */
-public final class EntityReference
-    implements Serializable
-{
-    /**
-     * Parse an URI to an EntityReference.
-     * @param uri the URI to parse
-     * @return the EntityReference represented by the given URI
-     */
-    public static EntityReference parseURI( String uri )
-    {
-        String identity = uri.substring( "urn:qi4j:entity:".length() );
-        return new EntityReference( identity );
-    }
-
-    /**
-     * Parse an Entity identity to an EntityReference.
-     * @param identity the EntityReference identity
-     * @return the EntityReference represented by the given identity
-     */
-    public static EntityReference parseEntityReference( String identity )
-    {
-        return new EntityReference( identity );
-    }
-
-    /**
-     * @param object an EntityComposite
-     * @return the EntityReference for the given EntityComposite
-     */
-    public static EntityReference entityReferenceFor( Object object )
-    {
-        return new EntityReference( (EntityComposite) object );
-    }
-
-    public static EntityReference create( Identity identity )
-    {
-        if( identity == null )
-            return null;
-        return new EntityReference( identity.identity().get() );
-    }
-
-    private static final long serialVersionUID = 1L;
-
-    private String identity;
-
-    /**
-     * @param entityComposite a non-null EntityComposite
-     * @throws NullPointerException if entityComposite is null
-     */
-    public EntityReference( EntityComposite entityComposite )
-    {
-        this( entityComposite.identity().get() );
-    }
-
-    /**
-     * @param identity reference identity
-     * @throws NullArgumentException if identity is null or empty
-     */
-    public EntityReference( String identity )
-    {
-        NullArgumentException.validateNotEmpty( "identity", identity );
-        this.identity = identity;
-    }
-
-    /**
-     * @return This EntityReference identity.
-     */
-    public final String identity()
-    {
-        return identity;
-    }
-
-    /**
-     * @return An URI representation of this EntityReference.
-     */
-    public String toURI()
-    {
-        return "urn:qi4j:entity:" + identity;
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        EntityReference that = (EntityReference) o;
-        return identity.equals( that.identity );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return identity.hashCode();
-    }
-
-    /**
-     * @return This EntityReference identity.
-     */
-    @Override
-    public String toString()
-    {
-        return identity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/Identity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Identity.java b/core/api/src/main/java/org/apache/zest/api/entity/Identity.java
deleted file mode 100644
index 06ab004..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/Identity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.entity;
-
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-
-/**
- * This interface provides the identity of the object which may be used
- * to store the state in a database. It is not the responsibility of the
- * framework to come up with a good identity string.
- */
-@Mixins( Identity.IdentityMixin.class )
-public interface Identity
-{
-    /**
-     * Returns the client view of the identity.
-     * <p>
-     * It is unique within the owning repository, but potentially not unique globally and between
-     * types.
-     * </p>
-     * @return The Identity of 'this' composite.
-     */
-    @Immutable
-    Property<String> identity();
-
-    /**
-     * Default Identity implementation.
-     */
-    class IdentityMixin
-        implements Identity
-    {
-        @State
-        private Property<String> identity;
-
-        @Override
-        public Property<String> identity()
-        {
-            return identity;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java b/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java
deleted file mode 100644
index 199e54a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.entity;
-
-/**
- * Generator for identities of EntityComposite's.
- */
-public interface IdentityGenerator
-{
-    /**
-     * Generate a new id for the given Composite type
-     *
-     * @param compositeType the type of composite
-     *
-     * @return a new identity
-     */
-    String generate( Class<?> compositeType );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java b/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java
deleted file mode 100644
index 9d2fc27..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.entity;
-
-/**
- * Lifecycle interface for all Composites.
- * <p>
- * This Lifecycle interface is a built-in feature of the Zest runtime, similar to the Initializable interface.
- * Any Mixin that implements this interface AND is part of an EntityComposite will have these two methods called
- * upon creation/removal of the EntityComposite instance to/from the EntityStore. Meaning, the create method is called
- * only when the identifiable EntityComposite is created the first time, and not when it is read from its persisted
- * state and created into memory.
- * </p>
- * <p>
- * Example;
- * </p>
- * <pre><code>
- * public interface System
- * {
- *     Property&lt;User&gt; admin();
- * }
- *
- * public class SystemAdminMixin&lt;LifeCycle&gt;
- *     implements System, Lifecyle, ...
- * {
- *      &#64;Structure private UnitOfWork uow;
- *      &#64;This private Identity meAsIdentity;
- *
- *      public void create()
- *      {
- *          String thisId = meAsIdentity.identity().get();
- *          EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class );
- *          User admin = builder.newInstance();
- *          admin.set( admin );
- *      }
- *
- *      public void remove()
- *      {
- *          uow.remove( admin.get() );
- *      }
- * }
- *
- * &#64;Mixins( SystemAdminMixin.class )
- * public interface SystemEntity extends System, EntityComposite
- * {}
- *
- * </code></pre>
- */
-public interface Lifecycle
-{
-
-    /**
-     * Creation callback method.
-     * <p>
-     * Called by the Zest runtime before the newInstance of the entity completes, before the constraints are checked,
-     * allowing for additional initialization.
-     * </p>
-     * @throws LifecycleException if the entity could not be created
-     */
-    void create()
-        throws LifecycleException;
-
-    /**
-     * Removal callback method.
-     * <p>
-     * Called by the Zest runtime before the entity is removed from the system, allowing
-     * for clean-up operations.
-     * </p>
-     * @throws LifecycleException if the entity could not be removed
-     */
-    void remove()
-        throws LifecycleException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java b/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java
deleted file mode 100644
index 15189cd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.entity;
-
-/**
- * Thrown by methods of Lifecycle if invocation fails
- */
-public class LifecycleException
-    extends RuntimeException
-{
-    public LifecycleException( String s )
-    {
-        super( s );
-    }
-
-    public LifecycleException( String s, Throwable throwable )
-    {
-        super( s, throwable );
-    }
-
-    public LifecycleException( Throwable throwable )
-    {
-        super( throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java b/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java
deleted file mode 100644
index 8bd7c6c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2008, Alin Dreghiciu. 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.zest.api.entity;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used to mark entity types or properties/associations that are indexable.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface Queryable
-{
-    boolean value() default true;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/entity/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/package.html b/core/api/src/main/java/org/apache/zest/api/entity/package.html
deleted file mode 100644
index 0386d8c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/entity/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Entity API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/event/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/event/package.html b/core/api/src/main/java/org/apache/zest/api/event/package.html
deleted file mode 100644
index a5ed0a7..0000000
--- a/core/api/src/main/java/org/apache/zest/api/event/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Event API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java b/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java
deleted file mode 100644
index f2b3642..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This is used to annotate annotation types which are used for injection.
- * Each scope signifies a particular scope from which the injection value should be taken.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.ANNOTATION_TYPE } )
-@Documented
-public @interface InjectionScope
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/package.html b/core/api/src/main/java/org/apache/zest/api/injection/package.html
deleted file mode 100644
index c41b495..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Dependency Injection API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java
deleted file mode 100644
index df1742f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a
- * invocation specific resource.
- * These include:
- * <pre><code>
- *  - The Method being invoked.
- *
- *  - An AnnotationElement with annotations
- *    from both mixin type, mixin
- *    implementation.
- *
- *  - An Annotation of a specific type
- * </code></pre>
- * Examples:
- * <pre><code>
- * &#64;Invocation Method theInvokedMethod
- * &#64;Invocation AnnotationElement annotations
- * &#64;Invocation Matches matchesAnnotation
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface Invocation
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java
deleted file mode 100644
index e636497..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a service dependency into a Fragment.
- * <p>
- * Examples:
- * </p>
- * <pre><code>
- * &#64;Service MyService service
- * &#64;Service Iterable&lt;MyService&gt; services
- * &#64;Service ServiceReference&lt;MyService&gt; serviceRef
- * &#64;Service Iterable&lt;ServiceReference&lt;MyService&gt;&gt; serviceRefs
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface Service
-{
-}
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java
deleted file mode 100644
index 9645600..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a property, association or
- * StateHolder.
- * <pre><code>
- * &#64;State Property&lt;StringState propertyName;
- * &#64;State Association&lt;MyEntityState associationName;
- * &#64;State ManyAssociation&lt;MyEntityState manyAssociationName;
- * &#64;State NamedAssociation&lt;MyEntityState namedAssociationName;
- * &#64;State StateHolder state;
- * &#64;State AssociationStateHolder associationState;
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface State
-{
-    /**
-     * Name of the property or association.
-     * If not set then name will be name of field.
-     *
-     * @return the name
-     */
-    public abstract String value() default "";
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java
deleted file mode 100644
index 7f1322f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a
- * resource specific for the module which the
- * injected object/fragment is instantiated in.
- * <p>
- * Valid types are:
- * </p>
- * <pre><code>
- * - TransientBuilderFactory
- * - ObjectBuilderFactory
- * - UnitOfWorkFactory
- * - ServiceFinder
- * - Module
- * - Layer
- * - Application
- * - Qi4j
- * - Qi4jSPI
- * </code></pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface Structure
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java
deleted file mode 100644
index d91e319..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a reference to the same Composite
- * as the fragment is a part of.
- * <p>
- * If the Composite type does not implement the type of the field or parameter
- * then it will be referencing a private mixin.
- * </p>
- * <p>
- * Calls to the reference will have the same semantics as calls to the Composite itself.
- * Specifically the same set of Modifiers will be used.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.FIELD, ElementType.PARAMETER } )
-@Documented
-@InjectionScope
-public @interface This
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java
deleted file mode 100644
index d6de357..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.injection.scope;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * Annotation to denote the injection of a dependency to be used by a Mixin. The injected
- * object is provided either by the TransientBuilder.uses() declarations, or if an instance of the appropriate types is not
- * found, then a new Transient or Object is instantiated.
- * Call {@link org.apache.zest.api.composite.TransientBuilder#use} to provide the instance
- * to be injected.
- *
- * Example:
- * <pre>@Uses SomeType someInstance</pre>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.PARAMETER, ElementType.FIELD } )
-@Documented
-@InjectionScope
-public @interface Uses
-{
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html b/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html
deleted file mode 100644
index b0ec496..0000000
--- a/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Dependency Injection Scopes.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java b/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java
deleted file mode 100644
index 44c1c9b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Marker interface for all Metric types.
- */
-public interface Metric
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java
deleted file mode 100644
index 9bd1392..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Metrics Counter.
- */
-public interface MetricsCounter extends Metric
-{
-    void increment();
-
-    void increment( int steps );
-
-    void decrement();
-
-    void decrement( int steps );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounterFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounterFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounterFactory.java
deleted file mode 100644
index ac1e7fe..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounterFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Create MetricsCounter instances.
- */
-public interface MetricsCounterFactory extends MetricsFactory
-{
-    /**
-     * Create a MetricsCounter instance.
-     * If the same arguments are given twice, the same instance must be returned.
-     *
-     * @param origin The class that instantiate the metric
-     * @param name   A human readable, short name of the metric.
-     *
-     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
-     */
-    MetricsCounter createCounter( Class<?> origin, String name );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsFactory.java
deleted file mode 100644
index 7e36034..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Metrics Factory.
- */
-public interface MetricsFactory
-{
-    Iterable<Metric> registered();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGauge.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGauge.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGauge.java
deleted file mode 100644
index 34aa4ca..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGauge.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * MetricsGauge is the most basic Metric type, and is completely flexible and therefor handled slightly differently in
- * the MetricsFactory than all other Gauges. It needs to pass on custom code, so the implementation is typically
- * an anonymous class, inlined at the implementation.
- *
- * @param <T> Any type holding the MetricsGauge's current value.
- */
-public interface MetricsGauge<T> extends Metric
-{
-    /**
-     * Returns the metric's current value.
-     *
-     * @return the metric's current value
-     */
-    T value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGaugeFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGaugeFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGaugeFactory.java
deleted file mode 100644
index 8e4ec95..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsGaugeFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Register MetricsGauge with the underlying Metrics system.
- */
-public interface MetricsGaugeFactory extends MetricsFactory
-{
-    /**
-     * Register a MetricsGauge with the underlying Metrics system.
-     *
-     * @param origin The class where the MetricsGauge is created.
-     * @param name   A human readable, short name of the metric.
-     * @param gauge  The implementation of the MetricsGauge.
-     * @param <T>    Any type holding the MetricsGauge's current value.
-     *
-     * @return The same MetricsGauge or the DefaultMetric.NULL MetricsGauge instance.
-     */
-    <T> MetricsGauge<T> registerGauge( Class<?> origin, String name, MetricsGauge<T> gauge );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheck.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheck.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheck.java
deleted file mode 100644
index c5d39d4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheck.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Metrics Health Check.
- */
-public interface MetricsHealthCheck extends Metric
-{
-    Result check()
-        throws Exception;
-
-    public final class Result
-    {
-        private final boolean healthy;
-        private final String message;
-        private final Throwable exception;
-
-        public Result( boolean isHealthy, String message, Throwable exception )
-        {
-            healthy = isHealthy;
-            this.message = message;
-            this.exception = exception;
-        }
-
-        public boolean isHealthy()
-        {
-            return healthy;
-        }
-
-        public String getMessage()
-        {
-            return message;
-        }
-
-        public Throwable getException()
-        {
-            return exception;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheckFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheckFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheckFactory.java
deleted file mode 100644
index efb2d03..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHealthCheckFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Create MetricsHealthCheck instances.
- */
-public interface MetricsHealthCheckFactory extends MetricsFactory
-{
-    /**
-     * Create a MetricsHealthCheck instance.
-     * If the same arguments are given twice, the same instance must be returned.
-     *
-     * @param origin The class that instantiate the metric
-     * @param name   A human readable, short name of the metric.
-     * @param check  The health check to be performed regularly.
-     *
-     * @return A MetricsHealthCheck instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
-     *
-     */
-    MetricsHealthCheck registerHealthCheck( Class<?> origin, String name, MetricsHealthCheck check );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogram.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogram.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogram.java
deleted file mode 100644
index 92fda33..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogram.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * A metric which calculates the distribution of a value.
- *
- * @see <a href="http://www.johndcook.com/standard_deviation.html">Accurately computing running
- *      variance</a>
- */
-public interface MetricsHistogram extends Metric
-{
-    void update( long newValue );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogramFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogramFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogramFactory.java
deleted file mode 100644
index 78cbbea..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsHistogramFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * Create MetricsHistogram instances.
- */
-public interface MetricsHistogramFactory extends MetricsFactory
-{
-    /**
-     * Create a MetricsHistogram instance.
-     * If the same arguments are given twice, the same instance must be returned.
-     *
-     * @param origin The class that instantiate the metric
-     * @param name   A human readable, short name of the metric.
-     *
-     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
-     *
-     */
-    MetricsHistogram createHistogram( Class<?> origin, String name );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeter.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeter.java
deleted file mode 100644
index d254d96..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-/**
- * A meter metric which measures mean throughput and one-, five-, and fifteen-minute
- * exponentially-weighted moving average throughputs.
- *
- * @see <a href="http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average">EMA</a>
- */
-public interface MetricsMeter extends Metric
-{
-    void mark();
-
-    /**
-     * Mark the occurrence of a given number of events.
-     *
-     * @param numberOfEvents the number of events
-     */
-    void mark( int numberOfEvents );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeterFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeterFactory.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeterFactory.java
deleted file mode 100644
index 6deb83c..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsMeterFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.metrics;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Create MetricsMeter instances.
- */
-public interface MetricsMeterFactory extends MetricsFactory
-{
-    /**
-     * Create a MetricsMeter instance.
-     * If the same arguments are given twice, the same instance must be returned.
-     *
-     * @param origin    The class that instantiate the metric
-     * @param name      A human readable, short name of the metric.
-     * @param eventType the plural name of the event the meter is measuring (e.g., {@code "requests"})
-     * @param rate      the scale unit for this timer's rate metrics
-     *
-     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
-     */
-    MetricsMeter createMeter( Class<?> origin, String name, String eventType, TimeUnit rate );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/metrics/MetricsNotSupportedException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsNotSupportedException.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsNotSupportedException.java
deleted file mode 100644
index 3f0dd0f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsNotSupportedException.java
+++ /dev/null
@@ -1,32 +0,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.
- */
-package org.apache.zest.api.metrics;
-
-/**
- * Thrown when the underlying MetricsProvider do not support a Metric type.
- */
-public class MetricsNotSupportedException extends RuntimeException
-{
-    public MetricsNotSupportedException( Class<? extends MetricsFactory> factoryType,
-                                         Class<? extends MetricsProvider> providerType
-    )
-    {
-        super( "Metrics [" + factoryType.getName() + "] is not supported by MetricsProvider [" + providerType.getName() + "]." );
-    }
-}


[11/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
deleted file mode 100644
index aa45b18..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Niclas Hedhman. 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.zest.runtime.entity;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.unitofwork.EntityCompositeAlreadyExistsException;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.CompositeModel;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entitystore.EntityAlreadyExistsException;
-import org.apache.zest.spi.entitystore.EntityStoreException;
-import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * JAVADOC
- */
-public final class EntityModel
-    extends CompositeModel
-    implements EntityDescriptor
-{
-    private static final Method IDENTITY_METHOD;
-
-    static
-    {
-        try
-        {
-            IDENTITY_METHOD = Identity.class.getMethod( "identity" );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
-        }
-    }
-
-    private final boolean queryable;
-
-    public EntityModel( Iterable<Class<?>> types,
-                        Visibility visibility,
-                        MetaInfo info,
-                        EntityMixinsModel mixinsModel,
-                        EntityStateModel stateModel,
-                        CompositeMethodsModel compositeMethodsModel
-    )
-    {
-        super( types, visibility, info, mixinsModel, stateModel, compositeMethodsModel );
-
-        final Queryable queryable = first( Iterables.<Queryable>cast(
-            filter( Annotations.isType( Queryable.class ),
-                    flattenIterables( map( Annotations.ANNOTATIONS_OF, types ) ) ) ) );
-        this.queryable = queryable == null || queryable.value();
-    }
-
-    @Override
-    public boolean queryable()
-    {
-        return queryable;
-    }
-
-    @Override
-    public EntityStateModel state()
-    {
-        return (EntityStateModel) super.state();
-    }
-
-    public EntityInstance newInstance( ModuleUnitOfWork uow, ModuleSpi moduleInstance, EntityState state )
-    {
-        EntityInstance instance = new EntityInstance( uow, moduleInstance, this, state );
-        return instance;
-    }
-
-    public Object[] newMixinHolder()
-    {
-        return mixinsModel.newMixinHolder();
-    }
-
-    public Object newMixin( Object[] mixins,
-                            EntityStateInstance entityState,
-                            EntityInstance entityInstance,
-                            Method method
-    )
-    {
-        return ( (EntityMixinsModel) mixinsModel ).newMixin( entityInstance, entityState, mixins, method );
-    }
-
-    public EntityState newEntityState( EntityStoreUnitOfWork store, ModuleSpi module, EntityReference identity )
-        throws ConstraintViolationException, EntityStoreException
-    {
-        try
-        {
-            // New EntityState
-            EntityState entityState = store.newEntityState( module, identity, this );
-
-            // Set identity property
-            PropertyDescriptor persistentPropertyDescriptor = state().propertyModelFor( IDENTITY_METHOD );
-            entityState.setPropertyValue( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
-
-            return entityState;
-        }
-        catch( EntityAlreadyExistsException e )
-        {
-            throw new EntityCompositeAlreadyExistsException( identity );
-        }
-        catch( EntityStoreException e )
-        {
-            throw new ConstructionException( "Could not create new entity in store", e );
-        }
-    }
-
-    public void initState( ModuleSpi module, EntityState entityState )
-    {
-        // Set new properties to default value
-        for( PropertyModel propertyDescriptor : state().properties() )
-        {
-            entityState.setPropertyValue( propertyDescriptor.qualifiedName(), propertyDescriptor.initialValue( module ) );
-        }
-
-        // Set new associations to null
-        for( AssociationDescriptor associationDescriptor : state().associations() )
-        {
-            entityState.setAssociationValue( associationDescriptor.qualifiedName(), null );
-        }
-
-        // Set new many-associations to empty
-        for( AssociationDescriptor associationDescriptor : state().manyAssociations() )
-        {
-            entityState.manyAssociationValueOf( associationDescriptor.qualifiedName() );
-        }
-
-        // Set new named-associations to empty
-        for( AssociationDescriptor associationDescriptor : state().namedAssociations() )
-        {
-            entityState.namedAssociationValueOf( associationDescriptor.qualifiedName() );
-        }
-    }
-
-    public void invokeLifecycle( boolean create, Object[] mixins, CompositeInstance instance, StateHolder state )
-    {
-        ( (EntityMixinsModel) mixinsModel ).invokeLifecycle( create, mixins, instance, state );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityPropertyInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityPropertyInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityPropertyInstance.java
deleted file mode 100644
index 5ac473f..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityPropertyInstance.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Edward Yakop. 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.zest.runtime.entity;
-
-import org.apache.zest.runtime.property.PropertyInfo;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * {@code EntityPropertyInstance} represents a property whose value must be backed by an EntityState.
- */
-public class EntityPropertyInstance<T>
-    extends PropertyInstance<T>
-{
-    private final EntityState entityState;
-
-    /**
-     * Construct an instance of {@code PropertyInstance} with the specified arguments.
-     *
-     * @param aPropertyInfo The property info. This argument must not be {@code null}.
-     * @param entityState EntityState
-     */
-    @SuppressWarnings( "unchecked" )
-    public EntityPropertyInstance( PropertyInfo aPropertyInfo, EntityState entityState )
-    {
-        super( aPropertyInfo, (T) entityState.propertyValueOf( aPropertyInfo.qualifiedName() ) );
-        this.entityState = entityState;
-    }
-
-    /**
-     * Sets this property value.
-     *
-     * @param aNewValue The new value.
-     */
-    @Override
-    public void set( T aNewValue )
-    {
-        super.set( aNewValue );
-        entityState.setPropertyValue( model.qualifiedName(), aNewValue );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
deleted file mode 100644
index fe528b3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.entity;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Function2;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.association.AssociationInstance;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationInstance;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationInstance;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.composite.ConstraintsCheck;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.unitofwork.BuilderEntityState;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * TODO
- */
-public final class EntityStateInstance
-    implements AssociationStateHolder
-{
-    private Map<AccessibleObject, Object> state;
-
-    private final EntityStateModel stateModel;
-    private EntityState entityState;
-    private final Function2<EntityReference, Type, Object> entityFunction;
-
-    public EntityStateInstance( EntityStateModel stateModel, final UnitOfWork uow, EntityState entityState )
-    {
-        this.stateModel = stateModel;
-        this.entityState = entityState;
-
-        entityFunction = new Function2<EntityReference, Type, Object>()
-        {
-            @Override
-            public Object map( EntityReference entityReference, Type type )
-            {
-                return uow.get( Classes.RAW_CLASS.map( type ), entityReference.identity() );
-            }
-        };
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> Property<T> propertyFor( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        Map<AccessibleObject, Object> state = state();
-
-        Property<T> property = (Property<T>) state.get( accessor );
-
-        if( property == null )
-        {
-            PropertyModel entityPropertyModel = stateModel.propertyModelFor( accessor );
-            property = new EntityPropertyInstance<>(
-                entityState instanceof BuilderEntityState
-                ? entityPropertyModel.getBuilderInfo()
-                : entityPropertyModel,
-                entityState );
-            state.put( accessor, property );
-        }
-
-        return property;
-    }
-
-    @Override
-    public Iterable<Property<?>> properties()
-    {
-        return Iterables.map( new Function<PropertyDescriptor, Property<?>>()
-        {
-            @Override
-            public Property<?> map( PropertyDescriptor propertyDescriptor )
-            {
-                return propertyFor( propertyDescriptor.accessor() );
-            }
-        }, stateModel.properties() );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> Association<T> associationFor( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        Map<AccessibleObject, Object> state = state();
-        Association<T> association = (Association<T>) state.get( accessor );
-
-        if( association == null )
-        {
-            final AssociationModel associationModel = stateModel.getAssociation( accessor );
-            association = new AssociationInstance<>(
-                entityState instanceof BuilderEntityState
-                ? associationModel.getBuilderInfo()
-                : associationModel,
-                entityFunction,
-                new Property<EntityReference>()
-            {
-                @Override
-                public EntityReference get()
-                {
-                    return entityState.associationValueOf( associationModel.qualifiedName() );
-                }
-
-                @Override
-                public void set( EntityReference newValue )
-                    throws IllegalArgumentException, IllegalStateException
-                {
-                    entityState.setAssociationValue( associationModel.qualifiedName(), newValue );
-                }
-            } );
-            state.put( accessor, association );
-        }
-
-        return association;
-    }
-
-    @Override
-    public Iterable<Association<?>> allAssociations()
-    {
-        return Iterables.map( new Function<AssociationDescriptor, Association<?>>()
-        {
-            @Override
-            public Association<?> map( AssociationDescriptor associationDescriptor )
-            {
-                return associationFor( associationDescriptor.accessor() );
-            }
-        }, stateModel.associations() );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> ManyAssociation<T> manyAssociationFor( AccessibleObject accessor )
-    {
-        Map<AccessibleObject, Object> state = state();
-
-        ManyAssociation<T> manyAssociation = (ManyAssociation<T>) state.get( accessor );
-
-        if( manyAssociation == null )
-        {
-            ManyAssociationModel associationModel = stateModel.getManyAssociation( accessor );
-            manyAssociation = new ManyAssociationInstance<>(
-                entityState instanceof BuilderEntityState
-                ? associationModel.getBuilderInfo()
-                : associationModel,
-                entityFunction,
-                entityState.manyAssociationValueOf( associationModel.qualifiedName() ) );
-            state.put( accessor, manyAssociation );
-        }
-
-        return manyAssociation;
-    }
-
-    @Override
-    public Iterable<ManyAssociation<?>> allManyAssociations()
-    {
-        return Iterables.map( new Function<AssociationDescriptor, ManyAssociation<?>>()
-        {
-            @Override
-            public ManyAssociation<?> map( AssociationDescriptor associationDescriptor )
-            {
-                return manyAssociationFor( associationDescriptor.accessor() );
-            }
-        }, stateModel.manyAssociations() );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> NamedAssociation<T> namedAssociationFor( AccessibleObject accessor )
-    {
-        Map<AccessibleObject, Object> state = state();
-
-        NamedAssociation<T> namedAssociation = (NamedAssociation<T>) state.get( accessor );
-
-        if( namedAssociation == null )
-        {
-            NamedAssociationModel associationModel = stateModel.getNamedAssociation( accessor );
-            namedAssociation = new NamedAssociationInstance<>(
-                entityState instanceof BuilderEntityState
-                ? associationModel.getBuilderInfo()
-                : associationModel,
-                entityFunction,
-                entityState.namedAssociationValueOf( associationModel.qualifiedName() ) );
-            state.put( accessor, namedAssociation );
-        }
-
-        return namedAssociation;
-    }
-
-    @Override
-    public Iterable<? extends NamedAssociation<?>> allNamedAssociations()
-    {
-        return Iterables.map( new Function<AssociationDescriptor, NamedAssociation<?>>()
-        {
-            @Override
-            public NamedAssociation<?> map( AssociationDescriptor associationDescriptor )
-            {
-                return namedAssociationFor( associationDescriptor.accessor() );
-            }
-        }, stateModel.namedAssociations() );
-    }
-
-    public void checkConstraints()
-    {
-        for( PropertyDescriptor propertyDescriptor : stateModel.properties() )
-        {
-            ConstraintsCheck constraints = (ConstraintsCheck) propertyDescriptor;
-            Property<Object> property = this.propertyFor( propertyDescriptor.accessor() );
-            constraints.checkConstraints( property.get() );
-        }
-
-        for( AssociationDescriptor associationDescriptor : stateModel.associations() )
-        {
-            ConstraintsCheck constraints = (ConstraintsCheck) associationDescriptor;
-            Association<Object> association = this.associationFor( associationDescriptor.accessor() );
-            constraints.checkConstraints( association.get() );
-        }
-
-        // TODO Should ManyAssociations and NamedAssociations be checked too?
-    }
-
-    private Map<AccessibleObject, Object> state()
-    {
-        if( state == null )
-        {
-            state = new HashMap<>();
-        }
-
-        return state;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateModel.java
deleted file mode 100644
index 8b9b56e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateModel.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.entity;
-
-import java.lang.reflect.AccessibleObject;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.property.PropertiesModel;
-
-/**
- * Model for EntityComposite state.
- */
-public final class EntityStateModel
-    extends StateModel
-    implements AssociationStateDescriptor
-{
-    private final AssociationsModel associationsModel;
-    private final ManyAssociationsModel manyAssociationsModel;
-    private final NamedAssociationsModel namedAssociationsModel;
-
-    public EntityStateModel( PropertiesModel propertiesModel,
-                             AssociationsModel associationsModel,
-                             ManyAssociationsModel manyAssociationsModel,
-                             NamedAssociationsModel namedAssociationsModel )
-    {
-        super( propertiesModel );
-        this.associationsModel = associationsModel;
-        this.manyAssociationsModel = manyAssociationsModel;
-        this.namedAssociationsModel = namedAssociationsModel;
-    }
-
-    public AssociationModel getAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        return associationsModel.getAssociation( accessor );
-    }
-
-    @Override
-    public AssociationDescriptor getAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        return associationsModel.getAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        return associationsModel.getAssociationByQualifiedName( name );
-    }
-
-    public ManyAssociationModel getManyAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        return manyAssociationsModel.getManyAssociation( accessor );
-    }
-
-    @Override
-    public AssociationDescriptor getManyAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        return manyAssociationsModel.getManyAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        return manyAssociationsModel.getManyAssociationByQualifiedName( name );
-    }
-
-    public NamedAssociationModel getNamedAssociation( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        return namedAssociationsModel.getNamedAssociation( accessor );
-    }
-
-    @Override
-    public AssociationDescriptor getNamedAssociationByName( String name )
-        throws IllegalArgumentException
-    {
-        return namedAssociationsModel.getNamedAssociationByName( name );
-    }
-
-    @Override
-    public AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
-        throws IllegalArgumentException
-    {
-        return namedAssociationsModel.getNamedAssociationByQualifiedName( name );
-    }
-
-    @Override
-    public Iterable<AssociationModel> associations()
-    {
-        return associationsModel.associations();
-    }
-
-    @Override
-    public Iterable<ManyAssociationModel> manyAssociations()
-    {
-        return manyAssociationsModel.manyAssociations();
-    }
-
-    @Override
-    public Iterable<NamedAssociationModel> namedAssociations()
-    {
-        return namedAssociationsModel.namedAssociations();
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            if( ( (VisitableHierarchy<Object, Object>) propertiesModel ).accept( visitor ) )
-            {
-                if( ( (VisitableHierarchy<AssociationsModel, AssociationModel>) associationsModel ).accept( visitor ) )
-                {
-                    if( ( (VisitableHierarchy<ManyAssociationsModel, ManyAssociationModel>) manyAssociationsModel ).accept( visitor ) )
-                    {
-                        ( (VisitableHierarchy<NamedAssociationsModel, NamedAssociationModel>) namedAssociationsModel ).accept( visitor );
-                    }
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/Dependencies.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/Dependencies.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/Dependencies.java
deleted file mode 100644
index f2b3cf5..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/Dependencies.java
+++ /dev/null
@@ -1,38 +0,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.
- */
-package org.apache.zest.runtime.injection;
-
-import org.apache.zest.functional.Function;
-
-/**
- * TODO
- */
-public interface Dependencies
-{
-    public static Function<Dependencies, Iterable<DependencyModel>> DEPENDENCIES_FUNCTION = new Function<Dependencies, Iterable<DependencyModel>>()
-    {
-        @Override
-        public Iterable<DependencyModel> map( Dependencies dependencies )
-        {
-            return dependencies.dependencies();
-        }
-    };
-
-    Iterable<DependencyModel> dependencies();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java
deleted file mode 100644
index 8ceecba..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/DependencyModel.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.Collections;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.composite.DependencyDescriptor;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.runtime.injection.provider.InjectionProviderException;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.api.util.Annotations.isType;
-import static org.apache.zest.functional.Iterables.iterable;
-
-/**
- * JAVADOC
- * move all the extraction code to a TypeUtils class
- */
-public final class DependencyModel
-    implements Binder, DependencyDescriptor, Visitable<DependencyModel>
-{
-    public static boolean isOptional( Annotation injectionAnnotation, Annotation[] annotations )
-    {
-        if( Iterables.matchesAny( isType( Optional.class ), iterable( annotations ) ) )
-        {
-            return true;
-        }
-
-        Method[] methods = injectionAnnotation.annotationType().getMethods();
-        for( Method method : methods )
-        {
-            if( method.getName().equals( "optional" ) )
-            {
-                try
-                {
-                    return (Boolean) method.invoke( injectionAnnotation );
-                }
-                catch( Throwable e )
-                {
-                    return false;
-                }
-            }
-        }
-
-        return false;
-    }
-
-    // Model
-    private final Annotation injectionAnnotation;
-    private final Type injectionType;
-    private final Class<?> injectedClass;
-    private final Class<?> rawInjectionClass;
-    private final boolean optional;
-    private final Annotation[] annotations;
-
-    // Binding
-    private InjectionProvider injectionProvider;
-
-    public DependencyModel( Annotation injectionAnnotation,
-                            Type genericType,
-                            Class<?> injectedClass,
-                            boolean optional,
-                            Annotation[] annotations
-    )
-    {
-        this.injectionAnnotation = injectionAnnotation;
-        this.injectedClass = injectedClass;
-
-        this.injectionType = genericType;
-        this.optional = optional;
-        this.annotations = annotations;
-        this.rawInjectionClass = mapPrimitiveTypes( extractRawInjectionClass( injectedClass, injectionType ) );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( Visitor<? super DependencyModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        return visitor.visit( this );
-    }
-
-    private Class<?> extractRawInjectionClass( Class<?> injectedClass, final Type injectionType )
-    {
-        // Calculate raw injection type
-        if( injectionType instanceof Class )
-        {
-            return (Class<?>) injectionType;
-        }
-        else if( injectionType instanceof ParameterizedType )
-        {
-            return (Class<?>) ( (ParameterizedType) injectionType ).getRawType();
-        }
-        else if( injectionType instanceof TypeVariable )
-        {
-            return extractRawInjectionClass( injectedClass, (TypeVariable<?>) injectionType );
-        }
-        throw new IllegalArgumentException(
-            "Could not extract the rawInjectionClass of " + injectedClass + " and " + injectionType );
-    }
-
-    private Class<?> extractRawInjectionClass( Class<?> injectedClass, TypeVariable<?> injectionTypeVariable )
-    {
-        int index = 0;
-        for( TypeVariable<?> typeVariable : injectionTypeVariable.getGenericDeclaration().getTypeParameters() )
-        {
-            if( injectionTypeVariable.getName().equals( typeVariable.getName() ) )
-            {
-                return (Class<?>) getActualType( injectedClass, index );
-            }
-            index++;
-        }
-        throw new IllegalArgumentException(
-            "Could not extract the rawInjectionClass of " + injectedClass + " and " + injectionTypeVariable );
-    }
-
-    // todo continue refactoring
-
-    private Type getActualType( Class<?> injectedClass, int index )
-    {
-        // Type index found - map it to actual type
-        Type genericType = injectedClass;
-        Type type = null;
-
-        while( !Object.class.equals( genericType ) && type == null )
-        {
-            genericType = ( (Class<?>) genericType ).getGenericSuperclass();
-            if( genericType instanceof ParameterizedType )
-            {
-                type = ( (ParameterizedType) genericType ).getActualTypeArguments()[ index ];
-            }
-            else
-            {
-                Type[] genericInterfaces = ( (Class<?>) genericType ).getGenericInterfaces();
-                if( genericInterfaces.length > index )
-                {
-                    type = genericInterfaces[ index ];
-                    if( type instanceof ParameterizedType )
-                    {
-                        type = ( (ParameterizedType) type ).getActualTypeArguments()[ index ];
-                    }
-                    // TODO type may still be one of the generic interfaces???
-                }
-            }
-        }
-
-        if( type == null )
-        {
-            type = Object.class; // Generic type with no constraints so Object is fine
-        }
-
-        return type;
-    }
-
-    // FIXME This method is unused, remove it.
-    private Type extractDependencyType( Type injectionType )
-    {
-        if( injectionType instanceof ParameterizedType )
-        {
-            return ( (ParameterizedType) injectionType ).getActualTypeArguments()[ 0 ];
-        }
-        else if( injectionType instanceof TypeVariable )
-        {
-            return ( (TypeVariable) injectionType ).getBounds()[ 0 ];
-        }
-        return injectionType;
-    }
-
-    // Model
-    @Override
-    public Annotation injectionAnnotation()
-    {
-        return injectionAnnotation;
-    }
-
-    @Override
-    public Type injectionType()
-    {
-        return injectionType;
-    }
-
-    @Override
-    public Class<?> injectedClass()
-    {
-        return injectedClass;
-    }
-
-    /**
-     * Get the raw dependency type.
-     * <p>
-     * If the dependency uses generics this is the raw type,
-     * and otherwise it is the type of the field.
-     * <p>
-     * Examples:
-     * <p>
-     * {@code @Service MyService service} -&gt; MyService
-     * <p>
-     * {@code @Entity Iterable<Foo> fooList} -&gt; Iterable
-     * <p>
-     * {@code @Entity Query<Foo> fooQuery} -&gt; Query
-     *
-     * @return raw injection type.
-     */
-    @Override
-    public Class<?> rawInjectionType()
-    {
-        return rawInjectionClass;
-    }
-
-    @Override
-    public boolean optional()
-    {
-        return optional;
-    }
-
-    @Override
-    public Annotation[] annotations()
-    {
-        return annotations;
-    }
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        InjectionProviderFactory providerFactory = resolution.application().injectionProviderFactory();
-
-        try
-        {
-            injectionProvider = providerFactory.newInjectionProvider( resolution, this );
-
-            if( injectionProvider == null && !optional )
-            {
-                String message =
-                    "[Module " + resolution.module()
-                        .name() + "] Non-optional @" + rawInjectionClass.getName() + " was not bound in " + injectedClass
-                        .getName();
-                throw new ConstructionException( message );
-            }
-        }
-        catch( InvalidInjectionException e )
-        {
-            throw new BindingException( "Could not bind dependency injection", e );
-        }
-    }
-
-    // Context
-    public Object inject( InjectionContext context )
-    {
-        if( injectionProvider == null )
-        {
-            return null;
-        }
-        Object injectedValue;
-        try
-        {
-            injectedValue = injectionProvider.provideInjection( context );
-        }
-        catch( InjectionProviderException e )
-        {
-            Throwable ex = e;
-            if( ex.getCause() != null )
-            {
-                ex = ex.getCause();
-            }
-
-            String message = "[Module " + context.module().name() + "] InjectionProvider unable to resolve @" +
-                             injectionAnnotation.annotationType().getSimpleName() + " " + injectionType.toString();
-            throw new ConstructionException( message, ex );
-        }
-        if( injectedValue == null && !optional )
-        {
-            String simpleName = injectionAnnotation.annotationType().getSimpleName();
-            String message = "[Module " + context.module().name() + "] Non-optional @" +
-                             simpleName + " " + injectionType.toString() +
-                             " was null in " + injectedClass.getName();
-            if( simpleName.toLowerCase().contains( "service" ) )
-            {
-                message = message + ". Did you mean the @Service injection scope?";
-            }
-            throw new ConstructionException( message );
-        }
-        return getInjectedValue( injectedValue );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Object getInjectedValue( Object injectionResult )
-    {
-        if( injectionResult == null )
-        {
-            return null;
-        }
-
-        if( injectionResult instanceof Iterable )
-        {
-            if( Iterable.class.isAssignableFrom( rawInjectionClass ) || rawInjectionClass.isInstance(
-                injectionResult ) )
-            {
-                return injectionResult;
-            }
-            else
-            {
-                return Iterables.first( (Iterable) injectionResult );
-            }
-        }
-        else
-        {
-            if( Iterable.class.equals( injectionType ) )
-            {
-                return Collections.singleton( injectionResult );
-            }
-        }
-        return injectionResult;
-    }
-
-    private final static Class<?>[] primitiveTypeMapping = {
-        boolean.class, Boolean.class,
-        byte.class, Byte.class,
-        short.class, Short.class,
-        char.class, Character.class,
-        long.class, Long.class,
-        double.class, Double.class,
-        float.class, Float.class,
-        int.class, Integer.class,
-    };
-
-    private Class<?> mapPrimitiveTypes( Class<?> rawInjectionType )
-    {
-        if( rawInjectionType == null || !rawInjectionType.isPrimitive() )
-        {
-            return rawInjectionType;
-        }
-        for( int i = 0; i < primitiveTypeMapping.length; i += 2 )
-        {
-            if( primitiveTypeMapping[ i ].equals( rawInjectionType ) )
-            {
-                return primitiveTypeMapping[ i + 1 ];
-            }
-        }
-        return rawInjectionType;
-    }
-
-    public boolean hasScope( final Class<? extends Annotation> scope )
-    {
-        return scope == null || scope.equals( injectionAnnotation().annotationType() );
-    }
-
-    public Class<? extends Annotation> injectionAnnotationType()
-    {
-        if( injectionAnnotation == null )
-        {
-            return null;
-        }
-        return injectionAnnotation.annotationType();
-    }
-
-    @Override
-    public String toString()
-    {
-        return injectionAnnotation + " for " + injectionType + " in " + injectedClass.getName();
-    }
-
-    public static class ScopeSpecification
-        implements Specification<DependencyModel>
-    {
-        private final Class<? extends Annotation> scope;
-
-        public ScopeSpecification( Class<? extends Annotation> scope )
-        {
-            this.scope = scope;
-        }
-
-        @Override
-        public boolean satisfiedBy( DependencyModel model )
-        {
-            return model.hasScope( scope );
-        }
-    }
-
-    public static class InjectionTypeFunction
-        implements Function<DependencyModel, Class<?>>
-    {
-        @Override
-        public Class<?> map( DependencyModel dependencyModel )
-        {
-            return dependencyModel.rawInjectionType();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java
deleted file mode 100644
index 60977a5..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldModel.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import org.apache.zest.api.composite.InjectedFieldDescriptor;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.bootstrap.InjectionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.composite.TransientInstance;
-import org.apache.zest.runtime.model.Resolution;
-
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singleton;
-
-/**
- * JAVADOC
- */
-public final class InjectedFieldModel
-    implements InjectedFieldDescriptor, VisitableHierarchy<InjectedFieldModel, DependencyModel>
-{
-    private DependencyModel dependencyModel;
-    private Field injectedField;
-
-    public InjectedFieldModel( Field injectedField, DependencyModel dependencyModel )
-    {
-        injectedField.setAccessible( true );
-        this.injectedField = injectedField;
-        this.dependencyModel = dependencyModel;
-    }
-
-    @Override
-    public DependencyModel dependency()
-    {
-        return dependencyModel;
-    }
-
-    @Override
-    public Field field()
-    {
-        return injectedField;
-    }
-
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        dependencyModel.bind( resolution.forField( injectedField ) );
-    }
-
-    public void inject( InjectionContext context, Object instance )
-    {
-        Object value = dependencyModel.inject( context );
-        try
-        {
-            injectedField.set( instance, value );
-        }
-        catch( IllegalAccessException e )
-        {
-            throw new InjectionException( e );
-        }
-        catch( IllegalArgumentException e )
-        {
-            String valueClassName;
-            if( Proxy.isProxyClass( value.getClass() ) )
-            {
-                InvocationHandler invocationHandler = Proxy.getInvocationHandler( value );
-                if( invocationHandler instanceof TransientInstance )
-                {
-                    TransientInstance handler = (TransientInstance) invocationHandler;
-                    valueClassName = Classes.toString( handler.descriptor().types() )
-                                     + " in [" + handler.module().name() + "] of [" + handler.layer().name() + "]";
-                }
-                else
-                {
-                    valueClassName = invocationHandler.toString();
-                }
-            }
-            else
-            {
-                valueClassName = value.getClass().getName();
-            }
-            StringBuilder annotBuilder = new StringBuilder();
-            for( Annotation annot : injectedField.getAnnotations() )
-            {
-                String s = annot.toString();
-                annotBuilder.append( "@" ).append( s.substring( s.lastIndexOf( '.' ) + 1, s.length() - 2 ) );
-                annotBuilder.append( " " );
-            }
-            String annots = annotBuilder.toString();
-            String message = "Can not inject the field\n    "
-                             + injectedField.getDeclaringClass()
-                             + "\n    {\n        " + annots + "\n        "
-                             + injectedField.getType().getSimpleName() + " " + injectedField.getName()
-                             + "\n    }\nwith value \n    " + value + "\nof type\n    "
-                             + valueClassName;
-            throw new InjectionException( message, e );
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super InjectedFieldModel, ? super DependencyModel, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            visitor.visit( dependencyModel );
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Collection<DependencyModel> filter( Specification<DependencyModel> specification )
-    {
-        if( specification.satisfiedBy( dependencyModel ) )
-        {
-            return singleton( dependencyModel );
-        }
-        else
-        {
-            return emptyList();
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return "InjectedFieldModel{" + ", injectedField=" + injectedField + '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
deleted file mode 100644
index e61bc39..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.injection.InjectionScope;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Fields;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.VisitableHierarchy;
-
-import static org.apache.zest.api.util.Annotations.hasAnnotation;
-import static org.apache.zest.api.util.Annotations.type;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Specifications.translate;
-
-/**
- * JAVADOC
- */
-public final class InjectedFieldsModel
-    implements Dependencies, VisitableHierarchy<Object, Object>
-{
-    private final List<InjectedFieldModel> fields = new ArrayList<InjectedFieldModel>();
-
-    public InjectedFieldsModel( Class fragmentClass )
-    {
-        Iterable<Field> mappedFields = Fields.FIELDS_OF.map( fragmentClass );
-        for( Field field : mappedFields )
-        {
-            Annotation injectionAnnotation = first( filter( translate( type(), hasAnnotation( InjectionScope.class ) ), iterable( field
-                                                                                                                                      .getAnnotations() ) ) );
-            if( injectionAnnotation != null )
-            {
-                addModel( fragmentClass, field, injectionAnnotation );
-            }
-        }
-    }
-
-    private void addModel( Class fragmentClass, Field field, Annotation injectionAnnotation )
-    {
-        Type genericType = field.getGenericType();
-        if( genericType instanceof ParameterizedType )
-        {
-            genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
-                .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );
-
-            for( int i = 0; i < ( (ParameterizedType) genericType ).getActualTypeArguments().length; i++ )
-            {
-                Type type = ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ];
-                if( type instanceof TypeVariable )
-                {
-                    type = Classes.resolveTypeVariable( (TypeVariable) type, field.getDeclaringClass(), fragmentClass );
-                    ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ] = type;
-                }
-            }
-        }
-
-        boolean optional = DependencyModel.isOptional( injectionAnnotation, field.getAnnotations() );
-        DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional, field
-            .getAnnotations() );
-        InjectedFieldModel injectedFieldModel = new InjectedFieldModel( field, dependencyModel );
-        this.fields.add( injectedFieldModel );
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return Iterables.map( new Function<InjectedFieldModel, DependencyModel>()
-        {
-            @Override
-            public DependencyModel map( InjectedFieldModel injectedFieldModel )
-            {
-                return injectedFieldModel.dependency();
-            }
-        }, fields );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( InjectedFieldModel field : fields )
-            {
-                if( !field.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-
-    public void inject( InjectionContext context, Object instance )
-    {
-        for( InjectedFieldModel field : fields )
-        {
-            field.inject( context, instance );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodModel.java
deleted file mode 100644
index b0ec660..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodModel.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.apache.zest.api.composite.InjectedMethodDescriptor;
-import org.apache.zest.bootstrap.InjectionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class InjectedMethodModel
-    implements InjectedMethodDescriptor, Dependencies, VisitableHierarchy<Object, Object>
-{
-    // Model
-    private Method method;
-    private InjectedParametersModel parameters;
-
-    public InjectedMethodModel( Method method, InjectedParametersModel parameters )
-    {
-        this.method = method;
-        this.method.setAccessible( true );
-        this.parameters = parameters;
-    }
-
-    @Override
-    public Method method()
-    {
-        return method;
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return parameters.dependencies();
-    }
-
-    // Context
-    public void inject( InjectionContext context, Object instance )
-        throws InjectionException
-    {
-        Object[] params = parameters.newParametersInstance( context );
-        try
-        {
-            if( !method.isAccessible() )
-            {
-                method.setAccessible( true );
-            }
-            method.invoke( instance, params );
-        }
-        catch( IllegalAccessException e )
-        {
-            throw new InjectionException( e );
-        }
-        catch( InvocationTargetException e )
-        {
-            throw new InjectionException( e.getTargetException() );
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            parameters.accept( visitor );
-        }
-        return visitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodsModel.java
deleted file mode 100644
index 82121a4..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedMethodsModel.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.injection.InjectionScope;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Methods;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Specifications;
-import org.apache.zest.functional.VisitableHierarchy;
-
-import static org.apache.zest.api.util.Annotations.hasAnnotation;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * JAVADOC
- */
-public final class InjectedMethodsModel
-    implements Dependencies, VisitableHierarchy<Object, Object>
-{
-    // Model
-    private final List<InjectedMethodModel> methodModels = new ArrayList<InjectedMethodModel>();
-
-    public InjectedMethodsModel( Class fragmentClass )
-    {
-        nextMethod:
-        for( Method method : Methods.METHODS_OF.map( fragmentClass ) )
-        {
-            Annotation[][] parameterAnnotations = method.getParameterAnnotations();
-            if( parameterAnnotations.length > 0 )
-            {
-                InjectedParametersModel parametersModel = new InjectedParametersModel();
-                final Type[] genericParameterTypes = method.getGenericParameterTypes();
-                for( int i = 0; i < parameterAnnotations.length; i++ )
-                {
-                    Annotation injectionAnnotation = first( filter( Specifications.translate( Annotations.type(), hasAnnotation( InjectionScope.class ) ), iterable( parameterAnnotations[ i ] ) ) );
-                    if( injectionAnnotation == null )
-                    {
-                        continue nextMethod;
-                    }
-
-                    Type genericType = genericParameterTypes[ i ];
-                    if( genericType instanceof ParameterizedType )
-                    {
-                        genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
-                            .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );
-
-                        for( int j = 0; j < ( (ParameterizedType) genericType ).getActualTypeArguments().length; j++ )
-                        {
-                            Type type = ( (ParameterizedType) genericType ).getActualTypeArguments()[ j ];
-                            if( type instanceof TypeVariable )
-                            {
-                                type = Classes.resolveTypeVariable( (TypeVariable) type, method.getDeclaringClass(), fragmentClass );
-                                ( (ParameterizedType) genericType ).getActualTypeArguments()[ j ] = type;
-                            }
-                        }
-                    }
-
-                    boolean optional = DependencyModel.isOptional( injectionAnnotation, parameterAnnotations[ i ] );
-                    DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional, parameterAnnotations[ i ] );
-                    parametersModel.addDependency( dependencyModel );
-                }
-                InjectedMethodModel methodModel = new InjectedMethodModel( method, parametersModel );
-                methodModels.add( methodModel );
-            }
-        }
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return flattenIterables( map( Dependencies.DEPENDENCIES_FUNCTION, methodModels ) );
-    }
-
-    // Context
-    public void inject( InjectionContext context, Object instance )
-    {
-        for( InjectedMethodModel methodModel : methodModels )
-        {
-            methodModel.inject( context, instance );
-        }
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( InjectedMethodModel methodModel : methodModels )
-            {
-                if( !methodModel.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java
deleted file mode 100644
index 2bb8360..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedParametersModel.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.zest.api.composite.InjectedParametersDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Specification;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class InjectedParametersModel
-    implements InjectedParametersDescriptor, Dependencies, VisitableHierarchy<Object, Object>
-{
-    private final List<DependencyModel> parameterDependencies;
-
-    public InjectedParametersModel()
-    {
-        parameterDependencies = new ArrayList<DependencyModel>();
-    }
-
-    @Override
-    public Iterable<DependencyModel> dependencies()
-    {
-        return parameterDependencies;
-    }
-
-    // Context
-    public Object[] newParametersInstance( InjectionContext context )
-    {
-        Object[] parametersInstance = new Object[ parameterDependencies.size() ];
-
-        // Inject parameterDependencies
-        for( int j = 0; j < parameterDependencies.size(); j++ )
-        {
-            DependencyModel dependencyModel = parameterDependencies.get( j );
-            Object parameter = dependencyModel.inject( context );
-            parametersInstance[ j ] = parameter;
-        }
-
-        return parametersInstance;
-    }
-
-    public void addDependency( DependencyModel dependency )
-    {
-        parameterDependencies.add( dependency );
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
-        throws ThrowableType
-    {
-        if( visitor.visitEnter( this ) )
-        {
-            for( DependencyModel parameterDependency : parameterDependencies )
-            {
-                if( !visitor.visit( parameterDependency ) )
-                {
-                    break;
-                }
-            }
-        }
-        return visitor.visitLeave( this );
-    }
-
-    public Collection<DependencyModel> filter( Specification<DependencyModel> specification )
-    {
-        ArrayList<DependencyModel> result = new ArrayList<DependencyModel>();
-        for( DependencyModel model : parameterDependencies )
-        {
-            if( specification.satisfiedBy( model ) )
-            {
-                result.add( model );
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "InjectedParametersModel{" +
-               "parameterDependencies=" + parameterDependencies +
-               '}';
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
deleted file mode 100644
index f9cefac..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.runtime.composite.ProxyReferenceInvocationHandler;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * JAVADOC
- */
-public final class InjectionContext
-{
-    private final ModuleSpi moduleInstance;
-    private CompositeInstance compositeInstance;
-    private UsesInstance uses;
-    private StateHolder state;
-    private Object next; // Only used for concerns and side-effects
-    private ProxyReferenceInvocationHandler proxyHandler;
-    private Object instance; // Only used for inner classes
-
-    // For mixins
-
-    public InjectionContext( CompositeInstance compositeInstance, UsesInstance uses, StateHolder state )
-    {
-        this.moduleInstance = (ModuleInstance) compositeInstance.module();
-        this.compositeInstance = compositeInstance;
-        this.uses = uses;
-        this.state = state;
-    }
-
-    // For concerns and side-effects
-    public InjectionContext( ModuleSpi moduleInstance, Object next, ProxyReferenceInvocationHandler proxyHandler )
-    {
-        this.moduleInstance = moduleInstance;
-        this.next = next;
-        this.proxyHandler = proxyHandler;
-    }
-
-    public InjectionContext( ModuleSpi moduleInstance, UsesInstance uses )
-    {
-        this.moduleInstance = moduleInstance;
-        this.uses = uses;
-    }
-
-    // For inner classes
-    public InjectionContext( ModuleSpi moduleInstance, UsesInstance uses, Object instance )
-    {
-        this.moduleInstance = moduleInstance;
-        this.uses = uses;
-        this.instance = instance;
-    }
-
-    public ModuleSpi module()
-    {
-        return moduleInstance;
-    }
-
-    public CompositeInstance compositeInstance()
-    {
-        return compositeInstance;
-    }
-
-    public UsesInstance uses()
-    {
-        return uses;
-    }
-
-    public StateHolder state()
-    {
-        return state;
-    }
-
-    public Object next()
-    {
-        return next;
-    }
-
-    public Object instance()
-    {
-        return instance;
-    }
-
-    public ProxyReferenceInvocationHandler proxyHandler()
-    {
-        return proxyHandler;
-    }
-
-    public void setUses( UsesInstance uses )
-    {
-        this.uses = uses;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "InjectionContext{" +
-               "compositeInstance=" + compositeInstance +
-               ", module=" + moduleInstance +
-               ", uses=" + uses +
-               ", state=" + state +
-               ", next=" + next +
-               ", proxyHandler=" + proxyHandler +
-               '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProvider.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProvider.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProvider.java
deleted file mode 100644
index f69c24e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import org.apache.zest.runtime.injection.provider.InjectionProviderException;
-
-/**
- * JAVADOC
- */
-public interface InjectionProvider
-{
-    Object provideInjection( InjectionContext context )
-        throws InjectionProviderException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProviderFactory.java
deleted file mode 100644
index a993367..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionProviderFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection;
-
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public interface InjectionProviderFactory
-{
-    /**
-     * Binding a dependency given an injection resolution. If no binding
-     * can be found, return null. If the dependency is optional the dependency will
-     * then be explicitly set to null.
-     *
-     * @param resolution Injection resolution
-     * @param dependencyModel Dependency model
-     * @return InjectionProvider
-     * @throws InvalidInjectionException if the injection is invalid
-     */
-    InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/ParameterizedTypeInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/ParameterizedTypeInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/ParameterizedTypeInstance.java
deleted file mode 100644
index 6a161b0..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/ParameterizedTypeInstance.java
+++ /dev/null
@@ -1,65 +0,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.
- */
-package org.apache.zest.runtime.injection;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-
-/**
- * TODO
- */
-public class ParameterizedTypeInstance
-    implements ParameterizedType
-{
-    private Type[] actualTypeArguments;
-    private Type rawType;
-    private Type ownerType;
-
-    public ParameterizedTypeInstance( Type[] actualTypeArguments, Type rawType, Type ownerType )
-    {
-        this.actualTypeArguments = actualTypeArguments;
-        this.rawType = rawType;
-        this.ownerType = ownerType;
-    }
-
-    @Override
-    public Type[] getActualTypeArguments()
-    {
-        return actualTypeArguments;
-    }
-
-    @Override
-    public Type getRawType()
-    {
-        return rawType;
-    }
-
-    @Override
-    public Type getOwnerType()
-    {
-        return ownerType;
-    }
-
-    @Override
-    public String toString()
-    {
-        return rawType.toString() + Arrays.asList( actualTypeArguments );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderDecorator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderDecorator.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderDecorator.java
deleted file mode 100644
index 300e1d7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderDecorator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.injection.provider;
-
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.injection.InjectionProvider;
-
-/**
- * If a dependency resolution should be a singleton, wrap it with this
- * to provide a single instance "cache".
- */
-public final class CachingInjectionProviderDecorator
-    implements InjectionProvider
-{
-    private final InjectionProvider decoratedProvider;
-    private volatile Object singletonInstance;
-
-    public CachingInjectionProviderDecorator( InjectionProvider injectionProvider )
-    {
-        this.decoratedProvider = injectionProvider;
-    }
-
-    public InjectionProvider decoratedProvider()
-    {
-        return decoratedProvider;
-    }
-
-    @Override
-    public Object provideInjection( InjectionContext context )
-        throws InjectionProviderException
-    {
-        if( singletonInstance == null )
-        {
-            synchronized( this )
-            {
-                if( singletonInstance == null )
-                {
-                    singletonInstance = decoratedProvider.provideInjection( context );
-                }
-            }
-        }
-
-        return singletonInstance;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderFactoryDecorator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderFactoryDecorator.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderFactoryDecorator.java
deleted file mode 100644
index cdb4f5a..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/CachingInjectionProviderFactoryDecorator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.injection.provider;
-
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public class CachingInjectionProviderFactoryDecorator
-    implements InjectionProviderFactory
-{
-    private final InjectionProviderFactory decoratedFactory;
-
-    public CachingInjectionProviderFactoryDecorator( InjectionProviderFactory decoratedFactory )
-    {
-        this.decoratedFactory = decoratedFactory;
-    }
-
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        InjectionProvider injectionProvider = decoratedFactory.newInjectionProvider( resolution, dependencyModel );
-        if( injectionProvider != null )
-        {
-            return new CachingInjectionProviderDecorator( injectionProvider );
-        }
-        else
-        {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderException.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderException.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderException.java
deleted file mode 100644
index abdae00..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.injection.provider;
-
-/**
- * JAVADOC
- */
-public class InjectionProviderException
-    extends RuntimeException
-{
-    public InjectionProviderException( String string )
-    {
-        super( string );
-    }
-
-    public InjectionProviderException( String string, Throwable throwable )
-    {
-        super( string, throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderFactoryStrategy.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderFactoryStrategy.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderFactoryStrategy.java
deleted file mode 100644
index 8d87bb9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/InjectionProviderFactoryStrategy.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.runtime.injection.provider;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.composite.InvalidValueCompositeException;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.concern.internal.ConcernFor;
-import org.apache.zest.api.injection.scope.Invocation;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.sideeffect.internal.SideEffectFor;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.injection.InjectionProvider;
-import org.apache.zest.runtime.injection.InjectionProviderFactory;
-import org.apache.zest.runtime.model.Resolution;
-
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * JAVADOC
- */
-public final class InjectionProviderFactoryStrategy
-    implements InjectionProviderFactory
-{
-    private final Map<Class<? extends Annotation>, InjectionProviderFactory> generalProviderFactories = new HashMap<Class<? extends Annotation>, InjectionProviderFactory>();
-    private final Map<Class<? extends Annotation>, InjectionProviderFactory> valuesProviderFactories = new HashMap<Class<? extends Annotation>, InjectionProviderFactory>();
-    private MetaInfo metaInfo;
-
-    public InjectionProviderFactoryStrategy( MetaInfo metaInfo )
-    {
-        this.metaInfo = metaInfo;
-        valuesProviderFactories.put( This.class, new ThisInjectionProviderFactory() );
-        ModifiesInjectionProviderFactory modifiesInjectionProviderFactory = new ModifiesInjectionProviderFactory();
-        valuesProviderFactories.put( ConcernFor.class, modifiesInjectionProviderFactory );
-        valuesProviderFactories.put( SideEffectFor.class, modifiesInjectionProviderFactory );
-        valuesProviderFactories.put( State.class, new StateInjectionProviderFactory() );
-
-        valuesProviderFactories.put( Structure.class, new CachingInjectionProviderFactoryDecorator( new StructureInjectionProviderFactory() ) );
-        valuesProviderFactories.put( Service.class, new CachingInjectionProviderFactoryDecorator( new ServiceInjectionProviderFactory() ) );
-        generalProviderFactories.put( Invocation.class, new InvocationInjectionProviderFactory() );
-        generalProviderFactories.put( Uses.class, new UsesInjectionProviderFactory() );
-    }
-
-    @Override
-    public InjectionProvider newInjectionProvider( Resolution resolution, DependencyModel dependencyModel )
-        throws InvalidInjectionException
-    {
-        Class<? extends Annotation> injectionAnnotationType = dependencyModel.injectionAnnotation().annotationType();
-        InjectionProviderFactory factory1 = generalProviderFactories.get( injectionAnnotationType );
-        InjectionProviderFactory factory2 = valuesProviderFactories.get( injectionAnnotationType );
-        if( factory1 == null && factory2 == null )
-        {
-            InjectionProviderFactory factory = metaInfo.get( InjectionProviderFactory.class );
-            if( factory != null )
-            {
-                return factory.newInjectionProvider( resolution, dependencyModel );
-            }
-            else
-            {
-                throw new InvalidInjectionException( "Unknown injection annotation @" + injectionAnnotationType.getSimpleName() );
-            }
-        }
-        ModelDescriptor composite = resolution.model();
-        Class<?> compositeType = first( composite.types() );
-        if( factory1 != null && ValueComposite.class.isAssignableFrom( compositeType ) )
-        {
-            throw new InvalidValueCompositeException( "@" + injectionAnnotationType.getSimpleName() + " is not allowed in ValueComposites: " + compositeType );
-        }
-
-        InjectionProviderFactory factory;
-        if( factory1 == null )
-        {
-            factory = factory2;
-        }
-        else
-        {
-            factory = factory1;
-        }
-        return factory.newInjectionProvider( resolution, dependencyModel );
-    }
-}


[23/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
deleted file mode 100644
index 504f52d..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
+++ /dev/null
@@ -1,441 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.importer.InstanceImporter;
-import org.apache.zest.api.service.importer.NewObjectImporter;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-public class DocumentationSupport
-{
-
-    public static Specification<ObjectAssembly> hasMyTypeSpecification = new Specification<ObjectAssembly>()
-    {
-
-        public boolean satisfiedBy( ObjectAssembly item )
-        {
-            return Iterables.toList( item.types() ).contains( String.class );
-        }
-
-    };
-
-    public static class objects
-            implements Assembler
-    {
-
-        public static class MyObject {}
-
-        // START SNIPPET: objects
-        @Override
-        public void assemble( ModuleAssembly module )
-                throws AssemblyException
-        {
-            module.objects( MyObject.class ).visibleIn( Visibility.layer );
-        }
-        // END SNIPPET: objects
-
-    }
-
-    public static class transients
-            implements Assembler
-    {
-
-        public static interface MyTransient {}
-
-        // START SNIPPET: transients
-        @Override
-        public void assemble( ModuleAssembly module )
-                throws AssemblyException
-        {
-            module.transients( MyTransient.class ).visibleIn( Visibility.layer );
-        }
-        // END SNIPPET: transients
-
-    }
-
-    public static class values
-            implements Assembler
-    {
-
-        public static interface MyValue {}
-
-        // START SNIPPET: values
-        @Override
-        public void assemble( ModuleAssembly module )
-                throws AssemblyException
-        {
-            module.values( MyValue.class ).visibleIn( Visibility.layer );
-        }
-        // END SNIPPET: values
-
-    }
-
-    public static class entities
-            implements Assembler
-    {
-
-        public static interface MyEntity {}
-
-        // START SNIPPET: entities
-        @Override
-        public void assemble( ModuleAssembly module )
-                throws AssemblyException
-        {
-            module.entities( MyEntity.class ).visibleIn( Visibility.layer );
-        }
-        // END SNIPPET: entities
-
-    }
-
-    public static class services
-            implements Assembler
-    {
-
-        public static interface MyService {}
-
-        // START SNIPPET: services
-        @Override
-        public void assemble( ModuleAssembly module )
-                throws AssemblyException
-        {
-            module.services( MyService.class ).visibleIn( Visibility.layer );
-        }
-        // END SNIPPET: services
-
-    }
-
-    public static class taggedServices
-        implements Assembler
-    {
-
-        public static interface MyService {}
-
-        // START SNIPPET: tagged-services
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-            module.services( MyService.class ).taggedWith( "foo", "bar" );
-        }
-        // END SNIPPET: tagged-services
-    }
-
-    public static class importedServices
-        implements Assembler
-    {
-
-        public static class MyService {}
-
-        // START SNIPPET: imported-services
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-            module.importedServices( MyService.class ).
-                importedBy( InstanceImporter.class ).
-                setMetaInfo( new MyService() );
-
-            // OR
-
-            module.objects( MyService.class );
-            module.importedServices( MyService.class ).
-                importedBy( NewObjectImporter.class );
-        }
-        // END SNIPPET: imported-services
-    }
-
-    public static class defaultPropertyValues
-        implements Assembler
-    {
-
-        public interface MyValue { Property<String> foo(); }
-        public interface MyEntity { Property<String> cathedral(); }
-
-        // START SNIPPET: properties-defaults
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-            module.values( MyValue.class );
-            MyValue myValueDefaults = module.forMixin( MyValue.class ).declareDefaults();
-            myValueDefaults.foo().set( "bar" );
-
-            module.entities( MyEntity.class );
-            MyEntity myEntityDefaults = module.forMixin( MyEntity.class ).declareDefaults();
-            myEntityDefaults.cathedral().set( "bazar" );
-        }
-        // END SNIPPET: properties-defaults
-    }
-
-    public static class singleton
-    {
-
-        public interface MyService { }
-        public interface Stuff { }
-
-        void singleton()
-            throws ActivationException, AssemblyException
-        {
-            // START SNIPPET: singleton
-            SingletonAssembler assembler = new SingletonAssembler()
-            {
-
-                @Override
-                public void assemble( ModuleAssembly module )
-                        throws AssemblyException
-                {
-                    module.services( MyService.class ).identifiedBy( "Foo" );
-                    module.services( MyService.class ).identifiedBy( "Bar" );
-                    module.objects( Stuff.class );
-                }
-
-            };
-            Module module = assembler.module();
-            Stuff stuff = module.newObject( Stuff.class );
-            // END SNIPPET: singleton
-        }
-
-    }
-
-    public static class pancake
-    {
-
-        public static class LoginAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class MenuAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class PerspectivesAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class ViewsAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class ReportingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class PdfAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class BookkeepingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class CashFlowAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class BalanceSheetAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class PricingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class ProductAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-
-        private static Energy4Java qi4j;
-
-        // START SNIPPET: pancake
-        public static void main( String[] args )
-                throws Exception
-        {
-            qi4j = new Energy4Java();
-            Assembler[][][] assemblers = new Assembler[][][]{
-                { // View Layer
-                    { // Login Module
-                        new LoginAssembler()
-                    // :
-                    },
-                    { // Main Workbench Module
-                        new MenuAssembler(),
-                        new PerspectivesAssembler(),
-                        new ViewsAssembler()
-                    // :
-                    },
-                    { // Printing Module
-                        new ReportingAssembler(),
-                        new PdfAssembler()
-                    // :
-                    }
-                },
-                { // Application Layer
-                    { // Accounting Module
-                        new BookkeepingAssembler(),
-                        new CashFlowAssembler(),
-                        new BalanceSheetAssembler()
-                    // :
-                    },
-                    { // Inventory Module
-                        new PricingAssembler(),
-                        new ProductAssembler()
-                    // :
-                    }
-                },
-                { // Domain Layer
-                // :
-                },
-                { // Infrastructure Layer
-                // :
-                }
-            };
-            ApplicationDescriptor model = newApplication( assemblers );
-            Application runtime = model.newInstance( qi4j.spi() );
-            runtime.activate();
-        }
-
-        private static ApplicationDescriptor newApplication( final Assembler[][][] assemblers )
-                throws AssemblyException
-        {
-            return qi4j.newApplicationModel( new ApplicationAssembler()
-            {
-
-                @Override
-                public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
-                        throws AssemblyException
-                {
-                    return appFactory.newApplicationAssembly( assemblers );
-                }
-
-            } );
-        }
-        // END SNIPPET: pancake
-
-    }
-
-    public static class full
-    {
-
-        public static class CustomerViewComposite{}
-        public static class CustomerEditComposite{}
-        public static class CustomerListViewComposite{}
-        public static class CustomerSearchComposite{}
-        public static class CustomerEntity{}
-        public static class CountryEntity{}
-        public static class AddressValue{}
-        public static class LdapAuthenticationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class ThrinkAuthorizationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class UserTrackingAuditAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-        public static class NeoAssembler implements Assembler{ NeoAssembler( String path ) {} public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-
-        // START SNIPPET: full
-        private static Energy4Java qi4j;
-
-        private static Application application;
-
-        public static void main( String[] args )
-                throws Exception
-        {
-            // Create a Zest Runtime
-            qi4j = new Energy4Java();
-            application = qi4j.newApplication( new ApplicationAssembler()
-            {
-
-                @Override
-                public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
-                        throws AssemblyException
-                {
-                    ApplicationAssembly assembly = appFactory.newApplicationAssembly();
-                    buildAssembly( assembly );
-                    return assembly;
-                }
-
-            } );
-            // activate the application
-            application.activate();
-        }
-
-        static void buildAssembly( ApplicationAssembly app ) throws AssemblyException
-        {
-            LayerAssembly webLayer = createWebLayer( app );
-            LayerAssembly domainLayer = createDomainLayer( app );
-            LayerAssembly persistenceLayer = createInfrastructureLayer( app );
-            LayerAssembly authLayer = createAuth2Layer( app );
-            LayerAssembly messagingLayer = createMessagingLayer( app );
-
-            webLayer.uses( domainLayer );
-            domainLayer.uses( authLayer );
-            domainLayer.uses( persistenceLayer );
-            domainLayer.uses( messagingLayer );
-        }
-
-        static LayerAssembly createWebLayer( ApplicationAssembly app ) throws AssemblyException
-        {
-            LayerAssembly layer = app.layer( "web-layer" );
-            createCustomerWebModule( layer );
-            return layer;
-        }
-
-        static LayerAssembly createDomainLayer( ApplicationAssembly app ) throws AssemblyException
-        {
-            LayerAssembly layer = app.layer( "domain-layer" );
-            createCustomerDomainModule( layer );
-            // :
-            // :
-            return layer;
-        }
-
-        static LayerAssembly createInfrastructureLayer( ApplicationAssembly app ) throws AssemblyException
-        {
-            LayerAssembly layer = app.layer( "infrastructure-layer" );
-            createPersistenceModule( layer );
-            return layer;
-        }
-
-        static LayerAssembly createMessagingLayer( ApplicationAssembly app ) throws AssemblyException
-        {
-            LayerAssembly layer = app.layer( "messaging-layer" );
-            createWebServiceModule( layer );
-            createMessagingPersistenceModule( layer );
-            return layer;
-        }
-
-        static LayerAssembly createAuth2Layer( ApplicationAssembly application ) throws AssemblyException
-        {
-            LayerAssembly layer = application.layer( "auth2-layer" );
-            createAuthModule( layer );
-            return layer;
-        }
-
-        static void createCustomerWebModule( LayerAssembly layer ) throws AssemblyException
-        {
-            ModuleAssembly assembly = layer.module( "customer-web-module" );
-            assembly.transients( CustomerViewComposite.class, CustomerEditComposite.class,
-                                 CustomerListViewComposite.class, CustomerSearchComposite.class );
-        }
-
-        static void createCustomerDomainModule( LayerAssembly layer ) throws AssemblyException
-        {
-            ModuleAssembly assembly = layer.module( "customer-domain-module" );
-            assembly.entities( CustomerEntity.class, CountryEntity.class );
-            assembly.values( AddressValue.class );
-        }
-
-        static void createAuthModule( LayerAssembly layer ) throws AssemblyException
-        {
-            ModuleAssembly assembly = layer.module( "auth-module" );
-            new LdapAuthenticationAssembler().assemble( assembly );
-            new ThrinkAuthorizationAssembler().assemble( assembly );
-            new UserTrackingAuditAssembler().assemble( assembly );
-        }
-
-        static void createPersistenceModule( LayerAssembly layer ) throws AssemblyException
-        {
-            ModuleAssembly assembly = layer.module( "persistence-module" );
-            // Someone has created an assembler for the Neo EntityStore
-            new NeoAssembler( "./neostore" ).assemble( assembly );
-        }
-
-        // END SNIPPET: full
-        private static void createWebServiceModule( LayerAssembly layer ) throws AssemblyException
-        {
-        }
-
-        private static void createMessagingPersistenceModule( LayerAssembly layer ) throws AssemblyException
-        {
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/TestValue.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/TestValue.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/TestValue.java
deleted file mode 100644
index 7fba35c..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/TestValue.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- */
-public interface TestValue
-    extends ValueComposite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/LayeredApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/LayeredApplicationAssemblerTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/LayeredApplicationAssemblerTest.java
deleted file mode 100644
index 8529ec9..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/LayeredApplicationAssemblerTest.java
+++ /dev/null
@@ -1,41 +0,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.
- */
-package org.apache.zest.bootstrap.assembly;
-
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.bootstrap.AssemblyException;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class LayeredApplicationAssemblerTest
-{
-    @Test
-    public void validateThatAssemblerCreatesApplication()
-        throws AssemblyException, ActivationException
-    {
-        TestApplication assembler = new TestApplication( "Test Application", "1.0.1", Application.Mode.test );
-        assembler.start();
-
-        assertThat( assembler.application().name(), equalTo("Test Application") );
-        assertThat( assembler.application().version(), equalTo("1.0.1") );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/TestApplication.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/TestApplication.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/TestApplication.java
deleted file mode 100644
index 7b4f1ca..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/TestApplication.java
+++ /dev/null
@@ -1,61 +0,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.
- */
-package org.apache.zest.bootstrap.assembly;
-
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.assembly.config.ConfigurationLayer;
-import org.apache.zest.bootstrap.assembly.connectivity.ConnectivityLayer;
-import org.apache.zest.bootstrap.assembly.domain.DomainLayer;
-import org.apache.zest.bootstrap.assembly.infrastructure.InfrastructureLayer;
-import org.apache.zest.bootstrap.assembly.service.ServiceLayer;
-
-// START SNIPPET: application
-public class TestApplication extends LayeredApplicationAssembler
-{
-
-    public TestApplication( String name, String version, Application.Mode mode )
-        throws AssemblyException
-    {
-        super( name, version, mode );
-    }
-
-    @Override
-    protected void assembleLayers( ApplicationAssembly assembly )
-        throws AssemblyException
-    {
-        LayerAssembly configLayer = createLayer( ConfigurationLayer.class );
-        ModuleAssembly configModule = configLayer.module( "Configuration Module" );
-        LayerAssembly infraLayer = new InfrastructureLayer( configModule ).assemble( assembly.layer( InfrastructureLayer.NAME  ));
-        LayerAssembly domainLayer = createLayer( DomainLayer.class );
-        LayerAssembly serviceLayer = createLayer( ServiceLayer.class );
-        LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );
-
-        connectivityLayer.uses( serviceLayer );
-        connectivityLayer.uses( domainLayer );
-        serviceLayer.uses( domainLayer );
-        domainLayer.uses( infraLayer );
-        infraLayer.uses( configLayer );
-    }
-}
-// END SNIPPET: application

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/config/ConfigurationLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/config/ConfigurationLayer.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/config/ConfigurationLayer.java
deleted file mode 100644
index 8d250ea..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/config/ConfigurationLayer.java
+++ /dev/null
@@ -1,33 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.config;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.layered.LayerAssembler;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public class ConfigurationLayer implements LayerAssembler
-{
-    @Override
-    public LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException
-    {
-        return layer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/connectivity/ConnectivityLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/connectivity/ConnectivityLayer.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/connectivity/ConnectivityLayer.java
deleted file mode 100644
index 570b526..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/connectivity/ConnectivityLayer.java
+++ /dev/null
@@ -1,35 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.connectivity;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.layered.LayerAssembler;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public class ConnectivityLayer implements LayerAssembler
-{
-    public static final String NAME = "Connectivity";
-
-    @Override
-    public LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException
-    {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/DomainLayer.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/DomainLayer.java
deleted file mode 100644
index 8976987..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/DomainLayer.java
+++ /dev/null
@@ -1,35 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.domain;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-public class DomainLayer extends LayeredLayerAssembler
-{
-    @Override
-    public LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException
-    {
-        createModule( layer, InvoicingModule.class );
-        createModule( layer, OrderModule.class );
-        return layer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/InvoicingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/InvoicingModule.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/InvoicingModule.java
deleted file mode 100644
index 059416e..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/InvoicingModule.java
+++ /dev/null
@@ -1,35 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.domain;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.ModuleAssembler;
-
-public class InvoicingModule
-    implements ModuleAssembler
-{
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        return module;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/OrderModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/OrderModule.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/OrderModule.java
deleted file mode 100644
index b3cc06b..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/domain/OrderModule.java
+++ /dev/null
@@ -1,56 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.domain;
-
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.ModuleAssembler;
-
-public class OrderModule
-    implements ModuleAssembler
-{
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.entities( Order.class, Customer.class );
-        module.values( Address.class );
-        return module;
-    }
-
-    public interface Order
-    {
-        Association<Customer> customer();
-
-        Property<Address> invoicingAddress();
-
-        Property<Address> deliveryAddress();
-    }
-
-    public interface Customer
-    {
-    }
-
-    public interface Address
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/IndexingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/IndexingModule.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/IndexingModule.java
deleted file mode 100644
index c641f7b..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/IndexingModule.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.infrastructure;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.ModuleAssembler;
-
-public class IndexingModule
-    implements ModuleAssembler
-{
-    public static final String NAME = "Indexing Module";
-    private final ModuleAssembly configModule;
-
-    public IndexingModule( ModuleAssembly configModule )
-    {
-        this.configModule = configModule;
-    }
-
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        return module;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/InfrastructureLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/InfrastructureLayer.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/InfrastructureLayer.java
deleted file mode 100644
index 4a79404..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/InfrastructureLayer.java
+++ /dev/null
@@ -1,47 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.infrastructure;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.LayerAssembler;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-public class InfrastructureLayer extends LayeredLayerAssembler
-    implements LayerAssembler
-{
-    public static final String NAME = "Infrastructure Layer";
-    private final ModuleAssembly configModule;
-
-    public InfrastructureLayer( ModuleAssembly configModule )
-    {
-        this.configModule = configModule;
-    }
-
-    @Override
-    public LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException
-    {
-        new StorageModule( configModule ).assemble( layer, layer.module( StorageModule.NAME ) );
-        new IndexingModule( configModule ).assemble( layer, layer.module( IndexingModule.NAME ) );
-        createModule( layer, SerializationModule.class );
-        return layer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/SerializationModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/SerializationModule.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/SerializationModule.java
deleted file mode 100644
index 8ac0e3d..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/SerializationModule.java
+++ /dev/null
@@ -1,36 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.infrastructure;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.ModuleAssembler;
-
-public class SerializationModule
-    implements ModuleAssembler
-{
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module
-    )
-        throws AssemblyException
-    {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/StorageModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/StorageModule.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/StorageModule.java
deleted file mode 100644
index 83c9f21..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/infrastructure/StorageModule.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.infrastructure;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.layered.ModuleAssembler;
-
-public class StorageModule
-    implements ModuleAssembler
-{
-    public static final String NAME = "Storage Module";
-    private final ModuleAssembly configModule;
-
-    public StorageModule( ModuleAssembly configModule )
-    {
-        this.configModule = configModule;
-    }
-
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        return module;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/service/ServiceLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/service/ServiceLayer.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/service/ServiceLayer.java
deleted file mode 100644
index f9796d4..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/assembly/service/ServiceLayer.java
+++ /dev/null
@@ -1,35 +0,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.
- */
-package org.apache.zest.bootstrap.assembly.service;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.layered.LayerAssembler;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public class ServiceLayer implements LayerAssembler
-{
-    public static final String NAME = "Service";
-
-    @Override
-    public LayerAssembly assemble( LayerAssembly layer )
-        throws AssemblyException
-    {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
deleted file mode 100644
index 2639c10..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2014 Niclas Hedhman.
- * Copyright 2014 Paul Merlin.
- *
- * 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.zest.bootstrap.builder;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import org.json.JSONException;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.apache.zest.bootstrap.ClassScanner.findClasses;
-import static org.apache.zest.bootstrap.ClassScanner.matches;
-import static org.apache.zest.functional.Iterables.filter;
-
-public class ApplicationBuilderTest
-{
-    @Test
-    public void givenBuilderUseWhenBuildingApplicationExpectSuccess()
-        throws AssemblyException, ActivationException
-    {
-        ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." );
-        builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" );
-        builder.withLayer( "layer2" );
-        builder.withLayer( "layer3" ).withModule( "test module" ).
-            withAssemblers( filter( matches( ".*ServiceAssembler" ), findClasses( getClass() ) ) );
-        Application application = builder.newApplication();
-        Module module = application.findModule( "layer3", "test module" );
-        TestService service = module.findService( TestService.class ).get();
-        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
-    }
-
-    @Test
-    public void givenJsonWhenBuildingApplicationExpectSuccess()
-        throws JSONException, ActivationException, AssemblyException
-    {
-        ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION );
-        Application application = builder.newApplication();
-        Module module = application.findModule( "layer3", "test module" );
-        TestService service = module.findService( TestService.class ).get();
-        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
-    }
-
-    @Test
-    public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess()
-        throws IOException, JSONException, ActivationException, AssemblyException
-    {
-        InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) );
-        ApplicationBuilder builder = ApplicationBuilder.fromJson( input );
-        Application application = builder.newApplication();
-        Module module = application.findModule( "layer3", "test module" );
-        TestService service = module.findService( TestService.class ).get();
-        assertThat( service.sayHello(), equalTo( "Hello Zest!" ) );
-    }
-
-
-    private static final String APPLICATION =
-        "{\n" +
-        "    \"name\": \"Build from JSON test.\",\n" +
-        "    \"layers\": [\n" +
-        "        {\n" +
-        "            \"name\": \"layer1\",\n" +
-        "            \"uses\": [ \"layer2\", \"layer3\"]\n" +
-        "        },\n" +
-        "        {\n" +
-        "            \"name\": \"layer2\"\n" +
-        "        },\n" +
-        "        {\n" +
-        "            \"name\": \"layer3\",\n" +
-        "            \"modules\" : [\n" +
-        "                {\n" +
-        "                    \"name\" : \"test module\",\n" +
-        "                    \"assemblers\" : [\n" +
-        "                            \"org.qi4j.bootstrap.builder.ApplicationBuilderTest$TestServiceAssembler\"\n" +
-        "                    ]\n" +
-        "                }\n" +
-        "            ]\n" +
-        "        }\n" +
-        "    ]\n" +
-        "}";
-
-    public static class TestServiceAssembler
-        implements Assembler
-    {
-        @Override
-        public void assemble( ModuleAssembly module )
-            throws AssemblyException
-        {
-            module.addServices( TestService.class );
-        }
-    }
-
-    @Mixins( TestService.TestMixin.class )
-    public interface TestService
-    {
-        String sayHello();
-
-        class TestMixin
-            implements TestService
-        {
-
-            @Override
-            public String sayHello()
-            {
-                return "Hello Zest!";
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/apache/zest/bootstrap/somepackage/Test2Value.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/somepackage/Test2Value.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/somepackage/Test2Value.java
deleted file mode 100644
index edd7635..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/somepackage/Test2Value.java
+++ /dev/null
@@ -1,28 +0,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.
- */
-package org.apache.zest.bootstrap.somepackage;
-
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- */
-public interface Test2Value
-    extends ValueComposite
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/ClassScannerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/ClassScannerTest.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/ClassScannerTest.java
new file mode 100644
index 0000000..33c9e21
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/ClassScannerTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.bootstrap.somepackage.Test2Value;
+import org.qi4j.functional.Iterables;
+
+import static org.qi4j.bootstrap.ClassScanner.findClasses;
+import static org.qi4j.bootstrap.ClassScanner.matches;
+import static org.qi4j.functional.Iterables.filter;
+
+/**
+ * Test and showcase of the ClassScanner assembly utility.
+ */
+public class ClassScannerTest
+{
+    @Test
+    public void testClassScannerFiles()
+        throws ActivationException, AssemblyException
+    {
+        SingletonAssembler singleton = new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                // Find all classes starting from TestValue, but include only the ones that are named *Value
+
+                for( Class aClass : filter( matches( ".*Value" ), findClasses( TestValue.class ) ) )
+                {
+                    module.values( aClass );
+                }
+            }
+        };
+
+        singleton.module().newValueBuilder( TestValue.class );
+        singleton.module().newValueBuilder( Test2Value.class );
+    }
+
+    @Test
+    public void testClassScannerJar()
+    {
+        Assert.assertEquals( 138, Iterables.count( findClasses( Test.class ) ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/DocumentationSupport.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/DocumentationSupport.java
new file mode 100644
index 0000000..ae57305
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/DocumentationSupport.java
@@ -0,0 +1,441 @@
+/*
+ * 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.qi4j.bootstrap;
+
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.service.importer.InstanceImporter;
+import org.qi4j.api.service.importer.NewObjectImporter;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.api.structure.Module;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+
+public class DocumentationSupport
+{
+
+    public static Specification<ObjectAssembly> hasMyTypeSpecification = new Specification<ObjectAssembly>()
+    {
+
+        public boolean satisfiedBy( ObjectAssembly item )
+        {
+            return Iterables.toList( item.types() ).contains( String.class );
+        }
+
+    };
+
+    public static class objects
+            implements Assembler
+    {
+
+        public static class MyObject {}
+
+        // START SNIPPET: objects
+        @Override
+        public void assemble( ModuleAssembly module )
+                throws AssemblyException
+        {
+            module.objects( MyObject.class ).visibleIn( Visibility.layer );
+        }
+        // END SNIPPET: objects
+
+    }
+
+    public static class transients
+            implements Assembler
+    {
+
+        public static interface MyTransient {}
+
+        // START SNIPPET: transients
+        @Override
+        public void assemble( ModuleAssembly module )
+                throws AssemblyException
+        {
+            module.transients( MyTransient.class ).visibleIn( Visibility.layer );
+        }
+        // END SNIPPET: transients
+
+    }
+
+    public static class values
+            implements Assembler
+    {
+
+        public static interface MyValue {}
+
+        // START SNIPPET: values
+        @Override
+        public void assemble( ModuleAssembly module )
+                throws AssemblyException
+        {
+            module.values( MyValue.class ).visibleIn( Visibility.layer );
+        }
+        // END SNIPPET: values
+
+    }
+
+    public static class entities
+            implements Assembler
+    {
+
+        public static interface MyEntity {}
+
+        // START SNIPPET: entities
+        @Override
+        public void assemble( ModuleAssembly module )
+                throws AssemblyException
+        {
+            module.entities( MyEntity.class ).visibleIn( Visibility.layer );
+        }
+        // END SNIPPET: entities
+
+    }
+
+    public static class services
+            implements Assembler
+    {
+
+        public static interface MyService {}
+
+        // START SNIPPET: services
+        @Override
+        public void assemble( ModuleAssembly module )
+                throws AssemblyException
+        {
+            module.services( MyService.class ).visibleIn( Visibility.layer );
+        }
+        // END SNIPPET: services
+
+    }
+
+    public static class taggedServices
+        implements Assembler
+    {
+
+        public static interface MyService {}
+
+        // START SNIPPET: tagged-services
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+            module.services( MyService.class ).taggedWith( "foo", "bar" );
+        }
+        // END SNIPPET: tagged-services
+    }
+
+    public static class importedServices
+        implements Assembler
+    {
+
+        public static class MyService {}
+
+        // START SNIPPET: imported-services
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+            module.importedServices( MyService.class ).
+                importedBy( InstanceImporter.class ).
+                setMetaInfo( new MyService() );
+
+            // OR
+
+            module.objects( MyService.class );
+            module.importedServices( MyService.class ).
+                importedBy( NewObjectImporter.class );
+        }
+        // END SNIPPET: imported-services
+    }
+
+    public static class defaultPropertyValues
+        implements Assembler
+    {
+
+        public interface MyValue { Property<String> foo(); }
+        public interface MyEntity { Property<String> cathedral(); }
+
+        // START SNIPPET: properties-defaults
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+            module.values( MyValue.class );
+            MyValue myValueDefaults = module.forMixin( MyValue.class ).declareDefaults();
+            myValueDefaults.foo().set( "bar" );
+
+            module.entities( MyEntity.class );
+            MyEntity myEntityDefaults = module.forMixin( MyEntity.class ).declareDefaults();
+            myEntityDefaults.cathedral().set( "bazar" );
+        }
+        // END SNIPPET: properties-defaults
+    }
+
+    public static class singleton
+    {
+
+        public interface MyService { }
+        public interface Stuff { }
+
+        void singleton()
+            throws ActivationException, AssemblyException
+        {
+            // START SNIPPET: singleton
+            SingletonAssembler assembler = new SingletonAssembler()
+            {
+
+                @Override
+                public void assemble( ModuleAssembly module )
+                        throws AssemblyException
+                {
+                    module.services( MyService.class ).identifiedBy( "Foo" );
+                    module.services( MyService.class ).identifiedBy( "Bar" );
+                    module.objects( Stuff.class );
+                }
+
+            };
+            Module module = assembler.module();
+            Stuff stuff = module.newObject( Stuff.class );
+            // END SNIPPET: singleton
+        }
+
+    }
+
+    public static class pancake
+    {
+
+        public static class LoginAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class MenuAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class PerspectivesAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class ViewsAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class ReportingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class PdfAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class BookkeepingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class CashFlowAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class BalanceSheetAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class PricingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class ProductAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+
+        private static Energy4Java qi4j;
+
+        // START SNIPPET: pancake
+        public static void main( String[] args )
+                throws Exception
+        {
+            qi4j = new Energy4Java();
+            Assembler[][][] assemblers = new Assembler[][][]{
+                { // View Layer
+                    { // Login Module
+                        new LoginAssembler()
+                    // :
+                    },
+                    { // Main Workbench Module
+                        new MenuAssembler(),
+                        new PerspectivesAssembler(),
+                        new ViewsAssembler()
+                    // :
+                    },
+                    { // Printing Module
+                        new ReportingAssembler(),
+                        new PdfAssembler()
+                    // :
+                    }
+                },
+                { // Application Layer
+                    { // Accounting Module
+                        new BookkeepingAssembler(),
+                        new CashFlowAssembler(),
+                        new BalanceSheetAssembler()
+                    // :
+                    },
+                    { // Inventory Module
+                        new PricingAssembler(),
+                        new ProductAssembler()
+                    // :
+                    }
+                },
+                { // Domain Layer
+                // :
+                },
+                { // Infrastructure Layer
+                // :
+                }
+            };
+            ApplicationDescriptor model = newApplication( assemblers );
+            Application runtime = model.newInstance( qi4j.spi() );
+            runtime.activate();
+        }
+
+        private static ApplicationDescriptor newApplication( final Assembler[][][] assemblers )
+                throws AssemblyException
+        {
+            return qi4j.newApplicationModel( new ApplicationAssembler()
+            {
+
+                @Override
+                public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
+                        throws AssemblyException
+                {
+                    return appFactory.newApplicationAssembly( assemblers );
+                }
+
+            } );
+        }
+        // END SNIPPET: pancake
+
+    }
+
+    public static class full
+    {
+
+        public static class CustomerViewComposite{}
+        public static class CustomerEditComposite{}
+        public static class CustomerListViewComposite{}
+        public static class CustomerSearchComposite{}
+        public static class CustomerEntity{}
+        public static class CountryEntity{}
+        public static class AddressValue{}
+        public static class LdapAuthenticationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class ThrinkAuthorizationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class UserTrackingAuditAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+        public static class NeoAssembler implements Assembler{ NeoAssembler( String path ) {} public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+
+        // START SNIPPET: full
+        private static Energy4Java qi4j;
+
+        private static Application application;
+
+        public static void main( String[] args )
+                throws Exception
+        {
+            // Create a Zest Runtime
+            qi4j = new Energy4Java();
+            application = qi4j.newApplication( new ApplicationAssembler()
+            {
+
+                @Override
+                public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
+                        throws AssemblyException
+                {
+                    ApplicationAssembly assembly = appFactory.newApplicationAssembly();
+                    buildAssembly( assembly );
+                    return assembly;
+                }
+
+            } );
+            // activate the application
+            application.activate();
+        }
+
+        static void buildAssembly( ApplicationAssembly app ) throws AssemblyException
+        {
+            LayerAssembly webLayer = createWebLayer( app );
+            LayerAssembly domainLayer = createDomainLayer( app );
+            LayerAssembly persistenceLayer = createInfrastructureLayer( app );
+            LayerAssembly authLayer = createAuth2Layer( app );
+            LayerAssembly messagingLayer = createMessagingLayer( app );
+
+            webLayer.uses( domainLayer );
+            domainLayer.uses( authLayer );
+            domainLayer.uses( persistenceLayer );
+            domainLayer.uses( messagingLayer );
+        }
+
+        static LayerAssembly createWebLayer( ApplicationAssembly app ) throws AssemblyException
+        {
+            LayerAssembly layer = app.layer( "web-layer" );
+            createCustomerWebModule( layer );
+            return layer;
+        }
+
+        static LayerAssembly createDomainLayer( ApplicationAssembly app ) throws AssemblyException
+        {
+            LayerAssembly layer = app.layer( "domain-layer" );
+            createCustomerDomainModule( layer );
+            // :
+            // :
+            return layer;
+        }
+
+        static LayerAssembly createInfrastructureLayer( ApplicationAssembly app ) throws AssemblyException
+        {
+            LayerAssembly layer = app.layer( "infrastructure-layer" );
+            createPersistenceModule( layer );
+            return layer;
+        }
+
+        static LayerAssembly createMessagingLayer( ApplicationAssembly app ) throws AssemblyException
+        {
+            LayerAssembly layer = app.layer( "messaging-layer" );
+            createWebServiceModule( layer );
+            createMessagingPersistenceModule( layer );
+            return layer;
+        }
+
+        static LayerAssembly createAuth2Layer( ApplicationAssembly application ) throws AssemblyException
+        {
+            LayerAssembly layer = application.layer( "auth2-layer" );
+            createAuthModule( layer );
+            return layer;
+        }
+
+        static void createCustomerWebModule( LayerAssembly layer ) throws AssemblyException
+        {
+            ModuleAssembly assembly = layer.module( "customer-web-module" );
+            assembly.transients( CustomerViewComposite.class, CustomerEditComposite.class,
+                                 CustomerListViewComposite.class, CustomerSearchComposite.class );
+        }
+
+        static void createCustomerDomainModule( LayerAssembly layer ) throws AssemblyException
+        {
+            ModuleAssembly assembly = layer.module( "customer-domain-module" );
+            assembly.entities( CustomerEntity.class, CountryEntity.class );
+            assembly.values( AddressValue.class );
+        }
+
+        static void createAuthModule( LayerAssembly layer ) throws AssemblyException
+        {
+            ModuleAssembly assembly = layer.module( "auth-module" );
+            new LdapAuthenticationAssembler().assemble( assembly );
+            new ThrinkAuthorizationAssembler().assemble( assembly );
+            new UserTrackingAuditAssembler().assemble( assembly );
+        }
+
+        static void createPersistenceModule( LayerAssembly layer ) throws AssemblyException
+        {
+            ModuleAssembly assembly = layer.module( "persistence-module" );
+            // Someone has created an assembler for the Neo EntityStore
+            new NeoAssembler( "./neostore" ).assemble( assembly );
+        }
+
+        // END SNIPPET: full
+        private static void createWebServiceModule( LayerAssembly layer ) throws AssemblyException
+        {
+        }
+
+        private static void createMessagingPersistenceModule( LayerAssembly layer ) throws AssemblyException
+        {
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/TestValue.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/TestValue.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/TestValue.java
new file mode 100644
index 0000000..c94b1ff
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/TestValue.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap;
+
+import org.qi4j.api.value.ValueComposite;
+
+/**
+ */
+public interface TestValue
+    extends ValueComposite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/LayeredApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/LayeredApplicationAssemblerTest.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/LayeredApplicationAssemblerTest.java
new file mode 100644
index 0000000..b1212ae
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/LayeredApplicationAssemblerTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.qi4j.bootstrap.assembly;
+
+import org.junit.Test;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.structure.Application;
+import org.qi4j.bootstrap.AssemblyException;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class LayeredApplicationAssemblerTest
+{
+    @Test
+    public void validateThatAssemblerCreatesApplication()
+        throws AssemblyException, ActivationException
+    {
+        TestApplication assembler = new TestApplication( "Test Application", "1.0.1", Application.Mode.test );
+        assembler.start();
+
+        assertThat( assembler.application().name(), equalTo("Test Application") );
+        assertThat( assembler.application().version(), equalTo("1.0.1") );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/TestApplication.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/TestApplication.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/TestApplication.java
new file mode 100644
index 0000000..03422cc
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/TestApplication.java
@@ -0,0 +1,61 @@
+/*
+ * 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.qi4j.bootstrap.assembly;
+
+import org.qi4j.api.structure.Application;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.layered.LayeredApplicationAssembler;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.assembly.config.ConfigurationLayer;
+import org.qi4j.bootstrap.assembly.connectivity.ConnectivityLayer;
+import org.qi4j.bootstrap.assembly.domain.DomainLayer;
+import org.qi4j.bootstrap.assembly.infrastructure.InfrastructureLayer;
+import org.qi4j.bootstrap.assembly.service.ServiceLayer;
+
+// START SNIPPET: application
+public class TestApplication extends LayeredApplicationAssembler
+{
+
+    public TestApplication( String name, String version, Application.Mode mode )
+        throws AssemblyException
+    {
+        super( name, version, mode );
+    }
+
+    @Override
+    protected void assembleLayers( ApplicationAssembly assembly )
+        throws AssemblyException
+    {
+        LayerAssembly configLayer = createLayer( ConfigurationLayer.class );
+        ModuleAssembly configModule = configLayer.module( "Configuration Module" );
+        LayerAssembly infraLayer = new InfrastructureLayer( configModule ).assemble( assembly.layer( InfrastructureLayer.NAME  ));
+        LayerAssembly domainLayer = createLayer( DomainLayer.class );
+        LayerAssembly serviceLayer = createLayer( ServiceLayer.class );
+        LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );
+
+        connectivityLayer.uses( serviceLayer );
+        connectivityLayer.uses( domainLayer );
+        serviceLayer.uses( domainLayer );
+        domainLayer.uses( infraLayer );
+        infraLayer.uses( configLayer );
+    }
+}
+// END SNIPPET: application

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/config/ConfigurationLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/config/ConfigurationLayer.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/config/ConfigurationLayer.java
new file mode 100644
index 0000000..1a35879
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/config/ConfigurationLayer.java
@@ -0,0 +1,33 @@
+/*
+ * 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.qi4j.bootstrap.assembly.config;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.layered.LayerAssembler;
+import org.qi4j.bootstrap.LayerAssembly;
+
+public class ConfigurationLayer implements LayerAssembler
+{
+    @Override
+    public LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException
+    {
+        return layer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/connectivity/ConnectivityLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/connectivity/ConnectivityLayer.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/connectivity/ConnectivityLayer.java
new file mode 100644
index 0000000..1002d37
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/connectivity/ConnectivityLayer.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap.assembly.connectivity;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.layered.LayerAssembler;
+import org.qi4j.bootstrap.LayerAssembly;
+
+public class ConnectivityLayer implements LayerAssembler
+{
+    public static final String NAME = "Connectivity";
+
+    @Override
+    public LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException
+    {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/DomainLayer.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/DomainLayer.java
new file mode 100644
index 0000000..8eac88b
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/DomainLayer.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap.assembly.domain;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.layered.LayeredLayerAssembler;
+
+public class DomainLayer extends LayeredLayerAssembler
+{
+    @Override
+    public LayerAssembly assemble( LayerAssembly layer )
+        throws AssemblyException
+    {
+        createModule( layer, InvoicingModule.class );
+        createModule( layer, OrderModule.class );
+        return layer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/InvoicingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/InvoicingModule.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/InvoicingModule.java
new file mode 100644
index 0000000..62a4640
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/InvoicingModule.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.bootstrap.assembly.domain;
+
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.ModuleAssembler;
+
+public class InvoicingModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/OrderModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/OrderModule.java b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/OrderModule.java
new file mode 100644
index 0000000..9e506e3
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/qi4j/bootstrap/assembly/domain/OrderModule.java
@@ -0,0 +1,56 @@
+/*
+ * 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.qi4j.bootstrap.assembly.domain;
+
+import org.qi4j.api.association.Association;
+import org.qi4j.api.property.Property;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.layered.ModuleAssembler;
+
+public class OrderModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.entities( Order.class, Customer.class );
+        module.values( Address.class );
+        return module;
+    }
+
+    public interface Order
+    {
+        Association<Customer> customer();
+
+        Property<Address> invoicingAddress();
+
+        Property<Address> deliveryAddress();
+    }
+
+    public interface Customer
+    {
+    }
+
+    public interface Address
+    {
+    }
+}


[28/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/Something.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/Something.java b/core/api/src/test/java/org/qi4j/api/mixin/Something.java
new file mode 100644
index 0000000..027404f
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/Something.java
@@ -0,0 +1,27 @@
+/*
+ * 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.qi4j.api.mixin;
+
+// START SNIPPET: something
+@Mixins( SomethingMixin.class )
+public interface Something
+{}
+// END SNIPPET: something
+
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/SomethingMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/SomethingMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/SomethingMixin.java
new file mode 100644
index 0000000..63153c4
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/SomethingMixin.java
@@ -0,0 +1,32 @@
+/*
+ * 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.qi4j.api.mixin;
+
+// START SNIPPET: something
+public class SomethingMixin
+        implements Something
+{
+    // State is allowed.
+
+    public void doSomething()
+    {
+        // do stuff...
+    }
+}
+// END SNIPPET: something

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/StartMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/StartMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/StartMixin.java
new file mode 100644
index 0000000..dbe1076
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/StartMixin.java
@@ -0,0 +1,22 @@
+/*
+ * 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.qi4j.api.mixin;
+
+public abstract class StartMixin implements Startable
+{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/Startable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/Startable.java b/core/api/src/test/java/org/qi4j/api/mixin/Startable.java
new file mode 100644
index 0000000..3603ca2
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/Startable.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.mixin;
+
+// START SNIPPET: mixins
+public interface Startable
+{
+    boolean start();
+    void stop();
+}
+
+// END SNIPPET: mixins
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/Vehicle.java b/core/api/src/test/java/org/qi4j/api/mixin/Vehicle.java
new file mode 100644
index 0000000..22705b6
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/Vehicle.java
@@ -0,0 +1,31 @@
+/*
+ * 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.qi4j.api.mixin;
+
+// START SNIPPET: mixins
+public interface Vehicle
+{
+    void turn(float angle);
+
+    void accelerate(float acceleration);
+
+    // more methods
+}
+
+// END SNIPPET: mixins
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/VehicleMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/VehicleMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/VehicleMixin.java
new file mode 100644
index 0000000..ad19d46
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/VehicleMixin.java
@@ -0,0 +1,22 @@
+/*
+ * 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.qi4j.api.mixin;
+
+public abstract class VehicleMixin
+{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/DecoratorMixinTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/DecoratorMixinTest.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/DecoratorMixinTest.java
new file mode 100644
index 0000000..d761d1a
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/DecoratorMixinTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.qi4j.api.mixin.decoratorMixin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import org.junit.Test;
+import org.qi4j.api.composite.TransientBuilder;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class DecoratorMixinTest extends AbstractQi4jTest
+{
+    // START SNIPPET: assembly
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.transients( View1.class );
+        module.transients( View2.class );
+        module.transients( FooModel.class );
+    }
+// END SNIPPET: assembly
+
+// START SNIPPET: test
+
+    @Test
+    public void testDecoration()
+    {
+        FooModelImpl model = new FooModelImpl( "Init" );
+        View1 view1 = createView1( model );
+        View2 view2 = createView2( model );
+        assertThat( view1.bar(), equalTo( "Init" ) );
+        assertThat( view2.bar(), equalTo( "Init" ) );
+        model.setBar( "New Value" );
+        assertThat( view1.bar(), equalTo( "New Value" ) );
+        assertThat( view2.bar(), equalTo( "New Value" ) );
+    }
+// END SNIPPET: test
+
+    @Test
+    public void testDecorationWithGenericMixin()
+    {
+        InvocationHandler handler = new FooModelInvocationHandler("Init");
+        ClassLoader cl = getClass().getClassLoader();
+        FooModel model = (FooModel) Proxy.newProxyInstance( cl, new Class[]{ FooModel.class }, handler );
+        View1 view1 = createView1( model );
+        View2 view2 = createView2( model );
+        assertThat( view1.bar(), equalTo( "Init" ) );
+        assertThat( view2.bar(), equalTo( "Init" ) );
+        model.setBar( "New Value" );
+        assertThat( view1.bar(), equalTo( "New Value" ) );
+        assertThat( view2.bar(), equalTo( "New Value" ) );
+    }
+
+    // START SNIPPET: create
+    public View1 createView1( FooModel model )
+    {
+        TransientBuilder<View1> builder = module.newTransientBuilder( View1.class );
+        builder.use( model );
+        return builder.newInstance();
+    }
+// END SNIPPET: create
+
+    public View2 createView2( FooModel model )
+    {
+        TransientBuilder<View2> builder = module.newTransientBuilder( View2.class );
+        builder.use( model );
+        return builder.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModel.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModel.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModel.java
new file mode 100644
index 0000000..bf74db4
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModel.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.api.mixin.decoratorMixin;
+
+import org.qi4j.api.composite.DecoratorMixin;
+import org.qi4j.api.mixin.Mixins;
+
+// START SNIPPET: decorator
+@Mixins(DecoratorMixin.class)
+// START SNIPPET: plain
+public interface FooModel
+// END SNIPPET: decorator
+{
+    String getBar();
+    void setBar(String value);
+// END SNIPPET: plain
+
+// START SNIPPET: plain
+}
+// END SNIPPET: plain

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelImpl.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelImpl.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelImpl.java
new file mode 100644
index 0000000..1ad5aee
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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.qi4j.api.mixin.decoratorMixin;
+
+public class FooModelImpl
+    implements FooModel
+{
+    private String bar;
+
+    public FooModelImpl( String bar )
+    {
+        this.bar = bar;
+    }
+
+    @Override
+    public String getBar()
+    {
+        return bar;
+    }
+
+    public void setBar( String bar )
+    {
+        this.bar = bar;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelInvocationHandler.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelInvocationHandler.java
new file mode 100644
index 0000000..eca17f3
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/FooModelInvocationHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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.qi4j.api.mixin.decoratorMixin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class FooModelInvocationHandler
+    implements InvocationHandler
+{
+    private String value;
+
+    public FooModelInvocationHandler( String value )
+    {
+        this.value = value;
+    }
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        if(method.getName().equals( "hashCode" ))
+            return hashCode();
+        if(method.getName().equals( "equals" ))
+            return equals(args[0]);
+        if(args==null || args.length==0)
+            return value;
+        value = (String) args[0];
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View1.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View1.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View1.java
new file mode 100644
index 0000000..a890433
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View1.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.mixin.decoratorMixin;
+
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+
+// START SNIPPET: decorator
+@Mixins(View1.Mixin.class)
+public interface View1
+{
+    String bar();
+
+    public class Mixin
+        implements View1
+    {
+        @This
+        FooModel model;
+
+        @Override
+        public String bar()
+        {
+            return model.getBar();
+        }
+    }
+}
+// END SNIPPET: decorator

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View2.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View2.java b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View2.java
new file mode 100644
index 0000000..4033072
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/decoratorMixin/View2.java
@@ -0,0 +1,40 @@
+/*
+ * 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.qi4j.api.mixin.decoratorMixin;
+
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+
+@Mixins(View2.Mixin.class)
+public interface View2
+{
+    String bar();
+    public class Mixin
+        implements View2
+    {
+        @This
+        FooModel model;
+
+        @Override
+        public String bar()
+        {
+            return model.getBar();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/Car.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/Car.java
new file mode 100644
index 0000000..cd2a668
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/Car.java
@@ -0,0 +1,30 @@
+/*
+ * 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.qi4j.api.mixin.partial;
+
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.mixin.StartMixin;
+import org.qi4j.api.mixin.Startable;
+
+// START SNIPPET: partial
+@Mixins( { StartMixin.class, SpeedMixin.class, CrashResultMixin.class } )
+public interface Car extends Startable, Vehicle
+{}
+
+// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/CrashResultMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/CrashResultMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/CrashResultMixin.java
new file mode 100644
index 0000000..830cb74
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/CrashResultMixin.java
@@ -0,0 +1,23 @@
+/*
+ * 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.qi4j.api.mixin.partial;
+
+public class CrashResultMixin implements Crashable
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/Crashable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/Crashable.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/Crashable.java
new file mode 100644
index 0000000..7ca07d0
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/Crashable.java
@@ -0,0 +1,23 @@
+/*
+ * 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.qi4j.api.mixin.partial;
+
+public interface Crashable
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedLocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedLocation.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedLocation.java
new file mode 100644
index 0000000..e8119da
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedLocation.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.mixin.partial;
+
+// START SNIPPET: partial
+public interface SpeedLocation
+{
+    void turn(float angle);
+
+    void accelerate(float acceleration);
+}
+// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedMixin.java
new file mode 100644
index 0000000..3f2cf6d
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/SpeedMixin.java
@@ -0,0 +1,33 @@
+/*
+ * 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.qi4j.api.mixin.partial;
+
+// START SNIPPET: partial
+public abstract class SpeedMixin
+        implements SpeedLocation
+{
+    // state for speed
+
+    public void accelerate( float acceleration )
+    {
+        // logic
+    }
+}
+
+// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/partial/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/partial/Vehicle.java b/core/api/src/test/java/org/qi4j/api/mixin/partial/Vehicle.java
new file mode 100644
index 0000000..4fa3597
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/partial/Vehicle.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.mixin.partial;
+
+// START SNIPPET: partial
+public interface Vehicle extends SpeedLocation, Crashable
+{
+}
+
+// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/Cargo.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/Cargo.java b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/Cargo.java
new file mode 100644
index 0000000..d8a8dcc
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/Cargo.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.api.mixin.privateMixin;
+
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.mixin.Mixins;
+
+// START SNIPPET: private
+@Mixins( CargoMixin.class )
+public interface Cargo extends EntityComposite
+{
+    String origin();
+
+    String destination();
+
+    void changeDestination( String newDestination );
+
+}
+
+// END SNIPPET: private

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoMixin.java b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoMixin.java
new file mode 100644
index 0000000..4bb059a
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoMixin.java
@@ -0,0 +1,46 @@
+/*
+ * 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.qi4j.api.mixin.privateMixin;
+
+import org.qi4j.api.injection.scope.This;
+
+// START SNIPPET: private
+public abstract class CargoMixin
+        implements Cargo
+{
+    @This
+    private CargoState state;
+
+    public String origin()
+    {
+        return state.origin().get();
+    }
+
+    public String destination()
+    {
+        return state.destination().get();
+    }
+
+    public void changeDestination( String newDestination )
+    {
+        state.destination().set( newDestination );
+    }
+}
+
+// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoState.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoState.java b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoState.java
new file mode 100644
index 0000000..f348aee
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/privateMixin/CargoState.java
@@ -0,0 +1,30 @@
+/*
+ * 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.qi4j.api.mixin.privateMixin;
+
+import org.qi4j.api.property.Property;
+
+// START SNIPPET: private
+public interface CargoState
+{
+    Property<String> origin();
+    Property<String> destination();
+}
+
+// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/object/ObjectBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/object/ObjectBuilderTest.java b/core/api/src/test/java/org/qi4j/api/object/ObjectBuilderTest.java
new file mode 100644
index 0000000..56cdcec
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/object/ObjectBuilderTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.api.object;
+
+import org.junit.Test;
+import org.qi4j.api.injection.scope.Uses;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * JAVADOC
+ */
+public class ObjectBuilderTest
+    extends AbstractQi4jTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.objects( A.class, B.class, C.class, D.class );
+    }
+
+    @Test
+    public void testNotProvidedUses()
+    {
+        A a = module.newObject( A.class );
+        assertNotNull( a );
+        assertNotNull( a.b );
+        assertNotNull( a.b.c );
+        assertNotNull( a.b.c.d );
+    }
+
+    public static class A
+    {
+        @Uses
+        B b;
+    }
+
+    public static class B
+    {
+        @Uses
+        C c;
+    }
+
+    public static class C
+    {
+        @Uses
+        D d;
+    }
+
+    public static class D
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/property/PropertyErrorTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/property/PropertyErrorTest.java b/core/api/src/test/java/org/qi4j/api/property/PropertyErrorTest.java
new file mode 100644
index 0000000..bd0e8e9
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/property/PropertyErrorTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.property;
+
+import org.junit.Test;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+/**
+ * Error messages for Properties
+ */
+public class PropertyErrorTest
+    extends AbstractQi4jTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( PersonEntity.class );
+    }
+
+    @Test( expected = ConstraintViolationException.class )
+    public void givenEntityWithNonOptionPropertyWhenInstantiatedThenException()
+        throws Exception
+    {
+        UnitOfWork unitOfWork = module.newUnitOfWork();
+        try
+        {
+            PersonEntity person = unitOfWork.newEntity( PersonEntity.class );
+
+            unitOfWork.complete();
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+    }
+
+    interface PersonEntity
+        extends EntityComposite
+    {
+        Property<String> foo();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/service/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/service/DocumentationSupport.java b/core/api/src/test/java/org/qi4j/api/service/DocumentationSupport.java
new file mode 100644
index 0000000..7042639
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/service/DocumentationSupport.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.service;
+
+import java.util.List;
+import org.qi4j.api.activation.Activators;
+import org.qi4j.api.injection.scope.Service;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.service.qualifier.ServiceTags;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.ServiceDeclaration;
+
+public class DocumentationSupport
+    implements Assembler
+{
+    // START SNIPPET: tag
+    // START SNIPPET: instantiateOnStartup
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        ServiceDeclaration service = module.addServices( MyDemoService.class );
+        // END SNIPPET: tag
+        service.instantiateOnStartup();
+        // END SNIPPET: instantiateOnStartup
+        // START SNIPPET: tag
+        service.taggedWith( "Important", "Drain" );
+        // END SNIPPET: tag
+    }
+
+    private static class MyDemoService
+    {
+    }
+
+    private static class MyOtherDemoService
+    {
+        // START SNIPPET: UseTag
+        @Service
+        private List<ServiceReference<MyDemoService>> services;
+
+        public MyDemoService locateImportantService()
+        {
+            for( ServiceReference<MyDemoService> ref : services )
+            {
+                ServiceTags serviceTags = ref.metaInfo( ServiceTags.class );
+                if( serviceTags.hasTag( "Important" ) )
+                {
+                    return ref.get();
+                }
+            }
+            return null;
+        }
+        // END SNIPPET: UseTag
+    }
+
+    // START SNIPPET: activation1
+    @Mixins( MyActivationMixin.class )
+    public static interface MyActivationDemoService
+        extends ServiceComposite, ServiceActivation
+    {
+    }
+
+    public static class MyActivationMixin
+        implements ServiceActivation
+    {
+        @Override
+        public void activateService()
+            throws Exception
+        {
+            // Activation code
+        }
+
+        @Override
+        public void passivateService()
+            throws Exception
+        {
+            // Passivation code
+        }
+    }
+    // END SNIPPET: activation1
+
+    // START SNIPPET: activation2
+    @Activators( MyActivator.class )
+    public static interface MyOtherActivationDemoService
+        extends ServiceComposite
+    {
+    }
+
+    public static class MyActivator
+        extends ServiceActivatorAdapter<MyOtherActivationDemoService>
+    {
+        @Override
+        public void afterActivation( ServiceReference<MyOtherActivationDemoService> activated )
+            throws Exception
+        {
+            // Activation code
+        }
+
+        @Override
+        public void beforePassivation( ServiceReference<MyOtherActivationDemoService> passivating )
+            throws Exception
+        {
+            // Passivation code
+        }
+    }
+    // END SNIPPET: activation2
+
+    static class Activation3
+        implements Assembler
+    {
+        // START SNIPPET: activation3
+        @Override
+        public void assemble( ModuleAssembly module )
+        {
+            module.services( MyDemoService.class ).withActivators( MyActivator.class );
+        }
+        // END SNIPPET: activation3
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/qi4j/api/unitofwork/RemovalTest.java
new file mode 100644
index 0000000..991ff73
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/unitofwork/RemovalTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.unitofwork;
+
+import org.junit.Test;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.entity.EntityBuilder;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.Property;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+public class RemovalTest
+    extends AbstractQi4jTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.entities( TestEntity.class );
+        module.entities( PidRegulator.class );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    @Test
+    public void givenEntityIsCreatedAndUnitOfWorkIsNotCompletedWhenEntityIsRemoveThenSuccessfulRemoval()
+        throws Exception
+    {
+        UnitOfWork uow = module.newUnitOfWork();
+        try
+        {
+            EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, "123" );
+            builder.instance().test().set( "habba" );
+            TestEntity test = builder.newInstance();
+            uow.remove( test );
+            uow.complete();
+        }
+        finally
+        {
+            uow.discard();
+        }
+    }
+
+    @Test
+    public void givenStandardPidRegulatorWhenNoChangeInInputExpectOutputToGoTowardsMinimum()
+        throws Exception
+    {
+        UnitOfWork uow = module.newUnitOfWork();
+        PidRegulator regulator = null;
+        try
+        {
+            regulator = createPidRegulator( uow );
+        }
+        finally
+        {
+            if( regulator != null )
+            {
+                uow.remove( regulator );
+            }
+            // TODO: This problem is related to that uow.remove() has a bug.
+            // If the Entity is both created and removed in the same session, then the remove() should simply remove
+            // the entity from the internal UoW holding area, and not set the REMOVED status.
+
+            // Probably that UnitOfWorkInstance.remove() should also call instanceCache.remove(), but the question is
+            // then what is an InstanceKey vs EntityReference
+            uow.complete();
+        }
+    }
+
+    public interface TestEntity
+        extends EntityComposite
+    {
+        @Optional
+        Property<String> test();
+    }
+
+    private PidRegulator createPidRegulator( UnitOfWork uow )
+        throws UnitOfWorkCompletionException
+    {
+        EntityBuilder<PidRegulator> builder = uow.newEntityBuilder( PidRegulator.class );
+        PidRegulator prototype = builder.instance();
+        prototype.p().set( 1.0f );
+        prototype.i().set( 10f );
+        prototype.d().set( 0.1f );
+        prototype.maxD().set( 10f );
+        prototype.maximum().set( 100f );
+        prototype.minimum().set( 0f );
+        PidRegulator regulator = builder.newInstance();
+
+        return regulator;
+    }
+
+    //    @Mixins( { PidRegulatorAlgorithmMixin.class } )
+    public interface PidRegulator
+        extends PidParameters, EntityComposite
+    {
+    }
+
+    public interface PidParameters
+    {
+        Property<Float> p();
+
+        Property<Float> i();
+
+        Property<Float> d();
+
+        Property<Float> maxD();
+
+        Property<Float> minimum();
+
+        Property<Float> maximum();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/unitofwork/UnitOfWorkTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/unitofwork/UnitOfWorkTemplateTest.java b/core/api/src/test/java/org/qi4j/api/unitofwork/UnitOfWorkTemplateTest.java
new file mode 100644
index 0000000..21212ae
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/unitofwork/UnitOfWorkTemplateTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.qi4j.api.unitofwork;
+
+import org.junit.Test;
+import org.qi4j.api.entity.EntityBuilderTemplate;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.Property;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+/**
+ * TODO
+ */
+public class UnitOfWorkTemplateTest
+    extends AbstractQi4jTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( TestEntity.class );
+    }
+
+    @Test
+    public void testTemplate()
+        throws UnitOfWorkCompletionException
+    {
+        new UnitOfWorkTemplate<Void, RuntimeException>()
+        {
+            @Override
+            protected Void withUnitOfWork( UnitOfWork uow )
+                throws RuntimeException
+            {
+                new EntityBuilderTemplate<TestEntity>( TestEntity.class )
+                {
+                    @Override
+                    protected void build( TestEntity prototype )
+                    {
+                        prototype.name().set( "Rickard" );
+                    }
+                }.newInstance( module );
+
+                return null;
+            }
+        }.withModule( module );
+    }
+
+    interface TestEntity
+        extends EntityComposite
+    {
+        Property<String> name();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/util/ClassesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/util/ClassesTest.java b/core/api/src/test/java/org/qi4j/api/util/ClassesTest.java
new file mode 100644
index 0000000..85be327
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/util/ClassesTest.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.api.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+import org.qi4j.functional.Specifications;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.qi4j.api.util.Classes.interfacesOf;
+import static org.qi4j.api.util.Classes.interfacesWithMethods;
+import static org.qi4j.functional.Iterables.count;
+
+/**
+ * Tests for Classes
+ */
+public class ClassesTest
+{
+
+    @Test
+    public void givenClassWithInterfacesWhenInterfacesOfThenGetCorrectSet()
+    {
+        assertThat( "one interface returned", count( interfacesOf( A.class ) ), equalTo( 1L ) );
+        assertThat( "two interface returned", count( interfacesOf( B.class ) ), equalTo( 2L ) );
+        assertThat( "tree interface returned", count( interfacesOf( C.class ) ), equalTo( 4L ) );
+    }
+
+    @Test
+    public void givenClassWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
+    {
+        HashSet<Class<?>> interfaces = new HashSet<Class<?>>();
+        interfaces.add( B.class );
+        Set<Class<?>> types = interfacesWithMethods( interfaces );
+        assertThat( "one interface returned", types.size(), equalTo( 1 ) );
+        assertThat( "correct interface returned", types.contains( B.class ), is( true ) );
+    }
+
+    @Test
+    public void givenClassesWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
+    {
+        Iterable<Type> types = Iterables.filter( Methods.HAS_METHODS, interfacesOf( C.class ) );
+        assertThat( "one interface returned", count( types ), equalTo( 1L ) );
+        assertThat( "correct interface returned", Iterables.matchesAny( (Specification) Specifications.in( B.class ), Iterables
+            .<Class<?>>cast( types ) ), is( true ) );
+    }
+
+    @Test
+    public void givenClassNameWhenToUriThenUriIsReturned()
+    {
+        assertThat( "URI is correct", Classes.toURI( A.class ), equalTo( "urn:qi4j:type:org.qi4j.api.util.ClassesTest-A" ) );
+    }
+
+    @Test
+    public void givenUriWhenToClassNameThenClassNameIsReturned()
+    {
+        assertThat( "Class name is correct", Classes.toClassName( "urn:qi4j:type:org.qi4j.api.util.ClassesTest-A" ), equalTo( "org.qi4j.api.util.ClassesTest$A" ) );
+    }
+
+    @Test
+    public void givenGenericTypeWithWildCardWhenGetRawClassThenCorrectTypeIsReturned()
+        throws NoSuchMethodException
+    {
+        Type returnType = Generics.class.getMethod( "wildcard" ).getGenericReturnType();
+        Type wildcardType = ( (ParameterizedType) returnType ).getActualTypeArguments()[ 0];
+        assertThat( "Return type is A", Classes.RAW_CLASS.map( wildcardType ), equalTo( (Class) A.class ) );
+    }
+
+    @Test
+    public void givenTypeVariableWhenResolveThenResolved()
+    {
+        for( Method method : Type1.class.getMethods() )
+        {
+            Type type = method.getGenericReturnType();
+            TypeVariable typeVariable = (TypeVariable) type;
+            Type resolvedType = Classes.resolveTypeVariable( typeVariable, method.getDeclaringClass(), Type1.class );
+            System.out.println( type + "=" + resolvedType );
+            switch( method.getName() )
+            {
+                case "type":
+                    assertThat( resolvedType, equalTo( (Type) String.class ) );
+                    break;
+                case "type1":
+                    assertThat( resolvedType, equalTo( (Type) String.class ) );
+                    break;
+                case "type2":
+                    assertThat( resolvedType, equalTo( (Type) Long.class ) );
+                    break;
+            }
+        }
+    }
+
+    @Test
+    public void givenGenericTypeWhenGetSimpleGenericNameThenCorrectStringIsReturned()
+        throws NoSuchMethodException
+    {
+        assertThat( "Simple Generic Name is 'A'",
+                    Classes.simpleGenericNameOf( A.class ),
+                    equalTo( "A" ) );
+        assertThat( "Simple Generic Name is 'B'",
+                    Classes.simpleGenericNameOf( B.class ),
+                    equalTo( "B" ) );
+        assertThat( "Simple Generic Name is 'C'",
+                    Classes.simpleGenericNameOf( C.class ),
+                    equalTo( "C" ) );
+
+        assertThat( "Simple Generic Name is 'Generics'",
+                    Classes.simpleGenericNameOf( Generics.class ),
+                    equalTo( "Generics" ) );
+        assertThat( "Simple Generic Name is 'Iterable<? extends A>'",
+                    Classes.simpleGenericNameOf( Generics.class.getMethod( "wildcard" ).getGenericReturnType() ),
+                    equalTo( "Iterable<? extends A>" ) );
+
+        assertThat( "Simple Generic Name is 'Type1'",
+                    Classes.simpleGenericNameOf( Type1.class ),
+                    equalTo( "Type1" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+        assertThat( "Simple Generic Name is 'TYPE1'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type1" ).getGenericReturnType() ),
+                    equalTo( "TYPE1" ) );
+        assertThat( "Simple Generic Name is 'TYPE2'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type2" ).getGenericReturnType() ),
+                    equalTo( "TYPE2" ) );
+
+        assertThat( "Simple Generic Name is 'Type2'",
+                    Classes.simpleGenericNameOf( Type2.class ),
+                    equalTo( "Type2" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+        assertThat( "Simple Generic Name is 'TYPE1'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type1" ).getGenericReturnType() ),
+                    equalTo( "TYPE1" ) );
+        assertThat( "Simple Generic Name is 'TYPE2'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type2" ).getGenericReturnType() ),
+                    equalTo( "TYPE2" ) );
+
+        assertThat( "Simple Generic Name is 'Type3'",
+                    Classes.simpleGenericNameOf( Type3.class ),
+                    equalTo( "Type3" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type3.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+    }
+
+    interface A
+    {
+    }
+
+    interface B
+        extends A
+    {
+
+        public void doStuff();
+
+    }
+
+    interface C
+        extends A, B
+    {
+    }
+
+    interface Generics
+    {
+
+        Iterable<? extends A> wildcard();
+
+    }
+
+    interface Type1
+        extends Type2<String, Long>
+    {
+    }
+
+    interface Type2<TYPE1, TYPE2>
+        extends Type3<TYPE1>
+    {
+
+        TYPE1 type1();
+
+        TYPE2 type2();
+
+    }
+
+    interface Type3<TYPE>
+    {
+
+        TYPE type();
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/value/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/value/DocumentationSupport.java b/core/api/src/test/java/org/qi4j/api/value/DocumentationSupport.java
new file mode 100644
index 0000000..32595b2
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/value/DocumentationSupport.java
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2013, Paul Merlin. 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.qi4j.api.value;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.qi4j.api.injection.scope.Service;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.CollectionType;
+import org.qi4j.bootstrap.ApplicationAssembler;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.Energy4Java;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.functional.Function;
+import org.qi4j.io.Inputs;
+import org.qi4j.io.Outputs;
+import org.qi4j.io.Transforms;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Snippets:
+ * - default : default ValueSerialization
+ * - service : assembled service ValueSerialization
+ * - lookup  : ValueSerialization values module finder
+ */
+public class DocumentationSupport
+    extends AbstractQi4jTest
+{
+
+    @Before
+    public void injectToThis()
+    {
+        module.injectTo( this );
+    }
+
+    // START SNIPPET: default
+    // START SNIPPET: service
+    public interface SomeValue // (1)
+    {
+
+        Property<String> foo();
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.values( SomeValue.class ); // (2)
+        // END SNIPPET: default
+        new OrgJsonValueSerializationAssembler().assemble( module ); // (3)
+        // START SNIPPET: default
+    }
+    // END SNIPPET: default
+    // END SNIPPET: service
+
+    @Test
+    // START SNIPPET: default
+    public void defaultValueSerialization()
+    {
+        SomeValue someValue = someNewValueInstance( module ); // (3)
+        String json = someValue.toString(); // (4)
+        SomeValue someNewValue = module.newValueFromSerializedState( SomeValue.class, json ); // (5)
+        // END SNIPPET: default
+
+        assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
+        assertThat( someNewValue, equalTo( someValue ) );
+
+        // START SNIPPET: default
+    }
+    // END SNIPPET: default
+    // START SNIPPET: service
+    @Service
+    private ValueSerializer valueSerializer; // (4)
+    @Service
+    private ValueDeserializer valueDeserializer; // (4)
+
+    // END SNIPPET: service
+    @Test
+    // START SNIPPET: service
+    public void assembledDefaultServiceSerialization()
+    {
+        SomeValue someValue = someNewValueInstance( module ); // (5)
+        String json = valueSerializer.serialize( someValue ); // (6)
+        SomeValue someNewValue = valueDeserializer.deserialize( SomeValue.class, json ); // (7)
+        // END SNIPPET: service
+
+        assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
+        assertThat( someNewValue, equalTo( someValue ) );
+
+        // START SNIPPET: service
+    }
+    // END SNIPPET: service
+
+    static enum AcmeValue
+    {
+
+        foo, bar
+    }
+
+    @Test
+    // START SNIPPET: stream
+    public void assembledServiceStreamingSerialization()
+    {
+        // END SNIPPET: stream
+
+        List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
+        ByteArrayOutputStream targetStream = new ByteArrayOutputStream();
+
+        // START SNIPPET: stream
+        // (1)
+        Iterable<AcmeValue> data = dataSource; // Eg. Entities converted to Values
+        OutputStream output = targetStream; // Eg. streaming JSON over HTTP
+
+        // (2)
+        valueSerializer.serialize( data, output );
+        // END SNIPPET: stream
+
+        byte[] serialized = targetStream.toByteArray();
+        ByteArrayInputStream sourceStream = new ByteArrayInputStream( serialized );
+
+        // START SNIPPET: stream
+        // (3)
+        InputStream input = sourceStream; // Eg. reading incoming JSON
+
+        // (4)
+        List<AcmeValue> values = valueDeserializer.deserialize( CollectionType.listOf( AcmeValue.class ), input );
+        // END SNIPPET: stream
+
+        assertThat( values, equalTo( dataSource ) );
+
+        // START SNIPPET: stream
+    }
+    // END SNIPPET: stream
+
+    @Test
+    // START SNIPPET: io
+    public void assembledServiceIOSerialization()
+        throws IOException
+    {
+        // END SNIPPET: io
+
+        List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
+        StringWriter outputWriter = new StringWriter();
+
+        // START SNIPPET: io
+        // (1)
+        Iterable<AcmeValue> queryResult = dataSource; // Eg. Entities converted to Values
+        Writer writer = outputWriter; // Eg. to pipe data to another process or to a file
+
+        // (2)
+        Function<AcmeValue, String> serialize = valueSerializer.serialize();
+
+        // (3)
+        Inputs.iterable( queryResult ).transferTo( Transforms.map( serialize, Outputs.text( writer ) ) );
+        // END SNIPPET: io
+
+        String string = writer.toString();
+        StringReader inputReader = new StringReader( string );
+
+        // START SNIPPET: io
+        // (4)
+        Reader reader = inputReader;
+        List<AcmeValue> values = new ArrayList<AcmeValue>();
+
+        // (5)
+        Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( AcmeValue.class );
+
+        // Deserialization of a collection of AcmeValue from a String.
+        // One serialized AcmeValue per line.
+        // (6)
+        Inputs.text( reader ).transferTo( Transforms.map( deserialize, Outputs.collection( values ) ) );
+        // END SNIPPET: io
+
+        assertThat( dataSource, equalTo( values ) );
+
+        // START SNIPPET: io
+    }
+    // END SNIPPET: io
+
+    @Test
+    // TODO Move to SPI !
+    // TODO Include in each ValueSerialization extensions documentation
+    public void assembledWithValuesModuleSerialization()
+        throws Exception
+    {
+        Application app = new Energy4Java().newApplication( new ApplicationAssembler()
+        {
+            @Override
+            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+                throws AssemblyException
+            {
+                Assembler[][][] pancakes = new Assembler[][][]
+                {
+                    {
+                        {
+                            new Assembler()
+                            {
+                                @Override
+                                public void assemble( ModuleAssembly valuesModule )
+                                    throws AssemblyException
+                                {
+                                    valuesModule.layer().setName( "SINGLE-Layer" );
+                                    valuesModule.setName( "VALUES-Module" );
+
+                                    valuesModule.values( SomeValue.class );
+                                }
+                            }
+                        },
+                        {
+                            new Assembler()
+                            {
+                                @Override
+                                public void assemble( ModuleAssembly servicesModule )
+                                    throws AssemblyException
+                                {
+                                    servicesModule.setName( "SERVICES-Module" );
+
+                                    Function<Application, Module> valuesModuleFinder = new Function<Application, Module>()
+                                    {
+                                        @Override
+                                        public Module map( Application app )
+                                        {
+                                            return app.findModule( "SINGLE-Layer", "VALUES-Module" );
+                                        }
+                                    };
+                                    new OrgJsonValueSerializationAssembler().
+                                        withValuesModuleFinder( valuesModuleFinder ).
+                                        assemble( servicesModule );
+                                }
+                            }
+                        }
+                    }
+                };
+                return applicationFactory.newApplicationAssembly( pancakes );
+            }
+        } );
+        app.activate();
+        try
+        {
+            Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" );
+            SomeValue someValue = someNewValueInstance( valuesModule );
+
+            Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" );
+            ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get();
+
+            String json = valueSerialization.serialize( someValue );
+            assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
+
+            SomeValue someNewValue = valueSerialization.deserialize( SomeValue.class, json );
+            assertThat( someNewValue, equalTo( someValue ) );
+        }
+        finally
+        {
+            app.passivate();
+        }
+    }
+
+    private SomeValue someNewValueInstance( Module module )
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        builder.prototype().foo().set( "bar" );
+        return builder.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/value/ValueBuilderTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/value/ValueBuilderTemplateTest.java b/core/api/src/test/java/org/qi4j/api/value/ValueBuilderTemplateTest.java
new file mode 100644
index 0000000..420d48e
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/value/ValueBuilderTemplateTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.qi4j.api.value;
+
+import org.junit.Test;
+import org.qi4j.api.property.Property;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+
+/**
+ * TODO
+ */
+public class ValueBuilderTemplateTest
+    extends AbstractQi4jTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.values( TestValue.class );
+    }
+
+    @Test
+    public void testTemplate()
+    {
+        new TestBuilder( "Rickard" ).newInstance( module );
+    }
+
+    @Test
+    public void testAnonymousTemplate()
+    {
+        new ValueBuilderTemplate<TestValue>( TestValue.class )
+        {
+            @Override
+            protected void build( TestValue prototype )
+            {
+                prototype.name().set( "Rickard" );
+            }
+        }.newInstance( module );
+    }
+
+    interface TestValue
+        extends ValueComposite
+    {
+        Property<String> name();
+    }
+
+    class TestBuilder
+        extends ValueBuilderTemplate<TestValue>
+    {
+        String name;
+
+        TestBuilder( String name )
+        {
+            super( TestValue.class );
+            this.name = name;
+        }
+
+        @Override
+        protected void build( TestValue prototype )
+        {
+            prototype.name().set( name );
+        }
+    }
+
+    ;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/value/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/value/ValueCompositeTest.java b/core/api/src/test/java/org/qi4j/api/value/ValueCompositeTest.java
new file mode 100644
index 0000000..1c545a4
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/value/ValueCompositeTest.java
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.value;
+
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.EntityBuilder;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.unitofwork.UnitOfWorkCompletionException;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.library.constraints.annotation.MaxLength;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests for ValueComposites
+ */
+public class ValueCompositeTest
+    extends AbstractQi4jTest
+{
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.values( SomeValue.class, AnotherValue.class, AssociationValue.class );
+        module.entities( SomeEntity.class );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    @Test( expected = IllegalStateException.class )
+    public void testImmutabilityOfValueComposite()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue some = builder.prototype();
+        some.other().set( "test" );
+        some = builder.newInstance();
+        some.other().set( "test2" );
+    }
+
+    @Test
+    public void testCreationOfValueComposite()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue some = builder.prototype();
+        some.other().set( "test" );
+        builder.newInstance();
+
+        // Check that @UseDefaults works for ValueComposites
+        assertEquals( "{\"val1\":\"\"}", some.another().get().toString() );
+    }
+
+    @Test
+    public void testEqualityOfValueComposite()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue prototype = builder.prototype();
+        prototype.other().set( "test" );
+        SomeValue instance = builder.newInstance();
+        SomeValue other = builder.newInstance();
+        Assert.assertFalse( "Instances should not be the same.", instance == other );
+        Assert.assertEquals( "Equal values.", instance, other );
+    }
+
+    @Test
+    public void testHashcodeOfValueComposite()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue prototype = builder.prototype();
+        prototype.other().set( "test" );
+        SomeValue instance = builder.newInstance();
+        SomeValue other = builder.newInstance();
+        Assert.assertFalse( "Instances should not be the same.", instance == other );
+        Assert.assertEquals( "Equal values.", instance.hashCode(), other.hashCode() );
+    }
+
+    @Test
+    public void testModifyValue()
+    {
+        ValueBuilder<AnotherValue> anotherBuilder = module.newValueBuilder( AnotherValue.class );
+        anotherBuilder.prototype().val1().set( "Val1" );
+        AnotherValue anotherValue = anotherBuilder.newInstance();
+
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue prototype = builder.prototype();
+        prototype.some().set( "foo" );
+        prototype.other().set( "test" );
+        prototype.xyzzyList().get().add( "blah" );
+        prototype.another().set( anotherValue );
+        SomeValue instance = builder.newInstance();
+
+        assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
+
+        // Modify value
+        builder = module.newValueBuilderWithPrototype( instance );
+        builder.prototype().some().set( "bar" );
+        instance = builder.newInstance();
+
+        assertThat( "Other is set to test", instance.other().get(), equalTo( "test" ) );
+        assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
+        assertThat( "AnotherValue.val1 has value Val1", instance.another().get().val1().get(), equalTo( "Val1" ) );
+
+        // Modify value again using method 2
+        builder = module.newValueBuilderWithPrototype( instance );
+        builder.prototype().other().set( "test2" );
+        instance = builder.newInstance();
+
+        assertThat( "Other is set to test2", instance.other().get(), equalTo( "test2" ) );
+        assertThat( "Some is set to bar", instance.some().get(), equalTo( "bar" ) );
+    }
+
+    @Test( expected = ConstraintViolationException.class )
+    public void givenValueWhenModifyToIncorrectValueThenThrowConstraintException()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        SomeValue prototype = builder.prototype();
+        prototype.some().set( "foo" );
+        SomeValue instance = builder.newInstance();
+
+        builder = module.newValueBuilderWithPrototype( instance );
+        builder.prototype().some().set( "123456" );
+    }
+
+    @Test
+    public void givenValueWithListOfValueWhenPrototypeThenListedValuesAreEditable()
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+        SomeValue some = builder.newInstance();
+
+        builder = module.newValueBuilderWithPrototype( some );
+        builder.prototype().anotherList().get().get( 0 ).val1().set( "Foo" );
+        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+        some = builder.newInstance();
+
+        assertThat( "Val1 has been set", some.anotherList().get().get( 0 ).val1().get(), equalTo( "Foo" ) );
+
+        try
+        {
+            some.anotherList().get().get( 0 ).val1().set( "Bar" );
+            Assert.fail( "Should not be allowed to modify value" );
+        }
+        catch( IllegalStateException e )
+        {
+            // Ok
+        }
+    }
+
+    @Test
+    public void givenEntityWhenUpdateValueThenValueIsSet()
+        throws UnitOfWorkCompletionException
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+        valueBuilder.prototype().val1().set( "Foo" );
+        builder.prototype().another().set( valueBuilder.newInstance() );
+        builder.prototype().number().set( 42L );
+        SomeValue some = builder.newInstance();
+
+        UnitOfWork unitOfWork = module.newUnitOfWork();
+        try
+        {
+            EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
+            entityBuilder.instance().someValue().set( some );
+            SomeEntity entity = entityBuilder.newInstance();
+
+            assertThat( "Value has been set", entity.someValue().get().another().get().val1().get(), equalTo( "Foo" ) );
+
+            unitOfWork.complete();
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+    }
+
+    @Test
+    public void givenValueWithAssociationsWhenNewUoWThenCanRead()
+        throws UnitOfWorkCompletionException
+    {
+        ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+        builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+        valueBuilder.prototype().val1().set( "Foo" );
+        builder.prototype().another().set( valueBuilder.newInstance() );
+        builder.prototype().number().set( 42L );
+        SomeValue some = builder.newInstance();
+
+        UnitOfWork unitOfWork = module.newUnitOfWork();
+        AssociationValue associationValue;
+        try
+        {
+            EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
+            entityBuilder.instance().someValue().set( some );
+            SomeEntity entity = entityBuilder.newInstance();
+
+            ValueBuilder<AssociationValue> associationBuilder = module.newValueBuilder( AssociationValue.class );
+            associationBuilder.prototype().some().set( entity );
+            associationValue = associationBuilder.newInstance();
+
+            String json = associationValue.toString();
+
+            unitOfWork.complete();
+
+            unitOfWork = module.newUnitOfWork();
+
+            AssociationValue newAssociationValue = module.newValueFromSerializedState( AssociationValue.class, json );
+
+            Assert.assertEquals( associationValue.some().get(), newAssociationValue.some().get() );
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+
+        // Should allow the toString() to print the entityRefs.
+        System.out.println( associationValue.toString() );
+        try
+        {
+            associationValue.some().get();
+            fail( "Should have thrown an exception" );
+        }
+        catch( Exception e )
+        {
+            // Ok
+        }
+    }
+
+    public enum TestEnum
+    {
+        somevalue, anothervalue
+    }
+
+    public interface SomeValue
+        extends ValueComposite
+    {
+        @UseDefaults
+        @MaxLength( 5 )
+        Property<String> some();
+
+        @UseDefaults
+        Property<String> other();
+
+        @UseDefaults
+        Property<Long> number();
+
+        @UseDefaults
+        Property<List<String>> xyzzyList();
+
+        @UseDefaults
+        Property<AnotherValue> another();
+
+        @UseDefaults
+        Property<List<AnotherValue>> anotherList();
+
+        @UseDefaults
+        Property<TestEnum> testEnum();
+    }
+
+    public interface AnotherValue
+        extends ValueComposite
+    {
+        @UseDefaults
+        Property<String> val1();
+    }
+
+    public interface AssociationValue
+        extends ValueComposite
+    {
+        @Optional
+        Association<SomeEntity> some();
+
+        ManyAssociation<SomeEntity> manySome();
+    }
+
+    public interface SomeEntity
+        extends EntityComposite
+    {
+        Property<SomeValue> someValue();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties
----------------------------------------------------------------------
diff --git a/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties b/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties
deleted file mode 100644
index 6ed5ff6..0000000
--- a/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties
+++ /dev/null
@@ -1,16 +0,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.
-
-me = { name : Niclas, address={ street1 : "Henan Lu 555", street2 : "Block 15", city : { cityName : "Shanghai", country : { countryName : "China" } } } }
\ No newline at end of file


[05/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsModel.java
new file mode 100644
index 0000000..04fc728
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/activation/ActivatorsModel.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012-2014, Paul Merlin. 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.qi4j.runtime.activation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.structure.Module;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.composite.UsesInstance;
+import org.qi4j.runtime.injection.InjectionContext;
+import org.qi4j.runtime.structure.ModuleInstance;
+
+/**
+ * Activators Model.
+ *
+ * @param <ActivateeType> Type of the activation target
+ */
+public class ActivatorsModel<ActivateeType>
+    implements VisitableHierarchy<Object, Object>
+{
+
+    private final List<ActivatorModel<ActivateeType>> activatorModels = new ArrayList<>();
+    private final Iterable<Class<? extends Activator<ActivateeType>>> activatorsClasses;
+
+    public ActivatorsModel( Iterable<Class<? extends Activator<ActivateeType>>> activatorsClasses )
+    {
+        this.activatorsClasses = activatorsClasses;
+        for( Class<? extends Activator<ActivateeType>> activatorClass : activatorsClasses )
+        {
+            activatorModels.add( new ActivatorModel<>( activatorClass ) );
+        }
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
+            {
+                if( !activatorModel.accept( visitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    public Iterable<ActivatorModel<ActivateeType>> models()
+    {
+        return activatorModels;
+    }
+
+    public Iterable<Activator<ActivateeType>> newInstances()
+        throws ActivationException
+    {
+        List<Activator<ActivateeType>> activators = new ArrayList<>();
+        for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
+        {
+            activators.add( activatorModel.newInstance() );
+        }
+        return activators;
+    }
+
+    public Iterable<Activator<ActivateeType>> newInstances( Module module )
+        throws ActivationException
+    {
+        List<Activator<ActivateeType>> activators = new ArrayList<>();
+        for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
+        {
+            InjectionContext injectionContext = new InjectionContext( (ModuleInstance) module, UsesInstance.EMPTY_USES );
+            activators.add( activatorModel.newInstance( injectionContext ) );
+        }
+        return activators;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/AbstractAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/AbstractAssociationInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/association/AbstractAssociationInstance.java
new file mode 100644
index 0000000..21d696a
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/AbstractAssociationInstance.java
@@ -0,0 +1,93 @@
+/*
+ * 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.qi4j.runtime.association;
+
+import java.lang.reflect.Type;
+import org.qi4j.api.association.AbstractAssociation;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.functional.Function2;
+
+/**
+ * Implementation of AbstractAssociation. Includes helper methods for subclasses
+ */
+public abstract class AbstractAssociationInstance<T>
+    implements AbstractAssociation
+{
+    protected AssociationInfo associationInfo;
+    private final Function2<EntityReference, Type, Object> entityFunction;
+
+    public AbstractAssociationInstance( AssociationInfo associationInfo,
+                                        Function2<EntityReference, Type, Object> entityFunction
+    )
+    {
+        this.associationInfo = associationInfo;
+        this.entityFunction = entityFunction;
+    }
+
+    public AssociationInfo associationInfo()
+    {
+        return associationInfo;
+    }
+
+    public void setAssociationInfo( AssociationInfo newInfo )
+    {
+        this.associationInfo = newInfo;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected T getEntity( EntityReference entityId )
+    {
+        if( entityId == null )
+        {
+            return null;
+        }
+
+        return (T) entityFunction.map( entityId, associationInfo.type() );
+    }
+
+    protected EntityReference getEntityReference( Object composite )
+    {
+        if( composite == null )
+        {
+            return null;
+        }
+
+        return new EntityReference( ( (Identity) composite ).identity().get() );
+    }
+
+    protected void checkType( Object instance )
+    {
+
+        if( instance instanceof Identity || instance == null )
+        {
+            return;
+        }
+        throw new IllegalArgumentException( "Object must be a subtype of org.qi4j.api.identity.Identity: " + instance.getClass() );
+    }
+
+    protected void checkImmutable()
+        throws IllegalStateException
+    {
+        if( associationInfo.isImmutable() )
+        {
+            throw new IllegalStateException( "Association [" + associationInfo.qualifiedName() + "] is immutable." );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInfo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInfo.java b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInfo.java
new file mode 100644
index 0000000..fd6695d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInfo.java
@@ -0,0 +1,36 @@
+/*
+ * 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.qi4j.runtime.association;
+
+import java.lang.reflect.Type;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.runtime.composite.ConstraintsCheck;
+
+/**
+ * TODO
+ */
+public interface AssociationInfo
+    extends ConstraintsCheck
+{
+    boolean isImmutable();
+
+    QualifiedName qualifiedName();
+
+    Type type();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInstance.java
new file mode 100644
index 0000000..e42d8eb
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationInstance.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.association;
+
+import java.lang.reflect.Type;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.AssociationWrapper;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.property.Property;
+import org.qi4j.functional.Function2;
+
+/**
+ * Implementation of Association to a single Entity.
+ */
+public final class AssociationInstance<T>
+    extends AbstractAssociationInstance<T>
+    implements Association<T>
+{
+    private Property<EntityReference> associationState;
+
+    public AssociationInstance( AssociationInfo associationInfo,
+                                Function2<EntityReference, Type, Object> entityFunction,
+                                Property<EntityReference> associationState
+    )
+    {
+        super( associationInfo, entityFunction );
+        this.associationState = associationState;
+    }
+
+    // Association implementation
+    @Override
+    public T get()
+    {
+        return getEntity( associationState.get() );
+    }
+
+    @Override
+    public void set( T newValue )
+        throws IllegalArgumentException
+    {
+        checkImmutable();
+        checkType( newValue );
+
+        associationInfo.checkConstraints( newValue );
+
+        // Change association
+        associationState.set( EntityReference.create( (Identity) newValue ));
+    }
+
+    @Override
+    public EntityReference reference()
+    {
+        return associationState.get();
+    }
+
+    public Property<EntityReference> getAssociationState()
+    {
+        return associationState;
+    }
+
+    @Override
+    public String toString()
+    {
+        if( associationState.get() == null )
+        {
+            return "";
+        }
+        else
+        {
+            return associationState.get().toString();
+        }
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = associationInfo.hashCode() * 39; // Descriptor
+        if( associationState.get() != null )
+        {
+            hash = hash * 997 + associationState.get().hashCode(); // State
+        }
+        return hash;
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        Association<?> that = (Association) o;
+        // Unwrap if needed
+        while( that instanceof AssociationWrapper )
+        {
+            that = ( (AssociationWrapper) that ).next();
+        }
+        // Descriptor equality
+        AssociationInstance<?> thatInstance = (AssociationInstance) that;
+        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
+        if( !associationInfo.equals( thatDescriptor ) )
+        {
+            return false;
+        }
+        // State equality
+        if( associationState.get() != null
+            ? !associationState.get().equals( thatInstance.associationState.get() )
+            : thatInstance.associationState.get() != null )
+        {
+            return false;
+        }
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationModel.java
new file mode 100644
index 0000000..d1d5f36
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationModel.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.List;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.constraint.ConstraintViolation;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.Aggregated;
+import org.qi4j.api.entity.Queryable;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.BindingException;
+import org.qi4j.functional.Visitable;
+import org.qi4j.functional.Visitor;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.model.Binder;
+import org.qi4j.runtime.model.Resolution;
+
+import static org.qi4j.functional.Iterables.empty;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Model for an Association.
+ *
+ * <p>Equality is based on the Association accessor object (associated type and name), not on the QualifiedName.</p>
+ */
+public final class AssociationModel
+    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<AssociationModel>
+{
+    private MetaInfo metaInfo;
+    private Type type;
+    private AccessibleObject accessor;
+    private QualifiedName qualifiedName;
+    private ValueConstraintsInstance constraints;
+    private ValueConstraintsInstance associationConstraints;
+    private boolean queryable;
+    private boolean immutable;
+    private boolean aggregated;
+    private AssociationInfo builderInfo;
+
+    public AssociationModel( AccessibleObject accessor,
+                             ValueConstraintsInstance valueConstraintsInstance,
+                             ValueConstraintsInstance associationConstraintsInstance,
+                             MetaInfo metaInfo
+    )
+    {
+        this.metaInfo = metaInfo;
+        this.constraints = valueConstraintsInstance;
+        this.associationConstraints = associationConstraintsInstance;
+        this.accessor = accessor;
+        initialize();
+    }
+
+    private void initialize()
+    {
+        this.type = GenericAssociationInfo.associationTypeOf( accessor );
+        this.qualifiedName = QualifiedName.fromAccessor( accessor );
+        this.immutable = metaInfo.get( Immutable.class ) != null;
+        this.aggregated = metaInfo.get( Aggregated.class ) != null;
+
+        final Queryable queryable = accessor.getAnnotation( Queryable.class );
+        this.queryable = queryable == null || queryable.value();
+    }
+
+    @Override
+    public <T> T metaInfo( Class<T> infoType )
+    {
+        return metaInfo.get( infoType );
+    }
+
+    @Override
+    public QualifiedName qualifiedName()
+    {
+        return qualifiedName;
+    }
+
+    @Override
+    public Type type()
+    {
+        return type;
+    }
+
+    @Override
+    public boolean isImmutable()
+    {
+        return immutable;
+    }
+
+    @Override
+    public boolean isAggregated()
+    {
+        return aggregated;
+    }
+
+    @Override
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public boolean queryable()
+    {
+        return queryable;
+    }
+
+    public AssociationInfo getBuilderInfo()
+    {
+        return builderInfo;
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( Visitor<? super AssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        return visitor.visit( this );
+    }
+
+    @Override
+    public void checkConstraints( Object value )
+        throws ConstraintViolationException
+    {
+        if( constraints != null )
+        {
+            List<ConstraintViolation> violations = constraints.checkConstraints( value );
+            if( !violations.isEmpty() )
+            {
+                Iterable<Class<?>> empty = empty();
+                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+            }
+        }
+    }
+
+    public void checkAssociationConstraints( Association<?> association )
+        throws ConstraintViolationException
+    {
+        if( associationConstraints != null )
+        {
+            List<ConstraintViolation> violations = associationConstraints.checkConstraints( association );
+            if( !violations.isEmpty() )
+            {
+                throw new ConstraintViolationException( (Composite) association.get(), (Member) accessor, violations );
+            }
+        }
+    }
+
+    @Override
+    public void bind( Resolution resolution )
+        throws BindingException
+    {
+        builderInfo = new AssociationInfo()
+        {
+            @Override
+            public boolean isImmutable()
+            {
+                return false;
+            }
+
+            @Override
+            public QualifiedName qualifiedName()
+            {
+                return qualifiedName;
+            }
+
+            @Override
+            public Type type()
+            {
+                return type;
+            }
+
+            @Override
+            public void checkConstraints( Object value )
+                throws ConstraintViolationException
+            {
+                AssociationModel.this.checkConstraints( value );
+            }
+        };
+
+        if( type instanceof TypeVariable )
+        {
+
+            Class mainType = first( resolution.model().types() );
+            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
+        }
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        AssociationModel that = (AssociationModel) o;
+
+        if( !accessor.equals( that.accessor ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return accessor.hashCode();
+    }
+
+    @Override
+    public String toString()
+    {
+        if( accessor instanceof Field )
+        {
+            return ( (Field) accessor ).toGenericString();
+        }
+        else
+        {
+            return ( (Method) accessor ).toGenericString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationsModel.java
new file mode 100644
index 0000000..310632d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/AssociationsModel.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2008-2011, Rickard Öberg. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.AssociationStateHolder;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+
+/**
+ * Model for Associations.
+ */
+public final class AssociationsModel
+    implements VisitableHierarchy<AssociationsModel, AssociationModel>
+{
+    private final Map<AccessibleObject, AssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
+
+    public AssociationsModel()
+    {
+    }
+
+    public Iterable<AssociationModel> associations()
+    {
+        return mapAccessorAssociationModel.values();
+    }
+
+    public void addAssociation( AssociationModel associationModel )
+    {
+        mapAccessorAssociationModel.put( associationModel.accessor(), associationModel );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super AssociationsModel, ? super AssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
+            {
+                if( !associationModel.accept( visitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    public AssociationModel getAssociation( AccessibleObject accessor )
+        throws IllegalArgumentException
+    {
+        AssociationModel associationModel = mapAccessorAssociationModel.get( accessor );
+        if( associationModel == null )
+        {
+            throw new IllegalArgumentException( "No association found with name:" + ( (Member) accessor ).getName() );
+        }
+        return associationModel;
+    }
+
+    public AssociationDescriptor getAssociationByName( String name )
+        throws IllegalArgumentException
+    {
+        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().name().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No association found with name:" + name );
+    }
+
+    public AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException
+    {
+        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No association found with qualified name:" + name );
+    }
+
+    public void checkConstraints( AssociationStateHolder state )
+    {
+        for( AssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            Association<Object> association = state.<Object>associationFor( associationModel.accessor() );
+            associationModel.checkAssociationConstraints( association );
+            associationModel.checkConstraints( association.get() );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationInstance.java
new file mode 100644
index 0000000..5c8b4b8
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationInstance.java
@@ -0,0 +1,225 @@
+/*
+ * 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.qi4j.runtime.association;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.ManyAssociationWrapper;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.util.NullArgumentException;
+import org.qi4j.functional.Function2;
+import org.qi4j.functional.Iterables;
+import org.qi4j.spi.entity.ManyAssociationState;
+
+/**
+ * JAVADOC
+ */
+public class ManyAssociationInstance<T>
+    extends AbstractAssociationInstance<T>
+    implements ManyAssociation<T>
+{
+    private ManyAssociationState manyAssociationState;
+
+    public ManyAssociationInstance( AssociationInfo associationInfo,
+                                    Function2<EntityReference, Type, Object> associationFunction,
+                                    ManyAssociationState manyAssociationState
+    )
+    {
+        super( associationInfo, associationFunction );
+        this.manyAssociationState = manyAssociationState;
+    }
+
+    @Override
+    public int count()
+    {
+        return manyAssociationState.count();
+    }
+
+    @Override
+    public boolean contains( T entity )
+    {
+        return manyAssociationState.contains( getEntityReference( entity ) );
+    }
+
+    @Override
+    public boolean add( int i, T entity )
+    {
+        NullArgumentException.validateNotNull( "entity", entity );
+        checkImmutable();
+        checkType( entity );
+        associationInfo.checkConstraints( entity );
+        return manyAssociationState.add( i, new EntityReference( ( (Identity) entity ).identity().get() ) );
+    }
+
+    @Override
+    public boolean add( T entity )
+    {
+        return add( manyAssociationState.count(), entity );
+    }
+
+    @Override
+    public boolean remove( T entity )
+    {
+        NullArgumentException.validateNotNull( "entity", entity );
+        checkImmutable();
+        checkType( entity );
+
+        return manyAssociationState.remove( new EntityReference( ( (Identity) entity ).identity().get() ) );
+    }
+
+    @Override
+    public T get( int i )
+    {
+        return getEntity( manyAssociationState.get( i ) );
+    }
+
+    @Override
+    public List<T> toList()
+    {
+        ArrayList<T> list = new ArrayList<>();
+        for( EntityReference entityReference : manyAssociationState )
+        {
+            list.add( getEntity( entityReference ) );
+        }
+
+        return list;
+    }
+
+    @Override
+    public Set<T> toSet()
+    {
+        Set<T> set = new HashSet<>();
+        for( EntityReference entityReference : manyAssociationState )
+        {
+            set.add( getEntity( entityReference ) );
+        }
+
+        return set;
+    }
+
+    @Override
+    public Iterable<EntityReference> references()
+    {
+        return Iterables.toList( manyAssociationState );
+    }
+
+    @Override
+    public String toString()
+    {
+        return manyAssociationState.toString();
+    }
+
+    @Override
+    public Iterator<T> iterator()
+    {
+        return new ManyAssociationIterator( manyAssociationState.iterator() );
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        ManyAssociation<?> that = (ManyAssociation) o;
+        // Unwrap if needed
+        while( that instanceof ManyAssociationWrapper )
+        {
+            that = ( (ManyAssociationWrapper) that ).next();
+        }
+        // Descriptor equality
+        ManyAssociationInstance<?> thatInstance = (ManyAssociationInstance) that;
+        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
+        if( !associationInfo.equals( thatDescriptor ) )
+        {
+            return false;
+        }
+        // State equality
+        if( manyAssociationState.count() != thatInstance.manyAssociationState.count() )
+        {
+            return false;
+        }
+        for( EntityReference ref : manyAssociationState )
+        {
+            if( !thatInstance.manyAssociationState.contains( ref ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = associationInfo.hashCode() * 31; // Descriptor
+        for( EntityReference ref : manyAssociationState )
+        {
+            hash += ref.hashCode() * 7; // State
+        }
+        return hash;
+    }
+
+    public ManyAssociationState getManyAssociationState()
+    {
+        return manyAssociationState;
+    }
+
+    protected class ManyAssociationIterator
+        implements Iterator<T>
+    {
+        private final Iterator<EntityReference> idIterator;
+
+        public ManyAssociationIterator( Iterator<EntityReference> idIterator )
+        {
+            this.idIterator = idIterator;
+        }
+
+        @Override
+        public boolean hasNext()
+        {
+            return idIterator.hasNext();
+        }
+
+        @Override
+        public T next()
+        {
+            return getEntity( idIterator.next() );
+        }
+
+        @Override
+        public void remove()
+        {
+            checkImmutable();
+            idIterator.remove();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationModel.java
new file mode 100644
index 0000000..3cc5d81
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationModel.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2008-2011, Rickard Öberg. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.List;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.constraint.ConstraintViolation;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.Aggregated;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Queryable;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.BindingException;
+import org.qi4j.functional.Function2;
+import org.qi4j.functional.Visitable;
+import org.qi4j.functional.Visitor;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.model.Binder;
+import org.qi4j.runtime.model.Resolution;
+import org.qi4j.runtime.structure.ModuleUnitOfWork;
+import org.qi4j.runtime.unitofwork.BuilderEntityState;
+import org.qi4j.spi.entity.EntityState;
+
+import static org.qi4j.functional.Iterables.empty;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Model for a ManyAssociation.
+ *
+ * <p>Equality is based on the ManyAssociation accessor object (associated type and name), not on the QualifiedName.</p>
+ */
+public final class ManyAssociationModel
+    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<ManyAssociationModel>
+{
+    private final ValueConstraintsInstance associationConstraints;
+    private final MetaInfo metaInfo;
+    private Type type;
+    private final AccessibleObject accessor;
+    private QualifiedName qualifiedName;
+    private final ValueConstraintsInstance constraints;
+    private boolean queryable;
+    private boolean immutable;
+    private boolean aggregated;
+    private AssociationInfo builderInfo;
+
+    public ManyAssociationModel( AccessibleObject accessor,
+                                 ValueConstraintsInstance valueConstraintsInstance,
+                                 ValueConstraintsInstance associationConstraintsInstance,
+                                 MetaInfo metaInfo
+    )
+    {
+        this.metaInfo = metaInfo;
+        this.constraints = valueConstraintsInstance;
+        this.associationConstraints = associationConstraintsInstance;
+        this.accessor = accessor;
+        initialize();
+    }
+
+    private void initialize()
+    {
+        this.type = GenericAssociationInfo.associationTypeOf( accessor );
+        this.qualifiedName = QualifiedName.fromAccessor( accessor );
+        this.immutable = metaInfo.get( Immutable.class ) != null;
+        this.aggregated = metaInfo.get( Aggregated.class ) != null;
+
+        final Queryable queryable = accessor.getAnnotation( Queryable.class );
+        this.queryable = queryable == null || queryable.value();
+    }
+
+    @Override
+    public <T> T metaInfo( Class<T> infoType )
+    {
+        return metaInfo.get( infoType );
+    }
+
+    @Override
+    public QualifiedName qualifiedName()
+    {
+        return qualifiedName;
+    }
+
+    @Override
+    public Type type()
+    {
+        return type;
+    }
+
+    @Override
+    public boolean isImmutable()
+    {
+        return immutable;
+    }
+
+    @Override
+    public boolean isAggregated()
+    {
+        return aggregated;
+    }
+
+    @Override
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public boolean queryable()
+    {
+        return queryable;
+    }
+
+    public AssociationInfo getBuilderInfo()
+    {
+        return builderInfo;
+    }
+
+    public <T> ManyAssociation<T> newInstance( final ModuleUnitOfWork uow, EntityState state )
+    {
+        return new ManyAssociationInstance<>( state instanceof BuilderEntityState ? builderInfo : this, new Function2<EntityReference, Type, Object>()
+        {
+            @Override
+            public Object map( EntityReference entityReference, Type type )
+            {
+                return uow.get( Classes.RAW_CLASS.map( type ), entityReference.identity() );
+            }
+        }, state.manyAssociationValueOf( qualifiedName ) );
+    }
+
+    @Override
+    public void checkConstraints( Object composite )
+        throws ConstraintViolationException
+    {
+        if( constraints != null )
+        {
+            List<ConstraintViolation> violations = constraints.checkConstraints( composite );
+            if( !violations.isEmpty() )
+            {
+                Iterable<Class<?>> empty = empty();
+                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+            }
+        }
+    }
+
+    public void checkAssociationConstraints( ManyAssociation manyAssociation )
+        throws ConstraintViolationException
+    {
+        if( associationConstraints != null )
+        {
+            List<ConstraintViolation> violations = associationConstraints.checkConstraints( manyAssociation );
+            if( !violations.isEmpty() )
+            {
+                Iterable<Class<?>> empty = empty();
+                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+            }
+        }
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( Visitor<? super ManyAssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        return visitor.visit( this );
+    }
+
+    @Override
+    public void bind( Resolution resolution )
+        throws BindingException
+    {
+        builderInfo = new AssociationInfo()
+        {
+            @Override
+            public boolean isImmutable()
+            {
+                return false;
+            }
+
+            @Override
+            public QualifiedName qualifiedName()
+            {
+                return qualifiedName;
+            }
+
+            @Override
+            public Type type()
+            {
+                return type;
+            }
+
+            @Override
+            public void checkConstraints( Object value )
+                throws ConstraintViolationException
+            {
+                ManyAssociationModel.this.checkConstraints( value );
+            }
+        };
+
+        if( type instanceof TypeVariable )
+        {
+            Class mainType = first( resolution.model().types() );
+            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
+        }
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        ManyAssociationModel that = (ManyAssociationModel) o;
+
+        return accessor.equals( that.accessor );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return accessor.hashCode();
+    }
+
+    @Override
+    public String toString()
+    {
+        if( accessor instanceof Field )
+        {
+            return ( (Field) accessor ).toGenericString();
+        }
+        else
+        {
+            return ( (Method) accessor ).toGenericString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationsModel.java
new file mode 100644
index 0000000..40c5653
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/ManyAssociationsModel.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2008-2011, Rickard Öberg. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.structure.ModuleUnitOfWork;
+import org.qi4j.runtime.value.ValueStateInstance;
+import org.qi4j.spi.entity.EntityState;
+
+/**
+ * Model for ManyAssociations.
+ */
+public final class ManyAssociationsModel
+    implements VisitableHierarchy<ManyAssociationsModel, ManyAssociationModel>
+{
+    private final Map<AccessibleObject, ManyAssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
+
+    public ManyAssociationsModel()
+    {
+    }
+
+    public Iterable<ManyAssociationModel> manyAssociations()
+    {
+        return mapAccessorAssociationModel.values();
+    }
+
+    public void addManyAssociation( ManyAssociationModel model )
+    {
+        mapAccessorAssociationModel.put( model.accessor(), model );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super ManyAssociationsModel, ? super ManyAssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
+            {
+                if( !associationModel.accept( visitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    public <T> ManyAssociation<T> newInstance( AccessibleObject accessor,
+                                               EntityState entityState,
+                                               ModuleUnitOfWork uow )
+    {
+        return mapAccessorAssociationModel.get( accessor ).newInstance( uow, entityState );
+    }
+
+    public ManyAssociationModel getManyAssociation( AccessibleObject accessor )
+        throws IllegalArgumentException
+    {
+        ManyAssociationModel manyAssociationModel = mapAccessorAssociationModel.get( accessor );
+        if( manyAssociationModel == null )
+        {
+            throw new IllegalArgumentException( "No many-association found with name:" + ( (Member) accessor ).getName() );
+        }
+        return manyAssociationModel;
+    }
+
+    public AssociationDescriptor getManyAssociationByName( String name )
+        throws IllegalArgumentException
+    {
+        for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().name().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No many-association found with name:" + name );
+    }
+
+    public AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException
+    {
+        for( ManyAssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No many-association found with qualified name:" + name );
+    }
+
+    public void checkConstraints( ValueStateInstance state )
+    {
+        for( ManyAssociationModel manyAssociationModel : mapAccessorAssociationModel.values() )
+        {
+            manyAssociationModel.checkAssociationConstraints( state.manyAssociationFor( manyAssociationModel.accessor() ) );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
new file mode 100644
index 0000000..c38ef1a
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.association;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.ManyAssociationWrapper;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.association.NamedAssociationWrapper;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Identity;
+import org.qi4j.api.util.NullArgumentException;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Function2;
+import org.qi4j.functional.Iterables;
+import org.qi4j.spi.entity.NamedAssociationState;
+
+import static org.qi4j.functional.Iterables.map;
+
+public class NamedAssociationInstance<T>
+    extends AbstractAssociationInstance<T>
+    implements NamedAssociation<T>
+{
+
+    private final NamedAssociationState namedAssociationState;
+
+    public NamedAssociationInstance( AssociationInfo associationInfo,
+                                     Function2<EntityReference, Type, Object> associationFunction,
+                                     NamedAssociationState namedAssociationState
+    )
+    {
+        super( associationInfo, associationFunction );
+        this.namedAssociationState = namedAssociationState;
+    }
+
+    @Override
+    public Iterator<String> iterator()
+    {
+        return namedAssociationState.iterator();
+    }
+
+    @Override
+    public int count()
+    {
+        return namedAssociationState.count();
+    }
+
+    @Override
+    public boolean containsName( String name )
+    {
+        return namedAssociationState.containsName( name );
+    }
+
+    @Override
+    public boolean put( String name, T entity )
+    {
+        NullArgumentException.validateNotNull( "entity", entity );
+        checkImmutable();
+        checkType( entity );
+        associationInfo.checkConstraints( entity );
+        return namedAssociationState.put( name, new EntityReference( ( (Identity) entity ).identity().get() ) );
+    }
+
+    @Override
+    public boolean remove( String name )
+    {
+        checkImmutable();
+        return namedAssociationState.remove( name );
+    }
+
+    @Override
+    public T get( String name )
+    {
+        return getEntity( namedAssociationState.get( name ) );
+    }
+
+    @Override
+    public String nameOf( T entity )
+    {
+        return namedAssociationState.nameOf( getEntityReference( entity ) );
+    }
+
+    @Override
+    public Map<String, T> toMap()
+    {
+        Map<String, T> map = new HashMap<>();
+        for( String name : namedAssociationState )
+        {
+            map.put( name, getEntity( namedAssociationState.get( name ) ) );
+        }
+        return map;
+    }
+
+    @Override
+    public Iterable<EntityReference> references()
+    {
+        return map( new Function<String, EntityReference>()
+        {
+            @Override
+            public EntityReference map( String name )
+            {
+                return namedAssociationState.get( name );
+            }
+        }, namedAssociationState );
+    }
+
+    @Override
+    public EntityReference referenceOf( String name )
+    {
+        return namedAssociationState.get( name );
+    }
+
+    public Iterable<Map.Entry<String, EntityReference>> getEntityReferences()
+    {
+        return map( new Function<String, Map.Entry<String, EntityReference>>()
+        {
+            @Override
+            public Map.Entry<String, EntityReference> map( final String key )
+            {
+                final EntityReference value = namedAssociationState.get( key );
+                return new Map.Entry<String, EntityReference>()
+                {
+                    @Override
+                    public String getKey()
+                    {
+                        return key;
+                    }
+
+                    @Override
+                    public EntityReference getValue()
+                    {
+                        return value;
+                    }
+
+                    @Override
+                    public EntityReference setValue( EntityReference value )
+                    {
+                        throw new UnsupportedOperationException( "Immutable Map" );
+                    }
+
+                    @Override
+                    public boolean equals( Object o )
+                    {
+                        if( o instanceof Map.Entry )
+                        {
+                            Map.Entry other = (Map.Entry) o;
+                            return key.equals( other.getKey() );
+                        }
+                        return false;
+                    }
+
+                    @Override
+                    public int hashCode()
+                    {
+                        return 997 * key.hashCode() + 981813497;
+                    }
+                };
+            }
+        }, namedAssociationState );
+    }
+
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        NamedAssociation<?> that = (NamedAssociation) o;
+        // Unwrap if needed
+        while( that instanceof NamedAssociationWrapper )
+        {
+            that = ( (NamedAssociationWrapper) that ).next();
+        }
+        // Descriptor equality
+        NamedAssociationInstance<?> thatInstance = (NamedAssociationInstance) that;
+        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
+        if( !associationInfo.equals( thatDescriptor ) )
+        {
+            return false;
+        }
+        // State equality
+        if( namedAssociationState.count() != thatInstance.namedAssociationState.count() )
+        {
+            return false;
+        }
+        for( String name : namedAssociationState )
+        {
+            if( !thatInstance.namedAssociationState.containsName( name ) )
+            {
+                return false;
+            }
+            EntityReference thisReference = namedAssociationState.get( name );
+            EntityReference thatReference = thatInstance.namedAssociationState.get( name );
+            if( !thisReference.equals( thatReference ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = associationInfo.hashCode() * 31; // Descriptor
+        for( String name : namedAssociationState )
+        {
+            hash += name.hashCode();
+            hash += namedAssociationState.get( name ).hashCode() * 7; // State
+        }
+        return hash;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationModel.java
new file mode 100644
index 0000000..7c144d0
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationModel.java
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.List;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.GenericAssociationInfo;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.constraint.ConstraintViolation;
+import org.qi4j.api.constraint.ConstraintViolationException;
+import org.qi4j.api.entity.Aggregated;
+import org.qi4j.api.entity.EntityReference;
+import org.qi4j.api.entity.Queryable;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.BindingException;
+import org.qi4j.functional.Function2;
+import org.qi4j.functional.Visitable;
+import org.qi4j.functional.Visitor;
+import org.qi4j.runtime.composite.ValueConstraintsInstance;
+import org.qi4j.runtime.model.Binder;
+import org.qi4j.runtime.model.Resolution;
+import org.qi4j.runtime.structure.ModuleUnitOfWork;
+import org.qi4j.runtime.unitofwork.BuilderEntityState;
+import org.qi4j.spi.entity.EntityState;
+
+import static org.qi4j.functional.Iterables.empty;
+import static org.qi4j.functional.Iterables.first;
+
+/**
+ * Model for a NamedAssociation.
+ *
+ * <p>Equality is based on the NamedAssociation accessor object (associated type and name), not on the QualifiedName.</p>
+ */
+public final class NamedAssociationModel
+    implements AssociationDescriptor, AssociationInfo, Binder, Visitable<NamedAssociationModel>
+{
+    private final ValueConstraintsInstance associationConstraints;
+    private final MetaInfo metaInfo;
+    private Type type;
+    private final AccessibleObject accessor;
+    private QualifiedName qualifiedName;
+    private final ValueConstraintsInstance constraints;
+    private boolean queryable;
+    private boolean immutable;
+    private boolean aggregated;
+    private AssociationInfo builderInfo;
+
+    public NamedAssociationModel( AccessibleObject accessor,
+                                  ValueConstraintsInstance valueConstraintsInstance,
+                                  ValueConstraintsInstance associationConstraintsInstance,
+                                  MetaInfo metaInfo
+    )
+    {
+        this.metaInfo = metaInfo;
+        this.constraints = valueConstraintsInstance;
+        this.associationConstraints = associationConstraintsInstance;
+        this.accessor = accessor;
+        initialize();
+    }
+
+    private void initialize()
+    {
+        this.type = GenericAssociationInfo.associationTypeOf( accessor );
+        this.qualifiedName = QualifiedName.fromAccessor( accessor );
+        this.immutable = metaInfo.get( Immutable.class ) != null;
+        this.aggregated = metaInfo.get( Aggregated.class ) != null;
+
+        final Queryable queryable = accessor.getAnnotation( Queryable.class );
+        this.queryable = queryable == null || queryable.value();
+    }
+
+    @Override
+    public <T> T metaInfo( Class<T> infoType )
+    {
+        return metaInfo.get( infoType );
+    }
+
+    @Override
+    public QualifiedName qualifiedName()
+    {
+        return qualifiedName;
+    }
+
+    @Override
+    public Type type()
+    {
+        return type;
+    }
+
+    @Override
+    public boolean isImmutable()
+    {
+        return immutable;
+    }
+
+    @Override
+    public boolean isAggregated()
+    {
+        return aggregated;
+    }
+
+    @Override
+    public AccessibleObject accessor()
+    {
+        return accessor;
+    }
+
+    @Override
+    public boolean queryable()
+    {
+        return queryable;
+    }
+
+    public AssociationInfo getBuilderInfo()
+    {
+        return builderInfo;
+    }
+
+    public <T> NamedAssociation<T> newInstance( final ModuleUnitOfWork uow, EntityState state )
+    {
+        return new NamedAssociationInstance<>( state instanceof BuilderEntityState ? builderInfo : this, new Function2<EntityReference, Type, Object>()
+        {
+            @Override
+            public Object map( EntityReference entityReference, Type type )
+            {
+                return uow.get( Classes.RAW_CLASS.map( type ), entityReference.identity() );
+            }
+        }, state.namedAssociationValueOf( qualifiedName ) );
+    }
+
+    @Override
+    public void checkConstraints( Object composite )
+        throws ConstraintViolationException
+    {
+        if( constraints != null )
+        {
+            List<ConstraintViolation> violations = constraints.checkConstraints( composite );
+            if( !violations.isEmpty() )
+            {
+                Iterable<Class<?>> empty = empty();
+                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+            }
+        }
+    }
+
+    public void checkAssociationConstraints( NamedAssociation association )
+        throws ConstraintViolationException
+    {
+        if( associationConstraints != null )
+        {
+            List<ConstraintViolation> violations = associationConstraints.checkConstraints( association );
+            if( !violations.isEmpty() )
+            {
+                Iterable<Class<?>> empty = empty();
+                throw new ConstraintViolationException( "", empty, (Member) accessor, violations );
+            }
+        }
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( Visitor<? super NamedAssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        return visitor.visit( this );
+    }
+
+    @Override
+    public void bind( Resolution resolution )
+        throws BindingException
+    {
+        builderInfo = new AssociationInfo()
+        {
+            @Override
+            public boolean isImmutable()
+            {
+                return false;
+            }
+
+            @Override
+            public QualifiedName qualifiedName()
+            {
+                return qualifiedName;
+            }
+
+            @Override
+            public Type type()
+            {
+                return type;
+            }
+
+            @Override
+            public void checkConstraints( Object value )
+                throws ConstraintViolationException
+            {
+                NamedAssociationModel.this.checkConstraints( value );
+            }
+        };
+
+        if( type instanceof TypeVariable )
+        {
+            Class mainType = first( resolution.model().types() );
+            type = Classes.resolveTypeVariable( (TypeVariable) type, ( (Member) accessor ).getDeclaringClass(), mainType );
+        }
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        NamedAssociationModel that = (NamedAssociationModel) o;
+
+        return accessor.equals( that.accessor );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return accessor.hashCode();
+    }
+
+    @Override
+    public String toString()
+    {
+        if( accessor instanceof Field )
+        {
+            return ( (Field) accessor ).toGenericString();
+        }
+        else
+        {
+            return ( (Method) accessor ).toGenericString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationsModel.java
new file mode 100644
index 0000000..4f3fac5
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationsModel.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2011-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.runtime.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.structure.ModuleUnitOfWork;
+import org.qi4j.runtime.value.ValueStateInstance;
+import org.qi4j.spi.entity.EntityState;
+
+/**
+ * Model for NamedAssociations.
+ */
+public final class NamedAssociationsModel
+    implements VisitableHierarchy<NamedAssociationsModel, NamedAssociationModel>
+{
+    private final Map<AccessibleObject, NamedAssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
+
+    public NamedAssociationsModel()
+    {
+    }
+
+    public Iterable<NamedAssociationModel> namedAssociations()
+    {
+        return mapAccessorAssociationModel.values();
+    }
+
+    public void addNamedAssociation( NamedAssociationModel model )
+    {
+        mapAccessorAssociationModel.put( model.accessor(), model );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super NamedAssociationsModel, ? super NamedAssociationModel, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
+            {
+                if( !associationModel.accept( visitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    public <T> NamedAssociation<T> newInstance( AccessibleObject accessor,
+                                                EntityState entityState,
+                                                ModuleUnitOfWork uow )
+    {
+        return mapAccessorAssociationModel.get( accessor ).newInstance( uow, entityState );
+    }
+
+    public NamedAssociationModel getNamedAssociation( AccessibleObject accessor )
+        throws IllegalArgumentException
+    {
+        if( false )
+        {
+            return (NamedAssociationModel) getNamedAssociationByName( QualifiedName.fromAccessor( accessor ).name() );
+        }
+        NamedAssociationModel namedAssociationModel = mapAccessorAssociationModel.get( accessor );
+        if( namedAssociationModel == null )
+        {
+            throw new IllegalArgumentException( "No named-association found with name:" + ( (Member) accessor ).getName() );
+        }
+        return namedAssociationModel;
+    }
+
+    public AssociationDescriptor getNamedAssociationByName( String name )
+        throws IllegalArgumentException
+    {
+        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().name().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No named-association found with name:" + name );
+    }
+
+    public AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException
+    {
+        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            if( associationModel.qualifiedName().equals( name ) )
+            {
+                return associationModel;
+            }
+        }
+        throw new IllegalArgumentException( "No named-association found with qualified name:" + name );
+    }
+
+    public void checkConstraints( ValueStateInstance state )
+    {
+        for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
+        {
+            associationModel.checkAssociationConstraints( state.namedAssociationFor( associationModel.accessor() ) );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AndAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AndAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AndAppliesToFilter.java
new file mode 100644
index 0000000..fafc6b7
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AndAppliesToFilter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class AndAppliesToFilter
+    implements AppliesToFilter
+{
+    private final AppliesToFilter left;
+    private final AppliesToFilter right;
+
+    AndAppliesToFilter( AppliesToFilter left, AppliesToFilter right )
+    {
+        this.left = left;
+        this.right = right;
+    }
+
+    @Override
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        return left.appliesTo( method, mixin, compositeType, fragmentClass ) &&
+               right.appliesTo( method, mixin, compositeType, fragmentClass );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AnnotationAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AnnotationAppliesToFilter.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AnnotationAppliesToFilter.java
new file mode 100644
index 0000000..54cf2ad
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/AnnotationAppliesToFilter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesToFilter;
+
+/**
+ * JAVADOC
+ */
+final class AnnotationAppliesToFilter
+    implements AppliesToFilter
+{
+    @SuppressWarnings( "raw" )
+    private final Class annotationType;
+
+    @SuppressWarnings( "raw" )
+    AnnotationAppliesToFilter( Class type )
+    {
+        this.annotationType = type;
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+    {
+        return method.getAnnotation( annotationType ) != null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
new file mode 100644
index 0000000..7a25eed
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.runtime.bootstrap;
+
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+/**
+ * Factory for ApplicationAssembly.
+ */
+public final class ApplicationAssemblyFactoryImpl
+    implements ApplicationAssemblyFactory
+{
+    @Override
+    public ApplicationAssembly newApplicationAssembly( Assembler assembler )
+        throws AssemblyException
+    {
+        return newApplicationAssembly( new Assembler[][][]{ { { assembler } } } );
+    }
+
+    @Override
+    public ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers )
+        throws AssemblyException
+    {
+        ApplicationAssembly applicationAssembly = newApplicationAssembly();
+
+        // Build all layers bottom-up
+        LayerAssembly below = null;
+        for( int layer = assemblers.length - 1; layer >= 0; layer-- )
+        {
+            // Create Layer
+            LayerAssembly layerAssembly = applicationAssembly.layer( "Layer " + ( layer + 1 ) );
+            for( int module = 0; module < assemblers[ layer ].length; module++ )
+            {
+                // Create Module
+                ModuleAssembly moduleAssembly = layerAssembly.module( "Module " + ( module + 1 ) );
+                for( Assembler assembler : assemblers[ layer ][ module ] )
+                {
+                    // Register Assembler
+                    assembler.assemble( moduleAssembly );
+                }
+            }
+            if( below != null )
+            {
+                layerAssembly.uses( below ); // Link layers
+            }
+            below = layerAssembly;
+        }
+        return applicationAssembly;
+    }
+
+    @Override
+    public ApplicationAssembly newApplicationAssembly()
+    {
+        return new ApplicationAssemblyImpl();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyImpl.java
new file mode 100644
index 0000000..48438e1
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationAssemblyImpl.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.qi4j.api.activation.Activator;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.structure.Application;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.AssemblyVisitor;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+/**
+ * The representation of an entire application. From
+ * this you can set information about the application
+ * and create LayerAssemblies.
+ */
+public final class ApplicationAssemblyImpl
+    implements ApplicationAssembly
+{
+    private final Map<String, LayerAssemblyImpl> layerAssemblies = new LinkedHashMap<>();
+    private String name = "Application";
+    private String version = "1.0"; // Default version
+    private Application.Mode mode;
+    private final MetaInfo metaInfo = new MetaInfo();
+    private final List<Class<? extends Activator<Application>>> activators = new ArrayList<>();
+
+    public ApplicationAssemblyImpl()
+    {
+        mode = Application.Mode.valueOf( System.getProperty( "mode", "production" ) );
+    }
+
+    @Override
+    public LayerAssembly layer( String name )
+    {
+        if( name != null )
+        {
+            LayerAssemblyImpl existing = layerAssemblies.get( name );
+            if( existing != null )
+            {
+                return existing;
+            }
+        }
+        LayerAssemblyImpl layerAssembly = new LayerAssemblyImpl( this, name );
+        layerAssemblies.put( name, layerAssembly );
+        return layerAssembly;
+    }
+
+    @Override
+    public ModuleAssembly module( String layerName, String moduleName )
+    {
+        return layer( layerName ).module( moduleName );
+    }
+
+    @Override
+    public ApplicationAssembly setName( String name )
+    {
+        this.name = name;
+        return this;
+    }
+
+    @Override
+    public ApplicationAssembly setVersion( String version )
+    {
+        this.version = version;
+        return this;
+    }
+
+    @Override
+    public ApplicationAssembly setMode( Application.Mode mode )
+    {
+        this.mode = mode;
+        return this;
+    }
+
+    @Override
+    public ApplicationAssembly setMetaInfo( Object info )
+    {
+        metaInfo.set( info );
+        return this;
+    }
+
+    @Override
+    @SafeVarargs
+    public final ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators )
+    {
+        this.activators.addAll( Arrays.asList( activators ) );
+        return this;
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
+        throws ThrowableType
+    {
+        visitor.visitApplication( this );
+        for( LayerAssemblyImpl layerAssembly : layerAssemblies.values() )
+        {
+            layerAssembly.visit( visitor );
+        }
+    }
+
+    public Collection<LayerAssemblyImpl> layerAssemblies()
+    {
+        return layerAssemblies.values();
+    }
+
+    public List<Class<? extends Activator<Application>>> activators()
+    {
+        return activators;
+    }
+
+    public MetaInfo metaInfo()
+    {
+        return metaInfo;
+    }
+
+    @Override
+    public String name()
+    {
+        return name;
+    }
+
+    public String version()
+    {
+        return version;
+    }
+
+    @Override
+    public Application.Mode mode()
+    {
+        return mode;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationModelFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationModelFactoryImpl.java b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationModelFactoryImpl.java
new file mode 100644
index 0000000..8669ed7
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/bootstrap/ApplicationModelFactoryImpl.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.runtime.bootstrap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.qi4j.api.composite.ModelDescriptor;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.api.structure.Layer;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationModelFactory;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.BindingException;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.runtime.activation.ActivatorsModel;
+import org.qi4j.runtime.composite.CompositeMethodModel;
+import org.qi4j.runtime.injection.InjectedFieldModel;
+import org.qi4j.runtime.model.Binder;
+import org.qi4j.runtime.model.Resolution;
+import org.qi4j.runtime.structure.ApplicationModel;
+import org.qi4j.runtime.structure.LayerModel;
+import org.qi4j.runtime.structure.ModuleModel;
+import org.qi4j.runtime.structure.UsedLayersModel;
+
+/**
+ * Factory for Applications.
+ */
+public final class ApplicationModelFactoryImpl
+    implements ApplicationModelFactory
+{
+    @Override
+    public ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly )
+        throws AssemblyException
+    {
+        AssemblyHelper helper = new AssemblyHelper();
+
+        ApplicationAssemblyImpl applicationAssembly = (ApplicationAssemblyImpl) assembly;
+        ActivatorsModel<Application> applicationActivators = new ActivatorsModel<>( applicationAssembly.activators() );
+        List<LayerModel> layerModels = new ArrayList<>();
+        final ApplicationModel applicationModel = new ApplicationModel( applicationAssembly.name(),
+                                                                        applicationAssembly.version(),
+                                                                        applicationAssembly.mode(),
+                                                                        applicationAssembly.metaInfo(),
+                                                                        applicationActivators,
+                                                                        layerModels );
+        Map<LayerAssembly, LayerModel> mapAssemblyModel = new HashMap<>();
+        Map<LayerAssembly, List<LayerModel>> mapUsedLayers = new HashMap<>();
+
+        // Build all layers
+        List<LayerAssemblyImpl> layerAssemblies = new ArrayList<>( applicationAssembly.layerAssemblies() );
+        for( LayerAssemblyImpl layerAssembly : layerAssemblies )
+        {
+            List<LayerModel> usedLayers = new ArrayList<>();
+            mapUsedLayers.put( layerAssembly, usedLayers );
+
+            UsedLayersModel usedLayersModel = new UsedLayersModel( usedLayers );
+            List<ModuleModel> moduleModels = new ArrayList<>();
+            String name = layerAssembly.name();
+            if( name == null )
+            {
+                throw new AssemblyException( "Layer must have name set" );
+            }
+            ActivatorsModel<Layer> layerActivators = new ActivatorsModel<>( layerAssembly.activators() );
+            LayerModel layerModel = new LayerModel( name, layerAssembly.metaInfo(), usedLayersModel, layerActivators, moduleModels );
+
+            for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() )
+            {
+                moduleModels.add( moduleAssembly.assembleModule( helper ) );
+            }
+            mapAssemblyModel.put( layerAssembly, layerModel );
+            layerModels.add( layerModel );
+        }
+
+        // Populate used layer lists
+        for( LayerAssemblyImpl layerAssembly : layerAssemblies )
+        {
+            Set<LayerAssembly> usesLayers = layerAssembly.uses();
+            List<LayerModel> usedLayers = mapUsedLayers.get( layerAssembly );
+            for( LayerAssembly usesLayer : usesLayers )
+            {
+                LayerModel layerModel = mapAssemblyModel.get( usesLayer );
+                usedLayers.add( layerModel );
+            }
+        }
+
+        // Bind model
+        // This will resolve all dependencies
+        try
+        {
+//            applicationModel.bind();
+            applicationModel.accept( new BindingVisitor( applicationModel ) );
+        }
+        catch( BindingException e )
+        {
+            throw new AssemblyException( "Unable to bind: " + applicationModel, e );
+        }
+
+        return applicationModel;
+    }
+
+    private static class BindingVisitor
+        implements HierarchicalVisitor<Object, Object, BindingException>
+    {
+        private LayerModel layer;
+        private ModuleModel module;
+        private ModelDescriptor objectDescriptor;
+        private CompositeMethodModel compositeMethodModel;
+
+        private Resolution resolution;
+        private final ApplicationModel applicationModel;
+
+        private BindingVisitor( ApplicationModel applicationModel )
+        {
+            this.applicationModel = applicationModel;
+        }
+
+        @Override
+        public boolean visitEnter( Object visited )
+            throws BindingException
+        {
+            if( visited instanceof Binder )
+            {
+                Binder binder = (Binder) visited;
+                binder.bind( resolution );
+
+                return false;
+            }
+            else if( visited instanceof CompositeMethodModel )
+            {
+                compositeMethodModel = (CompositeMethodModel) visited;
+                resolution = new Resolution( applicationModel, layer, module, objectDescriptor, compositeMethodModel, null );
+            }
+            else if( visited instanceof ModelDescriptor )
+            {
+                objectDescriptor = (ModelDescriptor) visited;
+                resolution = new Resolution( applicationModel, layer, module, objectDescriptor, null, null );
+            }
+            else if( visited instanceof InjectedFieldModel )
+            {
+                InjectedFieldModel fieldModel = (InjectedFieldModel) visited;
+                fieldModel.bind( new Resolution( applicationModel, layer, module,
+                                                 objectDescriptor, compositeMethodModel, fieldModel.field() ) );
+            }
+            else if( visited instanceof ModuleModel )
+            {
+                module = (ModuleModel) visited;
+            }
+            else if( visited instanceof LayerModel )
+            {
+                layer = (LayerModel) visited;
+            }
+
+            return true;
+        }
+
+        @Override
+        public boolean visitLeave( Object visited )
+            throws BindingException
+        {
+            return true;
+        }
+
+        @Override
+        public boolean visit( Object visited )
+            throws BindingException
+        {
+            if( visited instanceof Binder )
+            {
+                ( (Binder) visited ).bind( resolution );
+            }
+            return true;
+        }
+    }
+}
\ No newline at end of file


[43/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/Qualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Qualifier.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Qualifier.java
deleted file mode 100644
index 0866501..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Qualifier.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Annotation used to declare Qualifiers annotations.
- */
-@Retention( RetentionPolicy.RUNTIME )
-public @interface Qualifier
-{
-    public abstract Class<? extends AnnotationQualifier> value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
deleted file mode 100644
index 3c79477..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceQualifier.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * This class helps you select a particular service
- * from a list.
- * <p>
- * Provide a Selector which does the actual
- * selection from the list. A common case is to select
- * based on identity of the service, which you can do this way:
- * </p>
- *
- * <pre><code>
- * new ServiceQualifier&lt;MyService&gt;(services, ServiceQualifier.withId("someId"))
- * </code></pre>
- * <p>
- * Many selectors can be combined by using firstOf. Example:
- * </p>
- * <pre><code>
- * new ServiceQualifier&lt;MyService&gt;(services, firstOf(withTags("sometag"), firstActive(), first()))
- * </code></pre>
- * <p>
- * This will pick a service that has the tag "sometag", or if none is found take the first active one. If no
- * service is active, then the first service will be picked.
- * </p>
- */
-public abstract class ServiceQualifier
-{
-    public static <T> T firstService( Specification<ServiceReference<?>> qualifier,
-                                      Iterable<ServiceReference<T>> services
-    )
-    {
-        for( ServiceReference<T> service : services )
-        {
-            if( qualifier.satisfiedBy( service ) )
-            {
-                return service.get();
-            }
-        }
-        return null;
-    }
-
-    public static Specification<ServiceReference<?>> withId( final String anId )
-    {
-        return new Specification<ServiceReference<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference<?> service )
-            {
-                return service.identity().equals( anId );
-            }
-        };
-    }
-
-    public static Specification<ServiceReference<?>> whereMetaInfoIs( final Object metaInfo )
-    {
-        return new Specification<ServiceReference<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference<?> service )
-            {
-                Object metaObject = service.metaInfo( metaInfo.getClass() );
-                return metaObject != null && metaInfo.equals( metaObject );
-            }
-        };
-    }
-
-    public static Specification<ServiceReference<?>> whereActive()
-    {
-        return new Specification<ServiceReference<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference<?> service )
-            {
-                return service.isActive();
-            }
-        };
-    }
-
-    public static Specification<ServiceReference<?>> whereAvailable()
-    {
-        return new Specification<ServiceReference<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference<?> service )
-            {
-                return service.isAvailable();
-            }
-        };
-    }
-
-    public static Specification<ServiceReference<?>> withTags( final String... tags )
-    {
-        return new Specification<ServiceReference<?>>()
-        {
-            @Override
-            public boolean satisfiedBy( ServiceReference<?> service )
-            {
-                ServiceTags serviceTags = service.metaInfo( ServiceTags.class );
-
-                return serviceTags != null && serviceTags.hasTags( tags );
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceTags.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceTags.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceTags.java
deleted file mode 100644
index ba627d3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/ServiceTags.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.io.Serializable;
-
-/**
- * Use this as metainfo about a Service to specify tags. Easiest way to set them on a service
- * is to use the <code>ServiceDeclaration.taggedWith(String...)</code> method.
- *
- * These can be used in conjunction with the withTags() Service
- * Selector.
- */
-public final class ServiceTags
-    implements Serializable
-{
-    private String[] tags;
-
-    public ServiceTags( String... tags )
-    {
-        this.tags = tags;
-    }
-
-    public String[] tags()
-    {
-        return tags;
-    }
-
-    public boolean hasTag( String tag )
-    {
-        for( String serviceTag : tags )
-        {
-            if( serviceTag.equals( tag ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    public boolean hasTags( String... aTags )
-    {
-        for( String tag : aTags )
-        {
-            if( !hasTag( tag ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java b/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
deleted file mode 100644
index e2f9b2d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/Tagged.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.service.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.functional.Specification;
-
-/**
- * Filter services based on tags. Tags can be set using the ServiceTags meta-info, like so:
- * <pre><code>
- * module.addService(MyService.class).taggedWith(new ServiceTags("onetag","twotag"));
- * </code></pre>
- *
- * and then at an injection point you can do this:
- *
- * <pre><code>
- * &#64;Service &#64;Tagged("onetag") MyService service;
- * </code></pre>
- * to get only a service tagged with MyService. If several match only the first match is used.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Qualifier( Tagged.TaggedQualifier.class )
-public @interface Tagged
-{
-    public abstract String[] value();
-
-    /**
-     * Tagged Annotation Qualifier.
-     * See {@link Tagged}.
-     */
-    public final class TaggedQualifier
-        implements AnnotationQualifier<Tagged>
-    {
-        @Override
-        public Specification<ServiceReference<?>> qualifier( Tagged tagged )
-        {
-            return ServiceQualifier.withTags( tagged.value() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/service/qualifier/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/qualifier/package.html b/core/api/src/main/java/org/apache/zest/api/service/qualifier/package.html
deleted file mode 100644
index ec0edd3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/service/qualifier/package.html
+++ /dev/null
@@ -1,59 +0,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.
--->
-<html>
-    <body>
-        <h2>Service Qualifiers.</h2>
-        <p>
-            The @Service injection is only able to specify the type of the service to be injected. If any other type of
-            qualification has to be done it has to be done manually but for common cases it's more convenient to use
-            annotations to do this filtering. This package contains annotations to perform this qualification.
-        </p>
-        <p>Example:</p>
-        <blockquote>
-            <pre>@Service @Tagged( "sometag" ) MyService service;</pre>
-        </blockquote>
-        <p>
-            This will only inject instances of MyService that have been tagged with "sometag". If none exist an
-            exception will occur at injection time since it is not optional.
-        </p>
-        <p>It also works with iterables:</p>
-        <blockquote>
-            <pre>@Service @Tagged( "sometag" ) Iterable&lt;MyService&gt; services;</pre>
-        </blockquote>
-        <p>
-            The qualification will be evaluated upon each call to iterator(), and since the qualifier has access to a
-            ServiceReference, which contains the isActive() method, it can even provide some dynamicity.
-        </p>
-        <blockquote>
-            <pre>@Service @Active Iterable&lt;SomeImportedService&gt; importedServices;</pre>
-        </blockquote>
-        <p>
-            Let's say these SomeImportedService are only sometimes available. Then whenever iterator() is called the
-            {@link org.qi4j.api.service.qualifier.Active} tag can kick in and filter out those whose
-            ServiceReference.isActive() returns false.
-        </p>
-        <p>Standard ones defined in the API are:</p>
-        <ul>
-            <li>{@link org.qi4j.api.service.qualifier.Active}</li>
-            <li>{@link org.qi4j.api.service.qualifier.Available}</li>
-            <li>{@link org.qi4j.api.service.qualifier.HasMetaInfo}</li>
-            <li>{@link org.qi4j.api.service.qualifier.IdentifiedBy}</li>
-            <li>{@link org.qi4j.api.service.qualifier.Tagged}</li>
-        </ul>
-        <p>See tests and API for more examples, and how to implement your own qualifiers.</p>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/GenericSideEffect.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/GenericSideEffect.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/GenericSideEffect.java
deleted file mode 100644
index 897eea2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/GenericSideEffect.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.sideeffect;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * Base class for generic SideEffects.
- */
-public abstract class GenericSideEffect
-    extends SideEffectOf<InvocationHandler>
-    implements InvocationHandler
-{
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Object invoke( final Object proxy, final Method method, final Object[] args )
-        throws Throwable
-    {
-        invoke( method, args );
-        return null;
-    }
-
-    /**
-     * Convenience method to be overridden by subclasses in order to avoid returning null, as returned value from side
-     * effects is not taken in consideration.
-     *
-     * @param method the method that was invoked
-     * @param args   the arguments of the method invocation
-     *
-     * @throws Throwable - the exception to throw from the method invocation on the proxy instance. The exception's type
-     *                   must be assignable either to any of the exception types declared in the throws clause of the
-     *                   interface method or to the unchecked exception types {code}java.lang.RuntimeException{code}
-     *                   or {code}java.lang.Error{code}. If a checked exception is thrown by this method that is not
-     *                   assignable to any of the exception types declared in the throws clause of the interface method,
-     *                   then an UndeclaredThrowableException containing the exception that was thrown by this method
-     *                   will be thrown by the method invocation on the proxy instance.
-     */
-    protected void invoke( final Method method, final Object[] args )
-        throws Throwable
-    {
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectDescriptor.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectDescriptor.java
deleted file mode 100644
index 2f573e5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.sideeffect;
-
-/**
- * SideEffect Descriptor.
- */
-public interface SideEffectDescriptor
-{
-    Class<?> modifierClass();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectOf.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectOf.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectOf.java
deleted file mode 100644
index 82812e8..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectOf.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.api.sideeffect;
-
-import org.apache.zest.api.sideeffect.internal.SideEffectFor;
-
-/**
- * Base class for SideEffects. It introduces a typed "next" pointer
- * that SideEffects can use to get the result of the original invocation.
- * <p>
- * Generic SideEffects should subclass {@link GenericSideEffect} instead.
- * </p>
- * <p>
- * SideEffects implementations must be thread-safe in their implementation,
- * as multiple threads may share instances.
- * </p>
- */
-public abstract class SideEffectOf<T>
-{
-    final
-    @SideEffectFor
-    protected T result = null;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffects.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffects.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffects.java
deleted file mode 100644
index f34ea01..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffects.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.sideeffect;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used by composites and mixins to declare what SideEffects
- * should apply to the type or specific method.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface SideEffects
-{
-    Class<?>[] value();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectsDescriptor.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectsDescriptor.java
deleted file mode 100644
index 9c9e64e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/SideEffectsDescriptor.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*  Copyright 2008 Edward Yakop.
-*
-* 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.zest.api.sideeffect;
-
-/**
- * SideEffects Descriptor.
- */
-public interface SideEffectsDescriptor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/SideEffectFor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/SideEffectFor.java b/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/SideEffectFor.java
deleted file mode 100644
index f3f16b2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/SideEffectFor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.sideeffect.internal;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.zest.api.injection.InjectionScope;
-
-/**
- * This annotation is required once in each SideEffect, to mark the
- * field where the element providing the invocation result should be
- * injected.
- * <p>
- * The type of the field must be of the same type as the SideEffect
- * itself, or an InvocationHandler.
- * </p>
- * <p>
- * Example;
- * </p>
- * <pre><code>
- * public interface MyStuff
- * {
- *     SomeResult doSomething();
- * }
- *
- * public class MyStuffSideEffect
- *     implements MyStuff
- * {
- *     &#64;SideEffectFor MyStuff next;
- *
- *     public SomeResult doSomething()
- *     {
- *          SomeResult result = next.doSomething();
- *
- *         // HERE DO THE SIDEEFFECT STUFF.
- *
- *          return result; // Result value is ignored, null would work too.
- *     }
- * }
- * </code></pre>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.FIELD, ElementType.PARAMETER })
-@Documented
-@InjectionScope
-public @interface SideEffectFor
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/package.html b/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/package.html
deleted file mode 100644
index 269774e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/internal/package.html
+++ /dev/null
@@ -1,25 +0,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.
--->
-<html>
-    <body>
-        <h1>Internal/Private package for the API.</h1>
-        <p>
-            This is an internal package, and no classes in this package is part of the API and compatibility
-            with these classes will not be attempted.
-        </p>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/sideeffect/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/sideeffect/package.html b/core/api/src/main/java/org/apache/zest/api/sideeffect/package.html
deleted file mode 100644
index a658adb..0000000
--- a/core/api/src/main/java/org/apache/zest/api/sideeffect/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>SideEffect API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/Application.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Application.java b/core/api/src/main/java/org/apache/zest/api/structure/Application.java
deleted file mode 100644
index 1786d11..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/Application.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Niclas Hedhman.
- *
- * 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.zest.api.structure;
-
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-
-/**
- * The Application represents a whole Zest application.
- */
-public interface Application
-    extends ActivationEventListenerRegistration, Activation, MetaInfoHolder
-{
-    /**
-     * Application modes.
-     */
-    public enum Mode
-    {
-        /**
-         * Should be used for unit test runs. Created files etc. should be cleaned up between runs.
-         */
-        test,
-        /**
-         * Should be used during development. Typically create in-memory databases etc.
-         */
-        development,
-        /**
-         * Should be used in QA environments, and other production-like settings where different set of external
-         * resources are utilized.
-         */
-        staging,
-        /**
-         * Should be used in production. All databases are persistent on disk etc.
-         */
-        production
-    }
-
-    /**
-     * @return Application name
-     */
-    String name();
-
-    /**
-     * The version of the application. This can be in any format, but
-     * most likely will follow the Dewey format, i.e. x.y.z.
-     *
-     * @return the version of the application
-     */
-    String version();
-
-    /**
-     * @return Application Mode
-     */
-    Mode mode();
-
-    /**
-     * Find a Layer.
-     *
-     * @param layerName Layer name
-     * @return Found Layer, never returns null
-     * @throws IllegalArgumentException if there's no such Layer
-     */
-    Layer findLayer( String layerName )
-        throws IllegalArgumentException;
-
-    /**
-     * Find a Module.
-     *
-     * @param layerName Layer name
-     * @param moduleName Module name
-     * @return Found Module, never returns null
-     * @throws IllegalArgumentException if there's no such Module
-     */
-    Module findModule( String layerName, String moduleName )
-        throws IllegalArgumentException;
-
-    /**
-     * @return Application Descriptor
-     */
-    ApplicationDescriptor descriptor();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/ApplicationDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/ApplicationDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/ApplicationDescriptor.java
deleted file mode 100644
index 9d89ebd..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/ApplicationDescriptor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.structure;
-
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * Application Descriptor.
- */
-public interface ApplicationDescriptor
-    extends VisitableHierarchy<Object, Object>
-{
-    /**
-     * Create a new instance of the Application.
-     * @param runtime Zest Runtime
-     * @param importedServiceInstances Imported Services instances
-     * @return a new instance of the Application.
-     */
-    Application newInstance( Qi4j runtime, Object... importedServiceInstances );
-
-    /**
-     * @return the Application's name
-     */
-    String name();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Layer.java b/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
deleted file mode 100644
index 2f6c28e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Niclas Hedhman.
- *
- * 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.zest.api.structure;
-
-import org.apache.zest.api.activation.Activation;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-
-/**
- * The Layer represents a single layer in a Zest application.
- */
-public interface Layer
-    extends ActivationEventListenerRegistration, Activation, MetaInfoHolder
-{
-    /**
-     * @return the Layer's name
-     */
-    String name();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
deleted file mode 100644
index 812b13f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.structure;
-
-/**
- * Layer Descriptor.
- */
-public interface LayerDescriptor
-{
-
-    /**
-     * @return the Layer's name
-     */
-    String name();
-
-    /**
-     * @return Layers used by this Layer
-     */
-    UsedLayersDescriptor usedLayers();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/MetaInfoHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/MetaInfoHolder.java b/core/api/src/main/java/org/apache/zest/api/structure/MetaInfoHolder.java
deleted file mode 100644
index cbaf7df..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/MetaInfoHolder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.structure;
-
-/**
- * MetaInfo holder.
- */
-public interface MetaInfoHolder
-{
-
-    /**
-     * Get metadata that implements the given type.
-     * The info is registered during assembly of the application.
-     *
-     * @param infoType the type of metadata to be returned
-     *
-     * @return the metadata for the given type, or <code>null</code> if
-     *         no such metadata has been registered
-     */
-    <T> T metaInfo( Class<T> infoType );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/Module.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Module.java b/core/api/src/main/java/org/apache/zest/api/structure/Module.java
deleted file mode 100644
index 09842c2..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/Module.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2008, Niclas Hedhman.
- *
- * 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.zest.api.structure;
-
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.composite.TransientBuilderFactory;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.object.ObjectFactory;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.api.value.ValueDescriptor;
-
-/**
- * API for interacting with a Module. Instances
- * of this can be accessed by using the {@link Structure}
- * injection scope.
- */
-public interface Module
-    extends ActivationEventListenerRegistration,
-            MetaInfoHolder,
-            ObjectFactory,
-            TransientBuilderFactory,
-            ValueBuilderFactory,
-            UnitOfWorkFactory,
-            QueryBuilderFactory,
-            ServiceFinder
-{
-
-    /**
-     * @return the Module's name
-     */
-    String name();
-
-    /**
-     * @return the Module's ClassLoader
-     */
-    ClassLoader classLoader();
-
-    /**
-     * @param typeName name of a transient composite type
-     * @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
-     */
-    TransientDescriptor transientDescriptor( String typeName );
-
-    /**
-     * @param typeName name of an entity composite type
-     * @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
-     */
-    EntityDescriptor entityDescriptor( String typeName );
-
-    /**
-     * @param typeName name of an object type
-     * @return the descriptor for an object or null if the class could not be found or the object is not visible
-     */
-    ObjectDescriptor objectDescriptor( String typeName );
-
-    /**
-     * @param typeName name of a value composite type
-     * @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
-     */
-    ValueDescriptor valueDescriptor( String typeName );
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
deleted file mode 100644
index 045a639..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.structure;
-
-/**
- * Module Descriptor.
- */
-public interface ModuleDescriptor
-{
-    String name();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
deleted file mode 100644
index 98e70d5..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.structure;
-
-/**
- * Used Layers Descriptor.
- */
-public interface UsedLayersDescriptor
-{
-    Iterable<? extends LayerDescriptor> layers();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/structure/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/package.html b/core/api/src/main/java/org/apache/zest/api/structure/package.html
deleted file mode 100644
index 3134a90..0000000
--- a/core/api/src/main/java/org/apache/zest/api/structure/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Application Structure API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/CollectionType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/CollectionType.java b/core/api/src/main/java/org/apache/zest/api/type/CollectionType.java
deleted file mode 100644
index 872c07d..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/CollectionType.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.type;
-
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import org.apache.zest.api.util.Classes;
-
-/**
- * Collection ValueType.
- * <p>This handles Collection, List and Set types.</p>
- */
-public final class CollectionType
-    extends ValueType
-{
-
-    public static boolean isCollection( Type type )
-    {
-        Class<?> cl = Classes.RAW_CLASS.map( type );
-        return cl.equals( Collection.class ) || cl.equals( List.class ) || cl.equals( Set.class );
-    }
-
-    public static CollectionType collectionOf( Class<?> collectedType )
-    {
-        return new CollectionType( Collection.class, ValueType.of( collectedType ) );
-    }
-
-    public static CollectionType listOf( Class<?> collectedType )
-    {
-        return new CollectionType( List.class, ValueType.of( collectedType ) );
-    }
-
-    public static CollectionType setOf( Class<?> collectedType )
-    {
-        return new CollectionType( Set.class, ValueType.of( collectedType ) );
-    }
-    private ValueType collectedType;
-
-    public CollectionType( Class<?> type, ValueType collectedType )
-    {
-        super( type );
-        this.collectedType = collectedType;
-        if( !isCollection( type ) )
-        {
-            throw new IllegalArgumentException( type + " is not a Collection, List or Set." );
-        }
-    }
-
-    public ValueType collectedType()
-    {
-        return collectedType;
-    }
-
-    @Override
-    public String toString()
-    {
-        return super.toString() + "<" + collectedType + ">";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/EnumType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/EnumType.java b/core/api/src/main/java/org/apache/zest/api/type/EnumType.java
deleted file mode 100644
index 692ab53..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/EnumType.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.type;
-
-import java.lang.reflect.Type;
-
-/**
- * Enum ValueType.
- */
-public final class EnumType
-    extends ValueType
-{
-
-    public static boolean isEnum( Type type )
-    {
-        if( type instanceof Class )
-        {
-            Class<?> typeClass = (Class) type;
-            return ( typeClass.isEnum() );
-        }
-        return false;
-    }
-
-    public static EnumType of( Class<?> type )
-    {
-        return new EnumType( type );
-    }
-
-    public EnumType( Class<?> type )
-    {
-        super( type );
-        if( !isEnum( type ) )
-        {
-            throw new IllegalArgumentException( type + " is not an Enum." );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java b/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
deleted file mode 100644
index 862b7eb..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
+++ /dev/null
@@ -1,27 +0,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.
- */
-package org.apache.zest.api.type;
-
-/**
- * Has types.
- */
-public interface HasTypes
-{
-    Iterable<Class<?>> types();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/MapType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/MapType.java b/core/api/src/main/java/org/apache/zest/api/type/MapType.java
deleted file mode 100644
index f2baf77..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/MapType.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.type;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-import org.apache.zest.api.util.Classes;
-
-/**
- * Map ValueType.
- * <p>This handles instances of Map.</p>
- */
-public final class MapType
-    extends ValueType
-{
-
-    private ValueType keyType;
-    private ValueType valueType;
-    private final Serialization.Variant variant;
-
-    public static boolean isMap( Type type )
-    {
-        Class<?> cl = Classes.RAW_CLASS.map( type );
-        return Map.class.isAssignableFrom( cl );
-    }
-
-    public static MapType of( Class<?> keyType, Class<?> valueType )
-    {
-        return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ) );
-    }
-
-    public static MapType of( Class<?> keyType, Class<?> valueType, Serialization.Variant variant )
-    {
-        return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ), variant );
-    }
-
-    public MapType( Class<?> type, ValueType keyType, ValueType valueType )
-    {
-        this( type, keyType, valueType, Serialization.Variant.entry );
-    }
-
-    public MapType( Class<?> type, ValueType keyType, ValueType valueType, Serialization.Variant variant )
-    {
-        super( type );
-        this.keyType = keyType;
-        this.valueType = valueType;
-        this.variant = variant;
-        if( !isMap( type ) )
-        {
-            throw new IllegalArgumentException( type + " is not a Map." );
-        }
-    }
-
-    public ValueType keyType()
-    {
-        return keyType;
-    }
-
-    public ValueType valueType()
-    {
-        return valueType;
-    }
-
-    public Serialization.Variant variant()
-    {
-        return variant;
-    }
-
-    @Override
-    public String toString()
-    {
-        return super.toString() + "<" + keyType + "," + valueType + ">";
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java b/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
deleted file mode 100644
index 328dcf4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/MatchTypeSpecification.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2012, Niclas Hedhman. 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.zest.api.type;
-
-import org.apache.zest.functional.Specification;
-
-/**
- * Match Type Specification for HasTypes.
- */
-public class MatchTypeSpecification
-    implements Specification<HasTypes>
-{
-    private final Class<?> matchType;
-
-    public MatchTypeSpecification( Class<?> matchType )
-    {
-        this.matchType = matchType;
-    }
-
-    @Override
-    public boolean satisfiedBy( HasTypes item )
-    {
-        for( Class<?> type : item.types() )
-        {
-            if( matchType.isAssignableFrom( type ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/Serialization.java b/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
deleted file mode 100644
index c0d70e6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.type;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Serialization options for Property intstances.
- * <p>
- * The {@code entry} type represents the explicit key=keyValue, value=valueValue. For JSON serialization;
- * </p>
- * <pre>
- *     [
- *         { "key1" : "value1" },
- *         { "key2" : "value2" }
- *     ]
- * </pre>
- * <p>
- * For XML serialization;
- * </p>
- * <pre>
- *     &lt;object&gt;
- *         &lt;
- *     &lt;/object&gt;
- * </pre>
- * <p>
- * The {@code object} type represents the explicit keyValue=valueValue.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface Serialization
-{
-    Variant value();
-
-    enum Variant
-    {
-        entry, object
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/ValueCompositeType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/ValueCompositeType.java b/core/api/src/main/java/org/apache/zest/api/type/ValueCompositeType.java
deleted file mode 100644
index 67cc7bf..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/ValueCompositeType.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. 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.zest.api.type;
-
-import java.lang.reflect.Type;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.api.value.ValueDescriptor;
-
-/**
- * ValueComposite ValueType.
- */
-public final class ValueCompositeType
-    extends ValueType
-{
-    private final ValueDescriptor model;
-
-    public static boolean isValueComposite( Type type )
-    {
-        return ValueComposite.class.isAssignableFrom( Classes.RAW_CLASS.map( type ) );
-    }
-
-    public ValueCompositeType( ValueDescriptor model )
-    {
-        super( model.types() );
-        this.model = model;
-    }
-
-    public Iterable<? extends PropertyDescriptor> properties()
-    {
-        return model.state().properties();
-    }
-
-    public Iterable<? extends AssociationDescriptor> associations()
-    {
-        return model.state().associations();
-    }
-
-    public Iterable<? extends AssociationDescriptor> manyAssociations()
-    {
-        return model.state().manyAssociations();
-    }
-
-    public Iterable<? extends AssociationDescriptor> namedAssociations()
-    {
-        return model.state().namedAssociations();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/ValueType.java b/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
deleted file mode 100644
index a13b509..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2013, Paul Merlin. 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.zest.api.type;
-
-import java.util.Collections;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Base class for types of values in ValueComposites and Properties.
- */
-public class ValueType
-    implements HasTypes
-{
-
-    public static ValueType of( Class<?> type )
-    {
-        return new ValueType( type );
-    }
-
-    /**
-     * Check if a non-null object is of any of the Primitive Value Types or an array of them.
-     * <p>
-     *     String, Boolean, Integer, Double, Float, Long, Byte, Short and Character and their Java primitive types
-     *     counterparts are considered as Primitive Value Types.
-     * </p>
-     * <p>
-     *     Date, BigInteger, BigDecimal and JodaTime types are not considered as Primitive Value Types.
-     * </p>
-     *
-     * @return true if object is a primitive value or an array of primitive values
-     * @throws IllegalArgumentException if object is null
-     */
-    public static boolean isPrimitiveValue( Object object )
-    {
-        NullArgumentException.validateNotNull( "object", object );
-        if( object instanceof String
-            || object instanceof Character
-            || object instanceof Boolean
-            || object instanceof Integer
-            || object instanceof Double
-            || object instanceof Float
-            || object instanceof Long
-            || object instanceof Byte
-            || object instanceof Short )
-        {
-            return true;
-        }
-        if( object.getClass().isArray() )
-        {
-            return isArrayOfPrimitiveValues( object );
-        }
-        return false;
-    }
-
-    private static boolean isArrayOfPrimitiveValues( Object array )
-    {
-        if( array instanceof String[]
-            || array instanceof char[] || array instanceof Character[]
-            || array instanceof boolean[] || array instanceof Boolean[]
-            || array instanceof int[] || array instanceof Integer[]
-            || array instanceof double[] || array instanceof Double[]
-            || array instanceof float[] || array instanceof Float[]
-            || array instanceof long[] || array instanceof Long[]
-            || array instanceof byte[] || array instanceof Byte[]
-            || array instanceof short[] || array instanceof Short[] )
-        {
-            return true;
-        }
-        return false;
-    }
-
-    public static boolean isPrimitiveValueType( ValueType valueType )
-    {
-        return isPrimitiveValueType( valueType.mainType() );
-    }
-
-    /**
-     * @see ValueType#isPrimitiveValue(java.lang.Object) 
-     */
-    public static boolean isPrimitiveValueType( Class<?> type )
-    {
-        NullArgumentException.validateNotNull( "type", type );
-        if( String.class.isAssignableFrom( type ) )
-        {
-            return true;
-        }
-        if( type.isArray() )
-        {
-            return isPrimitiveValueType( type.getComponentType() );
-        }
-        return false;
-    }
-    protected final Iterable<Class<?>> types;
-
-    public ValueType( Class<?> type )
-    {
-        this( Collections.singleton( type ) );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public ValueType( Iterable<? extends Class<?>> types )
-    {
-        this.types = (Iterable<Class<?>>) types;
-    }
-
-    public Class<?> mainType()
-    {
-        return first( types );
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return types;
-    }
-
-    @Override
-    public String toString()
-    {
-        String name = Iterables.toString(
-            types,
-            new Function<Class<?>, String>()
-            {
-                @Override
-                public String map( Class<?> item )
-                {
-                    return item.getName();
-                }
-            },
-            "," );
-        if( name.contains( "," ) )
-        {
-            name = "{" + name + "}";
-        }
-        return name;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/type/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/package.html b/core/api/src/main/java/org/apache/zest/api/type/package.html
deleted file mode 100644
index d42baa3..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Type API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
deleted file mode 100644
index 5d02845..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/ConcurrentEntityModificationException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.unitofwork;
-
-import org.apache.zest.api.entity.EntityComposite;
-
-/**
- * This exception is thrown by UnitOfWork.complete() if any entities that are being committed
- * had been changed while the UnitOfWork was being executed.
- */
-public class ConcurrentEntityModificationException
-    extends UnitOfWorkCompletionException
-{
-    private static final long serialVersionUID = 3872723845064767689L;
-
-    private final Iterable<EntityComposite> concurrentlyModifiedEntities;
-
-    public ConcurrentEntityModificationException( Iterable<EntityComposite> concurrentlyModifiedEntities )
-    {
-        super("Entities changed concurrently :" + concurrentlyModifiedEntities);
-        this.concurrentlyModifiedEntities = concurrentlyModifiedEntities;
-    }
-
-    public Iterable<EntityComposite> concurrentlyModifiedEntities()
-    {
-        return concurrentlyModifiedEntities;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityCompositeAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityCompositeAlreadyExistsException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityCompositeAlreadyExistsException.java
deleted file mode 100644
index 0872ba6..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityCompositeAlreadyExistsException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman.
- *
- * 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.zest.api.unitofwork;
-
-import org.apache.zest.api.entity.EntityReference;
-
-/**
- * If you try to create an EntityComposite whose identity already exists,
- * then this exception will be thrown.
- */
-public class EntityCompositeAlreadyExistsException
-    extends UnitOfWorkException
-{
-    private static final long serialVersionUID = -7297710939536508481L;
-
-    private final EntityReference identity;
-
-    public EntityCompositeAlreadyExistsException( EntityReference identity )
-    {
-        super( "EntityComposite (" + identity + ") already exists." );
-        this.identity = identity;
-    }
-
-    public EntityReference identity()
-    {
-        return identity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
deleted file mode 100644
index 58da2e1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007-2008, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2007, Alin Dreghiciu. 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.zest.api.unitofwork;
-
-import org.apache.zest.functional.Function;
-
-import static org.apache.zest.functional.Iterables.fold;
-
-/**
- * Zest exception to be thrown in case that an entity composite
- * was not found during a lookup call.
- */
-public class EntityTypeNotFoundException
-    extends UnitOfWorkException
-{
-    private final String compositeType;
-
-    public EntityTypeNotFoundException( String entityType, String moduleName, Iterable<String> visibility )
-    {
-        super( "Could not find an EntityComposite of type " + entityType + " in module [" + moduleName + "].\n" +
-               "\tThe following entity types are visible:\n" + join(visibility) );
-        this.compositeType = entityType;
-    }
-
-    private static String join( Iterable<String> visibility )
-    {
-        return fold( new Function<String, String>()
-        {
-            StringBuilder result;
-            {
-                result = new StringBuilder();
-            }
-
-            @Override
-            public String map( String type )
-            {
-                result.append( type );
-                result.append( "\n" );
-                return result.toString();
-            }
-        }, visibility );
-    }
-
-    public String compositeType()
-    {
-        return compositeType;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/NoSuchEntityException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/NoSuchEntityException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/NoSuchEntityException.java
deleted file mode 100644
index 297344b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/NoSuchEntityException.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2008-2013, Niclas Hedhman. 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.zest.api.unitofwork;
-
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-
-/**
- * This exception indicates that the requested Entity with the given
- * identity does not exist.
- */
-public class NoSuchEntityException
-    extends UnitOfWorkException
-{
-    private final EntityReference identity;
-    private final Usecase usecase;
-    private final Class<?>[] mixinTypes;
-
-    public NoSuchEntityException( EntityReference identity, Class<?> mixinType, Usecase usecase )
-    {
-        super( "Could not find entity (" + identity + ") of type " + mixinType.getName() + " in usecase '" + usecase.name() + "'" );
-        this.identity = identity;
-        this.usecase = usecase;
-        this.mixinTypes = new Class<?>[]{ mixinType };
-    }
-
-    public NoSuchEntityException( EntityReference identity, Class<?>[] mixinTypes, Usecase usecase )
-    {
-        super( "Could not find entity (" + identity + ") of type " + toString( mixinTypes ) + " in usecase '" + usecase.name() + "'" );
-        this.identity = identity;
-        this.mixinTypes = mixinTypes;
-        this.usecase = usecase;
-    }
-
-    public NoSuchEntityException( EntityReference identity, Iterable<Class<?>> types, Usecase usecase )
-    {
-        this( identity, castToArray( types ), usecase );
-    }
-
-    public EntityReference identity()
-    {
-        return identity;
-    }
-
-    public Class<?>[] mixinTypes()
-    {
-        return mixinTypes;
-    }
-
-    public Usecase usecase()
-    {
-        return usecase;
-    }
-
-    private static Class<?>[] castToArray( Iterable<Class<?>> iterableClasses )
-    {
-        Iterable<Class> types = Iterables.cast( iterableClasses );
-        return Iterables.toArray( Class.class, types );
-    }
-
-    private static String toString( Class<?>[] mixinTypes )
-    {
-        Iterable<String> map = Iterables.map( new Function<Class<?>, String>()
-        {
-            @Override
-            public String map( Class<?> item )
-            {
-                return item.getName();
-            }
-        }, Iterables.iterable( mixinTypes ) );
-        return Iterables.fold( new Function<String, String>()
-        {
-            StringBuilder result;
-            boolean first = true;
-
-            {
-                result = new StringBuilder();
-                result.append( "[" );
-            }
-
-            @Override
-            public String map( String strings )
-            {
-                if( !first )
-                {
-                    result.append( ',' );
-                }
-                first = false;
-                result.append( strings );
-                return result.toString() + "]";
-            }
-        }, map );
-    }
-}


[20/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/qi4j/functional/IterablesTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/qi4j/functional/IterablesTest.java b/core/functional/src/test/java/org/qi4j/functional/IterablesTest.java
new file mode 100644
index 0000000..6aee556
--- /dev/null
+++ b/core/functional/src/test/java/org/qi4j/functional/IterablesTest.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+import static java.util.Collections.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test of Iterables utility methods
+ */
+public class IterablesTest
+{
+
+    private List<String> numbers = Arrays.asList( "1", "2", "3" );
+    private Iterable<Long> numberLongs = Arrays.asList( 1L, 2L, 3L );
+    private Iterable<Integer> numberIntegers = Arrays.asList( 1, 2, 3 );
+
+    @Test
+    public void testConstant()
+    {
+        String str = "";
+
+        for( String string : Iterables.limit( 3, Iterables.constant( "123" ) ) )
+        {
+            str += string;
+        }
+
+        assertThat( str, CoreMatchers.equalTo( "123123123" ) );
+    }
+
+    @Test
+    public void testUnique()
+    {
+        String str = "";
+
+        for( String string : Iterables.unique( Iterables.<String>flatten( numbers, numbers, numbers ) ) )
+        {
+            str += string;
+        }
+        assertThat( str, CoreMatchers.equalTo( "123" ) );
+    }
+
+    @Test
+    public void testAddAll()
+    {
+        List<String> strings = Iterables.toList( numbers );
+        assertThat( strings.toString(), equalTo( "[1, 2, 3]" ) );
+        assertThat( Iterables.toList( numberLongs ).toString(), equalTo( "[1, 2, 3]" ) );
+    }
+
+    @Test
+    public void testCount()
+    {
+        assertThat( Iterables.count( numbers ), equalTo( 3L ) );
+    }
+
+    @Test
+    public void testFilter()
+    {
+        assertThat( Iterables.first( Iterables.filter( Specifications.in( "2" ), numbers ) ), equalTo( "2" ) );
+    }
+
+    @Test
+    public void testFirst()
+    {
+        assertThat( Iterables.first( numbers ), equalTo( "1" ) );
+        assertThat( Iterables.first( emptyList() ), nullValue() );
+    }
+
+    @Test
+    public void testLast()
+    {
+        assertThat( Iterables.last( numbers ), equalTo( "3" ) );
+        assertThat( Iterables.last( emptyList() ), nullValue() );
+    }
+
+    @Test
+    public void testFolding()
+    {
+        assertThat( Iterables.fold( new Function<Integer, Integer>()
+        {
+
+            int sum = 0;
+
+            @Override
+            public Integer map( Integer number )
+            {
+                return sum += number;
+            }
+
+        }, numberIntegers ), equalTo( 6 ) );
+    }
+
+    @Test
+    public void testAppend()
+    {
+        assertThat( Iterables.toList( Iterables.append( "C", Iterables.iterable( "A", "B" ) ) ).toString(),
+                    equalTo( "[A, B, C]" ) );
+    }
+
+    @Test
+    public void testReverse()
+    {
+        assertThat( Iterables.reverse( numbers ).toString(), equalTo( "[3, 2, 1]" ) );
+        assertThat( Iterables.reverse( emptyList() ), equalTo( (Object) emptyList() ) );
+    }
+
+    @Test
+    public void testMatchesAny()
+    {
+        assertThat( Iterables.matchesAny( Specifications.in( "2" ), numbers ), equalTo( true ) );
+        assertThat( Iterables.matchesAny( Specifications.in( "4" ), numbers ), equalTo( false ) );
+    }
+
+    @Test
+    public void testMatchesAll()
+    {
+        assertThat( Iterables.matchesAll( Specifications.in( "1", "2", "3" ), numbers ), equalTo( true ) );
+        assertThat( Iterables.matchesAll( Specifications.in( "2", "3", "4" ), numbers ), equalTo( false ) );
+    }
+
+    @Test
+    public void testFlatten()
+    {
+        assertThat( Iterables.toList( Iterables.flatten( numbers, numbers ) ).toString(),
+                    equalTo( "[1, 2, 3, 1, 2, 3]" ) );
+
+        Iterable<? extends Number> flatten = Iterables.flatten( numberIntegers, numberLongs );
+        assertThat( Iterables.toList( flatten ).toString(), equalTo( "[1, 2, 3, 1, 2, 3]" ) );
+    }
+
+    @Test
+    public void testFlattenIterables()
+    {
+        Iterable<List<String>> iterable = Iterables.iterable( numbers, numbers );
+        assertThat( Iterables.toList( Iterables.flattenIterables( iterable ) ).toString(),
+                    equalTo( "[1, 2, 3, 1, 2, 3]" ) );
+    }
+
+    @Test
+    public void testMix()
+    {
+        assertThat( Iterables.toList( Iterables.mix( Iterables.iterable( "A", "B", "C" ),
+                                                     Iterables.iterable( "1", "2", "3", "4", "5" ),
+                                                     Iterables.iterable( "X", "Y", "Z" ) ) ).toString(),
+                    equalTo( "[A, 1, X, B, 2, Y, C, 3, Z, 4, 5]" ) );
+    }
+
+    @Test
+    public void testMap()
+    {
+        assertThat( Iterables.toList( Iterables.map( new Function<String, String>()
+        {
+
+            public String map( String s )
+            {
+                return s + s;
+            }
+
+        }, numbers ) ).toString(), equalTo( "[11, 22, 33]" ) );
+
+        Iterable<List<String>> numberIterable = Iterables.iterable( numbers, numbers, numbers );
+        assertThat( Iterables.toList( Iterables.map( new Function<Collection, Integer>()
+        {
+
+            @Override
+            public Integer map( Collection collection )
+            {
+                return collection.size();
+            }
+
+        }, numberIterable ) ).toString(), equalTo( "[3, 3, 3]" ) );
+    }
+
+    @Test
+    public void testIterableEnumeration()
+    {
+
+        Enumeration<String> enumeration = enumeration( numbers );
+        assertThat( Iterables.toList( Iterables.iterable( enumeration ) ).toString(),
+                    equalTo( "[1, 2, 3]" ) );
+    }
+
+    @Test
+    public void testIterableVarArg()
+    {
+        assertThat( Iterables.toList( Iterables.iterable( "1", "2", "3" ) ).toString(),
+                    equalTo( "[1, 2, 3]" ) );
+    }
+
+    @Test
+    public void testCast()
+    {
+        Iterable<Long> values = numberLongs;
+        Iterable<Number> numbers = Iterables.cast( values );
+    }
+
+    @Test
+    public void testDebug()
+    {
+        assertThat( Iterables.first( Iterables.debug( "Filtered number:{0}",
+                                                      Iterables.filter( Specifications.in( "2" ),
+                                                                        Iterables.debug( "Number:{0}", numbers ) ) ) ),
+                    equalTo( "2" ) );
+    }
+
+    @Test
+    public void testDebugWithFunctions()
+    {
+        Function<String, String> fun = new Function<String, String>()
+        {
+
+            @Override
+            public String map( String s )
+            {
+                return s + ":" + s.length();
+            }
+
+        };
+        assertThat( Iterables.first( Iterables.debug( "Filtered number:{0}",
+                                                      Iterables.filter( Specifications.in( "2" ),
+                                                                        Iterables.debug( "Number:{0}", numbers, fun ) ) ) ),
+                    equalTo( "2" ) );
+    }
+
+    @Test
+    public void testCache()
+    {
+        final int[] count = new int[ 1 ];
+
+        Iterable<String> b = Iterables.cache( Iterables.filter( Specifications.and( new Specification<String>()
+        {
+
+            @Override
+            public boolean satisfiedBy( String item )
+            {
+                count[ 0] = count[ 0] + 1;
+                return true;
+            }
+
+        }, Specifications.in( "B" ) ), Iterables.iterable( "A", "B", "C" ) ) );
+
+        assertThat( count[ 0], equalTo( 0 ) );
+
+        Iterables.toList( b );
+
+        assertThat( count[ 0], equalTo( 3 ) );
+
+        Iterables.toList( b );
+
+        assertThat( count[ 0], equalTo( 3 ) );
+    }
+
+    @Test
+    public void testSort()
+    {
+        assertThat( Iterables.sort( Iterables.reverse( numberLongs ) ).toString(), equalTo( "[1, 2, 3]" ) );
+
+        Comparator<Long> inverseLongComparator = new Comparator<Long>()
+        {
+
+            @Override
+            public int compare( Long left, Long right )
+            {
+                return left.compareTo( right ) * -1;
+            }
+
+        };
+        assertThat( Iterables.sort( inverseLongComparator, numberLongs ).toString(), equalTo( "[3, 2, 1]" ) );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/qi4j/functional/SpecificationsTest.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/qi4j/functional/SpecificationsTest.java b/core/functional/src/test/java/org/qi4j/functional/SpecificationsTest.java
new file mode 100644
index 0000000..98b893e
--- /dev/null
+++ b/core/functional/src/test/java/org/qi4j/functional/SpecificationsTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.functional;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+
+/**
+ * JAVADOC
+ */
+public class SpecificationsTest
+{
+    @Test
+    public void testTRUE()
+    {
+        Assert.assertThat( Specifications.<Object>TRUE().satisfiedBy( new Object() ), equalTo( true ) );
+    }
+
+    @Test
+    public void testNot()
+    {
+        Assert.assertThat( Specifications.not( Specifications.<Object>TRUE() )
+                               .satisfiedBy( new Object() ), equalTo( false ) );
+    }
+
+    @Test
+    public void testAnd()
+    {
+        Specification<Object> trueSpec = Specifications.<Object>TRUE();
+        Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() );
+
+        Assert.assertThat( Specifications.and( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
+        Assert.assertThat( Specifications.and( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
+        Assert.assertThat( Specifications.and( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( false ) );
+        Assert.assertThat( Specifications.and( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
+    }
+
+    @Test
+    public void testOr()
+    {
+        Specification<Object> trueSpec = Specifications.<Object>TRUE();
+        Specification<Object> falseSpec = Specifications.not( Specifications.<Object>TRUE() );
+
+        Assert.assertThat( Specifications.or( falseSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( false ) );
+        Assert.assertThat( Specifications.or( trueSpec, falseSpec ).satisfiedBy( new Object() ), equalTo( true ) );
+        Assert.assertThat( Specifications.or( falseSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
+        Assert.assertThat( Specifications.or( trueSpec, trueSpec ).satisfiedBy( new Object() ), equalTo( true ) );
+    }
+
+    @Test
+    public void testIn()
+    {
+        Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "2" ), equalTo( true ) );
+        Assert.assertThat( Specifications.in( "1", "2", "3" ).satisfiedBy( "4" ), equalTo( false ) );
+    }
+
+    @Test
+    public void testTranslate()
+    {
+        Function<Object, String> stringifier = new Function<Object, String>()
+        {
+            @Override
+            public String map( Object s )
+            {
+                return s.toString();
+            }
+        };
+
+        Assert.assertTrue( Specifications.translate( stringifier, Specifications.in( "3" ) ).satisfiedBy( 3L ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/functional/src/test/java/org/qi4j/functional/docsupport/FunctionalDocs.java
----------------------------------------------------------------------
diff --git a/core/functional/src/test/java/org/qi4j/functional/docsupport/FunctionalDocs.java b/core/functional/src/test/java/org/qi4j/functional/docsupport/FunctionalDocs.java
new file mode 100644
index 0000000..7110a21
--- /dev/null
+++ b/core/functional/src/test/java/org/qi4j/functional/docsupport/FunctionalDocs.java
@@ -0,0 +1,55 @@
+/*
+ * 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.qi4j.functional.docsupport;
+
+import java.util.ArrayList;
+
+// START SNIPPET: func2
+import static org.qi4j.functional.ForEach.forEach;
+import static org.qi4j.functional.Functions.longSum;
+// END SNIPPET: func2
+
+public class FunctionalDocs
+{
+    public static void main( String[] args )
+    {
+        {
+// START SNIPPET: func1
+            Iterable<Long> data = new ArrayList<Long>();
+// END SNIPPET: func1
+// START SNIPPET: func1
+
+            long sum = 0;
+            for( Long point : data )
+            {
+                sum = sum + point;
+            }
+            System.out.println( "The sum is " + sum );
+// END SNIPPET: func1
+        }
+        {
+// START SNIPPET: func2
+            Iterable<Number> data = new ArrayList<Number>();
+            Long sum = forEach( data ).map( longSum() ).last();
+            System.out.println( "The sum is " + sum );
+
+// END SNIPPET: func2
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Files.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Files.java b/core/io/src/main/java/org/apache/zest/io/Files.java
deleted file mode 100644
index 14834f3..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Files.java
+++ /dev/null
@@ -1,35 +0,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.
- */
-package org.apache.zest.io;
-
-import java.io.File;
-import java.util.Random;
-
-/**
- * Utility class for files.
- */
-public class Files
-{
-    private static Random random = new Random();
-
-    public static File createTemporayFileOf( File file )
-    {
-        return new File(  file.getAbsolutePath() + "_" + Math.abs( random.nextLong() ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Input.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Input.java b/core/io/src/main/java/org/apache/zest/io/Input.java
deleted file mode 100644
index d7bf8ab..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Input.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-/**
- * Input source of data.
- * <p>
- * Invoke transferTo to send data from this input to given output. transferTo can be invoked
- * as many times as you want. The transferTo implementation must ensure that any exceptions thrown
- * by the Input or the Output which transferred data is sent to is handled properly, i.e. that resources
- * are closed. Any client code to transferTo calls should not have to bother with resource management,
- * but may catch exceptions anyway for logging and similar purposes.
- * </p>
- */
-// START SNIPPET: input
-public interface Input<T, SenderThrowableType extends Throwable>
-{
-    <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
-        throws SenderThrowableType, ReceiverThrowableType;
-}
-// END SNIPPET: input

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Inputs.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Inputs.java b/core/io/src/main/java/org/apache/zest/io/Inputs.java
deleted file mode 100644
index 51f03fb..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Inputs.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.Scanner;
-import java.util.zip.GZIPInputStream;
-import org.apache.zest.functional.Visitor;
-
-/**
- * Common inputs
- */
-public class Inputs
-{
-    // START SNIPPET: method
-
-    /**
-     * Read lines from a String.
-     *
-     * @param source lines
-     *
-     * @return Input that provides lines from the string as strings
-     */
-    public static Input<String, RuntimeException> text( final String source )
-    // END SNIPPET: method
-    {
-        return new Input<String, RuntimeException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws RuntimeException, ReceiverThrowableType
-            {
-
-                output.receiveFrom( new Sender<String, RuntimeException>()
-                {
-                    @Override
-                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
-                        throws Receiver2ThrowableType, RuntimeException
-                    {
-                        Scanner scanner = new Scanner( source );
-                        while( scanner.hasNextLine() )
-                        {
-                            receiver.receive( scanner.nextLine() );
-                        }
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read lines from a Reader.
-     *
-     * @param source lines
-     *
-     * @return Input that provides lines from the string as strings
-     */
-    public static Input<String, RuntimeException> text( final Reader source )
-    // END SNIPPET: method
-    {
-        return new Input<String, RuntimeException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws RuntimeException, ReceiverThrowableType
-            {
-
-                output.receiveFrom( new Sender<String, RuntimeException>()
-                {
-                    @Override
-                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
-                        throws Receiver2ThrowableType, RuntimeException
-                    {
-                        Scanner scanner = new Scanner( source );
-                        while( scanner.hasNextLine() )
-                        {
-                            receiver.receive( scanner.nextLine() );
-                        }
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read lines from a UTF-8 encoded textfile.
-     *
-     * If the filename ends with .gz, then the data is automatically unzipped when read.
-     *
-     * @param source textfile with lines separated by \n character
-     *
-     * @return Input that provides lines from the textfiles as strings
-     */
-    public static Input<String, IOException> text( final File source )
-    // END SNIPPET: method
-    {
-        return text( source, "UTF-8" );
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read lines from a textfile with the given encoding.
-     *
-     * If the filename ends with .gz, then the data is automatically unzipped when read.
-     *
-     * @param source   textfile with lines separated by \n character
-     * @param encoding encoding of file, e.g. "UTF-8"
-     *
-     * @return Input that provides lines from the textfiles as strings
-     */
-    public static Input<String, IOException> text( final File source, final String encoding )
-    // END SNIPPET: method
-    {
-        return new Input<String, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                InputStream stream = new FileInputStream( source );
-
-                // If file is gzipped, unzip it automatically
-                if( source.getName().endsWith( ".gz" ) )
-                {
-                    stream = new GZIPInputStream( stream );
-                }
-
-                try (BufferedReader reader = new BufferedReader( new InputStreamReader( stream, encoding ) ))
-                {
-                    output.receiveFrom( new Sender<String, IOException>()
-                    {
-                        @Override
-                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
-                            throws Receiver2ThrowableType, IOException
-                        {
-                            String line;
-                            while( ( line = reader.readLine() ) != null )
-                            {
-                                receiver.receive( line );
-                            }
-                        }
-                    } );
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read lines from a textfile at a given URL.
-     *
-     * If the content support gzip encoding, then the data is automatically unzipped when read.
-     *
-     * The charset in the content-type of the URL will be used for parsing. Default is UTF-8.
-     *
-     * @param source textfile with lines separated by \n character
-     *
-     * @return Input that provides lines from the textfiles as strings
-     */
-    public static Input<String, IOException> text( final URL source )
-    // END SNIPPET: method
-    {
-        return new Input<String, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                URLConnection urlConnection = source.openConnection();
-                urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
-                InputStream stream = urlConnection.getInputStream();
-
-                // If file is gzipped, unzip it automatically
-                if( "gzip".equals( urlConnection.getContentEncoding() ) )
-                {
-                    stream = new GZIPInputStream( stream );
-                }
-
-                // Figure out charset given content-type
-                String contentType = urlConnection.getContentType();
-                String charSet = "UTF-8";
-                if( contentType.contains( "charset=" ) )
-                {
-                    charSet = contentType.substring( contentType.indexOf( "charset=" ) + "charset=".length() );
-                }
-
-                try (BufferedReader reader = new BufferedReader( new InputStreamReader( stream, charSet ) ))
-                {
-                    output.receiveFrom( new Sender<String, IOException>()
-                    {
-                        @Override
-                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
-                            throws Receiver2ThrowableType, IOException
-                        {
-                            String line;
-                            while( ( line = reader.readLine() ) != null )
-                            {
-                                receiver.receive( line );
-                            }
-                        }
-                    } );
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read a file using ByteBuffer of a given size. Useful for transferring raw data.
-     *
-     * @param source The file to be read.
-     * @param bufferSize The size of the byte array.
-     *
-     * @return An Input instance to be applied to streaming operations.
-     */
-    public static Input<ByteBuffer, IOException> byteBuffer( final File source, final int bufferSize )
-    // END SNIPPET: method
-    {
-        return new Input<ByteBuffer, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                final FileInputStream stream = new FileInputStream( source );
-                final FileChannel fci = stream.getChannel();
-
-                final ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
-
-                try
-                {
-                    output.receiveFrom( new Sender<ByteBuffer, IOException>()
-                    {
-                        @Override
-                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
-                            throws Receiver2ThrowableType, IOException
-                        {
-                            while( fci.read( buffer ) != -1 )
-                            {
-                                buffer.flip();
-                                receiver.receive( buffer );
-                                buffer.clear();
-                            }
-                        }
-                    } );
-                }
-                finally
-                {
-                    stream.close();
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Read an inputstream using ByteBuffer of a given size.
-     *
-     * @param source The InputStream to be read.
-     * @param bufferSize The size of the byte array.
-     *
-     * @return An Input instance to be applied to streaming operations.
-     */
-    public static Input<ByteBuffer, IOException> byteBuffer( final InputStream source, final int bufferSize )
-    // END SNIPPET: method
-    {
-        return new Input<ByteBuffer, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                try
-                {
-                    output.receiveFrom( new Sender<ByteBuffer, IOException>()
-                    {
-                        @Override
-                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
-                            throws Receiver2ThrowableType, IOException
-                        {
-                            byte[] buffer = new byte[ bufferSize ];
-
-                            int len;
-                            while( ( len = source.read( buffer ) ) != -1 )
-                            {
-                                ByteBuffer byteBuffer = ByteBuffer.wrap( buffer, 0, len );
-                                receiver.receive( byteBuffer );
-                            }
-                        }
-                    } );
-                }
-                finally
-                {
-                    source.close();
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Combine many Input into one single Input. When a transfer is initiated from it all items from all inputs will be transferred
-     * to the given Output.
-     *
-     * @param inputs An Iterable of Input instances to be combined.
-     * @param <T> The item type of the Input
-     * @param <SenderThrowableType> The Throwable that might be thrown by the Inputs.
-     *
-     * @return A combined Input, allowing for easy aggregation of many Input sources.
-     */
-    public static <T, SenderThrowableType extends Throwable> Input<T, SenderThrowableType> combine( final Iterable<Input<T, SenderThrowableType>> inputs )
-    // END SNIPPET: method
-    {
-        return new Input<T, SenderThrowableType>()
-        {
-            @Override
-            public <Receiver2ThrowableType extends Throwable> void transferTo( Output<? super T, Receiver2ThrowableType> output )
-                throws SenderThrowableType, Receiver2ThrowableType
-            {
-                output.receiveFrom( new Sender<T, SenderThrowableType>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, SenderThrowableType
-                    {
-                        for( Input<T, SenderThrowableType> input : inputs )
-                        {
-                            input.transferTo( new Output<T, ReceiverThrowableType>()
-                            {
-                                @Override
-                                public <Sender2ThrowableType extends Throwable> void receiveFrom( Sender<? extends T, Sender2ThrowableType> sender )
-                                    throws ReceiverThrowableType, Sender2ThrowableType
-                                {
-                                    sender.sendTo( new Receiver<T, ReceiverThrowableType>()
-                                    {
-                                        @Override
-                                        public void receive( T item )
-                                            throws ReceiverThrowableType
-                                        {
-                                            receiver.receive( item );
-                                        }
-                                    } );
-                                }
-                            } );
-                        }
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Create an Input that takes its items from the given Iterable.
-     *
-     * @param iterable The Iterable to be used as an Input.
-     * @param <T> The item type of the Input
-     *
-     * @return An Input instance that is backed by the Iterable.
-     */
-    public static <T> Input<T, RuntimeException> iterable( final Iterable<T> iterable )
-    // END SNIPPET: method
-    {
-        return new Input<T, RuntimeException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
-                throws RuntimeException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<T, RuntimeException>()
-                {
-                    @Override
-                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super T, Receiver2ThrowableType> receiver )
-                        throws Receiver2ThrowableType, RuntimeException
-                    {
-                        for( T item : iterable )
-                        {
-                            receiver.receive( item );
-                        }
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Create an Input that allows a Visitor to write to an OutputStream. The stream is a BufferedOutputStream, so when enough
-     * data has been gathered it will send this in chunks of the given size to the Output it is transferred to. The Visitor does not have to call
-     * close() on the OutputStream, but should ensure that any wrapper streams or writers are flushed so that all data is sent.
-     *
-     * @param outputVisitor The OutputStream Visitor that will be backing the Input ByteBuffer.
-     * @param bufferSize The buffering size.
-     *
-     * @return An Input instance of ByteBuffer, that is backed by an Visitor to an OutputStream.
-     */
-    public static Input<ByteBuffer, IOException> output( final Visitor<OutputStream, IOException> outputVisitor,
-                                                         final int bufferSize
-    )
-    // END SNIPPET: method
-    {
-        return new Input<ByteBuffer, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<ByteBuffer, IOException>()
-                {
-                    @Override
-                    @SuppressWarnings( "unchecked" )
-                    public <Receiver2ThrowableType extends Throwable> void sendTo( final Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
-                        throws Receiver2ThrowableType, IOException
-                    {
-                        try (OutputStream out = new BufferedOutputStream( new OutputStream()
-                        {
-                            @Override
-                            public void write( int b )
-                                throws IOException
-                            {
-                                // Ignore
-                            }
-
-                            @SuppressWarnings( "NullableProblems" )
-                            @Override
-                            public void write( byte[] b, int off, int len )
-                                throws IOException
-                            {
-                                try
-                                {
-                                    ByteBuffer byteBuffer = ByteBuffer.wrap( b, 0, len );
-                                    receiver.receive( byteBuffer );
-                                }
-                                catch( Throwable ex )
-                                {
-                                    throw new IOException( ex );
-                                }
-                            }
-                        }, bufferSize ))
-                        {
-                            outputVisitor.visit( out );
-                        }
-                        catch( IOException ex )
-                        {
-                            throw (Receiver2ThrowableType) ex.getCause();
-                        }
-                    }
-                } );
-            }
-        };
-    }
-
-    private Inputs()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Output.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Output.java b/core/io/src/main/java/org/apache/zest/io/Output.java
deleted file mode 100644
index 9aa514f..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Output.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-/**
- * Output for data.
- */
-// START SNIPPET: output
-public interface Output<T, ReceiverThrowableType extends Throwable>
-{
-// END SNIPPET: output
-
-    /**
-     * This initiates a transfer from an Input. Implementations should open any resources to be written to
-     * and then call sender.sendTo() when it is ready to receive data. When sendTo() returns the resource should be
-     * closed properly. Make sure to handle any exceptions from sendTo.
-     *
-     * @param sender                the sender of data to this output
-     * @param <SenderThrowableType> the exception that sendTo can throw
-     *
-     * @throws SenderThrowableType   the exception that the sender can throw
-     * @throws ReceiverThrowableType the exception that this output can throw from receiveItem()
-     */
-// START SNIPPET: output
-    <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
-        throws ReceiverThrowableType, SenderThrowableType;
-}
-// END SNIPPET: output

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Outputs.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Outputs.java b/core/io/src/main/java/org/apache/zest/io/Outputs.java
deleted file mode 100644
index e90f384..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Outputs.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.Collection;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Utility methods for creating standard Outputs
- */
-public class Outputs
-{
-    // START SNIPPET: method
-
-    /**
-     * Write lines to a text file with UTF-8 encoding. Separate each line with a newline ("\n" character). If the writing or sending fails,
-     * the file is deleted.
-     * <p>
-     * If the filename ends with .gz, then the data is automatically GZipped.
-     * </p>
-     * @param file the file to save the text to
-     *
-     * @return an Output for storing text in a file
-     */
-    public static Output<String, IOException> text( final File file )
-    // END SNIPPET: method
-    {
-        return text( file, "UTF-8" );
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write lines to a text file. Separate each line with a newline ("\n" character). If the writing or sending fails,
-     * the file is deleted.
-     * <p>
-     * If the filename ends with .gz, then the data is automatically GZipped.
-     * </p>
-     * @param file the file to save the text to
-     *
-     * @return an Output for storing text in a file
-     */
-    public static Output<String, IOException> text( final File file, final String encoding )
-    // END SNIPPET: method
-    {
-        return new Output<String, IOException>()
-        {
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                File tmpFile = Files.createTemporayFileOf( file );
-
-                OutputStream stream = new FileOutputStream( tmpFile );
-
-                // If file should be gzipped, do that automatically
-                if( file.getName().endsWith( ".gz" ) )
-                {
-                    stream = new GZIPOutputStream( stream );
-                }
-
-                final BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( stream, encoding ) );
-
-                try
-                {
-                    sender.sendTo( new Receiver<String, IOException>()
-                    {
-                        @Override
-                        public void receive( String item )
-                            throws IOException
-                        {
-                            writer.append( item ).append( '\n' );
-                        }
-                    } );
-                    writer.close();
-
-                    // Replace file with temporary file
-                    if( !file.exists() || file.delete() )
-                    {
-                        if( ! tmpFile.renameTo( file ) )
-                        {
-                            // TODO: What?? Throw an Exception?
-                            System.err.println( "Unable to rename file: " + tmpFile + " to " + file );
-                        }
-                    }
-                }
-                catch( IOException e )
-                {
-                    // We failed writing - close and delete
-                    writer.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-                }
-                catch( Throwable senderThrowableType )
-                {
-                    // We failed writing - close and delete
-                    writer.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-                    throw (SenderThrowableType) senderThrowableType;
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write lines to a Writer. Separate each line with a newline ("\n" character).
-     *
-     * @param writer the Writer to write the text to
-     * @return an Output for storing text in a Writer
-     */
-    public static Output<String, IOException> text( final Writer writer )
-    // END SNIPPET: method
-    {
-        return new Output<String, IOException>()
-        {
-
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                sender.sendTo( new Receiver<String, IOException>()
-                {
-
-                    @Override
-                    public void receive( String item )
-                        throws IOException
-                    {
-                        writer.append( item ).append( "\n" );
-                    }
-
-                } );
-            }
-
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write lines to a StringBuilder. Separate each line with a newline ("\n" character).
-     *
-     * @param builder the StringBuilder to append the text to
-     * @return an Output for storing text in a StringBuilder
-     */
-    public static Output<String, IOException> text( final StringBuilder builder )
-    // END SNIPPET: method
-    {
-        return new Output<String, IOException>()
-        {
-
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                sender.sendTo( new Receiver<String, IOException>()
-                {
-
-                    @Override
-                    public void receive( String item )
-                        throws IOException
-                    {
-                        builder.append( item ).append( "\n" );
-                    }
-
-                } );
-            }
-
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write ByteBuffer data to a file. If the writing or sending of data fails the file will be deleted.
-     *
-     * @param file The destination file.
-     *
-     * @return The Output ByteBuffer instance backed by a File.
-     */
-    public static Output<ByteBuffer, IOException> byteBuffer( final File file )
-    // END SNIPPET: method
-    {
-        return new Output<ByteBuffer, IOException>()
-        {
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends ByteBuffer, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                File tmpFile = Files.createTemporayFileOf( file );
-                FileOutputStream stream = new FileOutputStream( tmpFile );
-                final FileChannel fco = stream.getChannel();
-
-                try
-                {
-                    sender.sendTo( new Receiver<ByteBuffer, IOException>()
-                    {
-                        @Override
-                        public void receive( ByteBuffer item )
-                            throws IOException
-                        {
-                            fco.write( item );
-                        }
-                    } );
-                    stream.close();
-
-                    // Replace file with temporary file
-                    if( !file.exists() || file.delete() )
-                    {
-                        if( ! tmpFile.renameTo( file ) )
-                        {
-                            // TODO: What can be done in this case?
-                            System.err.println( "Unable to rename file: " + tmpFile + " to " + file );
-                        }
-                    }
-                }
-                catch( IOException e )
-                {
-                    // We failed writing - close and delete
-                    stream.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-
-                }
-                catch( Throwable senderThrowableType )
-                {
-                    // We failed writing - close and delete
-                    stream.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-                    throw (SenderThrowableType) senderThrowableType;
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write ByteBuffer data to an OutputStream.
-     *
-     * @param stream Destination OutputStream
-     *
-     * @return The Output of ByteBuffer that will be backed by the OutputStream.
-     */
-    public static Output<ByteBuffer, IOException> byteBuffer( final OutputStream stream )
-    // END SNIPPET: method
-    {
-        return new Output<ByteBuffer, IOException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends ByteBuffer, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                try
-                {
-                    sender.sendTo( new Receiver<ByteBuffer, IOException>()
-                    {
-                        @Override
-                        public void receive( ByteBuffer item )
-                            throws IOException
-                        {
-                            if( item.hasArray() )
-                            {
-                                stream.write( item.array(), item.arrayOffset(), item.limit() );
-                            }
-                            else
-                            {
-                                for( int i = 0; i < item.limit(); i++ )
-                                {
-                                    stream.write( item.get( i ) );
-                                }
-                            }
-                        }
-                    } );
-                }
-                finally
-                {
-                    stream.close();
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write byte array data to a file. If the writing or sending of data fails the file will be deleted.
-     *
-     * @param file The File to be written to.
-     * @param bufferSize The size of the ByteBuffer.
-     *
-     * @return An Output instance that will write to the given File.
-     */
-    public static Output<byte[], IOException> bytes( final File file, final int bufferSize )
-    // END SNIPPET: method
-    {
-        return new Output<byte[], IOException>()
-        {
-            @Override
-            @SuppressWarnings( "unchecked" )
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends byte[], SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                File tmpFile = Files.createTemporayFileOf( file );
-                final OutputStream stream = new BufferedOutputStream( new FileOutputStream( tmpFile ), bufferSize );
-
-                try
-                {
-                    sender.sendTo( new Receiver<byte[], IOException>()
-                    {
-                        @Override
-                        public void receive( byte[] item )
-                            throws IOException
-                        {
-                            stream.write( item );
-                        }
-                    } );
-                    stream.close();
-
-                    // Replace file with temporary file
-                    if( !file.exists() || file.delete() )
-                    {
-                        if( ! tmpFile.renameTo( file ) )
-                        {
-                            // TODO: WHAT???
-                            System.err.println( "Unable to rename " + tmpFile + " to " + file );
-                        }
-                    }
-                }
-                catch( IOException e )
-                {
-                    // We failed writing - close and delete
-                    stream.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-                }
-                catch( Throwable senderThrowableType )
-                {
-                    // We failed writing - close and delete
-                    stream.close();
-                    if( ! tmpFile.delete() )
-                    {
-                        System.err.println("Unable to delete temporary file." );
-                        tmpFile.deleteOnExit();
-                    }
-                    throw (SenderThrowableType) senderThrowableType;
-                }
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Do nothing. Use this if you have all logic in filters and/or specifications
-     *
-     * @param <T> The item type.
-     *
-     * @return An Output instance that ignores all data.
-     */
-    public static <T> Output<T, RuntimeException> noop()
-    // END SNIPPET: method
-    {
-        return withReceiver( new Receiver<T, RuntimeException>()
-        {
-            @Override
-            public void receive( T item )
-                throws RuntimeException
-            {
-                // Do nothing
-            }
-        } );
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Use given receiver as Output. Use this if there is no need to create a "transaction" for each transfer, and no need
-     * to do batch writes or similar.
-     *
-     * @param <T> The item type
-     * @param receiver receiver for this Output
-     *
-     * @return An Output instance backed by a Receiver of items.
-     */
-    public static <T, ReceiverThrowableType extends Throwable> Output<T, ReceiverThrowableType> withReceiver( final Receiver<T, ReceiverThrowableType> receiver )
-    // END SNIPPET: method
-    {
-        return new Output<T, ReceiverThrowableType>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
-                throws ReceiverThrowableType, SenderThrowableType
-            {
-                sender.sendTo( receiver );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write objects to System.out.println.
-     *
-     * @return An Output instance that is backed by System.out
-     */
-    public static Output<Object, RuntimeException> systemOut()
-    // END SNIPPET: method
-    {
-        return new Output<Object, RuntimeException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<?, SenderThrowableType> sender )
-                throws RuntimeException, SenderThrowableType
-            {
-                sender.sendTo( new Receiver<Object, RuntimeException>()
-                {
-                    @Override
-                    public void receive( Object item )
-                    {
-                        System.out.println( item );
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Write objects to System.err.println.
-     *
-     * @return An Output instance backed by System.in
-     */
-    @SuppressWarnings( "UnusedDeclaration" )
-    public static Output<Object, RuntimeException> systemErr()
-    // END SNIPPET: method
-    {
-        return new Output<Object, RuntimeException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<?, SenderThrowableType> sender )
-                throws RuntimeException, SenderThrowableType
-            {
-                sender.sendTo( new Receiver<Object, RuntimeException>()
-                {
-                    @Override
-                    public void receive( Object item )
-                    {
-                        System.err.println( item );
-                    }
-                } );
-            }
-        };
-    }
-
-    // START SNIPPET: method
-
-    /**
-     * Add items to a collection
-     */
-    public static <T> Output<T, RuntimeException> collection( final Collection<T> collection )
-    // END SNIPPET: method
-    {
-        return new Output<T, RuntimeException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
-                throws RuntimeException, SenderThrowableType
-            {
-                sender.sendTo( new Receiver<T, RuntimeException>()
-                {
-                    @Override
-                    public void receive( T item )
-                        throws RuntimeException
-                    {
-                        collection.add( item );
-                    }
-                } );
-            }
-        };
-    }
-
-    private Outputs()
-    {
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Receiver.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Receiver.java b/core/io/src/main/java/org/apache/zest/io/Receiver.java
deleted file mode 100644
index e0038d0..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Receiver.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-/**
- * Receiver of items during a specific transfer from an Input to an Output.
- */
-// START SNIPPET: receiver
-public interface Receiver<T, ReceiverThrowableType extends Throwable>
-{
-// END SNIPPET: receiver
-    /**
-     * Receive a single item of the given type. The receiver should process it
-     * and optionally throw an exception if it fails.
-     *
-     * @param item
-     *
-     * @throws ReceiverThrowableType
-     */
-// START SNIPPET: receiver
-    void receive( T item )
-        throws ReceiverThrowableType;
-}
-// END SNIPPET: receiver

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Sender.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Sender.java b/core/io/src/main/java/org/apache/zest/io/Sender.java
deleted file mode 100644
index 5812cc6..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Sender.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-/**
- * Sender of items for a particular transfer from an Input to an Output
- */
-// START SNIPPET: sender
-public interface Sender<T, SenderThrowableType extends Throwable>
-{
-// END SNIPPET: sender
-    /**
-     * The sender should send all items it holds to the receiver by invoking receiveItem for each item.
-     *
-     * If the receive fails it should properly close any open resources.
-     *
-     * @param receiver
-     * @param <ReceiverThrowableType>
-     *
-     * @throws ReceiverThrowableType
-     * @throws SenderThrowableType
-     */
-// START SNIPPET: sender
-    <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super T, ReceiverThrowableType> receiver )
-        throws ReceiverThrowableType, SenderThrowableType;
-}
-// END SNIPPET: sender

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/Transforms.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/Transforms.java b/core/io/src/main/java/org/apache/zest/io/Transforms.java
deleted file mode 100644
index b17c542..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Transforms.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.text.MessageFormat;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.logging.Logger;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Specification;
-
-/**
- * Utility class for I/O transforms
- */
-public class Transforms
-{
-    /**
-     * Filter items in a transfer by applying the given Specification to each item.
-     *
-     * @param specification            The Specification defining the items to not filter away.
-     * @param output                   The Output instance to receive to result.
-     * @param <T>                      The item type
-     * @param <Receiver2ThrowableType> Exception type that might be thrown by the Receiver.
-     *
-     * @return And Output encapsulation the filter operation.
-     */
-    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filter( final Specification<? super T> specification,
-                                                                                                          final Output<T, Receiver2ThrowableType> output
-    )
-    {
-        return new Output<T, Receiver2ThrowableType>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends T, SenderThrowableType> sender )
-                throws Receiver2ThrowableType, SenderThrowableType
-            {
-                output.receiveFrom( new Sender<T, SenderThrowableType>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, SenderThrowableType
-                    {
-                        sender.sendTo( new Receiver<T, ReceiverThrowableType>()
-                        {
-                            @Override
-                            public void receive( T item )
-                                throws ReceiverThrowableType
-                            {
-                                if( specification.satisfiedBy( item ) )
-                                {
-                                    receiver.receive( item );
-                                }
-                            }
-                        } );
-                    }
-                } );
-            }
-        };
-    }
-
-    /**
-     * Map items in a transfer from one type to another by applying the given function.
-     *
-     * @param function                 The transformation function to apply to the streaming items.
-     * @param output                   The output to receive the transformed items.
-     * @param <From>                   The type of the incoming items.
-     * @param <To>                     The type of the transformed items.
-     * @param <Receiver2ThrowableType> The exception type that the Receiver might throw.
-     *
-     * @return An Output instance that encapsulates the map transformation.
-     */
-    public static <From, To, Receiver2ThrowableType extends Throwable> Output<From, Receiver2ThrowableType> map( final Function<? super From, ? extends To> function,
-                                                                                                                 final Output<To, Receiver2ThrowableType> output
-    )
-    {
-        return new Output<From, Receiver2ThrowableType>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends From, SenderThrowableType> sender )
-                throws Receiver2ThrowableType, SenderThrowableType
-            {
-                output.receiveFrom( new Sender<To, SenderThrowableType>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super To, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, SenderThrowableType
-                    {
-                        sender.sendTo( new Receiver<From, ReceiverThrowableType>()
-                        {
-                            @Override
-                            public void receive( From item )
-                                throws ReceiverThrowableType
-                            {
-                                receiver.receive( function.map( item ) );
-                            }
-                        } );
-                    }
-                } );
-            }
-        };
-    }
-
-    /**
-     * Apply the given function to items in the transfer that match the given specification. Other items will pass
-     * through directly.
-     *
-     * @param specification            The Specification defining which items should be transformed.
-     * @param function                 The transformation function.
-     * @param output                   The Output that will receive the resulting items.
-     * @param <T>                      The item type. Items can not be transformed to a new type.
-     * @param <Receiver2ThrowableType> The exception that the Receiver might throw.
-     *
-     * @return An Output instance that encapsulates the operation.
-     */
-    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filteredMap( final Specification<? super T> specification,
-                                                                                                               final Function<? super T, ? extends T> function,
-                                                                                                               final Output<T, Receiver2ThrowableType> output
-    )
-    {
-        return new Output<T, Receiver2ThrowableType>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends T, SenderThrowableType> sender )
-                throws Receiver2ThrowableType, SenderThrowableType
-            {
-                output.receiveFrom( new Sender<T, SenderThrowableType>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, SenderThrowableType
-                    {
-                        sender.sendTo( new Receiver<T, ReceiverThrowableType>()
-                        {
-                            @Override
-                            public void receive( T item )
-                                throws ReceiverThrowableType
-                            {
-                                if( specification.satisfiedBy( item ) )
-                                {
-                                    receiver.receive( function.map( item ) );
-                                }
-                                else
-                                {
-                                    receiver.receive( item );
-                                }
-                            }
-                        } );
-                    }
-                } );
-            }
-        };
-    }
-
-    /**
-     * Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on
-     * the sending side and a write-lock would be used on the receiving side. Inputs can use this as well to create a
-     * wrapper on the send side when transferTo is invoked.
-     *
-     * @param lock                    the lock to be used for transfers
-     * @param output                  output to be wrapped
-     * @param <T>                     The Item type
-     * @param <Receiver2ThrowableType> The Exception type that the Receiver might throw.
-     *
-     * @return Output wrapper that uses the given lock during transfers.
-     */
-    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> lock( final Lock lock,
-                                                                                                      final Output<T, Receiver2ThrowableType> output
-    )
-    {
-        return new Output<T, Receiver2ThrowableType>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
-                throws Receiver2ThrowableType, SenderThrowableType
-            {
-                /**
-                 * Fix for this bug:
-                 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370
-                 */
-                while( true )
-                {
-                    try
-                    {
-                        //noinspection StatementWithEmptyBody
-                        while( !lock.tryLock( 1000, TimeUnit.MILLISECONDS ) )
-                        {
-                            // On timeout, try again
-                        }
-                        break; // Finally got a lock
-                    }
-                    catch( InterruptedException e )
-                    {
-                        // Try again
-                    }
-                }
-
-                try
-                {
-                    output.receiveFrom( sender );
-                }
-                finally
-                {
-                    lock.unlock();
-                }
-            }
-        };
-    }
-
-    /**
-     * Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on the sending side and a write-lock
-     * would be used on the receiving side.
-     *
-     * @param lock                  the lock to be used for transfers
-     * @param input                 input to be wrapped
-     * @param <T>                   The item type.
-     * @param <SenderThrowableType> The Exception type that the Sender might throw.
-     *
-     * @return Input wrapper that uses the given lock during transfers.
-     */
-    public static <T, SenderThrowableType extends Throwable> Input<T, SenderThrowableType> lock( final Lock lock,
-                                                                                                 final Input<T, SenderThrowableType> input
-    )
-    {
-        return new Input<T, SenderThrowableType>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
-                throws SenderThrowableType, ReceiverThrowableType
-            {
-                /**
-                 * Fix for this bug:
-                 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370
-                 */
-                while( true )
-                {
-                    try
-                    {
-                        //noinspection StatementWithEmptyBody
-                        while( !( lock.tryLock() || lock.tryLock( 1000, TimeUnit.MILLISECONDS ) ) )
-                        {
-                            // On timeout, try again
-                        }
-                        break; // Finally got a lock
-                    }
-                    catch( InterruptedException e )
-                    {
-                        // Try again
-                    }
-                }
-
-                try
-                {
-                    input.transferTo( output );
-                }
-                finally
-                {
-                    lock.unlock();
-                }
-            }
-        };
-    }
-
-    /**
-     * Count the number of items in the transfer.
-     *
-     * @param <T>
-     */
-    // START SNIPPET: counter
-    public static class Counter<T>
-        implements Function<T, T>
-    {
-        private volatile long count = 0;
-
-        public long count()
-        {
-            return count;
-        }
-
-        @Override
-        public T map( T t )
-        {
-            count++;
-            return t;
-        }
-    }
-    // END SNIPPET: counter
-
-    /**
-     * Convert strings to bytes using the given CharSet
-     */
-    @SuppressWarnings( "UnusedDeclaration" )
-    public static class String2Bytes
-        implements Function<String, byte[]>
-    {
-        private Charset charSet;
-
-        public String2Bytes( Charset charSet )
-        {
-            this.charSet = charSet;
-        }
-
-        @Override
-        public byte[] map( String s )
-        {
-            return s.getBytes( charSet );
-        }
-    }
-
-    /**
-     * Convert ByteBuffers to Strings using the given CharSet
-     */
-    public static class ByteBuffer2String
-        implements Function<ByteBuffer, String>
-    {
-        private Charset charSet;
-
-        public ByteBuffer2String( Charset charSet )
-        {
-            this.charSet = charSet;
-        }
-
-        @Override
-        public String map( ByteBuffer buffer )
-        {
-            return new String( buffer.array(), charSet );
-        }
-    }
-
-    /**
-     * Convert objects to Strings using .toString()
-     */
-    @SuppressWarnings( "UnusedDeclaration" )
-    public static class ObjectToString
-        implements Function<Object, String>
-    {
-        @Override
-        public String map( Object o )
-        {
-            return o.toString();
-        }
-    }
-
-    /**
-     * Log the toString() representation of transferred items to the given log. The string is first formatted using MessageFormat
-     * with the given format.
-     *
-     * @param <T>
-     */
-    public static class Log<T>
-        implements Function<T, T>
-    {
-        private Logger logger;
-        private MessageFormat format;
-
-        public Log( Logger logger, String format )
-        {
-            this.logger = logger;
-            this.format = new MessageFormat( format );
-        }
-
-        @Override
-        public T map( T item )
-        {
-            logger.info( format.format( new String[]{ item.toString() } ) );
-            return item;
-        }
-    }
-
-    /**
-     * Track progress of transfer by emitting a log message in given intervals.
-     *
-     * If logger or format is null, then you need to override the logProgress to do something
-     *
-     * @param <T> type of items to be transferred
-     */
-    // START SNIPPET: progress
-    public static class ProgressLog<T>
-        implements Function<T, T>
-    {
-        private Counter<T> counter;
-        private Log<String> log;
-        private final long interval;
-
-        public ProgressLog( Logger logger, String format, long interval )
-        {
-            this.interval = interval;
-            if( logger != null && format != null )
-            {
-                log = new Log<>( logger, format );
-            }
-            counter = new Counter<>();
-        }
-
-        public ProgressLog( long interval )
-        {
-            this.interval = interval;
-            counter = new Counter<>();
-        }
-
-        @Override
-        public T map( T t )
-        {
-            counter.map( t );
-            if( counter.count % interval == 0 )
-            {
-                logProgress();
-            }
-            return t;
-        }
-
-        // Override this to do something other than logging the progress
-        protected void logProgress()
-        {
-            if( log != null )
-            {
-                log.map( counter.count + "" );
-            }
-        }
-    }
-    // END SNIPPET: progress
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/apache/zest/io/package.html
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/apache/zest/io/package.html b/core/io/src/main/java/org/apache/zest/io/package.html
deleted file mode 100644
index aac8a54..0000000
--- a/core/io/src/main/java/org/apache/zest/io/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>I/O API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Files.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Files.java b/core/io/src/main/java/org/qi4j/io/Files.java
new file mode 100644
index 0000000..562d03c
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Files.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.io;
+
+import java.io.File;
+import java.util.Random;
+
+/**
+ * Utility class for files.
+ */
+public class Files
+{
+    private static Random random = new Random();
+
+    public static File createTemporayFileOf( File file )
+    {
+        return new File(  file.getAbsolutePath() + "_" + Math.abs( random.nextLong() ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Input.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Input.java b/core/io/src/main/java/org/qi4j/io/Input.java
new file mode 100644
index 0000000..bde80e5
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Input.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+/**
+ * Input source of data.
+ * <p>
+ * Invoke transferTo to send data from this input to given output. transferTo can be invoked
+ * as many times as you want. The transferTo implementation must ensure that any exceptions thrown
+ * by the Input or the Output which transferred data is sent to is handled properly, i.e. that resources
+ * are closed. Any client code to transferTo calls should not have to bother with resource management,
+ * but may catch exceptions anyway for logging and similar purposes.
+ * </p>
+ */
+// START SNIPPET: input
+public interface Input<T, SenderThrowableType extends Throwable>
+{
+    <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
+        throws SenderThrowableType, ReceiverThrowableType;
+}
+// END SNIPPET: input


[37/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/Identity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/Identity.java b/core/api/src/main/java/org/qi4j/api/entity/Identity.java
new file mode 100644
index 0000000..b4adbc5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/Identity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.entity;
+
+import org.qi4j.api.injection.scope.State;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Immutable;
+import org.qi4j.api.property.Property;
+
+/**
+ * This interface provides the identity of the object which may be used
+ * to store the state in a database. It is not the responsibility of the
+ * framework to come up with a good identity string.
+ */
+@Mixins( Identity.IdentityMixin.class )
+public interface Identity
+{
+    /**
+     * Returns the client view of the identity.
+     * <p>
+     * It is unique within the owning repository, but potentially not unique globally and between
+     * types.
+     * </p>
+     * @return The Identity of 'this' composite.
+     */
+    @Immutable
+    Property<String> identity();
+
+    /**
+     * Default Identity implementation.
+     */
+    class IdentityMixin
+        implements Identity
+    {
+        @State
+        private Property<String> identity;
+
+        @Override
+        public Property<String> identity()
+        {
+            return identity;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/IdentityGenerator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/IdentityGenerator.java b/core/api/src/main/java/org/qi4j/api/entity/IdentityGenerator.java
new file mode 100644
index 0000000..8d076e5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/IdentityGenerator.java
@@ -0,0 +1,32 @@
+/*  Copyright 2007 Niclas Hedhman.
+ *
+ * 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.qi4j.api.entity;
+
+/**
+ * Generator for identities of EntityComposite's.
+ */
+public interface IdentityGenerator
+{
+    /**
+     * Generate a new id for the given Composite type
+     *
+     * @param compositeType the type of composite
+     *
+     * @return a new identity
+     */
+    String generate( Class<?> compositeType );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/Lifecycle.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/Lifecycle.java b/core/api/src/main/java/org/qi4j/api/entity/Lifecycle.java
new file mode 100644
index 0000000..3eabd78
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/Lifecycle.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.entity;
+
+/**
+ * Lifecycle interface for all Composites.
+ * <p>
+ * This Lifecycle interface is a built-in feature of the Zest runtime, similar to the Initializable interface.
+ * Any Mixin that implements this interface AND is part of an EntityComposite will have these two methods called
+ * upon creation/removal of the EntityComposite instance to/from the EntityStore. Meaning, the create method is called
+ * only when the identifiable EntityComposite is created the first time, and not when it is read from its persisted
+ * state and created into memory.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ * public interface System
+ * {
+ *     Property&lt;User&gt; admin();
+ * }
+ *
+ * public class SystemAdminMixin&lt;LifeCycle&gt;
+ *     implements System, Lifecyle, ...
+ * {
+ *      &#64;Structure private UnitOfWork uow;
+ *      &#64;This private Identity meAsIdentity;
+ *
+ *      public void create()
+ *      {
+ *          String thisId = meAsIdentity.identity().get();
+ *          EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class );
+ *          User admin = builder.newInstance();
+ *          admin.set( admin );
+ *      }
+ *
+ *      public void remove()
+ *      {
+ *          uow.remove( admin.get() );
+ *      }
+ * }
+ *
+ * &#64;Mixins( SystemAdminMixin.class )
+ * public interface SystemEntity extends System, EntityComposite
+ * {}
+ *
+ * </code></pre>
+ */
+public interface Lifecycle
+{
+
+    /**
+     * Creation callback method.
+     * <p>
+     * Called by the Zest runtime before the newInstance of the entity completes, before the constraints are checked,
+     * allowing for additional initialization.
+     * </p>
+     * @throws LifecycleException if the entity could not be created
+     */
+    void create()
+        throws LifecycleException;
+
+    /**
+     * Removal callback method.
+     * <p>
+     * Called by the Zest runtime before the entity is removed from the system, allowing
+     * for clean-up operations.
+     * </p>
+     * @throws LifecycleException if the entity could not be removed
+     */
+    void remove()
+        throws LifecycleException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/LifecycleException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/LifecycleException.java b/core/api/src/main/java/org/qi4j/api/entity/LifecycleException.java
new file mode 100644
index 0000000..b358fa1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/LifecycleException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.entity;
+
+/**
+ * Thrown by methods of Lifecycle if invocation fails
+ */
+public class LifecycleException
+    extends RuntimeException
+{
+    public LifecycleException( String s )
+    {
+        super( s );
+    }
+
+    public LifecycleException( String s, Throwable throwable )
+    {
+        super( s, throwable );
+    }
+
+    public LifecycleException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/Queryable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/Queryable.java b/core/api/src/main/java/org/qi4j/api/entity/Queryable.java
new file mode 100644
index 0000000..768e17d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/Queryable.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008, Alin Dreghiciu. 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.qi4j.api.entity;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used to mark entity types or properties/associations that are indexable.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Queryable
+{
+    boolean value() default true;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/entity/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/entity/package.html b/core/api/src/main/java/org/qi4j/api/entity/package.html
new file mode 100644
index 0000000..0386d8c
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/entity/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Entity API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/event/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/event/package.html b/core/api/src/main/java/org/qi4j/api/event/package.html
new file mode 100644
index 0000000..a5ed0a7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/event/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Event API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/InjectionScope.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/InjectionScope.java b/core/api/src/main/java/org/qi4j/api/injection/InjectionScope.java
new file mode 100644
index 0000000..7ada2e6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/InjectionScope.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This is used to annotate annotation types which are used for injection.
+ * Each scope signifies a particular scope from which the injection value should be taken.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.ANNOTATION_TYPE } )
+@Documented
+public @interface InjectionScope
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/package.html b/core/api/src/main/java/org/qi4j/api/injection/package.html
new file mode 100644
index 0000000..c41b495
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Dependency Injection API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/Invocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/Invocation.java b/core/api/src/main/java/org/qi4j/api/injection/scope/Invocation.java
new file mode 100644
index 0000000..230e5c9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/Invocation.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a
+ * invocation specific resource.
+ * These include:
+ * <pre><code>
+ *  - The Method being invoked.
+ *
+ *  - An AnnotationElement with annotations
+ *    from both mixin type, mixin
+ *    implementation.
+ *
+ *  - An Annotation of a specific type
+ * </code></pre>
+ * Examples:
+ * <pre><code>
+ * &#64;Invocation Method theInvokedMethod
+ * &#64;Invocation AnnotationElement annotations
+ * &#64;Invocation Matches matchesAnnotation
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Invocation
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/Service.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/Service.java b/core/api/src/main/java/org/qi4j/api/injection/scope/Service.java
new file mode 100644
index 0000000..6116cc1
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/Service.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a service dependency into a Fragment.
+ * <p>
+ * Examples:
+ * </p>
+ * <pre><code>
+ * &#64;Service MyService service
+ * &#64;Service Iterable&lt;MyService&gt; services
+ * &#64;Service ServiceReference&lt;MyService&gt; serviceRef
+ * &#64;Service Iterable&lt;ServiceReference&lt;MyService&gt;&gt; serviceRefs
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Service
+{
+}
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/State.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/State.java b/core/api/src/main/java/org/qi4j/api/injection/scope/State.java
new file mode 100644
index 0000000..ec3c52a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/State.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a property, association or
+ * StateHolder.
+ * <pre><code>
+ * &#64;State Property&lt;StringState propertyName;
+ * &#64;State Association&lt;MyEntityState associationName;
+ * &#64;State ManyAssociation&lt;MyEntityState manyAssociationName;
+ * &#64;State NamedAssociation&lt;MyEntityState namedAssociationName;
+ * &#64;State StateHolder state;
+ * &#64;State AssociationStateHolder associationState;
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface State
+{
+    /**
+     * Name of the property or association.
+     * If not set then name will be name of field.
+     *
+     * @return the name
+     */
+    public abstract String value() default "";
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/Structure.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/Structure.java b/core/api/src/main/java/org/qi4j/api/injection/scope/Structure.java
new file mode 100644
index 0000000..252af5e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/Structure.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a
+ * resource specific for the module which the
+ * injected object/fragment is instantiated in.
+ * <p>
+ * Valid types are:
+ * </p>
+ * <pre><code>
+ * - TransientBuilderFactory
+ * - ObjectBuilderFactory
+ * - UnitOfWorkFactory
+ * - ServiceFinder
+ * - Module
+ * - Layer
+ * - Application
+ * - Qi4j
+ * - Qi4jSPI
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Structure
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/This.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/This.java b/core/api/src/main/java/org/qi4j/api/injection/scope/This.java
new file mode 100644
index 0000000..4d806d0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/This.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a reference to the same Composite
+ * as the fragment is a part of.
+ * <p>
+ * If the Composite type does not implement the type of the field or parameter
+ * then it will be referencing a private mixin.
+ * </p>
+ * <p>
+ * Calls to the reference will have the same semantics as calls to the Composite itself.
+ * Specifically the same set of Modifiers will be used.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface This
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/Uses.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/Uses.java b/core/api/src/main/java/org/qi4j/api/injection/scope/Uses.java
new file mode 100644
index 0000000..d5b4080
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/Uses.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.qi4j.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a dependency to be used by a Mixin. The injected
+ * object is provided either by the TransientBuilder.uses() declarations, or if an instance of the appropriate types is not
+ * found, then a new Transient or Object is instantiated.
+ * Call {@link org.qi4j.api.composite.TransientBuilder#use} to provide the instance
+ * to be injected.
+ *
+ * Example:
+ * <pre>@Uses SomeType someInstance</pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.PARAMETER, ElementType.FIELD } )
+@Documented
+@InjectionScope
+public @interface Uses
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/injection/scope/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/injection/scope/package.html b/core/api/src/main/java/org/qi4j/api/injection/scope/package.html
new file mode 100644
index 0000000..b0ec496
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/injection/scope/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Dependency Injection Scopes.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/Metric.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/Metric.java b/core/api/src/main/java/org/qi4j/api/metrics/Metric.java
new file mode 100644
index 0000000..775ab5d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/Metric.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Marker interface for all Metric types.
+ */
+public interface Metric
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounter.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounter.java
new file mode 100644
index 0000000..67404b3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounter.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Metrics Counter.
+ */
+public interface MetricsCounter extends Metric
+{
+    void increment();
+
+    void increment( int steps );
+
+    void decrement();
+
+    void decrement( int steps );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounterFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounterFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounterFactory.java
new file mode 100644
index 0000000..caa2915
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsCounterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Create MetricsCounter instances.
+ */
+public interface MetricsCounterFactory extends MetricsFactory
+{
+    /**
+     * Create a MetricsCounter instance.
+     * If the same arguments are given twice, the same instance must be returned.
+     *
+     * @param origin The class that instantiate the metric
+     * @param name   A human readable, short name of the metric.
+     *
+     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
+     */
+    MetricsCounter createCounter( Class<?> origin, String name );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsFactory.java
new file mode 100644
index 0000000..0813dde
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsFactory.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Metrics Factory.
+ */
+public interface MetricsFactory
+{
+    Iterable<Metric> registered();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsGauge.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsGauge.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsGauge.java
new file mode 100644
index 0000000..1dd293b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsGauge.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * MetricsGauge is the most basic Metric type, and is completely flexible and therefor handled slightly differently in
+ * the MetricsFactory than all other Gauges. It needs to pass on custom code, so the implementation is typically
+ * an anonymous class, inlined at the implementation.
+ *
+ * @param <T> Any type holding the MetricsGauge's current value.
+ */
+public interface MetricsGauge<T> extends Metric
+{
+    /**
+     * Returns the metric's current value.
+     *
+     * @return the metric's current value
+     */
+    T value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsGaugeFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsGaugeFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsGaugeFactory.java
new file mode 100644
index 0000000..a469ac2
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsGaugeFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Register MetricsGauge with the underlying Metrics system.
+ */
+public interface MetricsGaugeFactory extends MetricsFactory
+{
+    /**
+     * Register a MetricsGauge with the underlying Metrics system.
+     *
+     * @param origin The class where the MetricsGauge is created.
+     * @param name   A human readable, short name of the metric.
+     * @param gauge  The implementation of the MetricsGauge.
+     * @param <T>    Any type holding the MetricsGauge's current value.
+     *
+     * @return The same MetricsGauge or the DefaultMetric.NULL MetricsGauge instance.
+     */
+    <T> MetricsGauge<T> registerGauge( Class<?> origin, String name, MetricsGauge<T> gauge );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheck.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheck.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheck.java
new file mode 100644
index 0000000..18bb151
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheck.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Metrics Health Check.
+ */
+public interface MetricsHealthCheck extends Metric
+{
+    Result check()
+        throws Exception;
+
+    public final class Result
+    {
+        private final boolean healthy;
+        private final String message;
+        private final Throwable exception;
+
+        public Result( boolean isHealthy, String message, Throwable exception )
+        {
+            healthy = isHealthy;
+            this.message = message;
+            this.exception = exception;
+        }
+
+        public boolean isHealthy()
+        {
+            return healthy;
+        }
+
+        public String getMessage()
+        {
+            return message;
+        }
+
+        public Throwable getException()
+        {
+            return exception;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheckFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheckFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheckFactory.java
new file mode 100644
index 0000000..12decc5
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHealthCheckFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Create MetricsHealthCheck instances.
+ */
+public interface MetricsHealthCheckFactory extends MetricsFactory
+{
+    /**
+     * Create a MetricsHealthCheck instance.
+     * If the same arguments are given twice, the same instance must be returned.
+     *
+     * @param origin The class that instantiate the metric
+     * @param name   A human readable, short name of the metric.
+     * @param check  The health check to be performed regularly.
+     *
+     * @return A MetricsHealthCheck instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
+     *
+     */
+    MetricsHealthCheck registerHealthCheck( Class<?> origin, String name, MetricsHealthCheck check );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogram.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogram.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogram.java
new file mode 100644
index 0000000..fe38869
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogram.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * A metric which calculates the distribution of a value.
+ *
+ * @see <a href="http://www.johndcook.com/standard_deviation.html">Accurately computing running
+ *      variance</a>
+ */
+public interface MetricsHistogram extends Metric
+{
+    void update( long newValue );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogramFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogramFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogramFactory.java
new file mode 100644
index 0000000..ab62508
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsHistogramFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Create MetricsHistogram instances.
+ */
+public interface MetricsHistogramFactory extends MetricsFactory
+{
+    /**
+     * Create a MetricsHistogram instance.
+     * If the same arguments are given twice, the same instance must be returned.
+     *
+     * @param origin The class that instantiate the metric
+     * @param name   A human readable, short name of the metric.
+     *
+     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
+     *
+     */
+    MetricsHistogram createHistogram( Class<?> origin, String name );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeter.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeter.java
new file mode 100644
index 0000000..acbb73d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeter.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * A meter metric which measures mean throughput and one-, five-, and fifteen-minute
+ * exponentially-weighted moving average throughputs.
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average">EMA</a>
+ */
+public interface MetricsMeter extends Metric
+{
+    void mark();
+
+    /**
+     * Mark the occurrence of a given number of events.
+     *
+     * @param numberOfEvents the number of events
+     */
+    void mark( int numberOfEvents );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeterFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeterFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeterFactory.java
new file mode 100644
index 0000000..53928bd
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsMeterFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Create MetricsMeter instances.
+ */
+public interface MetricsMeterFactory extends MetricsFactory
+{
+    /**
+     * Create a MetricsMeter instance.
+     * If the same arguments are given twice, the same instance must be returned.
+     *
+     * @param origin    The class that instantiate the metric
+     * @param name      A human readable, short name of the metric.
+     * @param eventType the plural name of the event the meter is measuring (e.g., {@code "requests"})
+     * @param rate      the scale unit for this timer's rate metrics
+     *
+     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
+     */
+    MetricsMeter createMeter( Class<?> origin, String name, String eventType, TimeUnit rate );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsNotSupportedException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsNotSupportedException.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsNotSupportedException.java
new file mode 100644
index 0000000..aec7859
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsNotSupportedException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.qi4j.api.metrics;
+
+/**
+ * Thrown when the underlying MetricsProvider do not support a Metric type.
+ */
+public class MetricsNotSupportedException extends RuntimeException
+{
+    public MetricsNotSupportedException( Class<? extends MetricsFactory> factoryType,
+                                         Class<? extends MetricsProvider> providerType
+    )
+    {
+        super( "Metrics [" + factoryType.getName() + "] is not supported by MetricsProvider [" + providerType.getName() + "]." );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsProvider.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsProvider.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsProvider.java
new file mode 100644
index 0000000..c11996b
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsProvider.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Metrics Provider SPI.
+ * <p>
+ * The Zest Runtime will automatically ook for a service that implements the MetricsProvider interdace
+ * and use it for internal Runtime metrics, such as the UnitOfWork measuring the time from creation to close.
+ * </p>
+ * <p>
+ * The Metrics Library is available to add metric functionality to applications in the same way, and
+ * will use the same MetricsProvider.
+ * </p>
+ * <p>
+ * Note that the usual visibitlity rules applies, so you might have more than one MetricsProvider server,
+ * perhaps per layer.
+ * </p>
+ */
+public interface MetricsProvider
+{
+    /**
+     * Creates a new factory instance.
+     *
+     * The instanctiation is done by providing a Metric type, which is one of
+     * <ul>
+     * <li>{@link MetricsCounter}</li>
+     * <li>{@link MetricsGauge}</li>
+     * <li>{@link MetricsHealthCheck}</li>
+     * <li>{@link MetricsHistogram}</li>
+     * <li>{@link MetricsMeter}</li>
+     * <li>{@link MetricsTimer}</li>
+     * </ul>
+     *
+     * @param factoryType The class of the metric type needed.
+     * @param <T>         The metric type requested.
+     *
+     * @return A factory instance
+     *
+     * @throws MetricsNotSupportedException when the MetricsProvider is not supporting the factory type requested.
+     */
+    <T extends MetricsFactory> T createFactory( Class<T> factoryType )
+        throws MetricsNotSupportedException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimer.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimer.java
new file mode 100644
index 0000000..6de4714
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+/**
+ * Timer Metrics.
+ */
+public interface MetricsTimer extends Metric
+{
+    /**
+     * Start the Timer Metrics.
+     */
+    Context start();
+
+    /**
+     * Timer Metrics Context.
+     */
+    public interface Context
+    {
+        /**
+         * Stop the Timer Metrics.
+         */
+        void stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimerFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimerFactory.java b/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimerFactory.java
new file mode 100644
index 0000000..18d3e38
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/MetricsTimerFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Create MetricsTimer instances.
+ */
+public interface MetricsTimerFactory extends MetricsFactory
+{
+    /**
+     * Create a MetricsTimer instance.
+     * If the same arguments are given twice, the same instance must be returned.
+     *
+     * @param origin   The class that instantiate the metric
+     * @param name     A human readable, short name of the metric.
+     * @param duration the scale unit for this timer's duration metrics
+     * @param rate     the scale unit for this timer's rate metrics
+     *
+     * @return A Metric instance to be used, OR org.qi4j.spi.metrics.DefaultMetric.NULL if not supported.
+     *
+     */
+    MetricsTimer createTimer( Class<?> origin, String name, TimeUnit duration, TimeUnit rate );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/metrics/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/metrics/package.html b/core/api/src/main/java/org/qi4j/api/metrics/package.html
new file mode 100644
index 0000000..d0280bd
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/metrics/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Metrics API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/Initializable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/Initializable.java b/core/api/src/main/java/org/qi4j/api/mixin/Initializable.java
new file mode 100644
index 0000000..53314e9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/Initializable.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.mixin;
+
+/**
+ * Fragments which want to be initialized can implement
+ * this callback interface. It will be invoked after
+ * the fragment has bee instantiated and all injections have been done.
+ */
+public interface Initializable
+{
+    /**
+     * Initialize the fragment
+     *
+     * @throws org.qi4j.api.mixin.InitializationException
+     *          if something went wrong
+     */
+    void initialize()
+        throws InitializationException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/InitializationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/InitializationException.java b/core/api/src/main/java/org/qi4j/api/mixin/InitializationException.java
new file mode 100644
index 0000000..4a42da6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/InitializationException.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.mixin;
+
+/**
+ * Thrown when a Fragment or object could not be instantiated.
+ */
+public class InitializationException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 1L;
+
+    public InitializationException()
+    {
+    }
+
+    public InitializationException( String message )
+    {
+        super( message );
+    }
+
+    public InitializationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public InitializationException( Throwable cause )
+    {
+        super( cause );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/InvalidMixinException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/InvalidMixinException.java b/core/api/src/main/java/org/qi4j/api/mixin/InvalidMixinException.java
new file mode 100644
index 0000000..967c6b6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/InvalidMixinException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.mixin;
+
+import java.lang.reflect.Method;
+
+/**
+ * This exception is thrown if a Mixin is invalid (missing method implementation).
+ */
+public class InvalidMixinException
+    extends RuntimeException
+{
+    public InvalidMixinException( Class mixinClass, Method method )
+    {
+        super( mixinClass.getName() + "does not have a method implementation for " + method );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java b/core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java
new file mode 100644
index 0000000..288aac3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.mixin;
+
+/**
+ * Mixin Descriptor.
+ */
+public interface MixinDescriptor
+{
+    Class<?> mixinClass();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/MixinMappingException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/MixinMappingException.java b/core/api/src/main/java/org/qi4j/api/mixin/MixinMappingException.java
new file mode 100644
index 0000000..4bd3a8a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/MixinMappingException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.mixin;
+
+/**
+ * This Exception is thrown when it is not possible to map the MixinType to a valid
+ * CompositeType.
+ */
+public class MixinMappingException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 6843167709252705294L;
+
+    public MixinMappingException( String message )
+    {
+        super( message );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/Mixins.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/Mixins.java b/core/api/src/main/java/org/qi4j/api/mixin/Mixins.java
new file mode 100644
index 0000000..e308381
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/Mixins.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.mixin;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used in composites to declare mixin implementation classes.
+ * <p>
+ * Mixins tells the runtime which implementation class of a Mixin should be
+ * used. The &#64;Mixins annotation can occur at any level in the composite hierarchy
+ * and the runtime will match each found Mixin implementation against a Mixins annotation.
+ * All mixin interfaces must have a Mixin implementation in the composite hierarchy or
+ * a runtime exception will occur.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ *
+ * &#64;Mixins( MyBeerOrder.class )
+ * public interface BeerOrderComposite extends BeerOrder, Composite
+ * {
+ * }
+ *
+ * public class MyBeerOrder
+ * implements BeerOrder
+ * {
+ * :
+ * }
+ * </code></pre>
+ * <p>
+ * Many implementations can be listed,
+ * </p>
+ * <pre><code>
+ * &#64;Mixins( { MyBeerOrder.class, DescriptionImpl.class } )
+ * public interface BeerOrderComposite extends BeerOrder, Description, Composite
+ * {
+ * }
+ * </code></pre>
+ * <p>
+ * If the Mixins is a class that implements InvocationHandler, it will be
+ * used for all mixins. To avoid that an invocation handler based implementation
+ * not service all mixin, use the AppliesTo annotation.
+ * </p>
+ *
+ * <p>
+ * It is valid to have multiple Mixins for a mixin. The first one found
+ * will be used. The search order is in the order they are written in the Mixins
+ * annotation left-to-right, and depth-first recursive search of the super-interfaces again
+ * left-to-right.
+ * </p>
+ *
+ * @see org.qi4j.api.common.AppliesTo
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+public @interface Mixins
+{
+    Class<?>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/NoopMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/NoopMixin.java b/core/api/src/main/java/org/qi4j/api/mixin/NoopMixin.java
new file mode 100644
index 0000000..948018e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/NoopMixin.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.mixin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * Generic mixin that is a no-op. Can be useful if the functionality
+ * of a method is mainly provided by concerns and side-effects.
+ */
+public final class NoopMixin
+    implements InvocationHandler
+{
+    private static final Boolean BOOLEAN_DEFAULT = Boolean.FALSE;
+    private static final Short SHORT_DEFAULT = 0;
+    private static final Character CHARACTER_DEFAULT = 0;
+    private static final Integer INTEGER_DEFAULT = 0;
+    private static final Long LONG_DEFAULT = 0L;
+    private static final Float FLOAT_DEFAULT = 0f;
+    private static final Double DOUBLE_DEFAULT = 0.0;
+
+    @Override
+    public Object invoke( Object object, Method method, Object[] args )
+        throws Throwable
+    {
+        Class<?> retType = method.getReturnType();
+        if( !retType.isPrimitive() )
+        {
+            return null;
+        }
+        if( Void.TYPE == retType )
+        {
+            return null;
+        }
+        if( Boolean.TYPE == retType )
+        {
+            return BOOLEAN_DEFAULT;
+        }
+        if( Short.TYPE == retType )
+        {
+            return SHORT_DEFAULT;
+        }
+        if( Character.TYPE == retType )
+        {
+            return CHARACTER_DEFAULT;
+        }
+        if( Integer.TYPE == retType )
+        {
+            return INTEGER_DEFAULT;
+        }
+        if( Long.TYPE == retType )
+        {
+            return LONG_DEFAULT;
+        }
+        if( Float.TYPE == retType )
+        {
+            return FLOAT_DEFAULT;
+        }
+        if( Double.TYPE == retType )
+        {
+            return DOUBLE_DEFAULT;
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/mixin/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/mixin/package.html b/core/api/src/main/java/org/qi4j/api/mixin/package.html
new file mode 100644
index 0000000..a0ebe07
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/mixin/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Mixin API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/object/NoSuchObjectException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/object/NoSuchObjectException.java b/core/api/src/main/java/org/qi4j/api/object/NoSuchObjectException.java
new file mode 100644
index 0000000..71a4cb7
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/object/NoSuchObjectException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008, Niclas Hedhman. 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.qi4j.api.object;
+
+import org.qi4j.api.common.InvalidApplicationException;
+
+/**
+ * This exception is thrown if no visible Object of the requested type can be found.
+ */
+public class NoSuchObjectException
+    extends InvalidApplicationException
+{
+    private static final long serialVersionUID = -1121690536365682511L;
+
+    private final String objectType;
+    private final String moduleName;
+
+    public NoSuchObjectException( String type, String moduleName )
+    {
+        super( "Could not find any visible Object of type [" + type + "] in module [" +
+               moduleName + "]." );
+        this.objectType = type;
+        this.moduleName = moduleName;
+    }
+
+    public String objectType()
+    {
+        return objectType;
+    }
+
+    public String moduleName()
+    {
+        return moduleName;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/object/ObjectDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/object/ObjectDescriptor.java b/core/api/src/main/java/org/qi4j/api/object/ObjectDescriptor.java
new file mode 100644
index 0000000..115c52e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/object/ObjectDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.object;
+
+import org.qi4j.api.composite.ModelDescriptor;
+
+/**
+ * Object Descriptor.
+ */
+public interface ObjectDescriptor
+    extends ModelDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/object/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/object/ObjectFactory.java b/core/api/src/main/java/org/qi4j/api/object/ObjectFactory.java
new file mode 100644
index 0000000..9b8ec47
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/object/ObjectFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.object;
+
+import org.qi4j.api.common.ConstructionException;
+
+/**
+ * This factory creates and injects POJO's.
+ */
+public interface ObjectFactory
+{
+    /**
+     * Create new objects of the given type.
+     *
+     * @param type an object class which will be instantiated.
+     *
+     * @return new objects.
+     *
+     * @throws ConstructionException Thrown if instantiation fails.
+     * @throws NoSuchObjectException Thrown if {@code type} class is not an object.
+     */
+    <T> T newObject( Class<T> type, Object... uses )
+        throws NoSuchObjectException, ConstructionException;
+
+    /**
+     * Inject an existing instance. Only fields and methods will be called.
+     *
+     * @param instance
+     *
+     * @throws ConstructionException
+     */
+    void injectTo( Object instance, Object... uses )
+        throws ConstructionException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/object/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/object/package.html b/core/api/src/main/java/org/qi4j/api/object/package.html
new file mode 100644
index 0000000..1e06504
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/object/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Object API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/package.html b/core/api/src/main/java/org/qi4j/api/package.html
new file mode 100644
index 0000000..ff7d9af
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Apache Zest™ API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/DefaultValues.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/DefaultValues.java b/core/api/src/main/java/org/qi4j/api/property/DefaultValues.java
new file mode 100644
index 0000000..3d0dbff
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/DefaultValues.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008, Michael Hunger. 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.qi4j.api.property;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Default values for various property types
+ */
+public final class DefaultValues
+{
+    private static final Map<Type, Object> DEFAULT_VALUES = new HashMap<Type, Object>();
+
+    static
+    {
+        DEFAULT_VALUES.put( Byte.class, 0 );
+        DEFAULT_VALUES.put( Short.class, 0 );
+        DEFAULT_VALUES.put( Character.class, 0 );
+        DEFAULT_VALUES.put( Integer.class, 0 );
+        DEFAULT_VALUES.put( Long.class, 0L );
+        DEFAULT_VALUES.put( Double.class, 0D );
+        DEFAULT_VALUES.put( Float.class, 0F );
+        DEFAULT_VALUES.put( Boolean.class, false );
+        DEFAULT_VALUES.put( String.class, "" );
+    }
+
+    public static Object getDefaultValueOf( Type type )
+    {
+        Object value = DEFAULT_VALUES.get( type );
+        if( value != null )
+        {
+            return value;
+        }
+        if( type instanceof ParameterizedType )
+        {
+            // List<Foo> -> List
+            type = ( (ParameterizedType) type ).getRawType();
+        }
+
+        if( type instanceof Class )
+        {
+            Class typeAsClass = (Class) type;
+            if( Set.class.isAssignableFrom( typeAsClass ) )
+            {
+                return new HashSet();
+            }
+            else if( Map.class.isAssignableFrom( typeAsClass ) )
+            {
+                return new LinkedHashMap();
+            }
+            else if( Collection.class.isAssignableFrom( typeAsClass ) )
+            {
+                return new ArrayList();
+            }
+            else if( typeAsClass.isEnum() )
+            {
+                return ( (Class) type ).getEnumConstants()[ 0 ];
+            }
+        }
+        throw new IllegalArgumentException( "Cannot use @UseDefaults with type " + type.toString() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/GenericPropertyInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/GenericPropertyInfo.java b/core/api/src/main/java/org/qi4j/api/property/GenericPropertyInfo.java
new file mode 100644
index 0000000..b8b9467
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/GenericPropertyInfo.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007,2008 Niclas Hedhman.
+ *
+ * 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.qi4j.api.property;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import static org.qi4j.api.util.Classes.typeOf;
+
+/**
+ * Generic Property info utility class.
+ */
+public final class GenericPropertyInfo
+{
+    public static Type propertyTypeOf( AccessibleObject accessor )
+    {
+        return toPropertyType( typeOf( accessor ) );
+    }
+
+    public static Type toPropertyType( Type methodReturnType )
+    {
+        if( methodReturnType instanceof ParameterizedType )
+        {
+            ParameterizedType parameterizedType = (ParameterizedType) methodReturnType;
+            if( Property.class.isAssignableFrom( (Class<?>) parameterizedType.getRawType() ) )
+            {
+                return parameterizedType.getActualTypeArguments()[ 0 ];
+            }
+        }
+
+        if( methodReturnType instanceof Class<?> )
+        {
+            Type[] interfaces = ( (Class<?>) methodReturnType ).getGenericInterfaces();
+            for( Type anInterface : interfaces )
+            {
+                Type propertyType = toPropertyType( anInterface );
+                if( propertyType != null )
+                {
+                    return propertyType;
+                }
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/property/Immutable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/property/Immutable.java b/core/api/src/main/java/org/qi4j/api/property/Immutable.java
new file mode 100644
index 0000000..39e3cf9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/property/Immutable.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.property;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation adds Immutability to Types, Properties and Associations
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Immutable
+{
+}


[02/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java
new file mode 100644
index 0000000..b457f1d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.runtime.injection.InjectedFieldsModel;
+import org.qi4j.runtime.injection.InjectedMethodsModel;
+import org.qi4j.runtime.injection.InjectionContext;
+import org.qi4j.spi.module.ModuleSpi;
+
+import static org.qi4j.api.util.Classes.RAW_CLASS;
+import static org.qi4j.api.util.Classes.interfacesOf;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Iterables.map;
+import static org.qi4j.functional.Iterables.toArray;
+import static org.qi4j.functional.Iterables.unique;
+
+/**
+ * JAVADOC
+ */
+public abstract class AbstractModifierModel
+    implements Dependencies, VisitableHierarchy<Object, Object>
+{
+    private final Class<?> modifierClass;
+
+    private final ConstructorsModel constructorsModel;
+    private final InjectedFieldsModel injectedFieldsModel;
+    private final InjectedMethodsModel injectedMethodsModel;
+
+    private final Class<?>[] nextInterfaces;
+
+    @SuppressWarnings( "unchecked" )
+    public AbstractModifierModel( Class<?> declaredModifierClass, Class<?> instantiationClass )
+    {
+        this.modifierClass = instantiationClass;
+        constructorsModel = new ConstructorsModel( modifierClass );
+        injectedFieldsModel = new InjectedFieldsModel( declaredModifierClass );
+        injectedMethodsModel = new InjectedMethodsModel( declaredModifierClass );
+        Class<Class<?>> componentType = (Class<Class<?>>) Class.class.cast( Class.class );
+        nextInterfaces = toArray( componentType, unique( map( RAW_CLASS, interfacesOf( declaredModifierClass ) ) ) );
+    }
+
+    public Class<?> modifierClass()
+    {
+        return modifierClass;
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public Iterable<DependencyModel> dependencies()
+    {
+        return flattenIterables( map( DEPENDENCIES_FUNCTION, iterable( constructorsModel, injectedFieldsModel, injectedMethodsModel ) ) );
+    }
+
+    public boolean isGeneric()
+    {
+        return InvocationHandler.class.isAssignableFrom( modifierClass );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            if( constructorsModel.accept( visitor ) )
+            {
+                if( injectedFieldsModel.accept( visitor ) )
+                {
+                    injectedMethodsModel.accept( visitor );
+                }
+            }
+        }
+
+        return visitor.visitLeave( this );
+    }
+
+    // Context
+    public InvocationHandler newInstance( ModuleSpi moduleInstance,
+                                          InvocationHandler next,
+                                          ProxyReferenceInvocationHandler proxyHandler,
+                                          Method method
+    )
+    {
+        InjectionContext injectionContext = new InjectionContext( moduleInstance, wrapNext( next ), proxyHandler );
+
+        Object modifier = constructorsModel.newInstance( injectionContext );
+
+        try
+        {
+            if( FragmentClassLoader.isGenerated( modifier ) )
+            {
+                modifier.getClass().getField( "_instance" ).set( modifier, proxyHandler );
+            }
+        }
+        catch( IllegalAccessException | NoSuchFieldException e )
+        {
+            e.printStackTrace();
+        }
+
+        injectedFieldsModel.inject( injectionContext, modifier );
+        injectedMethodsModel.inject( injectionContext, modifier );
+
+        if( isGeneric() )
+        {
+            return (InvocationHandler) modifier;
+        }
+        else
+        {
+            try
+            {
+                Method invocationMethod = modifierClass.getMethod( "_" + method.getName(), method.getParameterTypes() );
+                TypedModifierInvocationHandler handler = new TypedModifierInvocationHandler();
+                handler.setFragment( modifier );
+                handler.setMethod( invocationMethod );
+                return handler;
+            }
+            catch( NoSuchMethodException e )
+            {
+                throw new ConstructionException( "Could not find modifier method", e );
+            }
+        }
+    }
+
+    private Object wrapNext( InvocationHandler next )
+    {
+        if( isGeneric() )
+        {
+            return next;
+        }
+        else
+        {
+            return Proxy.newProxyInstance( modifierClass.getClassLoader(), nextInterfaces, next );
+        }
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        AbstractModifierModel that = (AbstractModifierModel) o;
+        return modifierClass.equals( that.modifierClass );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return modifierClass.hashCode();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/AtomicInstancePool.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/AtomicInstancePool.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/AtomicInstancePool.java
new file mode 100644
index 0000000..656b3f8
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/AtomicInstancePool.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Method instance pool that keeps a linked list. Uses atomic reference
+ * to ensure that instances are acquired and returned in a thread-safe
+ * manner.
+ */
+public final class AtomicInstancePool
+    implements InstancePool<CompositeMethodInstance>
+{
+    private final AtomicReference<CompositeMethodInstance> first = new AtomicReference<CompositeMethodInstance>();
+
+    @Override
+    public CompositeMethodInstance obtainInstance()
+    {
+        CompositeMethodInstance firstInstance;
+        do
+        {
+            firstInstance = first.get();
+        }
+        while( firstInstance != null && !first.compareAndSet( firstInstance, firstInstance.getNext() ) );
+
+        return firstInstance;
+    }
+
+    @Override
+    public void releaseInstance( CompositeMethodInstance compositeMethodInstance )
+    {
+        CompositeMethodInstance firstInstance;
+        do
+        {
+            firstInstance = first.get();
+            compositeMethodInstance.setNext( firstInstance );
+        }
+        while( !first.compareAndSet( firstInstance, compositeMethodInstance ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompactLevel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompactLevel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompactLevel.java
new file mode 100644
index 0000000..199fd4f
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompactLevel.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.runtime.composite;
+
+/**
+ * Compaction Level of the StackTrace clenaup operation.
+ *
+ * <pre>
+ * <b>off</b>       = Do not modify the stack trace.
+ * <b>proxy</b>     = Remove all Zest internal classes and all JDK internal classes from
+ *             the originating method call.
+ * <b>semi</b>      = Remove all JDK internal classes on the entire stack.
+ * <b>extensive</b> = Remove all Zest internal and JDK internal classes from the entire stack.
+ * </pre>
+ *
+ * <p>
+ * The Compaction is set through the System Property "<code><b>qi4j.compacttrace</b></code>" to
+ * any of the above values.
+ * </p>
+ */
+enum CompactLevel
+{
+    off, proxy, semi, extensive
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeConstraintModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeConstraintModel.java
new file mode 100644
index 0000000..54a7131
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeConstraintModel.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.constraint.Constraint;
+
+/**
+ * JAVADOC
+ */
+public final class CompositeConstraintModel
+    extends AbstractConstraintModel
+{
+    private final ValueConstraintsModel constraintsModel;
+
+    public CompositeConstraintModel( Annotation annotation, ValueConstraintsModel constraintsModel )
+    {
+        super( annotation );
+        this.constraintsModel = constraintsModel;
+    }
+
+    @Override
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public ConstraintInstance<?, ?> newInstance()
+    {
+        try
+        {
+            ValueConstraintsInstance compositeConstraintsInstance = constraintsModel.newInstance();
+            Constraint<?, ?> constraint = new CompositeConstraintInstance( compositeConstraintsInstance );
+            return new ConstraintInstance( constraint, annotation );
+        }
+        catch( Exception e )
+        {
+            throw new ConstructionException( "Could not instantiate constraint implementation", e );
+        }
+    }
+
+    private static class CompositeConstraintInstance
+        implements Constraint<Annotation, Object>
+    {
+        private final ValueConstraintsInstance valueConstraintsInstance;
+
+        private CompositeConstraintInstance( ValueConstraintsInstance valueConstraintsInstance )
+        {
+            this.valueConstraintsInstance = valueConstraintsInstance;
+        }
+
+        @Override
+        public boolean isValid( Annotation annotation, Object value )
+            throws NullPointerException
+        {
+            return valueConstraintsInstance.checkConstraints( value ).isEmpty();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodInstance.java
new file mode 100644
index 0000000..c3a4ad2
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodInstance.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * JAVADOC
+ */
+public final class CompositeMethodInstance
+{
+    private final InvocationHandler invoker;
+    private final FragmentInvocationHandler mixinInvoker;
+    private final Method method;
+    private final int methodIdx;
+
+    private CompositeMethodInstance next;
+
+    public CompositeMethodInstance( InvocationHandler invoker,
+                                    FragmentInvocationHandler mixinInvoker,
+                                    Method method, int methodIdx
+    )
+    {
+        this.invoker = invoker;
+        this.method = method;
+        this.mixinInvoker = mixinInvoker;
+        this.methodIdx = methodIdx;
+    }
+
+    public Method method()
+    {
+        return method;
+    }
+
+    public Object getMixinFrom( Object[] mixins )
+    {
+        return mixins[ methodIdx ];
+    }
+
+    public Object invoke( Object composite, Object[] params, Object mixin )
+        throws Throwable
+    {
+        mixinInvoker.setFragment( mixin );
+
+        try
+        {
+            return invoker.invoke( composite, method, params );
+        }
+        finally
+        {
+            mixinInvoker.setFragment( null );
+        }
+    }
+
+    public CompositeMethodInstance getNext()
+    {
+        return next;
+    }
+
+    public void setNext( CompositeMethodInstance next )
+    {
+        this.next = next;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
new file mode 100644
index 0000000..3162130
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.composite.MethodDescriptor;
+import org.qi4j.api.util.NullArgumentException;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.spi.module.ModuleSpi;
+
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.flattenIterables;
+import static org.qi4j.functional.Iterables.iterable;
+import static org.qi4j.functional.Specifications.notNull;
+
+/**
+ * JAVADOC
+ */
+public final class CompositeMethodModel
+    implements MethodDescriptor, Dependencies, VisitableHierarchy<Object, Object>
+{
+    // Model
+    private final Method method;
+    private Method invocationMethod; // This will be the _ prefixed method on typed mixins
+    private final ConstraintsModel constraints;
+    private final ConcernsModel concerns;
+    private final SideEffectsModel sideEffects;
+    private final MixinsModel mixins;
+    private AnnotatedElement annotations;
+
+    // Context
+//    private final SynchronizedCompositeMethodInstancePool instancePool = new SynchronizedCompositeMethodInstancePool();
+    private final AtomicInstancePool instancePool = new AtomicInstancePool();
+    private final ConstraintsInstance constraintsInstance;
+
+    public CompositeMethodModel( Method method,
+                                 ConstraintsModel constraintsModel,
+                                 ConcernsModel concernsModel,
+                                 SideEffectsModel sideEffectsModel,
+                                 MixinsModel mixinsModel
+    )
+    {
+        this.method = method;
+        mixins = mixinsModel;
+        concerns = concernsModel;
+        sideEffects = sideEffectsModel;
+        constraints = constraintsModel;
+        constraintsInstance = constraints.newInstance();
+        initialize();
+    }
+
+    private void initialize()
+    {
+        annotations = new CompositeMethodAnnotatedElement();
+        this.method.setAccessible( true );
+//        instancePool = new SynchronizedCompositeMethodInstancePool();
+    }
+
+    // Model
+
+    @Override
+    public Method method()
+    {
+        return method;
+    }
+
+    public MixinModel mixin()
+    {
+        return mixins.mixinFor( method );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public Iterable<DependencyModel> dependencies()
+    {
+        return flattenIterables( filter( notNull(), iterable( concerns != null ? concerns.dependencies() : null,
+                                                              sideEffects != null ? sideEffects.dependencies() : null ) ) );
+    }
+
+    // Context
+    public Object invoke( Object composite, Object[] params, MixinsInstance mixins, ModuleSpi moduleInstance )
+        throws Throwable
+    {
+        constraintsInstance.checkValid( composite, method, params );
+
+        CompositeMethodInstance methodInstance = getInstance( moduleInstance );
+        try
+        {
+            return mixins.invoke( composite, params, methodInstance );
+        }
+        finally
+        {
+            instancePool.releaseInstance( methodInstance );
+        }
+    }
+
+    private CompositeMethodInstance getInstance( ModuleSpi moduleInstance )
+    {
+        CompositeMethodInstance methodInstance = instancePool.obtainInstance();
+        if( methodInstance == null )
+        {
+            methodInstance = newCompositeMethodInstance( moduleInstance );
+        }
+
+        return methodInstance;
+    }
+
+    private CompositeMethodInstance newCompositeMethodInstance( ModuleSpi moduleInstance )
+        throws ConstructionException
+    {
+        FragmentInvocationHandler mixinInvocationHandler = mixins.newInvocationHandler( method );
+        InvocationHandler invoker = mixinInvocationHandler;
+        if( concerns != ConcernsModel.EMPTY_CONCERNS )
+        {
+            ConcernsInstance concernsInstance = concerns.newInstance( method, moduleInstance, mixinInvocationHandler );
+            invoker = concernsInstance;
+        }
+        if( sideEffects != SideEffectsModel.EMPTY_SIDEEFFECTS )
+        {
+            SideEffectsInstance sideEffectsInstance = sideEffects.newInstance( method, moduleInstance, invoker );
+            invoker = sideEffectsInstance;
+        }
+
+        if( invocationMethod == null )
+        {
+            MixinModel model = mixins.mixinFor( method );
+            if( !InvocationHandler.class.isAssignableFrom( model.mixinClass() ) )
+            {
+                try
+                {
+                    invocationMethod = model.instantiationClass()
+                        .getMethod( "_" + method.getName(), method.getParameterTypes() );
+                }
+                catch( NoSuchMethodException e )
+                {
+                    invocationMethod = method;
+//                    throw new ConstructionException( "Could not find the subclass method", e );
+                }
+            }
+            else
+            {
+                invocationMethod = method;
+            }
+        }
+
+        mixinInvocationHandler.setMethod( invocationMethod );
+
+        return new CompositeMethodInstance( invoker, mixinInvocationHandler, method, mixins.methodIndex.get( method ) );
+    }
+
+    public AnnotatedElement annotatedElement()
+    {
+        return annotations;
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        if( modelVisitor.visitEnter( this ) )
+        {
+            constraints.accept( modelVisitor );
+            concerns.accept( modelVisitor );
+            sideEffects.accept( modelVisitor );
+        }
+        return modelVisitor.visitLeave( this );
+    }
+
+    @Override
+    public String toString()
+    {
+        return method.toGenericString();
+    }
+
+    public Iterable<Method> invocationsFor( Class<?> mixinClass )
+    {
+        return mixins.invocationsFor( mixinClass );
+    }
+
+    public class CompositeMethodAnnotatedElement
+        implements AnnotatedElement
+    {
+        @Override
+        public boolean isAnnotationPresent( Class<? extends Annotation> annotationClass )
+        {
+            // Check method
+            if( method.isAnnotationPresent( annotationClass ) )
+            {
+                return true;
+            }
+
+            // Check mixin
+            try
+            {
+                MixinModel model = mixins.mixinFor( method );
+                if( GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
+                {
+                    return false;
+                }
+                return ( model.mixinClass()
+                             .getMethod( method.getName(), method.getParameterTypes() )
+                             .isAnnotationPresent( annotationClass ) );
+            }
+            catch( NoSuchMethodException e )
+            {
+                return false;
+            }
+        }
+
+        @Override
+        public <T extends Annotation> T getAnnotation( Class<T> annotationClass )
+        {
+            // Check mixin
+            try
+            {
+                MixinModel model = mixins.mixinFor( method );
+                if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
+                {
+                    T annotation = annotationClass.cast( model.mixinClass()
+                                                             .getMethod( method.getName(), method.getParameterTypes() )
+                                                             .getAnnotation( annotationClass ) );
+                    if( annotation != null )
+                    {
+                        return annotation;
+                    }
+                }
+            }
+            catch( NoSuchMethodException e )
+            {
+                // Ignore
+            }
+
+            // Check method
+            return method.getAnnotation( annotationClass );
+        }
+
+        @Override
+        public Annotation[] getAnnotations()
+        {
+            // Add mixin annotations
+            List<Annotation> annotations = new ArrayList<Annotation>();
+            MixinModel model = mixins.mixinFor( method );
+            Annotation[] mixinAnnotations = new Annotation[ 0 ];
+            if( !GenericSpecification.INSTANCE.satisfiedBy( model.mixinClass() ) )
+            {
+                mixinAnnotations = model.mixinClass().getAnnotations();
+                annotations.addAll( Arrays.asList( mixinAnnotations ) );
+            }
+
+            // Add method annotations, but don't include duplicates
+            Annotation[] methodAnnotations = method.getAnnotations();
+            next:
+            for( Annotation methodAnnotation : methodAnnotations )
+            {
+                for( int i = 0; i < mixinAnnotations.length; i++ )
+                {
+                    if( annotations.get( i ).annotationType().equals( methodAnnotation.annotationType() ) )
+                    {
+                        continue next;
+                    }
+                }
+
+                annotations.add( methodAnnotation );
+            }
+
+            return annotations.toArray( new Annotation[ annotations.size() ] );
+        }
+
+        @Override
+        public Annotation[] getDeclaredAnnotations()
+        {
+            return new Annotation[ 0 ];
+        }
+
+        // @Override (Since JDK 8)
+        @SuppressWarnings( "unchecked" )
+        public <T extends Annotation> T[] getAnnotationsByType( Class<T> annotationClass )
+        {
+            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+            return (T[]) Array.newInstance( annotationClass, 0 );
+        }
+
+        // @Override (Since JDK 8)
+        public <T extends Annotation> T getDeclaredAnnotation( Class<T> annotationClass )
+        {
+            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+            return null;
+        }
+
+        // @Override (Since JDK 8)
+        @SuppressWarnings( "unchecked" )
+        public <T extends Annotation> T[] getDeclaredAnnotationsByType( Class<T> annotationClass )
+        {
+            NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+            return (T[]) Array.newInstance( annotationClass, 0 );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodsModel.java
new file mode 100644
index 0000000..bf0c113
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodsModel.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.Method;
+import java.util.LinkedHashMap;
+import org.qi4j.api.composite.MissingMethodException;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.spi.module.ModuleSpi;
+
+import static org.qi4j.functional.Iterables.map;
+
+/**
+ * Model for Composite methods. This includes both private and public methods.
+ */
+public final class CompositeMethodsModel
+    implements VisitableHierarchy<Object, Object>
+{
+    private final LinkedHashMap<Method, CompositeMethodModel> methods;
+    private final MixinsModel mixinsModel;
+
+    public CompositeMethodsModel( MixinsModel mixinsModel )
+    {
+        methods = new LinkedHashMap<>();
+        this.mixinsModel = mixinsModel;
+    }
+
+    public Iterable<DependencyModel> dependencies()
+    {
+        return Iterables.flattenIterables( map( Dependencies.DEPENDENCIES_FUNCTION, methods.values() ) );
+    }
+
+    // Context
+    public Object invoke( MixinsInstance mixins,
+                          Object proxy,
+                          Method method,
+                          Object[] args,
+                          ModuleSpi moduleInstance
+    )
+        throws Throwable
+    {
+        CompositeMethodModel compositeMethod = methods.get( method );
+
+        if( compositeMethod == null )
+        {
+            if( method.getDeclaringClass().equals( Object.class ) )
+            {
+                return mixins.invokeObject( proxy, args, method );
+            }
+
+            if( !method.getDeclaringClass().isInterface() )
+            {
+                Iterable<Class<?>> types = mixinsModel.mixinTypes();
+                for( Class<?> aClass : types )
+                {
+                    try
+                    {
+                        Method realMethod = aClass.getMethod( method.getName(), method.getParameterTypes() );
+                        compositeMethod = methods.get( realMethod );
+                        break;
+                    }
+                    catch( NoSuchMethodException e )
+                    {
+                    }
+                    catch( SecurityException e )
+                    {
+                    }
+                }
+            }
+//            return mixins.invokeObject( proxy, args, method );
+            throw new MissingMethodException( "Method '" + method + "' is not implemented" );
+        }
+        else
+        {
+            return compositeMethod.invoke( proxy, args, mixins, moduleInstance );
+        }
+    }
+
+    public void addMethod( CompositeMethodModel methodModel )
+    {
+        methods.put( methodModel.method(), methodModel );
+    }
+
+    public boolean isImplemented( Method method )
+    {
+        return methods.containsKey( method );
+    }
+
+    public Iterable<Method> methods()
+    {
+        return methods.keySet();
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        if( modelVisitor.visitEnter( this ) )
+        {
+            for( CompositeMethodModel compositeMethodModel : methods.values() )
+            {
+                if( !compositeMethodModel.accept( modelVisitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return modelVisitor.visitLeave( this );
+    }
+
+    @Override
+    public String toString()
+    {
+        return methods().toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeModel.java
new file mode 100644
index 0000000..a6ea122
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeModel.java
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.common.MetaInfo;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.InvalidCompositeException;
+import org.qi4j.api.structure.Module;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.runtime.structure.ModuleInstance;
+import org.qi4j.spi.module.ModuleSpi;
+
+import static java.lang.reflect.Proxy.newProxyInstance;
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.toList;
+
+/**
+ * JAVADOC
+ */
+public abstract class CompositeModel
+    implements VisitableHierarchy<Object, Object>, Dependencies, CompositeDescriptor
+{
+    protected final MixinsModel mixinsModel;
+    protected final CompositeMethodsModel compositeMethodsModel;
+    private final Set<Class<?>> types;
+    private final Visibility visibility;
+    private final MetaInfo metaInfo;
+    protected final StateModel stateModel;
+    protected Class<? extends Composite> proxyClass;
+    protected Constructor<? extends Composite> proxyConstructor;
+
+    protected CompositeModel( final Iterable<Class<?>> types,
+                              final Visibility visibility,
+                              final MetaInfo metaInfo,
+                              final MixinsModel mixinsModel,
+                              final StateModel stateModel,
+                              final CompositeMethodsModel compositeMethodsModel
+    )
+    {
+        this.types = Iterables.addAll( new LinkedHashSet<Class<?>>(), types );
+        this.visibility = visibility;
+        this.metaInfo = metaInfo;
+        this.stateModel = stateModel;
+        this.compositeMethodsModel = compositeMethodsModel;
+        this.mixinsModel = mixinsModel;
+
+        // Create proxy class
+        createProxyClass();
+    }
+
+    // Model
+    @Override
+    public Iterable<Class<?>> types()
+    {
+        return types;
+    }
+
+    public StateModel state()
+    {
+        return stateModel;
+    }
+
+    @Override
+    public <T> T metaInfo( Class<T> infoType )
+    {
+        return metaInfo.get( infoType );
+    }
+
+    @Override
+    public Visibility visibility()
+    {
+        return visibility;
+    }
+
+    @Override
+    public boolean isAssignableTo( Class<?> type )
+    {
+        for( Class<?> aClass : types )
+        {
+            if( type.isAssignableFrom( aClass ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public MixinsModel mixinsModel()
+    {
+        return mixinsModel;
+    }
+
+    @Override
+    @SuppressWarnings( { "raw", "unchecked" } )
+    public Class<?> primaryType()
+    {
+        Class primaryType = null;
+        for( Class type : mixinTypes() )
+        {
+            if( type.getName().equals( "scala.ScalaObject" ) )
+            {
+                continue;
+            }
+            if( primaryType == null )
+            {
+                primaryType = type;
+            }
+            else if( primaryType.isAssignableFrom( type ) )
+            {
+                primaryType = type;
+            }
+        }
+        return primaryType;
+    }
+
+    @Override
+    public Iterable<Class<?>> mixinTypes()
+    {
+        return mixinsModel.mixinTypes();
+    }
+
+    @Override
+    public Iterable<DependencyModel> dependencies()
+    {
+        return Iterables.flatten( mixinsModel.dependencies(), compositeMethodsModel.dependencies() );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            if( compositeMethodsModel.accept( visitor ) )
+            {
+                if( stateModel.accept( visitor ) )
+                {
+                    mixinsModel.accept( visitor );
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    @SuppressWarnings( { "raw", "unchecked" } )
+    private void createProxyClass()
+    {
+        Class<?> mainType = first( types );
+        if( mainType.isInterface() )
+        {
+            ClassLoader proxyClassloader = mainType.getClassLoader();
+
+            Class<?>[] interfaces = Iterables.toArray( Class.class, Iterables.<Class>cast( types ) );
+            proxyClass = (Class<? extends Composite>) ProxyGenerator.createProxyClass( proxyClassloader, interfaces );
+
+            try
+            {
+                proxyConstructor = proxyClass.getConstructor( InvocationHandler.class );
+            }
+            catch( NoSuchMethodException e )
+            {
+                throw (InvalidCompositeException) new InvalidCompositeException( "Could not get proxy constructor" ).initCause( e );
+            }
+            proxyConstructor.setAccessible( true );
+        }
+        else
+        {
+            try
+            {
+                proxyClass = new TransientClassLoader( getClass().getClassLoader() ).loadFragmentClass( mainType );
+                proxyConstructor = (Constructor<? extends Composite>) proxyClass.getConstructors()[ 0 ];
+            }
+            catch( ClassNotFoundException e )
+            {
+                throw (InvalidCompositeException) new InvalidCompositeException( "Could not get proxy constructor" ).initCause( e );
+            }
+        }
+    }
+
+    // Context
+    public final Object invoke( MixinsInstance mixins,
+                                Object proxy,
+                                Method method,
+                                Object[] args,
+                                ModuleSpi moduleInstance
+    )
+        throws Throwable
+    {
+        return compositeMethodsModel.invoke( mixins, proxy, method, args, moduleInstance );
+    }
+
+    public Composite newProxy( InvocationHandler invocationHandler )
+        throws ConstructionException
+    {
+        Class<?> mainType = first( types() );
+        if( mainType.isInterface() )
+        {
+
+            try
+            {
+                return Composite.class.cast( proxyConstructor.newInstance( invocationHandler ) );
+            }
+            catch( Exception e )
+            {
+                throw new ConstructionException( e );
+            }
+        }
+        else
+        {
+            try
+            {
+                Object[] args = new Object[ proxyConstructor.getParameterTypes().length ];
+                Composite composite = Composite.class.cast( proxyConstructor.newInstance( args ) );
+                proxyClass.getField( "_instance" ).set( composite, invocationHandler );
+                return composite;
+            }
+            catch( Exception e )
+            {
+                throw new ConstructionException( e );
+            }
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    public <T> T newProxy( InvocationHandler invocationHandler, Class<T> mixinType )
+        throws IllegalArgumentException
+    {
+
+//        if (!matchesAny( isAssignableFrom( mixinType ), types ))
+        if( !mixinsModel.isImplemented( mixinType ) )
+        {
+            String message = "Composite " + primaryType().getName() + " does not implement type " + mixinType.getName();
+            throw new IllegalArgumentException( message );
+        }
+
+        // Instantiate proxy for given mixin interface
+        return mixinType.cast( newProxyInstance( mixinType.getClassLoader(), new Class[]{ mixinType }, invocationHandler ) );
+    }
+
+    @Override
+    public String toString()
+    {
+        return toList( types ).toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernModel.java
new file mode 100644
index 0000000..893737c
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernModel.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import org.qi4j.api.concern.ConcernDescriptor;
+
+/**
+ * JAVADOC
+ */
+public final class ConcernModel extends AbstractModifierModel
+    implements ConcernDescriptor
+{
+    public ConcernModel( Class concernClass, Class instantiationClass )
+    {
+        super( concernClass, instantiationClass );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsInstance.java
new file mode 100644
index 0000000..b65d52d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsInstance.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * JAVADOC
+ */
+public final class ConcernsInstance
+    implements InvocationHandler
+{
+    private final InvocationHandler firstConcern;
+    private final FragmentInvocationHandler mixinInvocationHandler;
+    private final ProxyReferenceInvocationHandler proxyHandler;
+
+    public ConcernsInstance( InvocationHandler firstConcern,
+                             FragmentInvocationHandler mixinInvocationHandler,
+                             ProxyReferenceInvocationHandler proxyHandler
+    )
+    {
+        this.firstConcern = firstConcern;
+        this.mixinInvocationHandler = mixinInvocationHandler;
+        this.proxyHandler = proxyHandler;
+    }
+
+    public boolean isEmpty()
+    {
+        return firstConcern == mixinInvocationHandler;
+    }
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] params )
+        throws Throwable
+    {
+        proxyHandler.setProxy( proxy );
+        try
+        {
+            return firstConcern.invoke( proxy, method, params );
+        }
+        catch( InvocationTargetException e )
+        {
+            throw e.getTargetException();
+        }
+        finally
+        {
+            proxyHandler.clearProxy();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsModel.java
new file mode 100644
index 0000000..74882f7
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConcernsModel.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+import org.qi4j.api.concern.ConcernsDescriptor;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.spi.module.ModuleSpi;
+
+/**
+ * JAVADOC
+ */
+public final class ConcernsModel
+    implements ConcernsDescriptor, Dependencies, VisitableHierarchy<Object, Object>
+{
+    public static final ConcernsModel EMPTY_CONCERNS = new ConcernsModel( Collections.<ConcernModel>emptyList() );
+
+    private List<ConcernModel> concernsFor;
+
+    public ConcernsModel( List<ConcernModel> concernsFor )
+    {
+        this.concernsFor = concernsFor;
+    }
+
+    @Override
+    public Iterable<DependencyModel> dependencies()
+    {
+        return Iterables.flattenIterables( Iterables.map( Dependencies.DEPENDENCIES_FUNCTION, concernsFor ) );
+    }
+
+    // Context
+    public ConcernsInstance newInstance( Method method, ModuleSpi moduleInstance,
+                                         FragmentInvocationHandler mixinInvocationHandler
+    )
+    {
+        ProxyReferenceInvocationHandler proxyHandler = new ProxyReferenceInvocationHandler();
+        InvocationHandler nextConcern = mixinInvocationHandler;
+        for( int i = concernsFor.size() - 1; i >= 0; i-- )
+        {
+            ConcernModel concernModel = concernsFor.get( i );
+
+            nextConcern = concernModel.newInstance( moduleInstance, nextConcern, proxyHandler, method );
+        }
+
+        return new ConcernsInstance( nextConcern, mixinInvocationHandler, proxyHandler );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        if( modelVisitor.visitEnter( this ) )
+        {
+            for( ConcernModel concernModel : concernsFor )
+            {
+                if( !concernModel.accept( modelVisitor ) )
+                {
+                    break;
+                }
+            }
+        }
+        return modelVisitor.visitLeave( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintDeclaration.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintDeclaration.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintDeclaration.java
new file mode 100644
index 0000000..048c4ed
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintDeclaration.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import org.qi4j.api.constraint.Constraint;
+import org.qi4j.api.util.Classes;
+
+/**
+ * JAVADOC
+ */
+public final class ConstraintDeclaration
+{
+    private final Class<? extends Constraint<?, ?>> constraintClass;
+    @SuppressWarnings( "raw" )
+    private final Class constraintAnnotationType;
+    private final Type constraintValueType;
+
+    @SuppressWarnings( "unchecked" )
+    public ConstraintDeclaration( Class<? extends Constraint<?, ?>> constraintClass )
+    {
+        this.constraintClass = constraintClass;
+
+        constraintAnnotationType = (Class<? extends Annotation>) ( (ParameterizedType) constraintClass.getGenericInterfaces()[ 0 ] )
+            .getActualTypeArguments()[ 0 ];
+        constraintValueType = ( (ParameterizedType) constraintClass.getGenericInterfaces()[ 0 ] ).getActualTypeArguments()[ 1 ];
+    }
+
+    public Class<? extends Constraint<?, ?>> constraintClass()
+    {
+        return constraintClass;
+    }
+
+    @SuppressWarnings( {"raw", "unchecked"} )
+    public boolean appliesTo( Class annotationType, Type valueType )
+    {
+        if( constraintValueType instanceof Class )
+        {
+            Class constraintValueClass = (Class) constraintValueType;
+            Class valueClass = Classes.RAW_CLASS.map( valueType );
+            return constraintAnnotationType.equals( annotationType ) && constraintValueClass.isAssignableFrom( valueClass );
+        }
+        else if( constraintValueType instanceof ParameterizedType )
+        {
+            // TODO Handle nested generics
+            Class constraintValueClass = Classes.RAW_CLASS.map( constraintValueType );
+            Class valueClass = Classes.RAW_CLASS.map( valueType );
+            return constraintAnnotationType.equals( annotationType ) && constraintValueClass.isAssignableFrom( valueClass );
+        }
+        else
+        {
+            return false; // TODO Handles more cases. What are they?
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintInstance.java
new file mode 100644
index 0000000..fc563e1
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintInstance.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import org.qi4j.api.constraint.Constraint;
+
+/**
+ * JAVADOC
+ */
+public final class ConstraintInstance<A extends Annotation, T>
+{
+    private final Constraint<A, T> constraint;
+    private final A annotation;
+
+    public ConstraintInstance( Constraint<A, T> constraint, A annotation )
+    {
+        this.constraint = constraint;
+        this.annotation = annotation;
+    }
+
+    public A annotation()
+    {
+        return annotation;
+    }
+
+    public boolean isValid( T value )
+    {
+        return constraint.isValid( annotation, value );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintModel.java
new file mode 100644
index 0000000..df891d8
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintModel.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.constraint.Constraint;
+
+/**
+ * JAVADOC
+ */
+public final class ConstraintModel
+    extends AbstractConstraintModel
+{
+    private final Class<? extends Constraint<?, ?>> constraintClass;
+
+    public ConstraintModel( Annotation annotation, Class<? extends Constraint<?, ?>> constraintClass )
+    {
+        super( annotation );
+        this.constraintClass = constraintClass;
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public ConstraintInstance<?, ?> newInstance()
+    {
+        try
+        {
+            Constraint<?, ?> constraint = constraintClass.newInstance();
+            return new ConstraintInstance( constraint, annotation );
+        }
+        catch( Exception e )
+        {
+            throw new ConstructionException( "Could not instantiate constraint implementation", e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsCheck.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsCheck.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsCheck.java
new file mode 100644
index 0000000..59737d0
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsCheck.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import org.qi4j.api.constraint.ConstraintViolationException;
+
+/**
+ * Call this to perform a value constraint check
+ */
+public interface ConstraintsCheck
+{
+    public void checkConstraints( Object value )
+        throws ConstraintViolationException;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsInstance.java
new file mode 100644
index 0000000..35fc533
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsInstance.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2009, Niclas Hedhman. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.composite.CompositeInstance;
+import org.qi4j.api.constraint.ConstraintViolation;
+import org.qi4j.api.constraint.ConstraintViolationException;
+
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * JAVADOC
+ */
+public final class ConstraintsInstance
+{
+    private final List<ValueConstraintsInstance> valueConstraintsInstances;
+
+    public ConstraintsInstance( List<ValueConstraintsInstance> parameterConstraints )
+    {
+        valueConstraintsInstances = parameterConstraints;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void checkValid( Object instance, Method method, Object[] params )
+        throws ConstraintViolationException
+    {
+        if( valueConstraintsInstances.isEmpty() )
+        {
+            return; // No constraints to check
+        }
+
+        // Check constraints
+        List<ConstraintViolation> violations = null;
+        for( int i = 0; i < params.length; i++ )
+        {
+            Object param = params[ i ];
+            List<ConstraintViolation> paramViolations = valueConstraintsInstances.get( i ).checkConstraints( param );
+            if( !paramViolations.isEmpty() )
+            {
+                if( violations == null )
+                {
+                    violations = new ArrayList<>();
+                }
+                violations.addAll( paramViolations );
+            }
+        }
+
+        // Check if any constraint failed
+        if( violations != null )
+        {
+            if( instance instanceof Composite )
+            {
+                throw new ConstraintViolationException( (Composite) instance, method, violations );
+            }
+            if( instance instanceof CompositeInstance )
+            {
+                throw new ConstraintViolationException( (Composite) ( (CompositeInstance) instance ).proxy(), method, violations );
+            }
+            Iterable<? extends Class<?>> types = iterable( instance.getClass() );
+            throw new ConstraintViolationException( instance.toString(), (Iterable<Class<?>>) types, method, violations );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsModel.java
new file mode 100644
index 0000000..a71d05d
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstraintsModel.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.qi4j.api.constraint.ConstraintsDescriptor;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+
+/**
+ * JAVADOC
+ */
+public final class ConstraintsModel
+    implements ConstraintsDescriptor, VisitableHierarchy<Object, Object>
+{
+    private List<ValueConstraintsModel> parameterConstraintModels;
+
+    private static ConstraintsInstance EMPTY_CONSTRAINTS = new ConstraintsInstance( Collections.<ValueConstraintsInstance>emptyList() );
+
+    public ConstraintsModel( List<ValueConstraintsModel> parameterConstraintModels )
+    {
+        this.parameterConstraintModels = parameterConstraintModels;
+    }
+
+    public ConstraintsInstance newInstance()
+    {
+        if( parameterConstraintModels.isEmpty() )
+        {
+            return EMPTY_CONSTRAINTS;
+        }
+        else
+        {
+            List<ValueConstraintsInstance> parameterConstraintsInstances = new ArrayList<ValueConstraintsInstance>( parameterConstraintModels
+                                                                                                                        .size() );
+            for( ValueConstraintsModel parameterConstraintModel : parameterConstraintModels )
+            {
+                parameterConstraintsInstances.add( parameterConstraintModel.newInstance() );
+            }
+            return new ConstraintsInstance( parameterConstraintsInstances );
+        }
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        if( modelVisitor.visitEnter( this ) )
+        {
+            if( parameterConstraintModels != null )
+            {
+                for( ValueConstraintsModel parameterConstraintModel : parameterConstraintModels )
+                {
+                    if( !parameterConstraintModel.accept( modelVisitor ) )
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+        return modelVisitor.visitLeave( this );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java
new file mode 100644
index 0000000..072168e
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.composite.ConstructorDescriptor;
+import org.qi4j.api.composite.InvalidCompositeException;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.runtime.injection.InjectedParametersModel;
+import org.qi4j.runtime.injection.InjectionContext;
+
+/**
+ * JAVADOC
+ */
+public final class ConstructorModel
+    implements ConstructorDescriptor, VisitableHierarchy<Object, Object>
+{
+    private Constructor<?> constructor;
+
+    private InjectedParametersModel parameters;
+
+    public ConstructorModel( Constructor<?> constructor, InjectedParametersModel parameters )
+    {
+        this.constructor = constructor;
+        this.parameters = parameters;
+        this.constructor.setAccessible( true );
+    }
+
+    @Override
+    public Constructor<?> constructor()
+    {
+        return constructor;
+    }
+
+    public Iterable<DependencyModel> dependencies()
+    {
+        return parameters.dependencies();
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
+        throws ThrowableType
+    {
+        if( modelVisitor.visitEnter( this ) )
+        {
+            parameters.accept( modelVisitor );
+        }
+
+        return modelVisitor.visitLeave( this );
+    }
+
+    // Context
+
+    public Object newInstance( InjectionContext context )
+        throws ConstructionException
+    {
+        // Create parameters
+        Object[] parametersInstance = parameters.newParametersInstance( context );
+        // Invoke constructor
+        try
+        {
+            return constructor.newInstance( parametersInstance );
+        }
+        catch( InvocationTargetException e )
+        {
+            Throwable targetException = e.getTargetException();
+            if( targetException instanceof InvalidCompositeException )
+            {
+                throw (InvalidCompositeException) targetException;
+            }
+            String message = "Could not instantiate \n    " + constructor.getDeclaringClass() + "\nusing constructor:\n    " + constructor
+                .toGenericString();
+            throw new ConstructionException( message, targetException );
+        }
+        catch( Throwable e )
+        {
+            System.err.println( constructor.toGenericString() );
+            System.err.println( Arrays.asList( parametersInstance ) );
+            throw new ConstructionException( "Could not instantiate " + constructor.getDeclaringClass(), e );
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return constructor.toGenericString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorsModel.java b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorsModel.java
new file mode 100644
index 0000000..f482d3b
--- /dev/null
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorsModel.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.runtime.composite;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import org.qi4j.api.common.ConstructionException;
+import org.qi4j.api.composite.CompositeDescriptor;
+import org.qi4j.api.composite.InvalidCompositeException;
+import org.qi4j.api.injection.InjectionScope;
+import org.qi4j.api.injection.scope.Uses;
+import org.qi4j.api.util.Annotations;
+import org.qi4j.api.util.Classes;
+import org.qi4j.bootstrap.BindingException;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.HierarchicalVisitor;
+import org.qi4j.functional.HierarchicalVisitorAdapter;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specifications;
+import org.qi4j.functional.VisitableHierarchy;
+import org.qi4j.runtime.injection.Dependencies;
+import org.qi4j.runtime.injection.DependencyModel;
+import org.qi4j.runtime.injection.InjectedParametersModel;
+import org.qi4j.runtime.injection.InjectionContext;
+import org.qi4j.runtime.injection.ParameterizedTypeInstance;
+import org.qi4j.runtime.model.Binder;
+import org.qi4j.runtime.model.Resolution;
+
+import static org.qi4j.functional.Iterables.filter;
+import static org.qi4j.functional.Iterables.first;
+import static org.qi4j.functional.Iterables.iterable;
+
+/**
+ * JAVADOC
+ */
+public final class ConstructorsModel
+    implements Binder, Dependencies, VisitableHierarchy<Object, Object>
+{
+    @SuppressWarnings( "raw" )
+    private final Class fragmentClass;
+    private final List<ConstructorModel> constructorModels;
+    private List<ConstructorModel> boundConstructors;
+
+    @SuppressWarnings( { "raw", "unchecked" } )
+    public ConstructorsModel( Class fragmentClass )
+    {
+        this.fragmentClass = fragmentClass;
+        validate( fragmentClass );
+        constructorModels = new ArrayList<>();
+        Constructor[] realConstructors = this.fragmentClass.getDeclaredConstructors();
+        Class injectionClass = FragmentClassLoader.getSourceClass( fragmentClass );
+        for( Constructor constructor : realConstructors )
+        {
+            constructor.setAccessible( true );
+            try
+            {
+                Constructor injectionConstructor = injectionClass.getDeclaredConstructor( constructor.getParameterTypes() );
+                injectionConstructor.setAccessible( true );
+                ConstructorModel constructorModel = newConstructorModel( this.fragmentClass, constructor,
+                                                                         injectionConstructor );
+                if( constructorModel != null )
+                {
+                    constructorModels.add( constructorModel );
+                }
+            }
+            catch( NoSuchMethodException e )
+            {
+                // Ignore and continue
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @SuppressWarnings( "raw" )
+    private void validate( Class fragmentClass )
+    {
+        // Ensure that the fragment class is not an inner class, in which case we should give a reasonable exception
+        if( fragmentClass.getDeclaringClass() == null )
+        {
+            return;
+        }
+        if( Modifier.isStatic( fragmentClass.getModifiers() ) )
+        {
+            return;
+        }
+        throw new InvalidCompositeException( "Inner classes can not be used. Use static nested classes instead: " + fragmentClass );
+    }
+
+    @Override
+    public Iterable<DependencyModel> dependencies()
+    {
+        Function<ConstructorModel, Iterable<DependencyModel>> constructorDependencies = new Function<ConstructorModel, Iterable<DependencyModel>>()
+        {
+            @Override
+            public Iterable<DependencyModel> map( ConstructorModel constructorModel )
+            {
+                return constructorModel.dependencies();
+            }
+        };
+
+        return Iterables.flattenIterables( Iterables.map( constructorDependencies, boundConstructors == null ? constructorModels : boundConstructors ) );
+    }
+
+    @SuppressWarnings( "raw" )
+    private ConstructorModel newConstructorModel( Class fragmentClass,
+                                                  Constructor realConstructor,
+                                                  Constructor injectedConstructor
+    )
+    {
+        int idx = 0;
+        InjectedParametersModel parameters = new InjectedParametersModel();
+        Annotation[][] parameterAnnotations = injectedConstructor.getParameterAnnotations();
+        for( Type type : injectedConstructor.getGenericParameterTypes() )
+        {
+            Annotation injectionAnnotation = first(
+                filter( Specifications.translate( Annotations.type(), Annotations.hasAnnotation( InjectionScope.class ) ), iterable( parameterAnnotations[ idx ] ) ) );
+
+            if( injectionAnnotation == null )
+            {
+                if( fragmentClass.getSuperclass().isMemberClass() )
+                {
+                    injectionAnnotation = new Uses()
+                    {
+                        @Override
+                        public Class<? extends Annotation> annotationType()
+                        {
+                            return Uses.class;
+                        }
+                    };
+                }
+                else
+                {
+                    return null; // invalid constructor parameter
+                }
+            }
+
+            boolean optional = DependencyModel.isOptional( injectionAnnotation, parameterAnnotations[ idx ] );
+
+            Type genericType = type;
+            if( genericType instanceof ParameterizedType )
+            {
+                genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
+                    .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );
+
+                for( int i = 0; i < ( (ParameterizedType) genericType ).getActualTypeArguments().length; i++ )
+                {
+                    Type typeArg = ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ];
+                    if( typeArg instanceof TypeVariable )
+                    {
+                        typeArg = Classes.resolveTypeVariable( (TypeVariable) typeArg, realConstructor.getDeclaringClass(), fragmentClass );
+                        ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ] = typeArg;
+                    }
+                }
+            }
+
+            DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional,
+                                                                   parameterAnnotations[ idx ] );
+            parameters.addDependency( dependencyModel );
+            idx++;
+        }
+        return new ConstructorModel( realConstructor, parameters );
+    }
+
+    @Override
+    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> visitor )
+        throws ThrowableType
+    {
+        if( visitor.visitEnter( this ) )
+        {
+            if( boundConstructors != null )
+            {
+                for( ConstructorModel constructorModel : boundConstructors )
+                {
+                    if( !constructorModel.accept( visitor ) )
+                    {
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                for( ConstructorModel constructorModel : constructorModels )
+                {
+                    if( !constructorModel.accept( visitor ) )
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+        return visitor.visitLeave( this );
+    }
+
+    // Binding
+    @Override
+    public void bind( final Resolution resolution )
+        throws BindingException
+    {
+        boundConstructors = new ArrayList<>();
+        for( ConstructorModel constructorModel : constructorModels )
+        {
+            try
+            {
+                constructorModel.accept( new HierarchicalVisitorAdapter<Object, Object, BindingException>()
+                {
+                    @Override
+                    public boolean visit( Object visitor )
+                        throws BindingException
+                    {
+                        if( visitor instanceof Binder )
+                        {
+                            ( (Binder) visitor ).bind( resolution );
+                        }
+                        return true;
+                    }
+                } );
+                boundConstructors.add( constructorModel );
+            }
+            catch( Exception e )
+            {
+                // Ignore
+                e.printStackTrace();
+            }
+        }
+
+        if( boundConstructors.isEmpty() )
+        {
+            StringBuilder messageBuilder = new StringBuilder( "Found no constructor that could be bound: " );
+            if( resolution.model() instanceof CompositeDescriptor )
+            {
+                messageBuilder.append( fragmentClass.getName() )
+                    .append( " in " )
+                    .append( resolution.model().toString() );
+            }
+            else
+            {
+                messageBuilder.append( resolution.model().toString() );
+            }
+
+            if( messageBuilder.indexOf( "$" ) >= 0 )
+            {
+                // This could be ok if instance is created manually
+                return;
+//                messageBuilder.append( "\nInner classes can not be used." );
+            }
+            String message = messageBuilder.toString();
+            throw new BindingException( message );
+        }
+
+        // Sort based on parameter count
+        Collections.sort( boundConstructors, new Comparator<ConstructorModel>()
+        {
+            @Override
+            public int compare( ConstructorModel o1, ConstructorModel o2 )
+            {
+                Integer model2ParametersCount = o2.constructor().getParameterTypes().length;
+                int model1ParametersCount = o1.constructor().getParameterTypes().length;
+                return model2ParametersCount.compareTo( model1ParametersCount );
+            }
+        } );
+    }
+
+    public Object newInstance( InjectionContext injectionContext )
+    {
+        // Try all bound constructors, in order
+        ConstructionException exception = null;
+        for( ConstructorModel constructorModel : boundConstructors )
+        {
+            try
+            {
+                return constructorModel.newInstance( injectionContext );
+            }
+            catch( ConstructionException e )
+            {
+                exception = e;
+            }
+        }
+
+        throw exception;
+    }
+}


[29/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/OperatorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/OperatorsTest.java b/core/api/src/test/java/org/qi4j/api/OperatorsTest.java
new file mode 100644
index 0000000..6f467e5
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/OperatorsTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.qi4j.api;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.api.composite.Composite;
+import org.qi4j.api.entity.EntityBuilder;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.QueryBuilder;
+import org.qi4j.api.query.QueryExpressions;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.unitofwork.UnitOfWorkCompletionException;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.SingletonAssembler;
+import org.qi4j.functional.Iterables;
+import org.qi4j.functional.Specification;
+import org.qi4j.test.EntityTestAssembler;
+
+/**
+ * TODO
+ */
+public class OperatorsTest
+{
+    @Test
+    public void testOperators()
+        throws UnitOfWorkCompletionException, ActivationException, AssemblyException
+    {
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                new EntityTestAssembler().assemble( module );
+
+                module.entities( TestEntity.class );
+                module.values( TestValue.class );
+                module.forMixin( TestEntity.class ).declareDefaults().foo().set( "Bar" );
+                module.forMixin( TestValue.class ).declareDefaults().bar().set( "Xyz" );
+            }
+        };
+
+        UnitOfWork uow = assembler.module().newUnitOfWork();
+
+        try
+        {
+            EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, "123" );
+            entityBuilder.instance().value().set( assembler.module().newValue( TestValue.class ) );
+            TestEntity testEntity = entityBuilder.newInstance();
+
+            uow.complete();
+            uow = assembler.module().newUnitOfWork();
+
+            Iterable<TestEntity> entities = Iterables.iterable( testEntity = uow.get( testEntity ) );
+
+            QueryBuilder<TestEntity> builder = assembler.module().newQueryBuilder( TestEntity.class );
+
+            {
+                Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
+                                                                          .foo(), "Bar" );
+                Assert.assertTrue( where.satisfiedBy( testEntity ) );
+                System.out.println( where );
+            }
+            {
+                Specification<Composite> where = QueryExpressions.eq( QueryExpressions.templateFor( TestEntity.class )
+                                                                          .value()
+                                                                          .get()
+                                                                          .bar(), "Xyz" );
+                Assert.assertTrue( where.satisfiedBy( testEntity ) );
+                System.out.println( where );
+
+                Assert.assertTrue( builder.where( where ).newQuery( entities ).find().equals( testEntity ) );
+            }
+        }
+        finally
+        {
+            uow.discard();
+        }
+    }
+
+    public interface TestEntity
+        extends EntityComposite
+    {
+        Property<String> foo();
+
+        Property<TestValue> value();
+    }
+
+    public interface TestValue
+        extends ValueComposite
+    {
+        Property<String> bar();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/activation/ActivationEventsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/activation/ActivationEventsTest.java b/core/api/src/test/java/org/qi4j/api/activation/ActivationEventsTest.java
new file mode 100644
index 0000000..acc5340
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/activation/ActivationEventsTest.java
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.junit.Test;
+import org.qi4j.api.activation.ActivationEvent.EventType;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Module;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.SingletonAssembler;
+
+import static org.junit.Assert.*;
+import static org.qi4j.api.activation.ActivationEvent.EventType.*;
+
+public class ActivationEventsTest
+{
+
+    public static interface TestService
+    {
+        void test();
+    }
+
+    public static class TestServiceInstance
+            implements TestService
+    {
+
+        @Override
+        public void test()
+        {
+        }
+
+    }
+
+    @Mixins( TestServiceInstance.class )
+    public static interface TestServiceComposite
+        extends TestService, ServiceComposite
+    {
+    }
+
+    @Test
+    public void testSingleModuleSingleService()
+        throws Exception
+    {
+        final List<ActivationEvent> events = new ArrayList<>();
+
+        new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.services( TestServiceComposite.class ).instantiateOnStartup();
+            }
+
+            @Override
+            protected void beforeActivation( Application application )
+            {
+                application.registerActivationEventListener( new EventsRecorder( events ) );
+            }
+
+
+        }.application().passivate();
+
+        Iterator<ActivationEvent> it = events.iterator();
+
+        // Activation
+        assertEvent( it.next(), ACTIVATING, "Application" );
+        assertEvent( it.next(), ACTIVATING, "Layer" );
+        assertEvent( it.next(), ACTIVATING, "Module" );
+        assertEvent( it.next(), ACTIVATING, "TestService" );
+        assertEvent( it.next(), ACTIVATED, "TestService" );
+        assertEvent( it.next(), ACTIVATED, "Module" );
+        assertEvent( it.next(), ACTIVATED, "Layer" );
+        assertEvent( it.next(), ACTIVATED, "Application" );
+
+        // Passivation
+        assertEvent( it.next(), PASSIVATING, "Application" );
+        assertEvent( it.next(), PASSIVATING, "Layer" );
+        assertEvent( it.next(), PASSIVATING, "Module" );
+        assertEvent( it.next(), PASSIVATING, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "Module" );
+        assertEvent( it.next(), PASSIVATED, "Layer" );
+        assertEvent( it.next(), PASSIVATED, "Application" );
+
+        assertFalse( it.hasNext() );
+    }
+
+    @Test
+    public void testSingleModuleSingleImportedService()
+            throws Exception
+    {
+        final List<ActivationEvent> events = new ArrayList<>();
+
+        new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.importedServices( TestService.class ).
+                        setMetaInfo( new TestServiceInstance() ).
+                        importOnStartup();
+            }
+
+            @Override
+            protected void beforeActivation( Application application )
+            {
+                application.registerActivationEventListener( new EventsRecorder( events ) );
+            }
+
+
+        }.application().passivate();
+
+        Iterator<ActivationEvent> it = events.iterator();
+
+        // Activation
+        assertEvent( it.next(), ACTIVATING, "Application" );
+        assertEvent( it.next(), ACTIVATING, "Layer" );
+        assertEvent( it.next(), ACTIVATING, "Module" );
+        assertEvent( it.next(), ACTIVATING, "TestService" );
+        assertEvent( it.next(), ACTIVATED, "TestService" );
+        assertEvent( it.next(), ACTIVATED, "Module" );
+        assertEvent( it.next(), ACTIVATED, "Layer" );
+        assertEvent( it.next(), ACTIVATED, "Application" );
+
+        // Passivation
+        assertEvent( it.next(), PASSIVATING, "Application" );
+        assertEvent( it.next(), PASSIVATING, "Layer" );
+        assertEvent( it.next(), PASSIVATING, "Module" );
+        assertEvent( it.next(), PASSIVATING, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "Module" );
+        assertEvent( it.next(), PASSIVATED, "Layer" );
+        assertEvent( it.next(), PASSIVATED, "Application" );
+
+        assertFalse( it.hasNext() );
+    }
+
+    @Test
+    public void testSingleModuleSingleLazyService()
+            throws Exception
+    {
+        final List<ActivationEvent> events = new ArrayList<>();
+
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+
+            @Override
+            public void assemble( ModuleAssembly module )
+                    throws AssemblyException
+            {
+                module.services( TestServiceComposite.class );
+            }
+
+            @Override
+            protected void beforeActivation( Application application )
+            {
+                application.registerActivationEventListener( new EventsRecorder( events ) );
+            }
+
+        };
+        Application application = assembler.application();
+        application.passivate();
+
+        Iterator<ActivationEvent> it = events.iterator();
+
+        // Activation
+        assertEvent( it.next(), ACTIVATING, "Application" );
+        assertEvent( it.next(), ACTIVATING, "Layer" );
+        assertEvent( it.next(), ACTIVATING, "Module" );
+        // Lazy Service NOT activated
+        assertEvent( it.next(), ACTIVATED, "Module" );
+        assertEvent( it.next(), ACTIVATED, "Layer" );
+        assertEvent( it.next(), ACTIVATED, "Application" );
+
+        // Passivation
+        assertEvent( it.next(), PASSIVATING, "Application" );
+        assertEvent( it.next(), PASSIVATING, "Layer" );
+        assertEvent( it.next(), PASSIVATING, "Module" );
+        // Lazy Service NOT passivated
+        assertEvent( it.next(), PASSIVATED, "Module" );
+        assertEvent( it.next(), PASSIVATED, "Layer" );
+        assertEvent( it.next(), PASSIVATED, "Application" );
+
+        assertFalse( it.hasNext() );
+
+        events.clear();
+        application.activate();
+        Module module = assembler.module();
+        module.findService( TestService.class ).get().test();
+        application.passivate();
+
+        for( ActivationEvent event : events ) {
+            System.out.println( event );
+        }
+
+        it = events.iterator();
+
+        // Activation
+        assertEvent( it.next(), ACTIVATING, "Application" );
+        assertEvent( it.next(), ACTIVATING, "Layer" );
+        assertEvent( it.next(), ACTIVATING, "Module" );
+        assertEvent( it.next(), ACTIVATED, "Module" );
+        assertEvent( it.next(), ACTIVATED, "Layer" );
+        assertEvent( it.next(), ACTIVATED, "Application" );
+
+        // Lazy Service Activation
+        assertEvent( it.next(), ACTIVATING, "TestService" );
+        assertEvent( it.next(), ACTIVATED, "TestService" );
+
+        // Passivation
+        assertEvent( it.next(), PASSIVATING, "Application" );
+        assertEvent( it.next(), PASSIVATING, "Layer" );
+        assertEvent( it.next(), PASSIVATING, "Module" );
+        assertEvent( it.next(), PASSIVATING, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "TestService" );
+        assertEvent( it.next(), PASSIVATED, "Module" );
+        assertEvent( it.next(), PASSIVATED, "Layer" );
+        assertEvent( it.next(), PASSIVATED, "Application" );
+
+        assertFalse( it.hasNext() );
+    }
+
+    private static class EventsRecorder
+            implements ActivationEventListener
+    {
+
+        private final List<ActivationEvent> events;
+
+        private EventsRecorder( List<ActivationEvent> events )
+        {
+            this.events = events;
+        }
+
+        @Override
+        public void onEvent( ActivationEvent event )
+        {
+            events.add( event );
+        }
+
+    }
+
+    // WARN This assertion depends on ApplicationInstance, LayerInstance, ModuleInstance and ServiceReferenceInstance toString() method.
+    private static void assertEvent( ActivationEvent event, EventType expectedType, String expected )
+    {
+        boolean wrongEvent = expectedType != event.type();
+        boolean wrongMessage = ! event.message().contains( expected );
+        if( wrongEvent || wrongMessage )
+        {
+            StringBuilder sb = new StringBuilder();
+            sb.append("Event (").append( event ).append( ") has");
+            if( wrongEvent )
+            {
+                sb.append( " wrong type (expected:'" ).append( expectedType ).
+                        append( "' but was:'" ).append( event.type() ).append( "')" );
+                if( wrongMessage )
+                {
+                    sb.append( ";" );
+                }
+            }
+            if( wrongMessage )
+            {
+                sb.append( " wrong message (expected:'" ).append( expected ).
+                        append( "' but was:'" ).append( event.message() ).append( "')" );
+            }
+            fail( sb.toString() );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/activation/PassivationExceptionTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/activation/PassivationExceptionTest.java b/core/api/src/test/java/org/qi4j/api/activation/PassivationExceptionTest.java
new file mode 100644
index 0000000..348e32d
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/activation/PassivationExceptionTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2013-2014, Paul Merlin. 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.qi4j.api.activation;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import org.junit.Test;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.service.ServiceReference;
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.Layer;
+import org.qi4j.api.structure.Module;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.builder.ApplicationBuilder;
+
+import static org.hamcrest.core.StringContains.containsString;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+public class PassivationExceptionTest
+{
+    private static String stack( Exception ex )
+    {
+        StringWriter writer = new StringWriter();
+        ex.printStackTrace( new PrintWriter( writer ) );
+        return writer.toString();
+    }
+
+    @Test
+    public void testEmptyPassivationException()
+    {
+        PassivationException empty = new PassivationException( Collections.<Exception>emptyList() );
+        assertThat( empty.getMessage(), containsString( "has 0 cause" ) );
+    }
+
+    @Test
+    public void testSinglePassivationException()
+    {
+        PassivationException single = new PassivationException( Collections.singletonList( new Exception( "single" ) ) );
+        String stack = stack( single );
+        assertThat( single.getMessage(), containsString( "has 1 cause" ) );
+        assertThat( stack, containsString( "Suppressed: java.lang.Exception: single" ) );
+    }
+
+    @Test
+    public void testMultiplePassivationException()
+    {
+        PassivationException multi = new PassivationException( Arrays.asList( new Exception( "one" ),
+                                                                              new Exception( "two" ),
+                                                                              new Exception( "three" ) ) );
+        String stack = stack( multi );
+        assertThat( multi.getMessage(), containsString( "has 3 cause(s)" ) );
+        assertThat( stack, containsString( "Suppressed: java.lang.Exception: one" ) );
+        assertThat( stack, containsString( "Suppressed: java.lang.Exception: two" ) );
+        assertThat( stack, containsString( "Suppressed: java.lang.Exception: three" ) );
+    }
+
+    @Test
+    public void testPassivationExceptionsAccrossStructure()
+        throws AssemblyException, ActivationException
+    {
+        ApplicationBuilder appBuilder = new ApplicationBuilder( "TestApplication" );
+        appBuilder.withLayer( "Layer 1" ).withModule( "Module A" ).withAssembler( new Assembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.services( TestService.class ).
+                    identifiedBy( "TestService_Module.A" ).
+                    withActivators( FailBeforePassivationServiceActivator.class ).
+                    instantiateOnStartup();
+            }
+        } );
+        appBuilder.withLayer( "Layer 2" ).withModule( "Module B" ).withAssembler( new Assembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.services( TestService.class ).
+                    identifiedBy( "TestService_Module.B" ).
+                    withActivators( FailAfterPassivationServiceActivator.class ).
+                    instantiateOnStartup();
+            }
+        } );
+        appBuilder.registerActivationEventListener( new TestActivationEventListener() );
+
+        Application app = appBuilder.newApplication();
+
+        try
+        {
+            Module moduleA = app.findModule( "Layer 1", "Module A" );
+            TestService service = moduleA.findService( TestService.class ).get();
+            assertThat( service.hello(), equalTo( "Hello Zest!" ) );
+        }
+        finally
+        {
+            try
+            {
+                app.passivate();
+                fail( "No PassivationException" );
+            }
+            catch( PassivationException ex )
+            {
+                ex.printStackTrace();
+                String stack = stack( ex );
+                assertThat( ex.getMessage(), containsString( "has 12 cause(s)" ) );
+                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for TestApplication" ) );
+                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Layer 2" ) );
+                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Module B" ) );
+                assertThat( stack, containsString( "ACTIVATOR: FAIL AFTER PASSIVATION for TestService_Module.B(active=false,module='Module B')" ) );
+                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Module B" ) );
+                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Layer 2" ) );
+                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Layer 1" ) );
+                assertThat( stack, containsString( "EVENT: FAIL BEFORE PASSIVATION for Module A" ) );
+                assertThat( stack, containsString( "ACTIVATOR: FAIL BEFORE PASSIVATION for TestService_Module.A(active=true,module='Module A')" ) );
+                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Module A" ) );
+                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for Layer 1" ) );
+                assertThat( stack, containsString( "EVENT: FAIL AFTER PASSIVATION for TestApplication" ) );
+            }
+        }
+    }
+
+    @Mixins( TestService.Mixin.class )
+    public interface TestService
+    {
+        String hello();
+
+        static class Mixin
+            implements TestService
+        {
+            @Structure
+            private Module module;
+
+            @Override
+            public String hello()
+            {
+                module.name();
+                return "Hello Zest!";
+            }
+        }
+
+    }
+
+    public static class FailBeforePassivationServiceActivator
+        extends ActivatorAdapter<ServiceReference<TestService>>
+    {
+        @Override
+        public void beforePassivation( ServiceReference<TestService> passivated )
+            throws Exception
+        {
+            throw new Exception( "ACTIVATOR: FAIL BEFORE PASSIVATION for " + passivated );
+        }
+    }
+
+    public static class FailAfterPassivationServiceActivator
+        extends ActivatorAdapter<ServiceReference<TestService>>
+    {
+        @Override
+        public void afterPassivation( ServiceReference<TestService> passivated )
+            throws Exception
+        {
+            throw new Exception( "ACTIVATOR: FAIL AFTER PASSIVATION for " + passivated );
+        }
+    }
+
+    public static class TestActivationEventListener
+        implements ActivationEventListener
+    {
+        @Override
+        public void onEvent( ActivationEvent event )
+            throws Exception
+        {
+            if( !( event.source() instanceof Application )
+                && !( event.source() instanceof Layer )
+                && !( event.source() instanceof Module ) )
+            {
+                return;
+            }
+            switch( event.type() )
+            {
+                case PASSIVATING:
+                    throw new Exception( "EVENT: FAIL BEFORE PASSIVATION for " + event.source() );
+                case PASSIVATED:
+                    throw new Exception( "EVENT: FAIL AFTER PASSIVATION for " + event.source() );
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/annotation/MixinsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/annotation/MixinsTest.java b/core/api/src/test/java/org/qi4j/api/annotation/MixinsTest.java
new file mode 100644
index 0000000..475ad75
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/annotation/MixinsTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 Alin Dreghiciu. 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.qi4j.api.annotation;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+import org.qi4j.api.mixin.Mixins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by Mixins annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class MixinsTest
+{
+
+    @Test
+    public void retention()
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", Mixins.class, annotations[ 0 ].annotationType() );
+    }
+
+    @Mixins( Object.class )
+    private static class Annotated
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/annotation/ModifiedByTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/annotation/ModifiedByTest.java b/core/api/src/test/java/org/qi4j/api/annotation/ModifiedByTest.java
new file mode 100644
index 0000000..50227c4
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/annotation/ModifiedByTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 Alin Dreghiciu. 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.qi4j.api.annotation;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+import org.qi4j.api.concern.Concerns;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by Concerns annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class ModifiedByTest
+{
+
+    @Test
+    public void retention()
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", Concerns.class, annotations[ 0 ].annotationType() );
+    }
+
+    @Concerns( Object.class )
+    private static class Annotated
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/annotation/scope/ModifiesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/annotation/scope/ModifiesTest.java b/core/api/src/test/java/org/qi4j/api/annotation/scope/ModifiesTest.java
new file mode 100644
index 0000000..d984105
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/annotation/scope/ModifiesTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 Alin Dreghiciu. 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.qi4j.api.annotation.scope;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+import org.qi4j.api.concern.internal.ConcernFor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by Modified annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class ModifiesTest
+{
+
+    @Test
+    public void retention()
+        throws NoSuchFieldException
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredField( "modified" ).getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", ConcernFor.class, annotations[ 0 ].annotationType() );
+    }
+
+    private static class Annotated
+    {
+        @ConcernFor
+        String modified;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/common/AppliesToTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/common/AppliesToTest.java b/core/api/src/test/java/org/qi4j/api/common/AppliesToTest.java
new file mode 100644
index 0000000..a2093f8
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/common/AppliesToTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2007 Alin Dreghiciu. 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.qi4j.api.common;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by AppliesTo annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class AppliesToTest
+{
+
+    @Test
+    public void retention()
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", AppliesTo.class, annotations[ 0 ].annotationType() );
+    }
+
+    @AppliesTo( Object.class )
+    private static class Annotated
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/common/QualifiedNameTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/common/QualifiedNameTest.java b/core/api/src/test/java/org/qi4j/api/common/QualifiedNameTest.java
new file mode 100644
index 0000000..44015e0
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/common/QualifiedNameTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.qi4j.api.common;
+
+import org.junit.Test;
+import org.qi4j.api.util.NullArgumentException;
+
+import static org.junit.Assert.assertEquals;
+
+public class QualifiedNameTest
+{
+    @Test
+    public void testQualifiedNameWithDollar()
+    {
+        assertEquals( "Name containing dollar is modified", "Test-Test",
+                      new QualifiedName( TypeName.nameOf( "Test$Test" ), "satisfiedBy" ).type() );
+    }
+
+    @Test
+    public void testQualifiedNameFromQNWithDollar()
+    {
+        assertEquals( "Name containing dollar is cleaned up", "Test-Test",
+                      QualifiedName.fromFQN( "Test$Test:satisfiedBy" ).type() );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments1()
+    {
+        new QualifiedName( TypeName.nameOf( "Test" ), null );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments2()
+    {
+        new QualifiedName( null, "satisfiedBy" );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments3()
+    {
+        new QualifiedName( null, null );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments4()
+    {
+        QualifiedName.fromFQN( null );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments5()
+    {
+        QualifiedName.fromAccessor( null );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments6()
+    {
+        QualifiedName.fromClass( null, "satisfiedBy" );
+    }
+
+    @Test( expected = NullArgumentException.class )
+    public void nonNullArguments7()
+    {
+        QualifiedName.fromClass( null, null );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/composite/PropertyMapperTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/composite/PropertyMapperTest.java b/core/api/src/test/java/org/qi4j/api/composite/PropertyMapperTest.java
new file mode 100644
index 0000000..1a10440
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/composite/PropertyMapperTest.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ *
+ * 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.qi4j.api.composite;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.junit.Test;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.value.ValueComposite;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class PropertyMapperTest
+{
+    private final static Method MAP_TO_TYPE;
+
+    static
+    {
+        try
+        {
+            MAP_TO_TYPE = PropertyMapper.class.getDeclaredMethod( "mapToType", Composite.class, Type.class, Object.class );
+            MAP_TO_TYPE.setAccessible( true );
+        }
+        catch( NoSuchMethodException e )
+        {
+            InternalError error = new InternalError();
+            error.initCause( e );
+            throw error;
+        }
+    }
+
+    @Test
+    public void testMappingOfInteger()
+        throws Exception
+    {
+        assertEquals( 5, mapToType( null, Integer.class, "5" ) );
+        assertEquals( -5, mapToType( null, Integer.class, "-5" ) );
+        assertEquals( Integer.class, mapToType( null, Integer.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfLong()
+        throws Exception
+    {
+        assertEquals( 5L, mapToType( null, Long.class, "5" ) );
+        assertEquals( 5876328476238746238L, mapToType( null, Long.class, "5876328476238746238" ) );
+        assertEquals( Long.class, mapToType( null, Long.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfBoolean()
+        throws Exception
+    {
+        assertEquals( false, mapToType( null, Boolean.class, "false" ) );
+        assertEquals( true, mapToType( null, Boolean.class, "true" ) );
+        assertEquals( Boolean.class, mapToType( null, Boolean.class, "false" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfFloat()
+        throws Exception
+    {
+        assertEquals( 5.1234f, mapToType( null, Float.class, "5.1234" ) );
+        assertEquals( 5876328476.6238f, mapToType( null, Float.class, "5876328476.6238" ) );
+        assertEquals( Float.class, mapToType( null, Float.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfDouble()
+        throws Exception
+    {
+        assertEquals( 5.1234, mapToType( null, Double.class, "5.1234" ) );
+        assertEquals( 5876328476.623823, mapToType( null, Double.class, "5876328476.623823" ) );
+        assertEquals( Double.class, mapToType( null, Double.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfBigDecimal()
+        throws Exception
+    {
+        assertEquals( new BigDecimal( 3 ), mapToType( null, BigDecimal.class, "3" ) );
+        assertEquals( new BigDecimal( "12345.67891011" ), mapToType( null, BigDecimal.class, "12345.67891011" ) );
+        assertEquals( BigDecimal.class, mapToType( null, BigDecimal.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfBigInteger()
+        throws Exception
+    {
+        assertEquals( new BigInteger( "20", 16 ), mapToType( null, BigInteger.class, "32" ) );
+        assertEquals( new BigInteger( "1234567891011" ), mapToType( null, BigInteger.class, "1234567891011" ) );
+        assertEquals( BigInteger.class, mapToType( null, BigInteger.class, "5" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfEnum()
+        throws Exception
+    {
+        assertEquals( TestEnum.FIRST, mapToType( null, TestEnum.class, "FIRST" ) );
+        assertEquals( TestEnum.SECOND, mapToType( null, TestEnum.class, "SECOND" ) );
+        assertEquals( TestEnum.class, mapToType( null, TestEnum.class, "SECOND" ).getClass() );
+    }
+
+    @Test
+    public void testMappingOfIntegerArray()
+        throws Exception
+    {
+        Object[] value = (Object[]) mapToType( null, Integer[].class, "5,4 , 3   ,2,1" );
+        assertEquals( 5, value.length );
+        assertEquals( 5, value[ 0 ] );
+        assertEquals( 4, value[ 1 ] );
+        assertEquals( 3, value[ 2 ] );
+        assertEquals( 2, value[ 3 ] );
+        assertEquals( 1, value[ 4 ] );
+    }
+
+    @Test
+    public void testMappingOfStringArray()
+        throws Exception
+    {
+        {
+            Object[] value = (Object[]) mapToType( null, String[].class, "5,4 , 3   ,2,1" );
+            assertEquals( 5, value.length );
+            assertEquals( "5", value[ 0 ] );
+            assertEquals( "4 ", value[ 1 ] );
+            assertEquals( " 3   ", value[ 2 ] );
+            assertEquals( "2", value[ 3 ] );
+            assertEquals( "1", value[ 4 ] );
+        }
+        {
+            Object[] value = (Object[]) mapToType( null, String[].class, "5,4 ,\" 3,   \",  \" 2\" ,1" );
+            assertEquals( "5", value[ 0 ] );
+            assertEquals( "4 ", value[ 1 ] );
+            assertEquals( " 3,   ", value[ 2 ] );
+            assertEquals( " 2", value[ 3 ] );
+            assertEquals( "1", value[ 4 ] );
+            assertEquals( 5, value.length );
+        }
+    }
+
+    @Test
+    public void testMappingOfBooleanArray()
+        throws Exception
+    {
+        Object[] value = (Object[]) mapToType( null, Boolean[].class, " true,false,  false, true ,true,false" );
+        assertEquals( true, value[ 0 ] );
+        assertEquals( false, value[ 1 ] );
+        assertEquals( false, value[ 2 ] );
+        assertEquals( true, value[ 3 ] );
+        assertEquals( true, value[ 4 ] );
+        assertEquals( false, value[ 5 ] );
+        assertEquals( 6, value.length );
+    }
+
+    @Test
+    public void testMappingOfList()
+        throws Exception
+    {
+        Type type = Testing.class.getDeclaredMethod( "list" ).getGenericReturnType();
+        List<String> value = (List<String>) mapToType( null, type, "5,4 ,\" 3,   \",  \" 2\" ,1" );
+        assertEquals( "5", value.get( 0 ) );
+        assertEquals( "4 ", value.get( 1 ) );
+        assertEquals( " 3,   ", value.get( 2 ) );
+        assertEquals( " 2", value.get( 3 ) );
+        assertEquals( "1", value.get( 4 ) );
+        assertEquals( 5, value.size() );
+    }
+
+    @Test
+    public void testMappingOfSet()
+        throws Exception
+    {
+        Type type = Testing.class.getDeclaredMethod( "set" ).getGenericReturnType();
+        Set<String> value = (Set<String>) mapToType( null, type, "5,4 ,\" 3,   \",  \" 2\" ,1" );
+        assertTrue( value.contains( "5" ) );
+        assertTrue( value.contains( "4 " ) );
+        assertTrue( value.contains( " 3,   " ) );
+        assertTrue( value.contains( " 2" ) );
+        assertTrue( value.contains( "1" ) );
+        assertEquals( 5, value.size() );
+    }
+
+    @Test
+    public void testMappingOfMap()
+        throws Exception
+    {
+        Type type = Testing.class.getDeclaredMethod( "map" ).getGenericReturnType();
+        Map<String, String> value = (Map<String, String>) mapToType( null, type, "first:5,second:4 , third:\" 3,   \", fourth:  \" 2\" ,fifth : 1" );
+        assertEquals( "5", value.get( "first" ) );
+        assertEquals( "4 ", value.get( "second" ) );
+        assertEquals( " 3,   ", value.get( " third" ) );
+        assertEquals( " 2", value.get( " fourth" ) );
+        assertEquals( " 1", value.get( "fifth " ) );
+        assertEquals( 5, value.size() );
+    }
+
+    private Object mapToType( Composite composite, Type propertyType, Object value )
+        throws IllegalAccessException, InvocationTargetException
+    {
+        return MAP_TO_TYPE.invoke( null, composite, propertyType, value );
+    }
+
+    interface Testing
+    {
+        List<String> list();
+
+        Set<String> set();
+
+        Map<String, String> map();
+    }
+
+    enum TestEnum
+    {
+        FIRST,
+        SECOND
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/concern/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/concern/DocumentationSupport.java b/core/api/src/test/java/org/qi4j/api/concern/DocumentationSupport.java
new file mode 100644
index 0000000..69cfc5c
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/concern/DocumentationSupport.java
@@ -0,0 +1,100 @@
+/*
+ * 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.qi4j.api.concern;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.injection.InjectionScope;
+
+public class DocumentationSupport
+{
+// START SNIPPET: class
+    @AppliesTo( java.sql.Connection.class )
+    public class CacheConcern extends GenericConcern
+        implements InvocationHandler
+    {
+// END SNIPPET: class
+        @Override
+        public Object invoke( Object proxy, Method method, Object[] args )
+            throws Throwable
+        {
+            return null;
+        }
+    }
+
+// START SNIPPET: filter
+    @AppliesTo( BusinessAppliesToFilter.class )
+    public class BusinessConcern extends GenericConcern
+        implements InvocationHandler
+    {
+// END SNIPPET: filter
+        @Override
+        public Object invoke( Object proxy, Method method, Object[] args )
+            throws Throwable
+        {
+            return null;
+        }
+    }
+
+// START SNIPPET: filter
+    public class BusinessAppliesToFilter
+        implements AppliesToFilter
+    {
+
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass
+        )
+        {
+            return true; // Some criteria for when a method is wrapped with the concern.
+        }
+    }
+// END SNIPPET: filter
+
+
+// START SNIPPET: annotation
+    @AppliesTo( Audited.class )
+    public class AuditConcern extends GenericConcern
+        implements InvocationHandler
+    {
+// START SNIPPET: annotation
+        @Override
+        public Object invoke( Object proxy, Method method, Object[] args )
+            throws Throwable
+        {
+            return null;
+        }
+    }
+
+// START SNIPPET: annotation
+    @Retention( RetentionPolicy.RUNTIME )
+    @Target( { ElementType.METHOD } )
+    @Documented
+    @InjectionScope
+    public @interface Audited
+    {
+    }
+// END SNIPPET: annotation
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/configuration/ConfigurationTest.java b/core/api/src/test/java/org/qi4j/api/configuration/ConfigurationTest.java
new file mode 100644
index 0000000..c72afe7
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/configuration/ConfigurationTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.qi4j.api.configuration;
+
+import org.junit.Test;
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.api.value.ValueComposite;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class ConfigurationTest extends AbstractQi4jTest
+{
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.services( MyService.class ).instantiateOnStartup();
+        module.entities( MyConfig.class );
+        module.values( PersonDetails.class, Address.class, City.class, Country.class );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    @Test
+    public void testConfiguration()
+        throws Exception
+    {
+        MyService service = module.findService( MyService.class ).get();
+        PersonDetails details = service.details();
+        assertThat(details.name().get(), equalTo( "Niclas" ) );
+        assertThat(details.address().get().street1().get(), equalTo( "Henan Lu 555" ) );
+        assertThat(details.address().get().street2().get(), equalTo( "Block 15" ) );
+        assertThat(details.address().get().city().get().cityName().get(), equalTo( "Shanghai" ) );
+        assertThat(details.address().get().city().get().country().get().countryName().get(), equalTo( "China" ) );
+    }
+
+    @Mixins(MyServiceMixin.class)
+    public interface MyService extends ServiceComposite
+    {
+        PersonDetails details();
+    }
+
+    public abstract class MyServiceMixin
+        implements MyService
+    {
+        @This
+        Configuration<MyConfig> myconf;
+
+        @Override
+        public PersonDetails details()
+        {
+            return myconf.get().me().get();
+        }
+    }
+
+    public interface MyConfig extends ConfigurationComposite
+    {
+        Property<PersonDetails> me();
+    }
+
+    public interface PersonDetails extends ValueComposite
+    {
+        Property<String> name();
+        Property<Address> address();
+
+    }
+
+    public interface Address extends ValueComposite
+    {
+        Property<String> street1();
+        Property<String> street2();
+        Property<City> city();
+    }
+
+    public interface City extends ValueComposite
+    {
+        Property<String> cityName();
+        Property<Country> country();
+    }
+
+    public interface Country extends ValueComposite
+    {
+        Property<String> countryName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/configuration/DeclareConfigurationDefaultsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/configuration/DeclareConfigurationDefaultsTest.java b/core/api/src/test/java/org/qi4j/api/configuration/DeclareConfigurationDefaultsTest.java
new file mode 100644
index 0000000..404f126
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/configuration/DeclareConfigurationDefaultsTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.api.configuration;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.service.ServiceComposite;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+public class DeclareConfigurationDefaultsTest
+        extends AbstractQi4jTest
+{
+
+    @Mixins( FooServiceMixin.class )
+    public static interface FooServiceComposite
+            extends ServiceComposite
+    {
+
+        String configuredFoo();
+
+    }
+
+    public static abstract class FooServiceMixin
+            implements FooServiceComposite
+    {
+
+        @This
+        private Configuration<FooConfigurationComposite> config;
+
+        public String configuredFoo()
+        {
+            return config.get().foo().get();
+        }
+
+    }
+
+    public static interface FooConfigurationComposite
+            extends ConfigurationComposite
+    {
+
+        Property<String> foo();
+
+    }
+
+    public void assemble( ModuleAssembly module )
+            throws AssemblyException
+    {
+        module.services( FooServiceComposite.class ).identifiedBy( "bazar" );
+        module.entities( FooConfigurationComposite.class );
+        new EntityTestAssembler().assemble( module );
+        FooConfigurationComposite config = module.forMixin( FooConfigurationComposite.class ).declareDefaults();
+        config.foo().set( "bar" );
+    }
+
+    @Test
+    public void testConfigurationDefaults()
+    {
+        FooServiceComposite fooService = module.findService( FooServiceComposite.class ).get();
+        Assert.assertEquals( "bar", fooService.configuredFoo() );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/configuration/MailService.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/configuration/MailService.java b/core/api/src/test/java/org/qi4j/api/configuration/MailService.java
new file mode 100644
index 0000000..18817cf
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/configuration/MailService.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * 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.qi4j.api.configuration;
+
+import org.qi4j.api.injection.scope.This;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.library.constraints.annotation.Email;
+import org.qi4j.library.constraints.annotation.MinLength;
+
+// Documentation Support
+@Mixins( MailService.MailServiceMixin.class )
+public interface MailService
+{
+    void sendMail( @Email String to, @MinLength( 8 ) String subject, String body );
+    
+    // START SNIPPET: write
+    void changeExternalMailService( String hostName, int port );
+    // END SNIPPET: write
+    
+    public class MailServiceMixin
+        implements MailService
+    {
+        // START SNIPPET: read        
+        @This
+        private Configuration<MailServiceConfiguration> config;
+
+        @Override
+        public void sendMail( @Email String to, @MinLength( 8 ) String subject, String body )
+        {
+            config.refresh();
+            MailServiceConfiguration conf = config.get();
+            String hostName = conf.hostName().get();
+            int port = conf.port().get();
+            // END SNIPPET: read
+
+            // START SNIPPET: read        
+        }
+        // END SNIPPET: read        
+
+        // START SNIPPET: write        
+        @Override
+        public void changeExternalMailService( String hostName, int port )
+        {
+            MailServiceConfiguration conf = config.get();
+            conf.hostName().set( hostName );
+            conf.port().set( port );
+            config.save();
+        }
+        // START SNIPPET: write        
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/configuration/MailServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/configuration/MailServiceConfiguration.java b/core/api/src/test/java/org/qi4j/api/configuration/MailServiceConfiguration.java
new file mode 100644
index 0000000..698fadf
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/configuration/MailServiceConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.configuration;
+
+import org.qi4j.api.property.Property;
+
+// Documentation Support class
+// START SNIPPET: configuration
+public interface MailServiceConfiguration extends ConfigurationComposite
+{
+    Property<String> hostName();
+
+    Property<Integer> port();
+}
+// END SNIPPET: configuration

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java b/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
new file mode 100644
index 0000000..6a6c3b8
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.qi4j.api.dataset.iterable;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.qi4j.api.dataset.DataSet;
+import org.qi4j.api.property.Property;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.functional.Iterables;
+import org.qi4j.test.AbstractQi4jTest;
+
+/**
+ * TODO
+ */
+@Ignore( "Not implemented yet" )
+public class IterableDataSetTest
+    extends AbstractQi4jTest
+{
+    DataSet<TestValue> dataSet;
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.values( TestValue.class );
+    }
+
+    @Before
+    public void setUp()
+    {
+        dataSet = new IterableDataSet<TestValue>( Iterables.iterable( newTestValue( "Rickard" ), newTestValue( "Niclas" ), newTestValue( "Paul" ) ) );
+    }
+
+    private TestValue newTestValue( String name )
+    {
+        return module.newValueFromSerializedState( TestValue.class, "{name:'" + name + "'}" );
+    }
+
+    interface TestValue
+    {
+        Property<String> name();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/docsupport/ApplicationDocs.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/docsupport/ApplicationDocs.java b/core/api/src/test/java/org/qi4j/api/docsupport/ApplicationDocs.java
new file mode 100644
index 0000000..0db8620
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/docsupport/ApplicationDocs.java
@@ -0,0 +1,274 @@
+/*
+ * 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.qi4j.api.docsupport;
+
+import org.qi4j.api.structure.Application;
+import org.qi4j.api.structure.ApplicationDescriptor;
+import org.qi4j.bootstrap.ApplicationAssembler;
+import org.qi4j.bootstrap.ApplicationAssembly;
+import org.qi4j.bootstrap.ApplicationAssemblyFactory;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.Energy4Java;
+import org.qi4j.bootstrap.LayerAssembly;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.SingletonAssembler;
+
+public class ApplicationDocs
+{
+    public static void someMethod( String[] args )
+        throws Exception
+    {
+        {
+// START SNIPPET: application1
+            SingletonAssembler qi4j = new SingletonAssembler()
+            {
+                public void assemble( ModuleAssembly assembly )
+                    throws AssemblyException
+                {
+                    assembly.values( MyStuffValueComposite.class );
+                }
+            };
+// END SNIPPET: application1
+        }
+        {
+            Assembler customerListEditAssembler = new DummyAssembler();
+            Assembler customerEditAssembler = new DummyAssembler();
+            Assembler customerSearchAssembler = new DummyAssembler();
+            Assembler accountsListEditAssembler = new DummyAssembler();
+            Assembler accountsEditAssembler = new DummyAssembler();
+            Assembler accountsSearchAssembler = new DummyAssembler();
+            Assembler customerDomainAssembler = new DummyAssembler();
+            Assembler accountsDomainAssembler = new DummyAssembler();
+// START SNIPPET: application2
+            final Assembler[][][] assemblers =
+                {
+                    { // web layer
+                      { // Customer Module
+                        customerListEditAssembler,
+                        customerEditAssembler,
+                        customerSearchAssembler
+                      },
+                      { // Accounts Module
+                        accountsListEditAssembler,
+                        accountsEditAssembler,
+                        accountsSearchAssembler
+                      }
+                    },
+                    { // domain layer
+                      { // Customer Module
+                        customerDomainAssembler,
+                      },
+                      { // Accounts Module
+                        accountsDomainAssembler,
+                      }
+                    }
+                };
+            Energy4Java qi4j = new Energy4Java();
+            Application app = qi4j.newApplication( new ApplicationAssembler()
+            {
+
+                @Override
+                public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+                    throws AssemblyException
+                {
+                    return applicationFactory.newApplicationAssembly( assemblers );
+                }
+            } );
+            app.activate();
+// END SNIPPET: application2
+        }
+    }
+
+    public interface MyStuffValueComposite
+    {
+    }
+
+    private static class DummyAssembler implements Assembler
+    {
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+
+        }
+    }
+
+    // START SNIPPET: application3
+    private static Energy4Java qi4j;
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        qi4j = new Energy4Java();
+        ApplicationDescriptor model = qi4j.newApplicationModel( new ApplicationAssembler()
+        {
+            @Override
+            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
+                throws AssemblyException
+            {
+                return createAssembly( applicationFactory );
+            }
+        } );
+        Application application = model.newInstance( qi4j.spi() );
+    }
+
+    private static ApplicationAssembly createAssembly( ApplicationAssemblyFactory factory )
+        throws AssemblyException
+    {
+        String applicationName = "Example Application";
+        ApplicationAssembly app = factory.newApplicationAssembly();
+        app.setName( applicationName );
+        LayerAssembly webLayer = createWebLayer( app );
+        LayerAssembly domainLayer = createDomainLayer( app );
+        LayerAssembly infraLayer = createInfrastructureLayer( app );
+        webLayer.uses( domainLayer );
+        webLayer.uses( infraLayer );  // Accesses the WebService
+        domainLayer.uses( infraLayer ); // For persistence
+        return app;
+    }
+
+    private static LayerAssembly createWebLayer(
+        ApplicationAssembly application
+    )
+    {
+        LayerAssembly layer = application.layer( "Web Layer" );
+        createCustomerWebModule( layer );
+        return layer;
+    }
+
+    private static LayerAssembly createDomainLayer(
+        ApplicationAssembly application
+    )
+    {
+        LayerAssembly layer = application.layer( "Domain Layer" );
+        createCustomerDomainModule( layer );
+        // :
+        // :
+        return layer;
+    }
+
+    private static LayerAssembly createInfrastructureLayer(
+        ApplicationAssembly application
+    )
+        throws AssemblyException
+    {
+        LayerAssembly layer = application.layer( "Infrastructure Layer" );
+        createWebServiceModule( layer );
+        createPersistenceModule( layer );
+        return layer;
+    }
+
+    private static void createCustomerWebModule( LayerAssembly layer )
+    {
+        ModuleAssembly assembly = layer.module( "Customer Web Module" );
+        assembly.transients( CustomerViewComposite.class );
+        assembly.transients( CustomerEditComposite.class );
+        assembly.transients( CustomerListViewComposite.class );
+        assembly.transients( CustomerSearchComposite.class );
+    }
+
+    private static void createCustomerDomainModule( LayerAssembly layer )
+    {
+        ModuleAssembly assembly = layer.module( "Customer Domain Module" );
+        assembly.entities( CustomerEntity.class );
+        assembly.entities( CountryEntity.class );
+        assembly.transients( AddressComposite.class );
+    }
+
+    private static void createWebServiceModule( LayerAssembly layer )
+        throws AssemblyException
+    {
+        ModuleAssembly assembly = layer.module( "Web Service Module" );
+        // Someone has created an assembler for a Jetty Web Service.
+        JettyAssembler jetty = new JettyAssembler( 8080 );
+        jetty.assemble( assembly );
+    }
+
+    private static void createPersistenceModule( LayerAssembly layer )
+        throws AssemblyException
+    {
+        ModuleAssembly assembly = layer.module( "Persistence Module" );
+        // Someone has created an assembler for the Neo EntityStore
+        NeoAssembler neo = new NeoAssembler( "./neostore" );
+        neo.assemble( assembly );
+    }
+// START SNIPPET: application3
+
+    public static class CustomerViewComposite
+    {
+
+    }
+    public static class CustomerEditComposite
+    {
+
+    }
+    public static class CustomerListViewComposite
+    {
+
+    }
+    public static class CustomerSearchComposite
+    {
+
+    }
+
+
+    public static class CustomerEntity
+    {
+
+    }
+    public static class CountryEntity
+    {
+
+    }
+    public static class AddressComposite
+    {
+
+    }
+
+    public static class JettyAssembler
+        implements Assembler
+    {
+
+        public JettyAssembler( int port )
+        {
+        }
+
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+        }
+    }
+    public static class NeoAssembler
+        implements Assembler
+    {
+
+        public NeoAssembler( String s )
+        {
+        }
+
+        @Override
+        public void assemble( ModuleAssembly module )
+            throws AssemblyException
+        {
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/docsupport/CompositionDocs.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/docsupport/CompositionDocs.java b/core/api/src/test/java/org/qi4j/api/docsupport/CompositionDocs.java
new file mode 100644
index 0000000..a6a366c
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/docsupport/CompositionDocs.java
@@ -0,0 +1,56 @@
+/*
+ * 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.qi4j.api.docsupport;
+
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+public class CompositionDocs
+{
+// START SNIPPET: comp1
+    @Mixins( { BalanceCheckMixin.class } )
+    public interface BankAccount
+    {
+        Money checkBalance();
+// END SNIPPET: comp1
+// START SNIPPET: comp1
+    }
+// END SNIPPET: comp1
+
+// START SNIPPET: comp2
+    public void assemble( ModuleAssembly module )
+    {
+        module.entities( BankAccount.class );
+    }
+// END SNIPPET: comp2
+
+    public static class BalanceCheckMixin
+        implements BankAccount
+    {
+        @Override
+        public Money checkBalance()
+        {
+            return null;
+        }
+    }
+
+    public static class Money
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/docsupport/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/docsupport/package.html b/core/api/src/test/java/org/qi4j/api/docsupport/package.html
new file mode 100644
index 0000000..f6fa115
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/docsupport/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+<body>
+This package exists to contain snippets for documentation.
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/injection/scope/StateFieldTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/injection/scope/StateFieldTest.java b/core/api/src/test/java/org/qi4j/api/injection/scope/StateFieldTest.java
new file mode 100644
index 0000000..38dcc52
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/injection/scope/StateFieldTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.injection.scope;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.qi4j.api.association.Association;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+
+/**
+ * Define a field to be a Property
+ */
+public class StateFieldTest
+    extends AbstractQi4jTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( PersonEntity.class );
+    }
+
+    @Test
+    public void givenEntityWithFieldPropertiesWhenUpdatedThenReturnCorrect()
+        throws Exception
+    {
+        UnitOfWork unitOfWork = module.newUnitOfWork();
+        try
+        {
+            PersonEntity charles = unitOfWork.newEntity( PersonEntity.class );
+            charles.changeName( "Charles" );
+            Assert.assertEquals( charles.getName(), "Charles" );
+
+            PersonEntity daniel = unitOfWork.newEntity( PersonEntity.class );
+            daniel.changeName( "Daniel" );
+            Assert.assertEquals( daniel.getName(), "Daniel" );
+
+            PersonEntity lisa = unitOfWork.newEntity( PersonEntity.class );
+            lisa.changeName( "Lisa" );
+            Assert.assertEquals( lisa.getName(), "Lisa" );
+
+            charles.befriend( daniel );
+            charles.befriend( lisa );
+            charles.marry( lisa );
+
+            unitOfWork.complete();
+
+            unitOfWork = module.newUnitOfWork();
+
+            charles = unitOfWork.get( charles );
+            daniel = unitOfWork.get( daniel );
+            Assert.assertTrue( charles.isFriend( daniel ) );
+
+            unitOfWork.complete();
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+    }
+
+    @Mixins( PersonEntity.Mixin.class )
+    public interface PersonEntity
+        extends EntityComposite
+    {
+        void changeName( String newName );
+
+        void marry( PersonEntity entity );
+
+        void befriend( PersonEntity entity );
+
+        boolean isFriend( PersonEntity entity );
+
+        String getName();
+
+        abstract class Mixin
+            implements PersonEntity
+        {
+            @State
+            @UseDefaults
+            public Property<String> name;
+
+            @State
+            @Optional
+            public Association<PersonEntity> spouse;
+
+            @State
+            public ManyAssociation<PersonEntity> friends;
+
+            @Override
+            public void changeName( String newName )
+            {
+                name.set( newName );
+            }
+
+            @Override
+            public void marry( PersonEntity entity )
+            {
+                spouse.set( entity );
+            }
+
+            @Override
+            public void befriend( PersonEntity entity )
+            {
+                friends.add( entity );
+            }
+
+            @Override
+            public String getName()
+            {
+                return name.get();
+            }
+
+            @Override
+            public boolean isFriend( PersonEntity entity )
+            {
+                return friends.contains( entity );
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/injection/scope/ThisTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/injection/scope/ThisTest.java b/core/api/src/test/java/org/qi4j/api/injection/scope/ThisTest.java
new file mode 100644
index 0000000..cae4e3b
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/injection/scope/ThisTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 Alin Dreghiciu. 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.qi4j.api.injection.scope;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+import org.qi4j.api.common.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by This annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class ThisTest
+{
+
+    @Test
+    public void retention()
+        throws NoSuchFieldException
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredField( "uses" ).getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", This.class, annotations[ 0 ].annotationType() );
+    }
+
+    private static class Annotated
+    {
+        @This
+        String uses;
+        @Optional
+        @This
+        String usesOptional;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/metrics/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/metrics/DocumentationSupport.java b/core/api/src/test/java/org/qi4j/api/metrics/DocumentationSupport.java
new file mode 100644
index 0000000..4d9a139
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/metrics/DocumentationSupport.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2012, Niclas Hedhman. 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.qi4j.api.metrics;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import org.qi4j.api.injection.scope.Service;
+
+public class DocumentationSupport
+{
+    // START SNIPPET: common
+    @Service
+    private MetricsProvider provider;
+    // END SNIPPET: common
+
+    public void forDocumentationOnly()
+    {
+        // START SNIPPET: gauge
+        final BlockingQueue queue = new LinkedBlockingQueue( 20 );
+        // END SNIPPET: gauge
+        // START SNIPPET: gauge
+        MetricsGaugeFactory gaugeFactory = provider.createFactory( MetricsGaugeFactory.class );
+        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( getClass(), "Sample Gauge", new MetricsGauge<Integer>()
+        {
+            @Override
+            public Integer value()
+            {
+                return queue.size();
+            }
+        } );
+        // END SNIPPET: gauge
+
+        // START SNIPPET: counter
+        MetricsCounterFactory counterFactory = provider.createFactory( MetricsCounterFactory.class );
+        MetricsCounter counter = counterFactory.createCounter( getClass(), "Sample Counter" );
+        // END SNIPPET: counter
+
+        // START SNIPPET: histogram
+        MetricsHistogramFactory histoFactory = provider.createFactory( MetricsHistogramFactory.class );
+        MetricsHistogram histogram = histoFactory.createHistogram( getClass(), "Sample Histogram" );
+        // END SNIPPET: histogram
+
+        // START SNIPPET: meter
+        MetricsMeterFactory meterFactory = provider.createFactory( MetricsMeterFactory.class );
+        MetricsMeter meter = meterFactory.createMeter( getClass(), "Sample Meter", "requests", TimeUnit.MINUTES );
+        // END SNIPPET: meter
+
+        // START SNIPPET: timer
+        MetricsTimerFactory timerFactory = provider.createFactory( MetricsTimerFactory.class );
+        MetricsTimer timer = timerFactory.createTimer( getClass(), "Sample Timer", TimeUnit.SECONDS, TimeUnit.HOURS );
+        // END SNIPPET: timer
+
+        // START SNIPPET: healthcheck
+        MetricsHealthCheckFactory healthFactory = provider.createFactory( MetricsHealthCheckFactory.class );
+        MetricsHealthCheck healthCheck = healthFactory.registerHealthCheck(
+            getClass(),
+            "Sample Healthcheck",
+            new MetricsHealthCheck()
+            {
+                @Override
+                public Result check()
+                    throws Exception
+                {
+                    ServiceStatus status = pingMyService();
+                    return new Result( status.isOk(), status.getErrorMessage(), status.getException() );
+                }
+            } );
+        // END SNIPPET: healthcheck
+
+    }
+
+    private ServiceStatus pingMyService()
+    {
+        return new ServiceStatus();
+    }
+
+    private static class ServiceStatus
+    {
+        String errorMessage;
+        Exception exception;
+
+        public String getErrorMessage()
+        {
+            return errorMessage;
+        }
+
+        public Exception getException()
+        {
+            return exception;
+        }
+
+        public boolean isOk()
+        {
+            return errorMessage.equals( "OK" );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/BankAccount.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/BankAccount.java b/core/api/src/test/java/org/qi4j/api/mixin/BankAccount.java
new file mode 100644
index 0000000..218a79c
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/BankAccount.java
@@ -0,0 +1,30 @@
+/*
+ * 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.qi4j.api.mixin;
+
+
+// START SNIPPET: mixinType
+public interface BankAccount
+{
+    Money checkBalance();
+}
+// END SNIPPET: mixinType
+
+class Money {}
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/test/java/org/qi4j/api/mixin/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/mixin/Car.java b/core/api/src/test/java/org/qi4j/api/mixin/Car.java
new file mode 100644
index 0000000..434952b
--- /dev/null
+++ b/core/api/src/test/java/org/qi4j/api/mixin/Car.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.qi4j.api.mixin;
+
+// START SNIPPET: mixins
+@Mixins( { StartMixin.class, VehicleMixin.class } )
+public interface Car extends Startable, Vehicle
+{}
+// END SNIPPET: mixins
+


[42/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
deleted file mode 100644
index 47fa360..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Copyright (c) 2007-2011, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007-2012, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2013-2015, Paul Merlin. 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.zest.api.unitofwork;
-
-import java.util.Map;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.composite.AmbiguousTypeException;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.LifecycleException;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.functional.Function;
-
-/**
- * All operations on entities goes through an UnitOfWork.
- * <p>
- * A UnitOfWork allows you to access
- * Entities and work with them. All modifications to Entities are recorded by the UnitOfWork,
- * and at the end they may be sent to the underlying EntityStore by calling complete(). If the
- * UoW was read-only you may instead simply discard() it.
- * </p>
- * <p>
- * A UoW differs from a traditional Transaction in the sense that it is not tied at all to the underlying
- * storage resource. Because of this there is no timeout on a UoW. It can be very short or very long.
- * Another difference is that if a call to complete() fails, and the cause is validation errors in the
- * Entities of the UoW, then these can be corrected and the UoW retried. By contrast, when a Transaction
- * commit fails, then the whole transaction has to be done from the beginning again.
- * </p>
- * <p>
- * A UoW can be associated with a Usecase. A Usecase describes the metainformation about the process
- * to be performed by the UoW.
- * </p>
- * <p>
- * If a code block that uses a UoW throws an exception you need to ensure that this is handled properly,
- * and that the UoW is closed before returning. Because discard() is a no-op if the UoW is closed, we therefore
- * recommend the following template to be used:
- * </p>
- * <pre>
- *     UnitOfWork uow = module.newUnitOfWork();
- *     try
- *     {
- *         ...
- *         uow.complete();
- *     }
- *     finally
- *     {
- *         uow.discard();
- *     }
- * </pre>
- * <p>
- * This ensures that in the happy case the UoW is completed, and if any exception is thrown the UoW is discarded. After
- * the UoW has completed the discard() method doesn't do anything, and so has no effect. You can choose to either add
- * catch blocks for any exceptions, including exceptions from complete(), or skip them.
- * </p>
- * <p>
- * Since 2.1 you can leverage Java 7 Automatic Resource Management (ie. Try With Resources) and use the following
- * template instead:
- * </p>
- * <pre>
- *     try( UnitOfWork uow = module.newUnitOfWork() )
- *     {
- *         ...
- *         uow.complete();
- *     }
- * </pre>
- * <p>
- * It has the very same effect than the template above but is shorter.</p>
- */
-public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
-{
-
-    /**
-     * Get the UnitOfWorkFactory that this UnitOfWork was created from.
-     *
-     * @return The UnitOfWorkFactory instance that was used to create this UnitOfWork.
-     */
-    UnitOfWorkFactory unitOfWorkFactory();
-
-    long currentTime();
-
-    /**
-     * Get the Usecase for this UnitOfWork
-     *
-     * @return the Usecase
-     */
-    Usecase usecase();
-
-    void setMetaInfo( Object metaInfo );
-
-    <T> Query<T> newQuery( QueryBuilder<T> queryBuilder );
-
-//    DataSet newDataSetBuilder(Specification<?>... constraints);
-
-    /**
-     * Create a new Entity which implements the given mixin type.
-     * <p>
-     * An EntityComposite
-     * will be chosen according to what has been registered and the visibility rules
-     * for Modules and Layers will be considered. If several
-     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
-     * </p>
-     * <p>
-     * The identity of the Entity will be generated by the IdentityGenerator of the Module of the EntityComposite.
-     * </p>
-     *
-     * @param type the mixin type that the EntityComposite must implement
-     *
-     * @return a new Entity
-     *
-     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     * @throws LifecycleException          if the entity cannot be created
-     */
-    <T> T newEntity( Class<T> type )
-        throws EntityTypeNotFoundException, AmbiguousTypeException, LifecycleException;
-
-    /**
-     * Create a new Entity which implements the given mixin type. An EntityComposite
-     * will be chosen according to what has been registered and the visibility rules
-     * for Modules and Layers will be considered. If several
-     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
-     *
-     * @param type     the mixin type that the EntityComposite must implement
-     * @param identity the identity of the new Entity
-     *
-     * @return a new Entity
-     *
-     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     * @throws LifecycleException          if the entity cannot be created
-     */
-    <T> T newEntity( Class<T> type, String identity )
-        throws EntityTypeNotFoundException, AmbiguousTypeException, LifecycleException;
-
-    /**
-     * Create a new EntityBuilder for an EntityComposite which implements the given mixin type. An EntityComposite
-     * will be chosen according to what has been registered and the visibility rules
-     * for Modules and Layers will be considered. If several
-     * EntityComposites implement the type then an AmbiguousTypeException will be thrown.
-     *
-     * @param type the mixin type that the EntityComposite must implement
-     *
-     * @return a new EntityBuilder
-     *
-     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     */
-    <T> EntityBuilder<T> newEntityBuilder( Class<T> type )
-        throws EntityTypeNotFoundException, AmbiguousTypeException;
-
-    /**
-     * Create a new EntityBuilder for an EntityComposite which implements the given mixin type. An EntityComposite
-     * will be chosen according to what has been registered and the visibility rules
-     * for Modules and Layers will be considered. If several
-     * mixins implement the type then an AmbiguousTypeException will be thrown.
-     *
-     * @param type     the mixin type that the EntityComposite must implement
-     * @param identity the identity of the new Entity
-     *
-     * @return a new EntityBuilder
-     *
-     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     */
-    <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
-        throws EntityTypeNotFoundException, AmbiguousTypeException;
-
-    /**
-     * Create a new EntityBuilder for an EntityComposite wich implements the given mixin type starting with the given
-     * state.
-     * <p>
-     * An EntityComposite will be chosen according to what has been registered and the visibility rules for Modules and
-     * Layers will be considered.
-     *
-     * @param <T>                      Entity type
-     * @param type                     Entity type
-     * @param propertyFunction         a function providing the state of properties
-     * @param associationFunction      a function providing the state of associations
-     * @param manyAssociationFunction  a function providing the state of many associations
-     * @param namedAssociationFunction a function providing the state of named associations
-     *
-     * @return a new EntityBuilder starting with the given state
-     *
-     * @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     */
-    <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type,
-                                                    Function<PropertyDescriptor, Object> propertyFunction,
-                                                    Function<AssociationDescriptor, EntityReference> associationFunction,
-                                                    Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-                                                    Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
-        throws EntityTypeNotFoundException, AmbiguousTypeException;
-
-    /**
-     * Create a new EntityBuilder for an EntityComposite wich implements the given mixin type starting with the given
-     * state.
-     * <p>
-     * An EntityComposite will be chosen according to what has been registered and the visibility rules for Modules and
-     * Layers will be considered.
-     *
-     * @param <T>                      Entity type
-     * @param type                     Entity type
-     * @param identity                 the identity of the new Entity
-     * @param propertyFunction         a function providing the state of properties
-     * @param associationFunction      a function providing the state of associations
-     * @param manyAssociationFunction  a function providing the state of many associations
-     * @param namedAssociationFunction a function providing the state of named associations
-     *
-     * @return a new EntityBuilder starting with the given state
-     *
-     * @throws EntityTypeNotFoundException If no mixins implements the given type
-     * @throws AmbiguousTypeException      If several mixins implement the given type
-     */
-    <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type, String identity,
-                                                    Function<PropertyDescriptor, Object> propertyFunction,
-                                                    Function<AssociationDescriptor, EntityReference> associationFunction,
-                                                    Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
-                                                    Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
-        throws EntityTypeNotFoundException, AmbiguousTypeException;
-
-    /**
-     * Find an Entity of the given mixin type with the give identity. This
-     * method verifies that it exists by asking the underlying EntityStore.
-     *
-     * @param type     of the entity
-     * @param identity of the entity
-     *
-     * @return the entity
-     *
-     * @throws EntityTypeNotFoundException if no entity type could be found
-     * @throws NoSuchEntityException       if the entity could not be found
-     */
-    <T> T get( Class<T> type, String identity )
-        throws EntityTypeNotFoundException, NoSuchEntityException;
-
-    /**
-     * If you have a reference to an Entity from another
-     * UnitOfWork and want to create a reference to it in this
-     * UnitOfWork, then call this method.
-     *
-     * @param entity the Entity to be dereferenced
-     *
-     * @return an Entity from this UnitOfWork
-     *
-     * @throws EntityTypeNotFoundException if no entity type could be found
-     */
-    <T> T get( T entity )
-        throws EntityTypeNotFoundException;
-
-    /**
-     * Remove the given Entity.
-     *
-     * @param entity the Entity to be removed.
-     *
-     * @throws LifecycleException if the entity could not be removed
-     */
-    void remove( Object entity )
-        throws LifecycleException;
-
-    /**
-     * Complete this UnitOfWork. This will send all the changes down to the underlying
-     * EntityStore's.
-     *
-     * @throws UnitOfWorkCompletionException         if the UnitOfWork could not be completed
-     * @throws ConcurrentEntityModificationException if entities have been modified by others
-     */
-    void complete()
-        throws UnitOfWorkCompletionException, ConcurrentEntityModificationException;
-
-    /**
-     * Discard this UnitOfWork. Use this if a failure occurs that you cannot handle,
-     * or if the usecase was of a read-only character. This is a no-op of the UnitOfWork
-     * is already closed.
-     */
-    void discard();
-
-    /**
-     * Discard this UnitOfWork. Use this if a failure occurs that you cannot handle,
-     * or if the usecase was of a read-only character. This is a no-op of the UnitOfWork
-     * is already closed. This simply call the {@link #discard()} method and is an
-     * implementation of the {@link AutoCloseable} interface providing Try With Resources
-     * support for UnitOfWork.
-     */
-    @Override
-    public void close();
-
-    /**
-     * Check if the UnitOfWork is open. It is closed after either complete() or discard()
-     * methods have been called successfully.
-     *
-     * @return true if the UnitOfWork is open.
-     */
-    boolean isOpen();
-
-    /**
-     * Check if the UnitOfWork is paused. It is not paused after it has been create through the
-     * UnitOfWorkFactory, and it can be paused by calling {@link #pause()} and then resumed by calling
-     * {@link #resume()}.
-     *
-     * @return true if this UnitOfWork has been paused.
-     */
-    boolean isPaused();
-
-    /**
-     * Pauses this UnitOfWork.
-     * <p>
-     * Calling this method will cause the underlying UnitOfWork to become the current UnitOfWork until the
-     * the resume() method is called. It is the client's responsibility not to drop the reference to this
-     * UnitOfWork while being paused.
-     * </p>
-     */
-    void pause();
-
-    /**
-     * Resumes this UnitOfWork to again become the current UnitOfWork.
-     */
-    void resume();
-
-    /**
-     * Register a callback. Callbacks are invoked when the UnitOfWork
-     * is completed or discarded.
-     *
-     * @param callback a callback to be registered with this UnitOfWork
-     */
-    void addUnitOfWorkCallback( UnitOfWorkCallback callback );
-
-    /**
-     * Unregister a callback. Callbacks are invoked when the UnitOfWork
-     * is completed or discarded.
-     *
-     * @param callback a callback to be unregistered with this UnitOfWork
-     */
-    void removeUnitOfWorkCallback( UnitOfWorkCallback callback );
-
-    /**
-     * Converts the provided Entity to a Value of the same type.
-     * This is a convenience method to convert an EntityComposite to a ValueComposite.
-     * <p>
-     * All Property values are transferred across as-is, and the Association, ManyAssociation
-     * and NamedAssociatino values are kept in the ValueComposite as EntityReferences
-     * until they are dereferenced (get() and other methods), and IF a UnitOfWork is
-     * present at dereferencing the corresponding EntityCompoiste is retrieved from the
-     * EntityStore. If there is not an UnitOfWork present, an exception is thrown.
-     * </p>
-     * <p>
-     * For this to work, the Composites (both Entity and Value) must not declare the
-     * EntityComposite and ValueComposite super types, but rely on the declaration in
-     * the assembly, and also extend the Identity supertype.
-     * </p>
-     * Example;
-     * <pre><code>
-     *     public interface Person extends Identity { ... };
-     *     public class MyAssembler
-     *     {
-     *         public void assemble( ModuleAssembly module )
-     *         {
-     *             module.values( Person.class );
-     *             module.entities( Person.class );
-     *         }
-     *     }
-     * </code></pre>
-     *
-     * @param primaryType The shared type for which the properties and associations will
-     *                    be converted. Properties outside this type will be ignored.
-     * @param entityComposite The entity to be convered.
-     */
-    <T extends Identity> T toValue( Class<T> primaryType, T entityComposite );
-
-    /**
-     * Converts the provided Value to an Entity of the same type.
-     * This is a convenience method to convert a ValueComposite to an EntityComposite.
-     * <p>
-     * All Property values are transferred across as-is (no deep copy in case mutable
-     * types (DISCOURAGED!) are used), and the Association, ManyAssociation
-     * and NamedAssociatino that were in the ValueComposite as EntityReferences are
-     * transferred into the EntityComposite correctly, and can be dereferenced.
-     * </p>
-     * <p>
-     * This method MUST be called within a UnitOfWork.
-     * </p>
-     * <p>
-     * If an Entity with the Identity in the ValueComposite already exists, then that
-     * Entity is updated with the values from the ValueComposite. If an Entity of
-     * that Identity doesn't exist and new one is created.
-     * </p>
-     * <p>
-     * For this to work, the Composites (both Entity and Value) must not declare the
-     * EntityComposite and ValueComposite super types, but rely on the declaration in
-     * the assembly, and also extend the Identity supertype.
-     * </p>
-     * Example;
-     * <pre><code>
-     *     public interface Person extends Identity { ... };
-     *     public class MyAssembler
-     *     {
-     *         public void assemble( ModuleAssembly module )
-     *         {
-     *             module.values( Person.class );
-     *             module.entities( Person.class );
-     *         }
-     *     }
-     * </code></pre>
-     *
-     * @param primaryType The shared type for which the properties and associations will
-     *                    be converted. Properties outside this type will be ignored.
-     * @param valueComposite The Value to be convered into an Entity.
-     */
-    <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite );
-
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCallback.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCallback.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCallback.java
deleted file mode 100644
index af0f987..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCallback.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.unitofwork;
-
-/**
- * Callback interface for UnitOfWork completion or discard. Implementations
- * of this interface can be registered through {@link UnitOfWork#addUnitOfWorkCallback(UnitOfWorkCallback)}.
- *
- * If Entities implement this interface they will also receive invocations of this callback interface.
- */
-public interface UnitOfWorkCallback
-{
-    /**
-     * This is called before the completion of the UnitOfWork.
-     * The callback may do any validation checks and throw
-     * UnitOfWorkCompletionException if there is any reason
-     * why the UnitOfWork is not in a valid state to be completed.
-     *
-     * @throws UnitOfWorkCompletionException
-     */
-    void beforeCompletion()
-        throws UnitOfWorkCompletionException;
-
-    /**
-     * This is called after the completion or discarding
-     * of the UnitOfWork. The callback may do any cleanup
-     * necessary related to the UnitOfWork. Note that the
-     * UnitOfWork is no longer active when this method is
-     * called, so no methods on it may be invoked.
-     *
-     * @param status
-     */
-    void afterCompletion( UnitOfWorkStatus status );
-
-    enum UnitOfWorkStatus
-    {
-        COMPLETED, DISCARDED
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
deleted file mode 100644
index 092fc62..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkCompletionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. 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.zest.api.unitofwork;
-
-/**
- * When an attempt to {@link UnitOfWork#complete()} an UnitOfWork
- * fails, this exception will be thrown.
- */
-public class UnitOfWorkCompletionException
-    extends Exception
-{
-    private static final long serialVersionUID = 6531642131384516904L;
-
-    public UnitOfWorkCompletionException()
-    {
-    }
-
-    public UnitOfWorkCompletionException( String string )
-    {
-        super( string );
-    }
-
-    public UnitOfWorkCompletionException( String string, Throwable throwable )
-    {
-        super( string, throwable );
-    }
-
-    public UnitOfWorkCompletionException( Throwable throwable )
-    {
-        super( throwable );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkException.java
deleted file mode 100644
index 4cc5c9f..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*  Copyright 2007 Niclas Hedhman.
- *
- * 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.zest.api.unitofwork;
-
-/**
- * Base Exception for UnitOfWork related concerns.
- */
-public class UnitOfWorkException
-    extends RuntimeException
-{
-    private static final long serialVersionUID = -8544178439804058558L;
-
-    public UnitOfWorkException()
-    {
-    }
-
-    public UnitOfWorkException( String message )
-    {
-        super( message );
-    }
-
-    public UnitOfWorkException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    public UnitOfWorkException( Throwable cause )
-    {
-        super( cause );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
deleted file mode 100644
index 0f3bcb4..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. 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.zest.api.unitofwork;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.usecase.Usecase;
-
-/**
- * Factory for UnitOfWork.
- */
-public interface UnitOfWorkFactory
-{
-    /**
-     * Create a new UnitOfWork and associate it with the current thread.
-     * <p>
-     * The UnitOfWork will use the default Usecase settings.
-     * </p>
-     * <p>
-     * Current time will be set to System.currentTimeMillis();
-     * </p>
-     * @return a new UnitOfWork
-     */
-    UnitOfWork newUnitOfWork();
-
-    /**
-     * Create a new UnitOfWork and associate it with the current thread.
-     * <p>
-     * The UnitOfWork will use the default Usecase settings.
-     * </p>
-     * @return a new UnitOfWork
-     */
-    UnitOfWork newUnitOfWork( long currentTime );
-
-    /**
-     * Create a new UnitOfWork for the given Usecase and associate it with the current thread.
-     * <p>
-     * Current time will be set to System.currentTimeMillis();
-     * </p>
-     * @param usecase the Usecase for this UnitOfWork
-     *
-     * @return a new UnitOfWork
-     */
-    UnitOfWork newUnitOfWork( Usecase usecase );
-
-    /**
-     * Create a new UnitOfWork for the given Usecase and associate it with the current thread.
-     *
-     * @param usecase the Usecase for this UnitOfWork
-     *
-     * @return a new UnitOfWork
-     */
-    UnitOfWork newUnitOfWork( Usecase usecase, long currentTime );
-
-    /**
-     * @return true if there is an active UnitOfWork associated with the executing thread
-     */
-    boolean isUnitOfWorkActive();
-
-    /**
-     * Returns the UnitOfWork that is currently associated with the executing thread.
-     *
-     * @return The current UnitOfWork associated with the executing thread
-     *
-     * @throws IllegalStateException if no current UnitOfWork is active
-     */
-    UnitOfWork currentUnitOfWork()
-        throws IllegalStateException;
-
-    /**
-     * Returns the UnitOfWork that the EntityComposite is bound to.
-     *
-     * @param entity the entity to be checked.
-     *
-     * @return The UnitOfWork instance that the Entity is bound to, or null if the entity is not associated with
-     *         any UnitOfWork.
-     */
-    UnitOfWork getUnitOfWork( EntityComposite entity );
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkOptions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkOptions.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkOptions.java
deleted file mode 100644
index 176d9a0..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkOptions.java
+++ /dev/null
@@ -1,43 +0,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.
- */
-package org.apache.zest.api.unitofwork;
-
-/**
- * Set instances of this in MetaInfo on UnitOfWork or the associated Usecase.
- *  <p>
- * Options:
- *  </p>
- * <p>
- * "pruneOnPause": if true, then clear out all instances that have been loaded in the UoW but not modified
- * </p>
- */
-public class UnitOfWorkOptions
-{
-    private boolean pruneOnPause = false;
-
-    public UnitOfWorkOptions( boolean pruneOnPause )
-    {
-        this.pruneOnPause = pruneOnPause;
-    }
-
-    public boolean isPruneOnPause()
-    {
-        return pruneOnPause;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
deleted file mode 100644
index cd91cb9..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
+++ /dev/null
@@ -1,93 +0,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.
- */
-package org.apache.zest.api.unitofwork;
-
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.usecase.Usecase;
-
-/**
- * UnitOfWork Template.
- */
-public abstract class UnitOfWorkTemplate<RESULT, ThrowableType extends Throwable>
-{
-    private Usecase usecase = Usecase.DEFAULT;
-    private int retries = 10;
-    private boolean complete = true;
-
-    protected UnitOfWorkTemplate()
-    {
-    }
-
-    protected UnitOfWorkTemplate( int retries, boolean complete )
-    {
-        this.retries = retries;
-        this.complete = complete;
-    }
-
-    protected UnitOfWorkTemplate( Usecase usecase, int retries, boolean complete )
-    {
-        this.usecase = usecase;
-        this.retries = retries;
-        this.complete = complete;
-    }
-
-    protected abstract RESULT withUnitOfWork( UnitOfWork uow )
-        throws ThrowableType;
-
-    @SuppressWarnings( "unchecked" )
-    public RESULT withModule( Module module )
-        throws ThrowableType, UnitOfWorkCompletionException
-    {
-        int loop = 0;
-        ThrowableType ex = null;
-        do
-        {
-            UnitOfWork uow = module.newUnitOfWork( usecase );
-
-            try
-            {
-                RESULT result = withUnitOfWork( uow );
-                if( complete )
-                {
-                    try
-                    {
-                        uow.complete();
-                        return result;
-                    }
-                    catch( ConcurrentEntityModificationException e )
-                    {
-                        // Retry?
-                        ex = (ThrowableType) e;
-                    }
-                }
-            }
-            catch( Throwable e )
-            {
-                ex = (ThrowableType) e;
-            }
-            finally
-            {
-                uow.discard();
-            }
-        }
-        while( loop++ < retries );
-
-        throw ex;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
deleted file mode 100644
index 9891b36..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*  Copyright 2008 Edward Yakop.
- *  Copyright 2009 Niclas Hedhman.
- *
- * 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.zest.api.unitofwork.concern;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.concern.GenericConcern;
-import org.apache.zest.api.injection.scope.Invocation;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-
-/**
- * {@code UnitOfWorkConcern} manages the unit of work complete, discard and retry policy.
- *
- * @see UnitOfWorkPropagation
- * @see UnitOfWorkDiscardOn
- */
-@AppliesTo( UnitOfWorkPropagation.class )
-public class UnitOfWorkConcern
-    extends GenericConcern
-{
-    private static final Class<?>[] DEFAULT_DISCARD_CLASSES = new Class[]{ Throwable.class };
-
-    @Structure
-    Module module;
-
-    @Invocation
-    UnitOfWorkPropagation propagation;
-
-    /**
-     * Handles method with {@code UnitOfWorkPropagation} annotation.
-     *
-     * @param proxy  The object.
-     * @param method The invoked method.
-     * @param args   The method arguments.
-     *
-     * @return The returned value of method invocation.
-     *
-     * @throws Throwable Thrown if the method invocation throw exception.
-     */
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        UnitOfWorkPropagation.Propagation propagationPolicy = propagation.value();
-        if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRED )
-        {
-            if( module.isUnitOfWorkActive() )
-            {
-                return next.invoke( proxy, method, args );
-            }
-            else
-            {
-                Usecase usecase = usecase();
-                return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
-            }
-        }
-        else if( propagationPolicy == UnitOfWorkPropagation.Propagation.MANDATORY )
-        {
-            if( !module.isUnitOfWorkActive() )
-            {
-                throw new IllegalStateException( "UnitOfWork was required but there is no available unit of work." );
-            }
-        }
-        else if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRES_NEW )
-        {
-            Usecase usecase = usecase();
-            return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
-        }
-        return next.invoke( proxy, method, args );
-    }
-
-    private Usecase usecase()
-    {
-        String usecaseName = propagation.usecase();
-        Usecase usecase;
-        if( usecaseName == null )
-        {
-            usecase = Usecase.DEFAULT;
-        }
-        else
-        {
-            usecase = UsecaseBuilder.newUsecase( usecaseName );
-        }
-        return usecase;
-    }
-
-    protected Object invokeWithCommit( Object proxy, Method method, Object[] args, UnitOfWork currentUnitOfWork )
-        throws Throwable
-    {
-        try
-        {
-            UnitOfWorkRetry retryAnnot = method.getAnnotation( UnitOfWorkRetry.class );
-            int maxTries = 0;
-            long delayFactor = 0;
-            long initialDelay = 0;
-            if( retryAnnot != null )
-            {
-                maxTries = retryAnnot.retries();
-                initialDelay = retryAnnot.initialDelay();
-                delayFactor = retryAnnot.delayFactory();
-            }
-            int retry = 0;
-            while( true )
-            {
-                Object result = next.invoke( proxy, method, args );
-                try
-                {
-                    currentUnitOfWork.complete();
-                    return result;
-                }
-                catch( ConcurrentEntityModificationException e )
-                {
-                    if( retry >= maxTries )
-                    {
-                        throw e;
-                    }
-                    module.currentUnitOfWork().discard();
-                    Thread.sleep( initialDelay + retry * delayFactor );
-                    retry++;
-                    currentUnitOfWork = module.newUnitOfWork( usecase() );
-                }
-            }
-        }
-        catch( Throwable throwable )
-        {
-            // Discard only if this concern create a unit of work
-            discardIfRequired( method, currentUnitOfWork, throwable );
-            throw throwable;
-        }
-    }
-
-    /**
-     * Discard unit of work if the discard policy match.
-     *
-     * @param aMethod     The invoked method. This argument must not be {@code null}.
-     * @param aUnitOfWork The current unit of work. This argument must not be {@code null}.
-     * @param aThrowable  The exception thrown. This argument must not be {@code null}.
-     */
-    protected void discardIfRequired( Method aMethod, UnitOfWork aUnitOfWork, Throwable aThrowable )
-    {
-        UnitOfWorkDiscardOn discardPolicy = aMethod.getAnnotation( UnitOfWorkDiscardOn.class );
-        Class<?>[] discardClasses;
-        if( discardPolicy != null )
-        {
-            discardClasses = discardPolicy.value();
-        }
-        else
-        {
-            discardClasses = DEFAULT_DISCARD_CLASSES;
-        }
-
-        Class<? extends Throwable> aThrowableClass = aThrowable.getClass();
-        for( Class<?> discardClass : discardClasses )
-        {
-            if( discardClass.isAssignableFrom( aThrowableClass ) )
-            {
-                aUnitOfWork.discard();
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkDiscardOn.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkDiscardOn.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkDiscardOn.java
deleted file mode 100644
index 566ddef..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkDiscardOn.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2008, Edward Yakop. 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.zest.api.unitofwork.concern;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Annotation to denote the unit of work discard policy.
- * <p>
- * By default, discard is applied on any method that has {@link UnitOfWorkPropagation} and any exception is thrown.
- * </p>
- * <p>
- * Apply {@code UnitOfWorkDiscardOn} to override the default settings.
- * </p>
- * <p>
- * Usage example:
- * </p>
- * <pre>
- * <code>
- *
- * &#64;Concerns( UnitOfWorkConcern.class )
- * public class MyBusinessServiceMixin implements BusinessService
- * {
- *   &#64;Structure UnitOfWorkFactory uowf;
- *
- *   &#64;UnitOfWorkDiscardOn( MyBusinessException.class )
- *   public void myBusinessMethod()
- *   {
- *     // Must invoke current unit of work.
- *     UnitOfWork uow = uowf.currentUnitOfWork();
- *
- *     // Perform business logic
- *   }
- * }
- * </code>
- * </pre>
- *
- * <p>
- * The unit of work will be discarded iff {@code MyBusinessException} exceptions or its subclass is thrown from within
- * {@code myBusinessMethod} method.
- * </p>
- */
-@Retention( RUNTIME )
-@Target( METHOD )
-@Inherited
-@Documented
-public @interface UnitOfWorkDiscardOn
-{
-    Class<? extends Throwable>[] value() default { Throwable.class };
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkPropagation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkPropagation.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkPropagation.java
deleted file mode 100644
index 3c0f23e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkPropagation.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2008, Edward Yakop. All Rights Reserved.
- * Copyright (c) 2009, Niclas Hedhman. 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.zest.api.unitofwork.concern;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Annotation to denote the unit of work propagation.
- * <p>
- * Usage example:
- * </p>
- * <pre>
- * <code>
- *
- * &#64;Concerns( UnitOfWorkConcern.class )
- * public class MyBusinessServiceMixin implements BusinessService
- * {
- *   &#64;Structure UnitOfWorkFactory uowf;
- *
- *   &#64;UnitOfWorkPropagation
- *   public void myBusinessMethod()
- *   {
- *     // Must invoke current unit of work.
- *     UnitOfWork uow = uowf.currentUnitOfWork();
- *
- *     // Perform business logic
- *   }
- * }
- * </code>
- * </pre>
- */
-@Retention( RUNTIME )
-@Target( METHOD )
-@Inherited
-@Documented
-public @interface UnitOfWorkPropagation
-{
-    Propagation value() default Propagation.REQUIRED;
-
-    String usecase() default "";
-
-    /**
-     * Propagation behaviors.
-     */
-    enum Propagation
-    {
-        /**
-         * Default propagation behavior.
-         * Behavior: <br>
-         * If no current transaction: creates a new UnitOfWork <br>
-         * If there is a current UnitOfWork: use the current UnitOfWork.
-         */
-        REQUIRED,
-
-        /**
-         * Behavior: <br>
-         * If no current UnitOfWork: throw an exception <br>
-         * If there is a current UnitOfWork: use the current UnitOfWork.
-         */
-        MANDATORY,
-
-        /**
-         * Behavior: <br>
-         * If no current UnitOfWork: creates a new UnitOfWork <br>
-         * If there is a current UnitOfWork: suspend the current UnitOfWork and create a new UnitOfWork.
-         */
-        REQUIRES_NEW
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkRetry.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkRetry.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkRetry.java
deleted file mode 100644
index 490cc49..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkRetry.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.zest.api.unitofwork.concern;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * This annotation describes the retries that should occur in case of {@link org.apache.zest.api.unitofwork.ConcurrentEntityModificationException}
- * occurs.
- */
-@Retention( RUNTIME )
-@Target( METHOD )
-@Inherited
-@Documented
-public @interface UnitOfWorkRetry
-{
-    int retries() default 1;
-
-    long initialDelay() default 0;
-
-    long delayFactory() default 10;
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/package.html b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/package.html
deleted file mode 100644
index 68cbe0e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/package.html
+++ /dev/null
@@ -1,24 +0,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.
--->
-<html>
-    <body>
-        <h2>UnitOfWork Concerns.</h2>
-        <p>
-            UnitOfWork Concerns allow declarative UnitOfWork propagation, discard wrt. exceptions and automatic retry.
-        </p>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/unitofwork/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/package.html b/core/api/src/main/java/org/apache/zest/api/unitofwork/package.html
deleted file mode 100644
index 1bc08fa..0000000
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>UnitOfWork API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/usecase/Usecase.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/usecase/Usecase.java b/core/api/src/main/java/org/apache/zest/api/usecase/Usecase.java
deleted file mode 100644
index f5bd66b..0000000
--- a/core/api/src/main/java/org/apache/zest/api/usecase/Usecase.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.usecase;
-
-import java.io.Serializable;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.MetaInfoHolder;
-
-/**
- * A Usecase. A Usecase is used as a model for UnitOfWork, and helps
- * implementations decide what to do in certain circumstances.
- */
-public final class Usecase
-    implements Serializable, MetaInfoHolder
-{
-    public static final Usecase DEFAULT = new Usecase( "Default", new MetaInfo() );
-
-    private static final long serialVersionUID = 1L;
-    private final String name;
-    private final MetaInfo metaInfo;
-
-    Usecase( String name, MetaInfo metaInfo )
-    {
-        this.name = name;
-        this.metaInfo = metaInfo;
-    }
-
-    /**
-     * Name of the usecase.
-     *
-     * @return the name
-     */
-    public String name()
-    {
-        return name;
-    }
-
-    /**
-     * Meta-info for the usecase. This can be of any type, and is typically set when creating the usecase
-     * and read during the execution of the usecase.
-     *
-     * @param infoType the MetaInfo type to retrieve.
-     *
-     * @return the previously stored metaInfo of the given type for the usecase.
-     */
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return metaInfo.get( infoType );
-    }
-
-    @Override
-    public String toString()
-    {
-        return name + ", meta info:" + metaInfo;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/usecase/UsecaseBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/usecase/UsecaseBuilder.java b/core/api/src/main/java/org/apache/zest/api/usecase/UsecaseBuilder.java
deleted file mode 100644
index 3bbbd93..0000000
--- a/core/api/src/main/java/org/apache/zest/api/usecase/UsecaseBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.usecase;
-
-import org.apache.zest.api.common.MetaInfo;
-
-/**
- * Builder for Usecases.
- */
-public final class UsecaseBuilder
-{
-    public static UsecaseBuilder buildUsecase( String aName )
-    {
-        return new UsecaseBuilder( aName );
-    }
-
-    public static Usecase newUsecase( String aName )
-    {
-        return new UsecaseBuilder( aName ).newUsecase();
-    }
-
-    private MetaInfo metaInfo = new MetaInfo();
-
-    private String name;
-
-    private UsecaseBuilder( String name )
-    {
-        this.name = name;
-    }
-
-    public UsecaseBuilder withMetaInfo( Object metaInfo )
-    {
-        this.metaInfo.set( metaInfo );
-        return this;
-    }
-
-    public Usecase newUsecase()
-    {
-        return new Usecase( name, metaInfo );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/usecase/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/usecase/package.html b/core/api/src/main/java/org/apache/zest/api/usecase/package.html
deleted file mode 100644
index 71c696a..0000000
--- a/core/api/src/main/java/org/apache/zest/api/usecase/package.html
+++ /dev/null
@@ -1,21 +0,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.
--->
-<html>
-    <body>
-        <h2>Usecase API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java b/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
deleted file mode 100644
index 553e6c1..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Annotations.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.api.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Type;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.functional.Specification;
-
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.api.util.Classes.typeOf;
-import static org.apache.zest.functional.Iterables.flatten;
-import static org.apache.zest.functional.Iterables.flattenIterables;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.functional.Iterables.map;
-
-/**
- * Useful methods for handling Annotations.
- */
-public final class Annotations
-{
-    public static Function<Type, Iterable<Annotation>> ANNOTATIONS_OF = Classes.forTypes( new Function<Type, Iterable<Annotation>>()
-    {
-        @Override
-        public Iterable<Annotation> map( Type type )
-        {
-            return Iterables.iterable( Classes.RAW_CLASS.map( type ).getAnnotations() );
-        }
-    } );
-
-    public static Specification<AnnotatedElement> hasAnnotation( final Class<? extends Annotation> annotationType )
-    {
-        return new Specification<AnnotatedElement>()
-        {
-            @Override
-            public boolean satisfiedBy( AnnotatedElement element )
-            {
-                return element.getAnnotation( annotationType ) != null;
-            }
-        };
-    }
-
-    public static Function<Annotation, Class<? extends Annotation>> type()
-    {
-        return new Function<Annotation, Class<? extends Annotation>>()
-        {
-            @Override
-            public Class<? extends Annotation> map( Annotation annotation )
-            {
-                return annotation.annotationType();
-            }
-        };
-    }
-
-    public static Specification<Annotation> isType( final Class<? extends Annotation> annotationType )
-    {
-        return new Specification<Annotation>()
-        {
-            @Override
-            public boolean satisfiedBy( Annotation annotation )
-            {
-                return annotation.annotationType().equals( annotationType );
-            }
-        };
-    }
-
-    public static <T extends Annotation> T annotationOn( Type type, Class<T> annotationType )
-    {
-        return annotationType.cast( Classes.RAW_CLASS.map( type ).getAnnotation( annotationType ) );
-    }
-
-    public static Iterable<Annotation> findAccessorAndTypeAnnotationsIn( AccessibleObject accessor )
-    {
-        return flatten( iterable( accessor.getAnnotations() ),
-                        flattenIterables( map( Annotations.ANNOTATIONS_OF, interfacesOf( typeOf( accessor ) ) ) ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/apache/zest/api/util/Base64Encoder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Base64Encoder.java b/core/api/src/main/java/org/apache/zest/api/util/Base64Encoder.java
deleted file mode 100644
index 2779d6e..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Base64Encoder.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2009 Alin Dreghiciu.
- *
- * 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.zest.api.util;
-
-/**
- * Base64Encoder.
- */
-public final class Base64Encoder
-{
-
-    /**
-     * Utility class. ment to be used via static methods.
-     */
-    private Base64Encoder()
-    {
-        // utility class
-    }
-
-    /**
-     * Encodes a String into a base 64 String. The resulting encoding is chunked at 76 bytes.
-     *
-     * @param s String to encode.
-     *
-     * @return encoded string.
-     */
-    public static String encode( String s, boolean includePadding )
-    {
-        byte[] sBytes = s.getBytes();
-        sBytes = encode( sBytes, includePadding );
-        s = new String( sBytes );
-        return s;
-    }
-
-    /**
-     * Decodes a base 64 String into a String.
-     *
-     * @param s String to decode.
-     *
-     * @return encoded string.
-     *
-     * @throws java.lang.IllegalArgumentException
-     *          _ If the given byte array was not valid base64 encoding.
-     */
-    public static String decode( String s )
-        throws IllegalArgumentException
-    {
-        s = s.replaceAll( "\n", "" );
-        s = s.replaceAll( "\r", "" );
-        byte[] sBytes = s.getBytes();
-        sBytes = decode( sBytes );
-        s = new String( sBytes );
-        return s;
-    }
-
-    private static final byte[] ALPHASET =
-        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".getBytes();
-
-    private static final int I6O2 = 255 - 3;
-    private static final int O6I2 = 3;
-    private static final int I4O4 = 255 - 15;
-    private static final int O4I4 = 15;
-    private static final int I2O6 = 255 - 63;
-    private static final int O2I6 = 63;
-
-    /**
-     * Encodes a byte array into a base 64 byte array.
-     *
-     * @param dData byte array to encode.
-     *
-     * @return encoded byte array.
-     */
-    public static byte[] encode( byte[] dData, boolean includePadding )
-    {
-        if( dData == null )
-        {
-            throw new IllegalArgumentException( "Cannot encode null" );
-        }
-        byte[] eData = new byte[ ( ( dData.length + 2 ) / 3 ) * 4 ];
-
-        int eIndex = 0;
-        for( int i = 0; i < dData.length; i += 3 )
-        {
-            int d1;
-            int d2 = 0;
-            int d3 = 0;
-            int e1;
-            int e2;
-            int e3;
-            int e4;
-            int pad = 0;
-
-            d1 = dData[ i ];
-            if( ( i + 1 ) < dData.length )
-            {
-                d2 = dData[ i + 1 ];
-                if( ( i + 2 ) < dData.length )
-                {
-                    d3 = dData[ i + 2 ];
-                }
-                else
-                {
-                    pad = 1;
-                }
-            }
-            else
-            {
-                pad = 2;
-            }
-
-            e1 = ALPHASET[ ( d1 & I6O2 ) >> 2 ];
-            e2 = ALPHASET[ ( d1 & O6I2 ) << 4 | ( d2 & I4O4 ) >> 4 ];
-            e3 = ALPHASET[ ( d2 & O4I4 ) << 2 | ( d3 & I2O6 ) >> 6 ];
-            e4 = ALPHASET[ ( d3 & O2I6 ) ];
-
-            eData[ eIndex++ ] = (byte) e1;
-            eData[ eIndex++ ] = (byte) e2;
-            eData[ eIndex++ ] = ( pad < 2 ) ? (byte) e3 : (byte) '=';
-            eData[ eIndex++ ] = ( pad < 1 ) ? (byte) e4 : (byte) '=';
-
-            if( pad > 0 && !includePadding )
-            {
-                byte[] neweData = new byte[ eData.length - pad ];
-                System.arraycopy( eData, 0, neweData, 0, eIndex - pad );
-                eData = neweData;
-            }
-        }
-
-        return eData;
-    }
-
-    private final static int[] CODES = new int[ 256 ];
-
-    static
-    {
-        for( int i = 0; i < CODES.length; i++ )
-        {
-            CODES[ i ] = 64;
-        }
-        for( int i = 0; i < ALPHASET.length; i++ )
-        {
-            CODES[ ALPHASET[ i ] ] = i;
-        }
-    }
-
-    /**
-     * Decodes a base64 byte array into a byte array.
-     * <p>
-     *
-     * @param eData byte array to decode.
-     *
-     * @return decoded byte array.
-     *
-     * @throws java.lang.IllegalArgumentException
-     *          thrown if the given byte array was not valid com.sun.syndication.io.impl.Base64 encoding.
-     */
-    public static byte[] decode( byte[] eData )
-    {
-        if( eData == null )
-        {
-            throw new IllegalArgumentException( "Cannot decode null" );
-        }
-        byte[] cleanEData = eData.clone();
-        int cleanELength = 0;
-        for( byte anEData : eData )
-        {
-            if( anEData < 256 && CODES[ anEData ] < 64 )
-            {
-                cleanEData[ cleanELength++ ] = anEData;
-            }
-        }
-
-        int dLength = ( cleanELength / 4 ) * 3;
-        switch( cleanELength % 4 )
-        {
-        case 3:
-            dLength += 2;
-            break;
-        case 2:
-            dLength++;
-            break;
-        }
-
-        byte[] dData = new byte[ dLength ];
-        int dIndex = 0;
-        for( int i = 0; i < eData.length; i += 4 )
-        {
-            if( ( i + 3 ) > eData.length )
-            {
-                throw new IllegalArgumentException(
-                    "byte array is not a valid base64 encoding"
-                );
-            }
-            int e1 = CODES[ cleanEData[ i ] ];
-            int e2 = CODES[ cleanEData[ i + 1 ] ];
-            int e3 = CODES[ cleanEData[ i + 2 ] ];
-            int e4 = CODES[ cleanEData[ i + 3 ] ];
-            dData[ dIndex++ ] = (byte) ( ( e1 << 2 ) | ( e2 >> 4 ) );
-            if( dIndex < dData.length )
-            {
-                dData[ dIndex++ ] = (byte) ( ( e2 << 4 ) | ( e3 >> 2 ) );
-            }
-            if( dIndex < dData.length )
-            {
-                dData[ dIndex++ ] = (byte) ( ( e3 << 6 ) | ( e4 ) );
-            }
-        }
-        return dData;
-    }
-}


[12/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/SynchronizedCompositeMethodInstancePool.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SynchronizedCompositeMethodInstancePool.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SynchronizedCompositeMethodInstancePool.java
deleted file mode 100644
index 2efa326..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SynchronizedCompositeMethodInstancePool.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-/**
- * Method instance pool that keeps a linked list. Uses synchronization
- * to ensure that instances are acquired and returned in a thread-safe
- * manner.
- */
-public final class SynchronizedCompositeMethodInstancePool
-    implements InstancePool<CompositeMethodInstance>
-{
-    private CompositeMethodInstance first = null;
-
-    @Override
-    public synchronized CompositeMethodInstance obtainInstance()
-    {
-        CompositeMethodInstance instance = first;
-        if( instance != null )
-        {
-            first = instance.getNext();
-        }
-        return instance;
-    }
-
-    @Override
-    public synchronized void releaseInstance( CompositeMethodInstance instance )
-    {
-        instance.setNext( first );
-        first = instance;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
deleted file mode 100644
index e834262..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.composite.TransientBuilder;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.runtime.property.PropertyInfo;
-import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.spi.module.ModelModule;
-
-/**
- * JAVADOC
- */
-public final class TransientBuilderInstance<T>
-    implements TransientBuilder<T>
-{
-    private ModelModule<TransientModel> model;
-
-    // lazy initialized in accessor
-    private UsesInstance uses = UsesInstance.EMPTY_USES;
-
-    // lazy initialized in accessor
-    private CompositeInstance prototypeInstance;
-
-    private TransientStateInstance state;
-
-    public TransientBuilderInstance( ModelModule<TransientModel> model,
-                                     TransientStateInstance state,
-                                     UsesInstance uses
-    )
-    {
-        this.model = model;
-        this.state = state;
-        this.uses = uses;
-    }
-
-    @Override
-    public TransientBuilder<T> use( Object... usedObjects )
-    {
-        uses = uses.use( usedObjects );
-        return this;
-    }
-
-    @Override
-    public T prototype()
-    {
-        // Instantiate given value type
-        if( prototypeInstance == null )
-        {
-            prototypeInstance = model.model().newInstance( model.module(), uses, state );
-        }
-
-        return prototypeInstance.<T>proxy();
-    }
-
-    @Override
-    public <K> K prototypeFor( Class<K> mixinType )
-    {
-        // Instantiate given value type
-        if( prototypeInstance == null )
-        {
-            prototypeInstance = model.model().newInstance( model.module(), uses, state );
-        }
-
-        return prototypeInstance.newProxy( mixinType );
-    }
-
-    @Override
-    public T newInstance()
-        throws ConstructionException
-    {
-        // Set correct info's (immutable) on the state
-        for( PropertyDescriptor propertyDescriptor : model.model().state().properties() )
-        {
-            ( (PropertyInstance<Object>) state.propertyFor( propertyDescriptor.accessor() ) ).setPropertyInfo( (PropertyInfo) propertyDescriptor );
-        }
-
-        model.model().checkConstraints( state );
-
-        CompositeInstance compositeInstance =
-            model.model().newInstance( model.module(), uses, state );
-        return compositeInstance.<T>proxy();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
deleted file mode 100644
index fc38920..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
+++ /dev/null
@@ -1,804 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.apache.zest.api.entity.Lifecycle;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Methods;
-import org.apache.zest.functional.Iterables;
-
-import static org.objectweb.asm.Opcodes.AASTORE;
-import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
-import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
-import static org.objectweb.asm.Opcodes.ACC_STATIC;
-import static org.objectweb.asm.Opcodes.ACC_SUPER;
-import static org.objectweb.asm.Opcodes.ACONST_NULL;
-import static org.objectweb.asm.Opcodes.ALOAD;
-import static org.objectweb.asm.Opcodes.ANEWARRAY;
-import static org.objectweb.asm.Opcodes.ARETURN;
-import static org.objectweb.asm.Opcodes.ASTORE;
-import static org.objectweb.asm.Opcodes.ATHROW;
-import static org.objectweb.asm.Opcodes.BIPUSH;
-import static org.objectweb.asm.Opcodes.CHECKCAST;
-import static org.objectweb.asm.Opcodes.DLOAD;
-import static org.objectweb.asm.Opcodes.DRETURN;
-import static org.objectweb.asm.Opcodes.DUP;
-import static org.objectweb.asm.Opcodes.FLOAD;
-import static org.objectweb.asm.Opcodes.FRETURN;
-import static org.objectweb.asm.Opcodes.GETFIELD;
-import static org.objectweb.asm.Opcodes.GETSTATIC;
-import static org.objectweb.asm.Opcodes.GOTO;
-import static org.objectweb.asm.Opcodes.ICONST_0;
-import static org.objectweb.asm.Opcodes.ICONST_1;
-import static org.objectweb.asm.Opcodes.ICONST_2;
-import static org.objectweb.asm.Opcodes.ICONST_3;
-import static org.objectweb.asm.Opcodes.ICONST_4;
-import static org.objectweb.asm.Opcodes.ICONST_5;
-import static org.objectweb.asm.Opcodes.ILOAD;
-import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
-import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
-import static org.objectweb.asm.Opcodes.INVOKESTATIC;
-import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
-import static org.objectweb.asm.Opcodes.IRETURN;
-import static org.objectweb.asm.Opcodes.LLOAD;
-import static org.objectweb.asm.Opcodes.LRETURN;
-import static org.objectweb.asm.Opcodes.POP;
-import static org.objectweb.asm.Opcodes.PUTSTATIC;
-import static org.objectweb.asm.Opcodes.RETURN;
-import static org.objectweb.asm.Type.getInternalName;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-
-/**
- * Generate subclasses of classes used for transients. All methods delegate to CompositeInvoker.
- */
-@SuppressWarnings( "raw" )
-/* package */ final class TransientClassLoader
-    extends ClassLoader
-{
-    private static final int JDK_VERSION;
-    public static final String GENERATED_POSTFIX = "_Proxy";
-
-    static
-    {
-        String jdkString = System.getProperty( "java.specification.version" );
-        switch( jdkString )
-        {
-            case "1.8":
-                JDK_VERSION = Opcodes.V1_8;
-                break;
-            case "1.7":
-            default:
-                JDK_VERSION = Opcodes.V1_7;
-                break;
-        }
-    }
-
-    /* package */ TransientClassLoader( ClassLoader parent )
-    {
-        super( parent );
-    }
-
-    @Override
-    protected Class findClass( String name )
-        throws ClassNotFoundException
-    {
-        if( name.endsWith( GENERATED_POSTFIX ) )
-        {
-            Class baseClass;
-            String baseName = name.substring( 0, name.length() - 6 );
-            try
-            {
-                baseClass = loadClass( baseName );
-            }
-            catch( ClassNotFoundException e )
-            {
-                // Try replacing the last _ with $
-                while( true )
-                {
-                    int idx = baseName.lastIndexOf( "_" );
-                    if( idx != -1 )
-                    {
-                        baseName = baseName.substring( 0, idx ) + "$" + baseName.substring( idx + 1 );
-                        try
-                        {
-                            baseClass = loadClass( baseName );
-                            break;
-                        }
-                        catch( ClassNotFoundException e1 )
-                        {
-                            // Try again
-                        }
-                    }
-                    else
-                    {
-                        throw e;
-                    }
-                }
-            }
-
-            byte[] b = generateClass( name, baseClass );
-            return defineClass( name, b, 0, b.length, baseClass.getProtectionDomain() );
-        }
-
-        // Try the classloader of this classloader -> get classes in Zest such as CompositeInvoker
-        return getClass().getClassLoader().loadClass( name );
-    }
-
-    public static byte[] generateClass( String name, Class baseClass )
-        throws ClassNotFoundException
-    {
-        String classSlash = name.replace( '.', '/' );
-        String baseClassSlash = getInternalName( baseClass );
-
-        ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
-        FieldVisitor fv;
-        MethodVisitor mv;
-        AnnotationVisitor av0;
-
-        // Class definition start
-        cw.visit( JDK_VERSION, ACC_PUBLIC + ACC_SUPER, classSlash, null, baseClassSlash, null );
-
-        // Composite reference
-        {
-            fv = cw.visitField( ACC_PUBLIC, "_instance", "Lorg/qi4j/api/composite/CompositeInvoker;", null, null );
-            fv.visitEnd();
-        }
-
-        // Static Method references
-        {
-            int idx = 1;
-            for( Method method : baseClass.getMethods() )
-            {
-                if( isOverloaded( method, baseClass ) )
-                {
-                    fv = cw.visitField( ACC_PRIVATE + ACC_STATIC, "m" + idx++, "Ljava/lang/reflect/Method;", null,
-                                        null );
-                    fv.visitEnd();
-                }
-            }
-        }
-
-        // Constructors
-        for( Constructor constructor : baseClass.getDeclaredConstructors() )
-        {
-            if( Modifier.isPublic( constructor.getModifiers() ) || Modifier.isProtected( constructor.getModifiers() ) )
-            {
-                String desc = org.objectweb.asm.commons.Method.getMethod( constructor ).getDescriptor();
-                mv = cw.visitMethod( ACC_PUBLIC, "<init>", desc, null, null );
-                mv.visitCode();
-                mv.visitVarInsn( ALOAD, 0 );
-
-                int idx = 1;
-                for( Class aClass : constructor.getParameterTypes() )
-                {
-                    // TODO Handle other types than objects (?)
-                    mv.visitVarInsn( ALOAD, idx++ );
-                }
-
-                mv.visitMethodInsn( INVOKESPECIAL, baseClassSlash, "<init>", desc, false );
-                mv.visitInsn( RETURN );
-                mv.visitMaxs( idx, idx );
-                mv.visitEnd();
-            }
-        }
-
-        // Overloaded and unimplemented methods
-        Method[] methods = baseClass.getMethods();
-        int idx = 0;
-        List<Label> exceptionLabels = new ArrayList<>();
-        for( Method method : methods )
-        {
-            if( isOverloaded( method, baseClass ) )
-            {
-                idx++;
-                String methodName = method.getName();
-                String desc = org.objectweb.asm.commons.Method.getMethod( method ).getDescriptor();
-
-                String[] exceptions = null;
-                {
-                    mv = cw.visitMethod( ACC_PUBLIC, methodName, desc, null, exceptions );
-                    if( isInternalQi4jMethod( method, baseClass ) )
-                    {
-                        // generate a NoOp method...
-                        mv.visitInsn( RETURN );
-                    }
-                    else
-                    {
-                        Label endLabel = null; // Use this if return type is void
-                        if( method.getExceptionTypes().length > 0 )
-                        {
-                            exceptions = new String[ method.getExceptionTypes().length ];
-                            for( int i = 0; i < method.getExceptionTypes().length; i++ )
-                            {
-                                Class<?> aClass = method.getExceptionTypes()[ i ];
-                                exceptions[ i ] = getInternalName( aClass );
-                            }
-                        }
-                        mv.visitCode();
-                        Label l0 = new Label();
-                        Label l1 = new Label();
-
-                        exceptionLabels.clear();
-                        for( Class<?> declaredException : method.getExceptionTypes() )
-                        {
-                            Label ld = new Label();
-                            mv.visitTryCatchBlock( l0, l1, ld, getInternalName( declaredException ) );
-                            exceptionLabels.add( ld ); // Reuse this further down for the catch
-                        }
-
-                        Label lruntime = new Label();
-                        mv.visitTryCatchBlock( l0, l1, lruntime, "java/lang/RuntimeException" );
-                        Label lerror = new Label();
-                        mv.visitTryCatchBlock( l0, l1, lerror, "java/lang/Throwable" );
-
-                        mv.visitLabel( l0 );
-                        mv.visitVarInsn( ALOAD, 0 );
-                        mv.visitFieldInsn( GETFIELD, classSlash, "_instance",
-                                           "Lorg/qi4j/api/composite/CompositeInvoker;" );
-                        mv.visitFieldInsn( GETSTATIC, classSlash, "m" + idx, "Ljava/lang/reflect/Method;" );
-
-                        int paramCount = method.getParameterTypes().length;
-                        int stackIdx = 0;
-                        if( paramCount == 0 )
-                        {
-                            // Send in null as parameter
-                            mv.visitInsn( ACONST_NULL );
-                        }
-                        else
-                        {
-                            insn( mv, paramCount );
-                            mv.visitTypeInsn( ANEWARRAY, "java/lang/Object" );
-                            int pidx = 0;
-                            for( Class<?> aClass : method.getParameterTypes() )
-                            {
-                                mv.visitInsn( DUP );
-                                insn( mv, pidx++ );
-                                stackIdx = wrapParameter( mv, aClass, stackIdx + 1 );
-                                mv.visitInsn( AASTORE );
-                            }
-                        }
-
-                        // Call method
-                        mv.visitMethodInsn( INVOKEINTERFACE, "org/qi4j/api/composite/CompositeInvoker",
-                                            "invokeComposite",
-                                            "(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;", true );
-
-                        // Return value
-                        if( !method.getReturnType().equals( Void.TYPE ) )
-                        {
-                            unwrapResult( mv, method.getReturnType(), l1 );
-                        }
-                        else
-                        {
-                            mv.visitInsn( POP );
-                            mv.visitLabel( l1 );
-                            endLabel = new Label();
-                            mv.visitJumpInsn( GOTO, endLabel );
-                        }
-
-                        // Increase stack to beyond method args
-                        stackIdx++;
-
-                        // Declared exceptions
-                        int exceptionIdx = 0;
-                        for( Class<?> aClass : method.getExceptionTypes() )
-                        {
-                            mv.visitLabel( exceptionLabels.get( exceptionIdx++ ) );
-                            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ getInternalName( aClass ) } );
-                            mv.visitVarInsn( ASTORE, stackIdx );
-                            mv.visitVarInsn( ALOAD, stackIdx );
-                            mv.visitInsn( ATHROW );
-                        }
-
-                        // RuntimeException and Error catch-all
-                        mv.visitLabel( lruntime );
-                        mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/RuntimeException" } );
-                        mv.visitVarInsn( ASTORE, stackIdx );
-                        mv.visitVarInsn( ALOAD, stackIdx );
-                        mv.visitInsn( ATHROW );
-
-                        mv.visitLabel( lerror );
-                        mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/Throwable" } );
-                        mv.visitVarInsn( ASTORE, stackIdx );
-                        mv.visitVarInsn( ALOAD, stackIdx );
-                        mv.visitTypeInsn( CHECKCAST, "java/lang/Error" );
-                        mv.visitInsn( ATHROW );
-
-                        // Return type = void
-                        if( endLabel != null )
-                        {
-                            mv.visitLabel( endLabel );
-                            mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
-                            mv.visitInsn( RETURN );
-                        }
-
-                        mv.visitMaxs( 0, 0 );
-                        mv.visitEnd();
-                    }
-                }
-
-                if( !Modifier.isAbstract( method.getModifiers() ) )
-                {
-                    // Add method with _ as prefix
-                    mv = cw.visitMethod( ACC_PUBLIC, "_" + method.getName(), desc, null, exceptions );
-                    mv.visitCode();
-                    mv.visitVarInsn( ALOAD, 0 );
-
-                    // Parameters
-                    int stackIdx = 1;
-                    for( Class<?> aClass : method.getParameterTypes() )
-                    {
-                        stackIdx = loadParameter( mv, aClass, stackIdx ) + 1;
-                    }
-
-                    // Call method
-                    mv.visitMethodInsn( INVOKESPECIAL, baseClassSlash, method.getName(), desc, false );
-
-                    // Return value
-                    if( !method.getReturnType().equals( Void.TYPE ) )
-                    {
-                        returnResult( mv, method.getReturnType() );
-                    }
-                    else
-                    {
-                        mv.visitInsn( RETURN );
-                    }
-
-                    mv.visitMaxs( 1, 1 );
-                    mv.visitEnd();
-                }
-            }
-        }
-
-        // Class initializer
-        {
-            mv = cw.visitMethod( ACC_STATIC, "<clinit>", "()V", null, null );
-            mv.visitCode();
-            Label l0 = new Label();
-            Label l1 = new Label();
-            Label l2 = new Label();
-            mv.visitTryCatchBlock( l0, l1, l2, "java/lang/NoSuchMethodException" );
-            mv.visitLabel( l0 );
-
-            // Lookup methods and store in static variables
-            int midx = 0;
-            for( Method method : methods )
-            {
-                if( isOverloaded( method, baseClass ) )
-                {
-                    method.setAccessible( true );
-                    Class methodClass;
-                    methodClass = method.getDeclaringClass();
-
-                    midx++;
-
-                    mv.visitLdcInsn( Type.getType( methodClass ) );
-                    mv.visitLdcInsn( method.getName() );
-                    insn( mv, method.getParameterTypes().length );
-                    mv.visitTypeInsn( ANEWARRAY, "java/lang/Class" );
-
-                    int pidx = 0;
-                    for( Class<?> aClass : method.getParameterTypes() )
-                    {
-                        mv.visitInsn( DUP );
-                        insn( mv, pidx++ );
-                        type( mv, aClass );
-                        mv.visitInsn( AASTORE );
-                    }
-
-                    mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "getMethod",
-                                        "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;", false );
-                    mv.visitFieldInsn( PUTSTATIC, classSlash, "m" + midx, "Ljava/lang/reflect/Method;" );
-                }
-            }
-
-            mv.visitLabel( l1 );
-            Label l3 = new Label();
-            mv.visitJumpInsn( GOTO, l3 );
-            mv.visitLabel( l2 );
-            mv.visitFrame( Opcodes.F_SAME1, 0, null, 1, new Object[]{ "java/lang/NoSuchMethodException" } );
-            mv.visitVarInsn( ASTORE, 0 );
-            mv.visitVarInsn( ALOAD, 0 );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/NoSuchMethodException", "printStackTrace", "()V", false );
-            mv.visitLabel( l3 );
-            mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
-            mv.visitInsn( RETURN );
-            mv.visitMaxs( 6, 1 );
-            mv.visitEnd();
-        }
-
-        cw.visitEnd();
-
-        return cw.toByteArray();
-    }
-
-    private static boolean isOverloaded( Method method, Class baseClass )
-    {
-        if( Modifier.isFinal( method.getModifiers() ) )
-        {
-            return false; // Cannot override final methods
-        }
-        else
-        {
-            return true;
-        }
-    }
-
-    private static boolean isInternalQi4jMethod( Method method, Class baseClass )
-    {
-        return isDeclaredIn( method, Initializable.class, baseClass )
-               || isDeclaredIn( method, Lifecycle.class, baseClass );
-    }
-
-    private static boolean isDeclaredIn( Method method, Class<?> clazz, Class<?> baseClass )
-    {
-        if( !clazz.isAssignableFrom( baseClass ) )
-        {
-            return false;
-        }
-
-        try
-        {
-            clazz.getMethod( method.getName(), method.getParameterTypes() );
-            return true;
-        }
-        catch( NoSuchMethodException e )
-        {
-            return false;
-        }
-    }
-
-    private static Class getInterfaceMethodDeclaration( Method method, Class clazz )
-        throws NoSuchMethodException
-    {
-        Iterable<Class<?>> interfaces = Iterables.map( Classes.RAW_CLASS, interfacesOf( clazz ) );
-        for( Class<?> anInterface : interfaces )
-        {
-            try
-            {
-                anInterface.getMethod( method.getName(), method.getParameterTypes() );
-                return anInterface;
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Try next
-            }
-        }
-
-        throw new NoSuchMethodException( method.getName() );
-    }
-
-    private static boolean isInterfaceMethod( Method method, Class<?> baseClass )
-    {
-        for( Class<?> aClass : Iterables.filter( Methods.HAS_METHODS, Iterables.map( Classes.RAW_CLASS, interfacesOf( baseClass ) ) ) )
-        {
-            try
-            {
-                Method m = aClass.getMethod( method.getName(), method.getParameterTypes() );
-                m.setAccessible( true );
-                return true;
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Ignore
-            }
-        }
-        return false;
-    }
-
-    private static void type( MethodVisitor mv, Class<?> aClass )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;" );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitFieldInsn( GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;" );
-        }
-        else
-        {
-            mv.visitLdcInsn( Type.getType( aClass ) );
-        }
-    }
-
-    private static int wrapParameter( MethodVisitor mv, Class<?> aClass, int idx )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitVarInsn( LLOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitVarInsn( DLOAD, idx );
-            idx++; // Extra jump
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitVarInsn( FLOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-            mv.visitMethodInsn( INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false );
-        }
-        else
-        {
-            mv.visitVarInsn( ALOAD, idx );
-        }
-
-        return idx;
-    }
-
-    private static void unwrapResult( MethodVisitor mv, Class<?> aClass, Label label )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Integer" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Long" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false );
-            mv.visitLabel( label );
-            mv.visitInsn( LRETURN );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Short" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Byte" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Double" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false );
-            mv.visitLabel( label );
-            mv.visitInsn( DRETURN );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Float" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false );
-            mv.visitLabel( label );
-            mv.visitInsn( FRETURN );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Boolean" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitTypeInsn( CHECKCAST, "java/lang/Character" );
-            mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false );
-            mv.visitLabel( label );
-            mv.visitInsn( IRETURN );
-        }
-        else
-        {
-            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
-            mv.visitLabel( label );
-            mv.visitInsn( ARETURN );
-        }
-    }
-
-    private static int loadParameter( MethodVisitor mv, Class<?> aClass, int idx )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitVarInsn( LLOAD, idx );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitVarInsn( DLOAD, idx );
-            idx++; // Extra jump
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitVarInsn( FLOAD, idx );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitVarInsn( ILOAD, idx );
-        }
-        else
-        {
-            mv.visitVarInsn( ALOAD, idx );
-        }
-
-        return idx;
-    }
-
-    private static void returnResult( MethodVisitor mv, Class<?> aClass )
-    {
-        if( aClass.equals( Integer.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Long.TYPE ) )
-        {
-            mv.visitInsn( LRETURN );
-        }
-        else if( aClass.equals( Short.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Byte.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Double.TYPE ) )
-        {
-            mv.visitInsn( DRETURN );
-        }
-        else if( aClass.equals( Float.TYPE ) )
-        {
-            mv.visitInsn( FRETURN );
-        }
-        else if( aClass.equals( Boolean.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else if( aClass.equals( Character.TYPE ) )
-        {
-            mv.visitInsn( IRETURN );
-        }
-        else
-        {
-            mv.visitTypeInsn( CHECKCAST, getInternalName( aClass ) );
-            mv.visitInsn( ARETURN );
-        }
-    }
-
-    private static void insn( MethodVisitor mv, int length )
-    {
-        switch( length )
-        {
-        case 0:
-            mv.visitInsn( ICONST_0 );
-            return;
-        case 1:
-            mv.visitInsn( ICONST_1 );
-            return;
-        case 2:
-            mv.visitInsn( ICONST_2 );
-            return;
-        case 3:
-            mv.visitInsn( ICONST_3 );
-            return;
-        case 4:
-            mv.visitInsn( ICONST_4 );
-            return;
-        case 5:
-            mv.visitInsn( ICONST_5 );
-            return;
-        default:
-            mv.visitIntInsn( BIPUSH, length );
-        }
-    }
-
-    public static boolean isGenerated( Class clazz )
-    {
-        return clazz.getName().endsWith( GENERATED_POSTFIX );
-    }
-
-    public static boolean isGenerated( Object object )
-    {
-        return object.getClass().getName().endsWith( GENERATED_POSTFIX );
-    }
-
-    public Class loadFragmentClass( Class fragmentClass )
-        throws ClassNotFoundException
-    {
-        return loadClass( fragmentClass.getName().replace( '$', '_' ) + GENERATED_POSTFIX );
-    }
-
-    public static Class getSourceClass( Class fragmentClass )
-    {
-        return fragmentClass.getName().endsWith( GENERATED_POSTFIX ) ? fragmentClass.getSuperclass() : fragmentClass;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
deleted file mode 100644
index 9d70a62..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2007, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2007, Alin Dreghiciu. 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import org.apache.zest.api.Qi4j;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * InvocationHandler for proxy objects.
- */
-public class TransientInstance
-    implements CompositeInstance, MixinsInstance
-{
-    public static TransientInstance compositeInstanceOf( Composite composite )
-    {
-        InvocationHandler handler = Proxy.getInvocationHandler( composite );
-        return (TransientInstance) handler;
-    }
-
-    private final Composite proxy;
-    protected final Object[] mixins;
-    protected StateHolder state;
-    protected final CompositeModel compositeModel;
-    private final ModuleSpi moduleInstance;
-
-    public TransientInstance( CompositeModel compositeModel,
-                              ModuleSpi moduleInstance,
-                              Object[] mixins,
-                              StateHolder state
-    )
-    {
-        this.compositeModel = compositeModel;
-        this.moduleInstance = moduleInstance;
-        this.mixins = mixins;
-        this.state = state;
-
-        proxy = compositeModel.newProxy( this );
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return compositeModel.invoke( this, proxy, method, args, moduleInstance );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> T proxy()
-    {
-        return (T) proxy;
-    }
-
-    @Override
-    public <T> T newProxy( Class<T> mixinType )
-        throws IllegalArgumentException
-    {
-        return compositeModel.newProxy( this, mixinType );
-    }
-
-    @Override
-    public Object invokeComposite( Method method, Object[] args )
-        throws Throwable
-    {
-        return compositeModel.invoke( this, proxy, method, args, moduleInstance );
-    }
-
-    @Override
-    public CompositeModel descriptor()
-    {
-        return compositeModel;
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return compositeModel.metaInfo( infoType );
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return compositeModel.types();
-    }
-
-    @Override
-    public Module module()
-    {
-        return moduleInstance;
-    }
-
-    public Layer layer()
-    {
-        return ( (ModuleInstance) moduleInstance ).layerInstance();
-    }
-
-    @Override
-    public StateHolder state()
-    {
-        return state;
-    }
-
-    @Override
-    public Object invoke( Object composite, Object[] params, CompositeMethodInstance methodInstance )
-        throws Throwable
-    {
-        Object mixin = methodInstance.getMixinFrom( mixins );
-        return methodInstance.invoke( proxy, params, mixin );
-    }
-
-    @Override
-    public Object invokeObject( Object proxy, Object[] args, Method method )
-        throws Throwable
-    {
-        return method.invoke( this, args );
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( o == null )
-        {
-            return false;
-        }
-        if( !Proxy.isProxyClass( o.getClass() ) )
-        {
-            return false;
-        }
-        TransientInstance other = (TransientInstance) Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( (Composite) o );
-        if( other.mixins.length != mixins.length )
-        {
-            return false;
-        }
-
-        for( int i = 0; i < mixins.length; i++ )
-        {
-            if( !mixins[ i ].equals( other.mixins[ i ] ) )
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hashCode = 0;
-        for( Object mixin : mixins )
-        {
-            hashCode = hashCode * 31 + mixin.hashCode();
-        }
-        return hashCode;
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder();
-        boolean first = true;
-        for( Object mixin : mixins )
-        {
-            try
-            {
-                if( mixin != null )  // Can happen during construction of incorrect composites, during exception creation.
-                {
-                    Class<?> type = mixin.getClass();
-                    Method toStringMethod = type.getMethod( "toString" );
-                    Class<?> declaringClass = toStringMethod.getDeclaringClass();
-                    if( !declaringClass.equals( Object.class ) )
-                    {
-                        if( !first )
-                        {
-                            buffer.append( ", " );
-                        }
-                        first = false;
-                        buffer.append( mixin.toString() );
-                    }
-                }
-            }
-            catch( NoSuchMethodException e )
-            {
-                // Can not happen??
-                e.printStackTrace();
-            }
-        }
-        if( first )
-        {
-            String modelTypeName = compositeModel.getClass().getSimpleName();
-            String metaTypeModel = modelTypeName.substring( 0, modelTypeName.length() - 5 );
-            return metaTypeModel + "Instance{" +
-                   "mixins=" + ( mixins == null ? null : Arrays.asList( mixins ) ) +
-                   ", state=" + state +
-                   ", compositeModel=" + compositeModel +
-                   ", module=" + moduleInstance +
-                   '}';
-        }
-        return buffer.toString();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
deleted file mode 100644
index 0d0ecac..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * Model for Transient Composites
- */
-public class TransientModel
-    extends CompositeModel
-    implements TransientDescriptor
-{
-    public TransientModel( Iterable<Class<?>> types, final Visibility visibility,
-                           final MetaInfo metaInfo,
-                           final MixinsModel mixinsModel,
-                           final StateModel stateModel,
-                           final CompositeMethodsModel compositeMethodsModel
-    )
-    {
-        super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-    }
-
-    public TransientInstance newInstance( ModuleSpi moduleInstance,
-                                          UsesInstance uses,
-                                          TransientStateInstance state
-    )
-    {
-        Object[] mixins = mixinsModel.newMixinHolder();
-        TransientInstance compositeInstance = new TransientInstance( this, moduleInstance, mixins, state );
-
-        // Instantiate all mixins
-        int i = 0;
-        InjectionContext injectionContext = new InjectionContext( compositeInstance, uses, state );
-        for( MixinModel mixinModel : mixinsModel.mixinModels() )
-        {
-            mixins[ i++ ] = mixinModel.newInstance( injectionContext );
-        }
-
-        // Return
-        return compositeInstance;
-    }
-
-    public void checkConstraints( TransientStateInstance instanceState )
-        throws ConstraintViolationException
-    {
-        for( PropertyModel propertyModel : stateModel.properties() )
-        {
-            propertyModel.checkConstraints( instanceState.<Object>propertyFor( propertyModel.accessor() ).get() );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientStateInstance.java
deleted file mode 100644
index 14d0901..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientStateInstance.java
+++ /dev/null
@@ -1,60 +0,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.
- */
-package org.apache.zest.runtime.composite;
-
-import java.lang.reflect.AccessibleObject;
-import java.util.Map;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.StateHolder;
-
-/**
- * TODO
- */
-public final class TransientStateInstance
-    implements StateHolder
-{
-    private final Map<AccessibleObject, Property<?>> properties;
-
-    public TransientStateInstance( Map<AccessibleObject, Property<?>> properties
-    )
-    {
-        this.properties = properties;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> Property<T> propertyFor( AccessibleObject accessor )
-        throws IllegalArgumentException
-    {
-        Property<T> property = (Property<T>) properties.get( accessor );
-
-        if( property == null )
-        {
-            throw new IllegalArgumentException( "No such property:" + accessor );
-        }
-
-        return property;
-    }
-
-    @Override
-    public Iterable<Property<?>> properties()
-    {
-        return properties.values();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientsModel.java
deleted file mode 100644
index 102719e..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientsModel.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public class TransientsModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final List<TransientModel> transientModels;
-
-    public TransientsModel( List<TransientModel> transientModels )
-    {
-        this.transientModels = transientModels;
-    }
-
-    public Iterable<TransientModel> models()
-    {
-        return transientModels;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( TransientModel transientModel : transientModels )
-            {
-                if( !transientModel.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/TypedModifierInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TypedModifierInvocationHandler.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TypedModifierInvocationHandler.java
deleted file mode 100644
index 3c5366d..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TypedModifierInvocationHandler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2007 Rickard Öberg
- * 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.zest.runtime.composite;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.apache.zest.api.composite.InvalidCompositeException;
-
-/**
- * JAVADOC
- */
-public final class TypedModifierInvocationHandler
-    extends FragmentInvocationHandler
-{
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        try
-        {
-            return this.method.invoke( fragment, args );
-        }
-        catch( InvocationTargetException e )
-        {
-            throw cleanStackTrace( e.getTargetException(), proxy, method );
-        }
-        catch( Throwable e )
-        {
-            if( fragment == null )
-            {
-                throw new InvalidCompositeException( "No fragment available for method " + method.getName() );
-            }
-            throw cleanStackTrace( e, proxy, method );
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/UnsynchronizedCompositeMethodInstancePool.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UnsynchronizedCompositeMethodInstancePool.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/UnsynchronizedCompositeMethodInstancePool.java
deleted file mode 100644
index 5aa0e74..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UnsynchronizedCompositeMethodInstancePool.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-/**
- * Method instance pool that keeps a linked list. Uses synchronization
- * to ensure that instances are acquired and returned in a thread-safe
- * manner.
- */
-public final class UnsynchronizedCompositeMethodInstancePool
-    implements InstancePool<CompositeMethodInstance>
-{
-    private CompositeMethodInstance first = null;
-
-    @Override
-    public CompositeMethodInstance obtainInstance()
-    {
-        CompositeMethodInstance instance = first;
-        if( instance != null )
-        {
-            first = instance.getNext();
-        }
-        return instance;
-    }
-
-    @Override
-    public void releaseInstance( CompositeMethodInstance instance )
-    {
-        instance.setNext( first );
-        first = instance;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsageGraph.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsageGraph.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsageGraph.java
deleted file mode 100644
index 540a886..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsageGraph.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2008 Niclas Hedhman. 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.zest.runtime.composite;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import org.apache.zest.bootstrap.BindingException;
-
-/**
- * This class is NOT thread-safe.
- * //TODO: Algorithm need to be optimized.
- */
-public final class UsageGraph<K>
-{
-    private final Collection<K> data;
-    private final Use<K> use;
-    private final boolean allowCyclic;
-    private List<K> resolved;
-    private HashMap<K, List<K>> transitive;
-
-    public UsageGraph( Collection<K> data, Use<K> use, boolean allowCyclic )
-    {
-        this.data = data;
-        this.use = use;
-        this.allowCyclic = allowCyclic;
-    }
-
-    public boolean transitiveUse( K source, K other )
-        throws BindingException
-    {
-        if( transitive == null )
-        {
-            buildUsageGraph();
-        }
-        return transitive.containsKey( source ) && transitive.get( source ).contains( other );
-    }
-
-    private void checkCyclic( List<K> visited, K sourceItem, K used )
-        throws BindingException
-    {
-        Collection<K> nextLevel = use.uses( used );
-        for( K next : nextLevel )
-        {
-            if( next == sourceItem )
-            {
-                if( !allowCyclic )
-                {
-                    visited.add( next );
-                    throw new BindingException( "Cyclic usage detected: " + sourceItem + " -> " + visited );
-                }
-            }
-            if( !visited.contains( next ) )
-            {
-                visited.add( next );
-                checkCyclic( visited, sourceItem, next );
-            }
-        }
-    }
-
-    /**
-     * Must be called if the data set has been modified.
-     */
-    public void invalidate()
-    {
-        resolved = null;
-        transitive = null;
-    }
-
-    public List<K> resolveOrder()
-        throws BindingException
-    {
-        if( resolved == null )
-        {
-            buildUsageGraph();
-            resolved = new LinkedList<K>();
-            for( K item : data )
-            {
-                int pos = resolved.size();
-                for( K entry : resolved )
-                {
-                    if( transitiveUse( entry, item ) )
-                    {
-                        pos = resolved.indexOf( entry );
-                        break;
-                    }
-                }
-                resolved.add( pos, item );
-            }
-        }
-        return resolved;
-    }
-
-    private void buildUsageGraph()
-        throws BindingException
-    {
-        transitive = new HashMap<K, List<K>>();
-        for( K sourceItem : data )
-        {
-            LinkedList<K> visited = new LinkedList<K>();
-            checkCyclic( visited, sourceItem, sourceItem );
-            transitive.put( sourceItem, visited );
-        }
-    }
-
-    public interface Use<K>
-    {
-
-        /**
-         * @param source The item to be queried.
-         *
-         * @return A list of items it uses.
-         */
-        Collection<K> uses( K source );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsesInstance.java
deleted file mode 100644
index 14cdf32..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/UsesInstance.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.zest.functional.Iterables;
-
-/**
- * JAVADOC
- */
-public final class UsesInstance
-{
-    public static final UsesInstance EMPTY_USES;
-    private final Set<Object> uses;
-
-    static
-    {
-        EMPTY_USES = new UsesInstance( new HashSet<>() );
-    }
-
-    private UsesInstance( HashSet<Object> uses )
-    {
-        this.uses = Collections.unmodifiableSet( uses );
-    }
-
-    public UsesInstance use( Object... objects )
-    {
-        HashSet<Object> useObjects = new HashSet<>();
-        if( !uses.isEmpty() )
-        {
-            useObjects.addAll( uses );
-            for( Object object : objects )
-            {
-                Object oldUseForType = useForType( object.getClass() );
-                if( oldUseForType != null )
-                {
-                    useObjects.remove( oldUseForType );
-                }
-            }
-        }
-        useObjects.addAll( Arrays.asList( objects ) );
-        return new UsesInstance( useObjects );
-    }
-
-    public Object useForType( Class<?> type )
-    {
-        // Check instances first
-        for( Object use : uses )
-        {
-            if( type.isInstance( use ) )
-            {
-                return use;
-            }
-        }
-
-        return null;
-    }
-
-    public Object[] toArray()
-    {
-        return Iterables.toArray( uses );
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        if( this == o )
-        {
-            return true;
-        }
-        if( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-        UsesInstance that = (UsesInstance) o;
-        return uses.equals( that.uses );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return uses.hashCode();
-    }
-
-    @Override
-    public String toString()
-    {
-        return "UsesInstance{" +
-               "uses=" + uses +
-               '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsInstance.java
deleted file mode 100644
index 25dddca..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsInstance.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.constraint.ConstraintViolation;
-
-/**
- * JAVADOC
- */
-public final class ValueConstraintsInstance
-{
-    private static final Optional OPTIONAL;
-
-    static
-    {
-        OPTIONAL = new OptionalDummy();
-    }
-
-    @SuppressWarnings( "raw" )
-    private final List<ConstraintInstance> constraints;
-    private String name;
-    private boolean optional;
-
-    public ValueConstraintsInstance( List<AbstractConstraintModel> constraintModels, String name, boolean optional )
-    {
-        this.name = name;
-        this.optional = optional;
-        constraints = new ArrayList<>();
-        for( AbstractConstraintModel constraintModel : constraintModels )
-        {
-            constraints.add( constraintModel.newInstance() );
-        }
-    }
-
-    @SuppressWarnings( {"raw", "unchecked"} )
-    public List<ConstraintViolation> checkConstraints( Object value )
-    {
-        List<ConstraintViolation> violations = null;
-
-        // Check optional first - this avoids NPE's in constraints
-        if( optional )
-        {
-            if( value == null )
-            {
-                violations = Collections.emptyList();
-            }
-        }
-        else
-        {
-            if( value == null )
-            {
-                violations = new ArrayList<>();
-                violations.add( new ConstraintViolation( name, OPTIONAL, null ) );
-            }
-        }
-
-        if( violations == null && value != null )
-        {
-            for( ConstraintInstance constraint : constraints )
-            {
-                boolean valid;
-                try
-                {
-                    valid = constraint.isValid( value );
-                }
-                catch( NullPointerException e )
-                {
-                    // A NPE is the same as a failing constraint
-                    valid = false;
-                }
-
-                if( !valid )
-                {
-                    if( violations == null )
-                    {
-                        violations = new ArrayList<>();
-                    }
-                    ConstraintViolation violation = new ConstraintViolation( name, constraint.annotation(), value );
-                    violations.add( violation );
-                }
-            }
-        }
-
-        if( violations == null )
-        {
-            violations = Collections.emptyList();
-        }
-
-        return violations;
-    }
-
-    @SuppressWarnings( "AnnotationAsSuperInterface" )
-    private static class OptionalDummy
-        implements Optional
-    {
-        @Override
-        public Class<? extends Annotation> annotationType()
-        {
-            return Optional.class;
-        }
-
-        @Override
-        public String toString()
-        {
-            return "not optional";
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsModel.java
deleted file mode 100644
index 4eb6007..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ValueConstraintsModel.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.composite;
-
-import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * JAVADOC
- */
-public final class ValueConstraintsModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final List<AbstractConstraintModel> constraintModels;
-    private String name;
-    private boolean optional;
-
-    public ValueConstraintsModel( List<AbstractConstraintModel> constraintModels, String name, boolean optional )
-    {
-        this.constraintModels = constraintModels;
-        this.name = name;
-        this.optional = optional;
-    }
-
-    public ValueConstraintsInstance newInstance()
-    {
-        return new ValueConstraintsInstance( constraintModels, name, optional );
-    }
-
-    public boolean isConstrained()
-    {
-        if( !constraintModels.isEmpty() )
-        {
-            return true;
-        }
-
-        return !optional;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        for( AbstractConstraintModel constraintModel : constraintModels )
-        {
-            if( constraintModel.accept( modelVisitor ) )
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntitiesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntitiesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntitiesModel.java
deleted file mode 100644
index 56deeb7..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntitiesModel.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.entity;
-
-import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
-
-/**
- * Model of entities in a particular Module.
- */
-public class EntitiesModel
-    implements VisitableHierarchy<Object, Object>
-{
-    private final List<EntityModel> entityModels;
-
-    public EntitiesModel( List<EntityModel> entityModels )
-    {
-        this.entityModels = entityModels;
-    }
-
-    public Iterable<EntityModel> models()
-    {
-        return entityModels;
-    }
-
-    @Override
-    public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
-        throws ThrowableType
-    {
-        if( modelVisitor.visitEnter( this ) )
-        {
-            for( EntityModel entityModel : entityModels )
-            {
-                if( !entityModel.accept( modelVisitor ) )
-                {
-                    break;
-                }
-            }
-        }
-        return modelVisitor.visitLeave( this );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
deleted file mode 100644
index 8512a87..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 2008-2009, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2009-2013, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2014, Paul Merlin. 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.zest.runtime.entity;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.composite.CompositeDescriptor;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.LifecycleException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkException;
-import org.apache.zest.runtime.composite.CompositeMethodInstance;
-import org.apache.zest.runtime.composite.MixinsInstance;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * Entity instance
- */
-public final class EntityInstance
-    implements CompositeInstance, MixinsInstance
-{
-    public static EntityInstance entityInstanceOf( EntityComposite composite )
-    {
-        return (EntityInstance) Proxy.getInvocationHandler( composite );
-    }
-
-    private final EntityComposite proxy;
-    private final ModuleUnitOfWork uow;
-    private final ModuleSpi moduleInstance;
-    private final EntityModel entityModel;
-    private final EntityReference identity;
-    private final EntityState entityState;
-
-    private Object[] mixins;
-    private EntityStateInstance state;
-
-    public EntityInstance( ModuleUnitOfWork uow,
-                           ModuleSpi moduleInstance,
-                           EntityModel entityModel,
-                           EntityState entityState
-    )
-    {
-        this.uow = uow;
-        this.moduleInstance = moduleInstance;
-        this.entityModel = entityModel;
-        this.identity = entityState.identity();
-        this.entityState = entityState;
-
-        proxy = (EntityComposite) entityModel.newProxy( this );
-    }
-
-    @Override
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        return entityModel.invoke( this, this.proxy, method, args, moduleInstance );
-    }
-
-    public EntityReference identity()
-    {
-        return identity;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public <T> T proxy()
-    {
-        return (T) proxy;
-    }
-
-    @Override
-    public CompositeDescriptor descriptor()
-    {
-        return entityModel;
-    }
-
-    @Override
-    public <T> T newProxy( Class<T> mixinType )
-        throws IllegalArgumentException
-    {
-        return entityModel.newProxy( this, mixinType );
-    }
-
-    @Override
-    public Object invokeComposite( Method method, Object[] args )
-        throws Throwable
-    {
-        return entityModel.invoke( this, proxy, method, args, moduleInstance );
-    }
-
-    @Override
-    public <T> T metaInfo( Class<T> infoType )
-    {
-        return entityModel.metaInfo( infoType );
-    }
-
-    public EntityModel entityModel()
-    {
-        return entityModel;
-    }
-
-    @Override
-    public Iterable<Class<?>> types()
-    {
-        return entityModel.types();
-    }
-
-    @Override
-    public ModuleSpi module()
-    {
-        return moduleInstance;
-    }
-
-    public UnitOfWork unitOfWork()
-    {
-        return uow;
-    }
-
-    public EntityState entityState()
-    {
-        return entityState;
-    }
-
-    @Override
-    public EntityStateInstance state()
-    {
-        if( state == null )
-        {
-            initState();
-        }
-
-        return state;
-    }
-
-    public EntityStatus status()
-    {
-        return entityState.status();
-    }
-
-    @Override
-    public Object invoke( Object composite, Object[] params, CompositeMethodInstance methodInstance )
-        throws Throwable
-    {
-        if( mixins == null )
-        {
-            initState();
-        }
-
-        Object mixin = methodInstance.getMixinFrom( mixins );
-
-        if( mixin == null )
-        {
-            mixin = entityModel.newMixin( mixins, state, this, methodInstance.method() );
-        }
-
-        return methodInstance.invoke( proxy, params, mixin );
-    }
-
-    @Override
-    public Object invokeObject( Object proxy, Object[] args, Method method )
-        throws Throwable
-    {
-        return method.invoke( this, args );
-    }
-
-    private void initState()
-    {
-        if( !uow.isOpen() )
-        {
-            throw new UnitOfWorkException( "Unit of work has been closed" );
-        }
-
-        if( status() == EntityStatus.REMOVED )
-        {
-            throw new NoSuchEntityException( identity, entityModel.types(), unitOfWork().usecase() );
-        }
-
-        mixins = entityModel.newMixinHolder();
-        state = new EntityStateInstance( entityModel.state(), uow, entityState );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return identity.hashCode();
-    }
-
-    @Override
-    public boolean equals( Object o )
-    {
-        try
-        {
-            Identity other = ( (Identity) o );
-            return other != null && other.identity().get().equals( identity.identity() );
-        }
-        catch( ClassCastException e )
-        {
-            return false;
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        return identity.toString();
-    }
-
-    public void remove( UnitOfWork unitOfWork )
-        throws LifecycleException
-    {
-        invokeRemove();
-
-        removeAggregatedEntities( unitOfWork );
-
-        entityState.remove();
-        mixins = null;
-    }
-
-    public void invokeCreate()
-    {
-        lifecyleInvoke( true );
-    }
-
-    private void invokeRemove()
-    {
-        lifecyleInvoke( false );
-    }
-
-    private void lifecyleInvoke( boolean create )
-    {
-        if( mixins == null )
-        {
-            initState();
-        }
-
-        entityModel.invokeLifecycle( create, mixins, this, state );
-    }
-
-    private void removeAggregatedEntities( UnitOfWork unitOfWork )
-    {
-        // Calculate aggregated Entities
-        AssociationStateDescriptor stateDescriptor = entityModel.state();
-        Set<Object> aggregatedEntities = new HashSet<>();
-        Iterable<? extends AssociationDescriptor> associations = stateDescriptor.associations();
-        for( AssociationDescriptor association : associations )
-        {
-            if( association.isAggregated() )
-            {
-                Association<?> assoc = state.associationFor( association.accessor() );
-                Object aggregatedEntity = assoc.get();
-                if( aggregatedEntity != null )
-                {
-                    aggregatedEntities.add( aggregatedEntity );
-                }
-            }
-        }
-        Iterable<? extends AssociationDescriptor> manyAssociations = stateDescriptor.manyAssociations();
-        for( AssociationDescriptor association : manyAssociations )
-        {
-            if( association.isAggregated() )
-            {
-                ManyAssociation<?> manyAssoc = state.manyAssociationFor( association.accessor() );
-                for( Object entity : manyAssoc )
-                {
-                    aggregatedEntities.add( entity );
-                }
-            }
-        }
-        Iterable<? extends AssociationDescriptor> namedAssociations = stateDescriptor.namedAssociations();
-        for( AssociationDescriptor association : namedAssociations )
-        {
-            if( association.isAggregated() )
-            {
-                NamedAssociation<?> namedAssoc = state.namedAssociationFor( association.accessor() );
-                for( String name : namedAssoc )
-                {
-                    aggregatedEntities.add( namedAssoc.get( name ) );
-                }
-            }
-        }
-
-        // Remove aggregated Entities
-        for( Object aggregatedEntity : aggregatedEntities )
-        {
-            unitOfWork.remove( aggregatedEntity );
-        }
-    }
-
-    public void checkConstraints()
-    {
-        try
-        {
-            state.checkConstraints();
-        }
-        catch( ConstraintViolationException e )
-        {
-            throw new ConstraintViolationException( identity.identity(), entityModel.types(), e.mixinTypeName(), e.methodName(), e
-                .constraintViolations() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityMixinsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityMixinsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityMixinsModel.java
deleted file mode 100644
index 2ad5b05..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityMixinsModel.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2008, Rickard Öberg. 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.zest.runtime.entity;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.composite.CompositeInstance;
-import org.apache.zest.api.entity.Lifecycle;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.model.Resolution;
-
-/**
- * JAVADOC
- */
-public final class EntityMixinsModel
-    extends MixinsModel
-{
-    List<Integer> lifecycleMixins;
-
-    @Override
-    public void bind( Resolution resolution )
-        throws BindingException
-    {
-        super.bind( resolution );
-
-        // Find what mixins implement Lifecycle
-        for( int i = 0; i < mixinModels.size(); i++ )
-        {
-            MixinModel mixinModel = mixinModels.get( i );
-            if( Lifecycle.class.isAssignableFrom( mixinModel.mixinClass() ) )
-            {
-                if( lifecycleMixins == null )
-                {
-                    lifecycleMixins = new ArrayList<Integer>();
-                }
-
-                lifecycleMixins.add( i );
-            }
-        }
-    }
-
-    public Object newMixin( EntityInstance entityInstance, StateHolder state, Object[] mixins, Method method )
-    {
-        MixinModel model = methodImplementation.get( method );
-        InjectionContext injectionContext = new InjectionContext( entityInstance, UsesInstance.EMPTY_USES, state );
-        Object mixin = model.newInstance( injectionContext );
-        mixins[ methodIndex.get( method ) ] = mixin;
-        return mixin;
-    }
-
-    public void invokeLifecycle( boolean create, Object[] mixins, CompositeInstance instance, StateHolder state )
-    {
-        if( lifecycleMixins != null )
-        {
-            InjectionContext injectionContext = new InjectionContext( instance, UsesInstance.EMPTY_USES, state );
-            for( Integer lifecycleMixin : lifecycleMixins )
-            {
-                Lifecycle lifecycle = (Lifecycle) mixins[ lifecycleMixin ];
-
-                if( lifecycle == null )
-                {
-                    lifecycle = (Lifecycle) mixinModels.get( lifecycleMixin ).newInstance( injectionContext );
-                }
-
-                if( create )
-                {
-                    lifecycle.create();
-                }
-                else
-                {
-                    lifecycle.remove();
-                }
-            }
-        }
-    }
-}


[19/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Inputs.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Inputs.java b/core/io/src/main/java/org/qi4j/io/Inputs.java
new file mode 100644
index 0000000..eb2001f
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Inputs.java
@@ -0,0 +1,490 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.Scanner;
+import java.util.zip.GZIPInputStream;
+import org.qi4j.functional.Visitor;
+
+/**
+ * Common inputs
+ */
+public class Inputs
+{
+    // START SNIPPET: method
+
+    /**
+     * Read lines from a String.
+     *
+     * @param source lines
+     *
+     * @return Input that provides lines from the string as strings
+     */
+    public static Input<String, RuntimeException> text( final String source )
+    // END SNIPPET: method
+    {
+        return new Input<String, RuntimeException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
+                throws RuntimeException, ReceiverThrowableType
+            {
+
+                output.receiveFrom( new Sender<String, RuntimeException>()
+                {
+                    @Override
+                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
+                        throws Receiver2ThrowableType, RuntimeException
+                    {
+                        Scanner scanner = new Scanner( source );
+                        while( scanner.hasNextLine() )
+                        {
+                            receiver.receive( scanner.nextLine() );
+                        }
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read lines from a Reader.
+     *
+     * @param source lines
+     *
+     * @return Input that provides lines from the string as strings
+     */
+    public static Input<String, RuntimeException> text( final Reader source )
+    // END SNIPPET: method
+    {
+        return new Input<String, RuntimeException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
+                throws RuntimeException, ReceiverThrowableType
+            {
+
+                output.receiveFrom( new Sender<String, RuntimeException>()
+                {
+                    @Override
+                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
+                        throws Receiver2ThrowableType, RuntimeException
+                    {
+                        Scanner scanner = new Scanner( source );
+                        while( scanner.hasNextLine() )
+                        {
+                            receiver.receive( scanner.nextLine() );
+                        }
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read lines from a UTF-8 encoded textfile.
+     *
+     * If the filename ends with .gz, then the data is automatically unzipped when read.
+     *
+     * @param source textfile with lines separated by \n character
+     *
+     * @return Input that provides lines from the textfiles as strings
+     */
+    public static Input<String, IOException> text( final File source )
+    // END SNIPPET: method
+    {
+        return text( source, "UTF-8" );
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read lines from a textfile with the given encoding.
+     *
+     * If the filename ends with .gz, then the data is automatically unzipped when read.
+     *
+     * @param source   textfile with lines separated by \n character
+     * @param encoding encoding of file, e.g. "UTF-8"
+     *
+     * @return Input that provides lines from the textfiles as strings
+     */
+    public static Input<String, IOException> text( final File source, final String encoding )
+    // END SNIPPET: method
+    {
+        return new Input<String, IOException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
+                throws IOException, ReceiverThrowableType
+            {
+                InputStream stream = new FileInputStream( source );
+
+                // If file is gzipped, unzip it automatically
+                if( source.getName().endsWith( ".gz" ) )
+                {
+                    stream = new GZIPInputStream( stream );
+                }
+
+                try (BufferedReader reader = new BufferedReader( new InputStreamReader( stream, encoding ) ))
+                {
+                    output.receiveFrom( new Sender<String, IOException>()
+                    {
+                        @Override
+                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
+                            throws Receiver2ThrowableType, IOException
+                        {
+                            String line;
+                            while( ( line = reader.readLine() ) != null )
+                            {
+                                receiver.receive( line );
+                            }
+                        }
+                    } );
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read lines from a textfile at a given URL.
+     *
+     * If the content support gzip encoding, then the data is automatically unzipped when read.
+     *
+     * The charset in the content-type of the URL will be used for parsing. Default is UTF-8.
+     *
+     * @param source textfile with lines separated by \n character
+     *
+     * @return Input that provides lines from the textfiles as strings
+     */
+    public static Input<String, IOException> text( final URL source )
+    // END SNIPPET: method
+    {
+        return new Input<String, IOException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
+                throws IOException, ReceiverThrowableType
+            {
+                URLConnection urlConnection = source.openConnection();
+                urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
+                InputStream stream = urlConnection.getInputStream();
+
+                // If file is gzipped, unzip it automatically
+                if( "gzip".equals( urlConnection.getContentEncoding() ) )
+                {
+                    stream = new GZIPInputStream( stream );
+                }
+
+                // Figure out charset given content-type
+                String contentType = urlConnection.getContentType();
+                String charSet = "UTF-8";
+                if( contentType.contains( "charset=" ) )
+                {
+                    charSet = contentType.substring( contentType.indexOf( "charset=" ) + "charset=".length() );
+                }
+
+                try (BufferedReader reader = new BufferedReader( new InputStreamReader( stream, charSet ) ))
+                {
+                    output.receiveFrom( new Sender<String, IOException>()
+                    {
+                        @Override
+                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super String, Receiver2ThrowableType> receiver )
+                            throws Receiver2ThrowableType, IOException
+                        {
+                            String line;
+                            while( ( line = reader.readLine() ) != null )
+                            {
+                                receiver.receive( line );
+                            }
+                        }
+                    } );
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read a file using ByteBuffer of a given size. Useful for transferring raw data.
+     *
+     * @param source The file to be read.
+     * @param bufferSize The size of the byte array.
+     *
+     * @return An Input instance to be applied to streaming operations.
+     */
+    public static Input<ByteBuffer, IOException> byteBuffer( final File source, final int bufferSize )
+    // END SNIPPET: method
+    {
+        return new Input<ByteBuffer, IOException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
+                throws IOException, ReceiverThrowableType
+            {
+                final FileInputStream stream = new FileInputStream( source );
+                final FileChannel fci = stream.getChannel();
+
+                final ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
+
+                try
+                {
+                    output.receiveFrom( new Sender<ByteBuffer, IOException>()
+                    {
+                        @Override
+                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
+                            throws Receiver2ThrowableType, IOException
+                        {
+                            while( fci.read( buffer ) != -1 )
+                            {
+                                buffer.flip();
+                                receiver.receive( buffer );
+                                buffer.clear();
+                            }
+                        }
+                    } );
+                }
+                finally
+                {
+                    stream.close();
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Read an inputstream using ByteBuffer of a given size.
+     *
+     * @param source The InputStream to be read.
+     * @param bufferSize The size of the byte array.
+     *
+     * @return An Input instance to be applied to streaming operations.
+     */
+    public static Input<ByteBuffer, IOException> byteBuffer( final InputStream source, final int bufferSize )
+    // END SNIPPET: method
+    {
+        return new Input<ByteBuffer, IOException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
+                throws IOException, ReceiverThrowableType
+            {
+                try
+                {
+                    output.receiveFrom( new Sender<ByteBuffer, IOException>()
+                    {
+                        @Override
+                        public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
+                            throws Receiver2ThrowableType, IOException
+                        {
+                            byte[] buffer = new byte[ bufferSize ];
+
+                            int len;
+                            while( ( len = source.read( buffer ) ) != -1 )
+                            {
+                                ByteBuffer byteBuffer = ByteBuffer.wrap( buffer, 0, len );
+                                receiver.receive( byteBuffer );
+                            }
+                        }
+                    } );
+                }
+                finally
+                {
+                    source.close();
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Combine many Input into one single Input. When a transfer is initiated from it all items from all inputs will be transferred
+     * to the given Output.
+     *
+     * @param inputs An Iterable of Input instances to be combined.
+     * @param <T> The item type of the Input
+     * @param <SenderThrowableType> The Throwable that might be thrown by the Inputs.
+     *
+     * @return A combined Input, allowing for easy aggregation of many Input sources.
+     */
+    public static <T, SenderThrowableType extends Throwable> Input<T, SenderThrowableType> combine( final Iterable<Input<T, SenderThrowableType>> inputs )
+    // END SNIPPET: method
+    {
+        return new Input<T, SenderThrowableType>()
+        {
+            @Override
+            public <Receiver2ThrowableType extends Throwable> void transferTo( Output<? super T, Receiver2ThrowableType> output )
+                throws SenderThrowableType, Receiver2ThrowableType
+            {
+                output.receiveFrom( new Sender<T, SenderThrowableType>()
+                {
+                    @Override
+                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
+                        throws ReceiverThrowableType, SenderThrowableType
+                    {
+                        for( Input<T, SenderThrowableType> input : inputs )
+                        {
+                            input.transferTo( new Output<T, ReceiverThrowableType>()
+                            {
+                                @Override
+                                public <Sender2ThrowableType extends Throwable> void receiveFrom( Sender<? extends T, Sender2ThrowableType> sender )
+                                    throws ReceiverThrowableType, Sender2ThrowableType
+                                {
+                                    sender.sendTo( new Receiver<T, ReceiverThrowableType>()
+                                    {
+                                        @Override
+                                        public void receive( T item )
+                                            throws ReceiverThrowableType
+                                        {
+                                            receiver.receive( item );
+                                        }
+                                    } );
+                                }
+                            } );
+                        }
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Create an Input that takes its items from the given Iterable.
+     *
+     * @param iterable The Iterable to be used as an Input.
+     * @param <T> The item type of the Input
+     *
+     * @return An Input instance that is backed by the Iterable.
+     */
+    public static <T> Input<T, RuntimeException> iterable( final Iterable<T> iterable )
+    // END SNIPPET: method
+    {
+        return new Input<T, RuntimeException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
+                throws RuntimeException, ReceiverThrowableType
+            {
+                output.receiveFrom( new Sender<T, RuntimeException>()
+                {
+                    @Override
+                    public <Receiver2ThrowableType extends Throwable> void sendTo( Receiver<? super T, Receiver2ThrowableType> receiver )
+                        throws Receiver2ThrowableType, RuntimeException
+                    {
+                        for( T item : iterable )
+                        {
+                            receiver.receive( item );
+                        }
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Create an Input that allows a Visitor to write to an OutputStream. The stream is a BufferedOutputStream, so when enough
+     * data has been gathered it will send this in chunks of the given size to the Output it is transferred to. The Visitor does not have to call
+     * close() on the OutputStream, but should ensure that any wrapper streams or writers are flushed so that all data is sent.
+     *
+     * @param outputVisitor The OutputStream Visitor that will be backing the Input ByteBuffer.
+     * @param bufferSize The buffering size.
+     *
+     * @return An Input instance of ByteBuffer, that is backed by an Visitor to an OutputStream.
+     */
+    public static Input<ByteBuffer, IOException> output( final Visitor<OutputStream, IOException> outputVisitor,
+                                                         final int bufferSize
+    )
+    // END SNIPPET: method
+    {
+        return new Input<ByteBuffer, IOException>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ByteBuffer, ReceiverThrowableType> output )
+                throws IOException, ReceiverThrowableType
+            {
+                output.receiveFrom( new Sender<ByteBuffer, IOException>()
+                {
+                    @Override
+                    @SuppressWarnings( "unchecked" )
+                    public <Receiver2ThrowableType extends Throwable> void sendTo( final Receiver<? super ByteBuffer, Receiver2ThrowableType> receiver )
+                        throws Receiver2ThrowableType, IOException
+                    {
+                        try (OutputStream out = new BufferedOutputStream( new OutputStream()
+                        {
+                            @Override
+                            public void write( int b )
+                                throws IOException
+                            {
+                                // Ignore
+                            }
+
+                            @SuppressWarnings( "NullableProblems" )
+                            @Override
+                            public void write( byte[] b, int off, int len )
+                                throws IOException
+                            {
+                                try
+                                {
+                                    ByteBuffer byteBuffer = ByteBuffer.wrap( b, 0, len );
+                                    receiver.receive( byteBuffer );
+                                }
+                                catch( Throwable ex )
+                                {
+                                    throw new IOException( ex );
+                                }
+                            }
+                        }, bufferSize ))
+                        {
+                            outputVisitor.visit( out );
+                        }
+                        catch( IOException ex )
+                        {
+                            throw (Receiver2ThrowableType) ex.getCause();
+                        }
+                    }
+                } );
+            }
+        };
+    }
+
+    private Inputs()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Output.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Output.java b/core/io/src/main/java/org/qi4j/io/Output.java
new file mode 100644
index 0000000..3dcd207
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Output.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+/**
+ * Output for data.
+ */
+// START SNIPPET: output
+public interface Output<T, ReceiverThrowableType extends Throwable>
+{
+// END SNIPPET: output
+
+    /**
+     * This initiates a transfer from an Input. Implementations should open any resources to be written to
+     * and then call sender.sendTo() when it is ready to receive data. When sendTo() returns the resource should be
+     * closed properly. Make sure to handle any exceptions from sendTo.
+     *
+     * @param sender                the sender of data to this output
+     * @param <SenderThrowableType> the exception that sendTo can throw
+     *
+     * @throws SenderThrowableType   the exception that the sender can throw
+     * @throws ReceiverThrowableType the exception that this output can throw from receiveItem()
+     */
+// START SNIPPET: output
+    <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
+        throws ReceiverThrowableType, SenderThrowableType;
+}
+// END SNIPPET: output

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Outputs.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Outputs.java b/core/io/src/main/java/org/qi4j/io/Outputs.java
new file mode 100644
index 0000000..2508788
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Outputs.java
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.Collection;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * Utility methods for creating standard Outputs
+ */
+public class Outputs
+{
+    // START SNIPPET: method
+
+    /**
+     * Write lines to a text file with UTF-8 encoding. Separate each line with a newline ("\n" character). If the writing or sending fails,
+     * the file is deleted.
+     * <p>
+     * If the filename ends with .gz, then the data is automatically GZipped.
+     * </p>
+     * @param file the file to save the text to
+     *
+     * @return an Output for storing text in a file
+     */
+    public static Output<String, IOException> text( final File file )
+    // END SNIPPET: method
+    {
+        return text( file, "UTF-8" );
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write lines to a text file. Separate each line with a newline ("\n" character). If the writing or sending fails,
+     * the file is deleted.
+     * <p>
+     * If the filename ends with .gz, then the data is automatically GZipped.
+     * </p>
+     * @param file the file to save the text to
+     *
+     * @return an Output for storing text in a file
+     */
+    public static Output<String, IOException> text( final File file, final String encoding )
+    // END SNIPPET: method
+    {
+        return new Output<String, IOException>()
+        {
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                File tmpFile = Files.createTemporayFileOf( file );
+
+                OutputStream stream = new FileOutputStream( tmpFile );
+
+                // If file should be gzipped, do that automatically
+                if( file.getName().endsWith( ".gz" ) )
+                {
+                    stream = new GZIPOutputStream( stream );
+                }
+
+                final BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( stream, encoding ) );
+
+                try
+                {
+                    sender.sendTo( new Receiver<String, IOException>()
+                    {
+                        @Override
+                        public void receive( String item )
+                            throws IOException
+                        {
+                            writer.append( item ).append( '\n' );
+                        }
+                    } );
+                    writer.close();
+
+                    // Replace file with temporary file
+                    if( !file.exists() || file.delete() )
+                    {
+                        if( ! tmpFile.renameTo( file ) )
+                        {
+                            // TODO: What?? Throw an Exception?
+                            System.err.println( "Unable to rename file: " + tmpFile + " to " + file );
+                        }
+                    }
+                }
+                catch( IOException e )
+                {
+                    // We failed writing - close and delete
+                    writer.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+                }
+                catch( Throwable senderThrowableType )
+                {
+                    // We failed writing - close and delete
+                    writer.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+                    throw (SenderThrowableType) senderThrowableType;
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write lines to a Writer. Separate each line with a newline ("\n" character).
+     *
+     * @param writer the Writer to write the text to
+     * @return an Output for storing text in a Writer
+     */
+    public static Output<String, IOException> text( final Writer writer )
+    // END SNIPPET: method
+    {
+        return new Output<String, IOException>()
+        {
+
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                sender.sendTo( new Receiver<String, IOException>()
+                {
+
+                    @Override
+                    public void receive( String item )
+                        throws IOException
+                    {
+                        writer.append( item ).append( "\n" );
+                    }
+
+                } );
+            }
+
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write lines to a StringBuilder. Separate each line with a newline ("\n" character).
+     *
+     * @param builder the StringBuilder to append the text to
+     * @return an Output for storing text in a StringBuilder
+     */
+    public static Output<String, IOException> text( final StringBuilder builder )
+    // END SNIPPET: method
+    {
+        return new Output<String, IOException>()
+        {
+
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                sender.sendTo( new Receiver<String, IOException>()
+                {
+
+                    @Override
+                    public void receive( String item )
+                        throws IOException
+                    {
+                        builder.append( item ).append( "\n" );
+                    }
+
+                } );
+            }
+
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write ByteBuffer data to a file. If the writing or sending of data fails the file will be deleted.
+     *
+     * @param file The destination file.
+     *
+     * @return The Output ByteBuffer instance backed by a File.
+     */
+    public static Output<ByteBuffer, IOException> byteBuffer( final File file )
+    // END SNIPPET: method
+    {
+        return new Output<ByteBuffer, IOException>()
+        {
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends ByteBuffer, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                File tmpFile = Files.createTemporayFileOf( file );
+                FileOutputStream stream = new FileOutputStream( tmpFile );
+                final FileChannel fco = stream.getChannel();
+
+                try
+                {
+                    sender.sendTo( new Receiver<ByteBuffer, IOException>()
+                    {
+                        @Override
+                        public void receive( ByteBuffer item )
+                            throws IOException
+                        {
+                            fco.write( item );
+                        }
+                    } );
+                    stream.close();
+
+                    // Replace file with temporary file
+                    if( !file.exists() || file.delete() )
+                    {
+                        if( ! tmpFile.renameTo( file ) )
+                        {
+                            // TODO: What can be done in this case?
+                            System.err.println( "Unable to rename file: " + tmpFile + " to " + file );
+                        }
+                    }
+                }
+                catch( IOException e )
+                {
+                    // We failed writing - close and delete
+                    stream.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+
+                }
+                catch( Throwable senderThrowableType )
+                {
+                    // We failed writing - close and delete
+                    stream.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+                    throw (SenderThrowableType) senderThrowableType;
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write ByteBuffer data to an OutputStream.
+     *
+     * @param stream Destination OutputStream
+     *
+     * @return The Output of ByteBuffer that will be backed by the OutputStream.
+     */
+    public static Output<ByteBuffer, IOException> byteBuffer( final OutputStream stream )
+    // END SNIPPET: method
+    {
+        return new Output<ByteBuffer, IOException>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends ByteBuffer, SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                try
+                {
+                    sender.sendTo( new Receiver<ByteBuffer, IOException>()
+                    {
+                        @Override
+                        public void receive( ByteBuffer item )
+                            throws IOException
+                        {
+                            if( item.hasArray() )
+                            {
+                                stream.write( item.array(), item.arrayOffset(), item.limit() );
+                            }
+                            else
+                            {
+                                for( int i = 0; i < item.limit(); i++ )
+                                {
+                                    stream.write( item.get( i ) );
+                                }
+                            }
+                        }
+                    } );
+                }
+                finally
+                {
+                    stream.close();
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write byte array data to a file. If the writing or sending of data fails the file will be deleted.
+     *
+     * @param file The File to be written to.
+     * @param bufferSize The size of the ByteBuffer.
+     *
+     * @return An Output instance that will write to the given File.
+     */
+    public static Output<byte[], IOException> bytes( final File file, final int bufferSize )
+    // END SNIPPET: method
+    {
+        return new Output<byte[], IOException>()
+        {
+            @Override
+            @SuppressWarnings( "unchecked" )
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends byte[], SenderThrowableType> sender )
+                throws IOException, SenderThrowableType
+            {
+                File tmpFile = Files.createTemporayFileOf( file );
+                final OutputStream stream = new BufferedOutputStream( new FileOutputStream( tmpFile ), bufferSize );
+
+                try
+                {
+                    sender.sendTo( new Receiver<byte[], IOException>()
+                    {
+                        @Override
+                        public void receive( byte[] item )
+                            throws IOException
+                        {
+                            stream.write( item );
+                        }
+                    } );
+                    stream.close();
+
+                    // Replace file with temporary file
+                    if( !file.exists() || file.delete() )
+                    {
+                        if( ! tmpFile.renameTo( file ) )
+                        {
+                            // TODO: WHAT???
+                            System.err.println( "Unable to rename " + tmpFile + " to " + file );
+                        }
+                    }
+                }
+                catch( IOException e )
+                {
+                    // We failed writing - close and delete
+                    stream.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+                }
+                catch( Throwable senderThrowableType )
+                {
+                    // We failed writing - close and delete
+                    stream.close();
+                    if( ! tmpFile.delete() )
+                    {
+                        System.err.println("Unable to delete temporary file." );
+                        tmpFile.deleteOnExit();
+                    }
+                    throw (SenderThrowableType) senderThrowableType;
+                }
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Do nothing. Use this if you have all logic in filters and/or specifications
+     *
+     * @param <T> The item type.
+     *
+     * @return An Output instance that ignores all data.
+     */
+    public static <T> Output<T, RuntimeException> noop()
+    // END SNIPPET: method
+    {
+        return withReceiver( new Receiver<T, RuntimeException>()
+        {
+            @Override
+            public void receive( T item )
+                throws RuntimeException
+            {
+                // Do nothing
+            }
+        } );
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Use given receiver as Output. Use this if there is no need to create a "transaction" for each transfer, and no need
+     * to do batch writes or similar.
+     *
+     * @param <T> The item type
+     * @param receiver receiver for this Output
+     *
+     * @return An Output instance backed by a Receiver of items.
+     */
+    public static <T, ReceiverThrowableType extends Throwable> Output<T, ReceiverThrowableType> withReceiver( final Receiver<T, ReceiverThrowableType> receiver )
+    // END SNIPPET: method
+    {
+        return new Output<T, ReceiverThrowableType>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
+                throws ReceiverThrowableType, SenderThrowableType
+            {
+                sender.sendTo( receiver );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write objects to System.out.println.
+     *
+     * @return An Output instance that is backed by System.out
+     */
+    public static Output<Object, RuntimeException> systemOut()
+    // END SNIPPET: method
+    {
+        return new Output<Object, RuntimeException>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<?, SenderThrowableType> sender )
+                throws RuntimeException, SenderThrowableType
+            {
+                sender.sendTo( new Receiver<Object, RuntimeException>()
+                {
+                    @Override
+                    public void receive( Object item )
+                    {
+                        System.out.println( item );
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Write objects to System.err.println.
+     *
+     * @return An Output instance backed by System.in
+     */
+    @SuppressWarnings( "UnusedDeclaration" )
+    public static Output<Object, RuntimeException> systemErr()
+    // END SNIPPET: method
+    {
+        return new Output<Object, RuntimeException>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<?, SenderThrowableType> sender )
+                throws RuntimeException, SenderThrowableType
+            {
+                sender.sendTo( new Receiver<Object, RuntimeException>()
+                {
+                    @Override
+                    public void receive( Object item )
+                    {
+                        System.err.println( item );
+                    }
+                } );
+            }
+        };
+    }
+
+    // START SNIPPET: method
+
+    /**
+     * Add items to a collection
+     */
+    public static <T> Output<T, RuntimeException> collection( final Collection<T> collection )
+    // END SNIPPET: method
+    {
+        return new Output<T, RuntimeException>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
+                throws RuntimeException, SenderThrowableType
+            {
+                sender.sendTo( new Receiver<T, RuntimeException>()
+                {
+                    @Override
+                    public void receive( T item )
+                        throws RuntimeException
+                    {
+                        collection.add( item );
+                    }
+                } );
+            }
+        };
+    }
+
+    private Outputs()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Receiver.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Receiver.java b/core/io/src/main/java/org/qi4j/io/Receiver.java
new file mode 100644
index 0000000..6318cdf
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Receiver.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+/**
+ * Receiver of items during a specific transfer from an Input to an Output.
+ */
+// START SNIPPET: receiver
+public interface Receiver<T, ReceiverThrowableType extends Throwable>
+{
+// END SNIPPET: receiver
+    /**
+     * Receive a single item of the given type. The receiver should process it
+     * and optionally throw an exception if it fails.
+     *
+     * @param item
+     *
+     * @throws ReceiverThrowableType
+     */
+// START SNIPPET: receiver
+    void receive( T item )
+        throws ReceiverThrowableType;
+}
+// END SNIPPET: receiver

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Sender.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Sender.java b/core/io/src/main/java/org/qi4j/io/Sender.java
new file mode 100644
index 0000000..05ac007
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Sender.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+/**
+ * Sender of items for a particular transfer from an Input to an Output
+ */
+// START SNIPPET: sender
+public interface Sender<T, SenderThrowableType extends Throwable>
+{
+// END SNIPPET: sender
+    /**
+     * The sender should send all items it holds to the receiver by invoking receiveItem for each item.
+     *
+     * If the receive fails it should properly close any open resources.
+     *
+     * @param receiver
+     * @param <ReceiverThrowableType>
+     *
+     * @throws ReceiverThrowableType
+     * @throws SenderThrowableType
+     */
+// START SNIPPET: sender
+    <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super T, ReceiverThrowableType> receiver )
+        throws ReceiverThrowableType, SenderThrowableType;
+}
+// END SNIPPET: sender

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/Transforms.java
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/Transforms.java b/core/io/src/main/java/org/qi4j/io/Transforms.java
new file mode 100644
index 0000000..a5d0040
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/Transforms.java
@@ -0,0 +1,435 @@
+/*
+ * Copyright (c) 2010, Rickard Öberg. 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.qi4j.io;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.text.MessageFormat;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.logging.Logger;
+import org.qi4j.functional.Function;
+import org.qi4j.functional.Specification;
+
+/**
+ * Utility class for I/O transforms
+ */
+public class Transforms
+{
+    /**
+     * Filter items in a transfer by applying the given Specification to each item.
+     *
+     * @param specification            The Specification defining the items to not filter away.
+     * @param output                   The Output instance to receive to result.
+     * @param <T>                      The item type
+     * @param <Receiver2ThrowableType> Exception type that might be thrown by the Receiver.
+     *
+     * @return And Output encapsulation the filter operation.
+     */
+    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filter( final Specification<? super T> specification,
+                                                                                                          final Output<T, Receiver2ThrowableType> output
+    )
+    {
+        return new Output<T, Receiver2ThrowableType>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends T, SenderThrowableType> sender )
+                throws Receiver2ThrowableType, SenderThrowableType
+            {
+                output.receiveFrom( new Sender<T, SenderThrowableType>()
+                {
+                    @Override
+                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
+                        throws ReceiverThrowableType, SenderThrowableType
+                    {
+                        sender.sendTo( new Receiver<T, ReceiverThrowableType>()
+                        {
+                            @Override
+                            public void receive( T item )
+                                throws ReceiverThrowableType
+                            {
+                                if( specification.satisfiedBy( item ) )
+                                {
+                                    receiver.receive( item );
+                                }
+                            }
+                        } );
+                    }
+                } );
+            }
+        };
+    }
+
+    /**
+     * Map items in a transfer from one type to another by applying the given function.
+     *
+     * @param function                 The transformation function to apply to the streaming items.
+     * @param output                   The output to receive the transformed items.
+     * @param <From>                   The type of the incoming items.
+     * @param <To>                     The type of the transformed items.
+     * @param <Receiver2ThrowableType> The exception type that the Receiver might throw.
+     *
+     * @return An Output instance that encapsulates the map transformation.
+     */
+    public static <From, To, Receiver2ThrowableType extends Throwable> Output<From, Receiver2ThrowableType> map( final Function<? super From, ? extends To> function,
+                                                                                                                 final Output<To, Receiver2ThrowableType> output
+    )
+    {
+        return new Output<From, Receiver2ThrowableType>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends From, SenderThrowableType> sender )
+                throws Receiver2ThrowableType, SenderThrowableType
+            {
+                output.receiveFrom( new Sender<To, SenderThrowableType>()
+                {
+                    @Override
+                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super To, ReceiverThrowableType> receiver )
+                        throws ReceiverThrowableType, SenderThrowableType
+                    {
+                        sender.sendTo( new Receiver<From, ReceiverThrowableType>()
+                        {
+                            @Override
+                            public void receive( From item )
+                                throws ReceiverThrowableType
+                            {
+                                receiver.receive( function.map( item ) );
+                            }
+                        } );
+                    }
+                } );
+            }
+        };
+    }
+
+    /**
+     * Apply the given function to items in the transfer that match the given specification. Other items will pass
+     * through directly.
+     *
+     * @param specification            The Specification defining which items should be transformed.
+     * @param function                 The transformation function.
+     * @param output                   The Output that will receive the resulting items.
+     * @param <T>                      The item type. Items can not be transformed to a new type.
+     * @param <Receiver2ThrowableType> The exception that the Receiver might throw.
+     *
+     * @return An Output instance that encapsulates the operation.
+     */
+    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> filteredMap( final Specification<? super T> specification,
+                                                                                                               final Function<? super T, ? extends T> function,
+                                                                                                               final Output<T, Receiver2ThrowableType> output
+    )
+    {
+        return new Output<T, Receiver2ThrowableType>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends T, SenderThrowableType> sender )
+                throws Receiver2ThrowableType, SenderThrowableType
+            {
+                output.receiveFrom( new Sender<T, SenderThrowableType>()
+                {
+                    @Override
+                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super T, ReceiverThrowableType> receiver )
+                        throws ReceiverThrowableType, SenderThrowableType
+                    {
+                        sender.sendTo( new Receiver<T, ReceiverThrowableType>()
+                        {
+                            @Override
+                            public void receive( T item )
+                                throws ReceiverThrowableType
+                            {
+                                if( specification.satisfiedBy( item ) )
+                                {
+                                    receiver.receive( function.map( item ) );
+                                }
+                                else
+                                {
+                                    receiver.receive( item );
+                                }
+                            }
+                        } );
+                    }
+                } );
+            }
+        };
+    }
+
+    /**
+     * Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on
+     * the sending side and a write-lock would be used on the receiving side. Inputs can use this as well to create a
+     * wrapper on the send side when transferTo is invoked.
+     *
+     * @param lock                    the lock to be used for transfers
+     * @param output                  output to be wrapped
+     * @param <T>                     The Item type
+     * @param <Receiver2ThrowableType> The Exception type that the Receiver might throw.
+     *
+     * @return Output wrapper that uses the given lock during transfers.
+     */
+    public static <T, Receiver2ThrowableType extends Throwable> Output<T, Receiver2ThrowableType> lock( final Lock lock,
+                                                                                                      final Output<T, Receiver2ThrowableType> output
+    )
+    {
+        return new Output<T, Receiver2ThrowableType>()
+        {
+            @Override
+            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
+                throws Receiver2ThrowableType, SenderThrowableType
+            {
+                /**
+                 * Fix for this bug:
+                 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370
+                 */
+                while( true )
+                {
+                    try
+                    {
+                        //noinspection StatementWithEmptyBody
+                        while( !lock.tryLock( 1000, TimeUnit.MILLISECONDS ) )
+                        {
+                            // On timeout, try again
+                        }
+                        break; // Finally got a lock
+                    }
+                    catch( InterruptedException e )
+                    {
+                        // Try again
+                    }
+                }
+
+                try
+                {
+                    output.receiveFrom( sender );
+                }
+                finally
+                {
+                    lock.unlock();
+                }
+            }
+        };
+    }
+
+    /**
+     * Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on the sending side and a write-lock
+     * would be used on the receiving side.
+     *
+     * @param lock                  the lock to be used for transfers
+     * @param input                 input to be wrapped
+     * @param <T>                   The item type.
+     * @param <SenderThrowableType> The Exception type that the Sender might throw.
+     *
+     * @return Input wrapper that uses the given lock during transfers.
+     */
+    public static <T, SenderThrowableType extends Throwable> Input<T, SenderThrowableType> lock( final Lock lock,
+                                                                                                 final Input<T, SenderThrowableType> input
+    )
+    {
+        return new Input<T, SenderThrowableType>()
+        {
+            @Override
+            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
+                throws SenderThrowableType, ReceiverThrowableType
+            {
+                /**
+                 * Fix for this bug:
+                 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370
+                 */
+                while( true )
+                {
+                    try
+                    {
+                        //noinspection StatementWithEmptyBody
+                        while( !( lock.tryLock() || lock.tryLock( 1000, TimeUnit.MILLISECONDS ) ) )
+                        {
+                            // On timeout, try again
+                        }
+                        break; // Finally got a lock
+                    }
+                    catch( InterruptedException e )
+                    {
+                        // Try again
+                    }
+                }
+
+                try
+                {
+                    input.transferTo( output );
+                }
+                finally
+                {
+                    lock.unlock();
+                }
+            }
+        };
+    }
+
+    /**
+     * Count the number of items in the transfer.
+     *
+     * @param <T>
+     */
+    // START SNIPPET: counter
+    public static class Counter<T>
+        implements Function<T, T>
+    {
+        private volatile long count = 0;
+
+        public long count()
+        {
+            return count;
+        }
+
+        @Override
+        public T map( T t )
+        {
+            count++;
+            return t;
+        }
+    }
+    // END SNIPPET: counter
+
+    /**
+     * Convert strings to bytes using the given CharSet
+     */
+    @SuppressWarnings( "UnusedDeclaration" )
+    public static class String2Bytes
+        implements Function<String, byte[]>
+    {
+        private Charset charSet;
+
+        public String2Bytes( Charset charSet )
+        {
+            this.charSet = charSet;
+        }
+
+        @Override
+        public byte[] map( String s )
+        {
+            return s.getBytes( charSet );
+        }
+    }
+
+    /**
+     * Convert ByteBuffers to Strings using the given CharSet
+     */
+    public static class ByteBuffer2String
+        implements Function<ByteBuffer, String>
+    {
+        private Charset charSet;
+
+        public ByteBuffer2String( Charset charSet )
+        {
+            this.charSet = charSet;
+        }
+
+        @Override
+        public String map( ByteBuffer buffer )
+        {
+            return new String( buffer.array(), charSet );
+        }
+    }
+
+    /**
+     * Convert objects to Strings using .toString()
+     */
+    @SuppressWarnings( "UnusedDeclaration" )
+    public static class ObjectToString
+        implements Function<Object, String>
+    {
+        @Override
+        public String map( Object o )
+        {
+            return o.toString();
+        }
+    }
+
+    /**
+     * Log the toString() representation of transferred items to the given log. The string is first formatted using MessageFormat
+     * with the given format.
+     *
+     * @param <T>
+     */
+    public static class Log<T>
+        implements Function<T, T>
+    {
+        private Logger logger;
+        private MessageFormat format;
+
+        public Log( Logger logger, String format )
+        {
+            this.logger = logger;
+            this.format = new MessageFormat( format );
+        }
+
+        @Override
+        public T map( T item )
+        {
+            logger.info( format.format( new String[]{ item.toString() } ) );
+            return item;
+        }
+    }
+
+    /**
+     * Track progress of transfer by emitting a log message in given intervals.
+     *
+     * If logger or format is null, then you need to override the logProgress to do something
+     *
+     * @param <T> type of items to be transferred
+     */
+    // START SNIPPET: progress
+    public static class ProgressLog<T>
+        implements Function<T, T>
+    {
+        private Counter<T> counter;
+        private Log<String> log;
+        private final long interval;
+
+        public ProgressLog( Logger logger, String format, long interval )
+        {
+            this.interval = interval;
+            if( logger != null && format != null )
+            {
+                log = new Log<>( logger, format );
+            }
+            counter = new Counter<>();
+        }
+
+        public ProgressLog( long interval )
+        {
+            this.interval = interval;
+            counter = new Counter<>();
+        }
+
+        @Override
+        public T map( T t )
+        {
+            counter.map( t );
+            if( counter.count % interval == 0 )
+            {
+                logProgress();
+            }
+            return t;
+        }
+
+        // Override this to do something other than logging the progress
+        protected void logProgress()
+        {
+            if( log != null )
+            {
+                log.map( counter.count + "" );
+            }
+        }
+    }
+    // END SNIPPET: progress
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/main/java/org/qi4j/io/package.html
----------------------------------------------------------------------
diff --git a/core/io/src/main/java/org/qi4j/io/package.html b/core/io/src/main/java/org/qi4j/io/package.html
new file mode 100644
index 0000000..aac8a54
--- /dev/null
+++ b/core/io/src/main/java/org/qi4j/io/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>I/O API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/test/java/org/apache/zest/io/InputOutputTest.java
----------------------------------------------------------------------
diff --git a/core/io/src/test/java/org/apache/zest/io/InputOutputTest.java b/core/io/src/test/java/org/apache/zest/io/InputOutputTest.java
deleted file mode 100644
index bc40f2e..0000000
--- a/core/io/src/test/java/org/apache/zest/io/InputOutputTest.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (c) 2010, Rickard Öberg. 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.zest.io;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.logging.Logger;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.functional.Function;
-import org.apache.zest.functional.Visitor;
-
-import static java.util.Arrays.asList;
-import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.io.Inputs.text;
-import static org.apache.zest.io.Transforms.lock;
-import static org.apache.zest.test.util.Assume.assumeConnectivity;
-
-/**
- * Test Input/Output.
- */
-public class InputOutputTest
-{
-    @Test
-    public void testCopyFileNoAPI()
-        throws IOException
-    {
-        File source = sourceFile();
-        File destination = File.createTempFile( "test", ".txt" );
-        destination.deleteOnExit();
-
-        BufferedReader reader = new BufferedReader( new FileReader( source ) );
-        long count = 0;
-        try
-        {
-            BufferedWriter writer = new BufferedWriter( new FileWriter( destination ) );
-            try
-            {
-                String line;
-                while( ( line = reader.readLine() ) != null )
-                {
-                    count++;
-                    writer.append( line ).append( '\n' );
-                }
-                writer.close();
-            }
-            catch( IOException e )
-            {
-                writer.close();
-                destination.delete();
-            }
-        }
-        finally
-        {
-            reader.close();
-        }
-        System.out.println( count );
-    }
-
-    @Test
-    public void testInputOutput()
-        throws IOException
-    {
-        URL source = getClass().getResource( "/iotest.txt" );
-        File destination = File.createTempFile( "test", ".txt" );
-        destination.deleteOnExit();
-        text( source ).transferTo( Outputs.text( destination ) );
-    }
-
-    @Test
-    public void testCopyFile()
-        throws IOException
-    {
-        File source = sourceFile();
-        File tempFile = File.createTempFile( "test", ".txt" );
-        tempFile.deleteOnExit();
-
-        Inputs.byteBuffer( source, 1024 ).transferTo( Outputs.byteBuffer( tempFile ) );
-
-        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( source.length() ) );
-    }
-
-    @Test
-    public void testCopyURL()
-        throws IOException
-    {
-        assumeConnectivity( "www.google.com", 80 );
-
-        File tempFile = File.createTempFile( "test", ".txt" );
-        tempFile.deleteOnExit();
-
-        Inputs.text( new URL( "http://www.google.com" ) ).transferTo( Outputs.text( tempFile ) );
-
-// Uncomment to check output        Inputs.text( tempFile ).transferTo( Outputs.systemOut() );
-    }
-
-    @Test
-    public void testCopyFileStreams()
-        throws IOException
-    {
-        File source = sourceFile();
-        File tempFile = File.createTempFile( "test", ".txt" );
-        tempFile.deleteOnExit();
-
-        Inputs.byteBuffer( new FileInputStream( source ), 1024 ).transferTo(
-            Outputs.byteBuffer( new FileOutputStream( tempFile ) ) );
-
-        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( source.length() ) );
-    }
-
-    @Test
-    public void testLog()
-        throws IOException
-    {
-        File source = sourceFile();
-
-        text( source ).transferTo(
-            Transforms.map( new Transforms.Log<String>( Logger.getLogger( getClass().getName() ), "Line: {0}" ),
-                            Outputs.<String>noop() ) );
-    }
-
-    @Test
-    public void testProgressLog()
-        throws Throwable
-    {
-        Integer[] data = new Integer[ 105 ];
-        Arrays.fill( data, 42 );
-
-        Inputs.iterable( iterable( data ) ).transferTo(
-            Transforms.map(
-                new Transforms.ProgressLog<Integer>(
-                    Logger.getLogger( InputOutputTest.class.getName() ), "Data transferred: {0}", 10 ),
-                Outputs.<Integer>noop() ) );
-    }
-
-    @Test
-    public void testTextInputsOutputs()
-        throws IOException
-    {
-        File tempFile = File.createTempFile( "test", ".txt" );
-        tempFile.deleteOnExit();
-        File sourceFile = sourceFile();
-        Transforms.Counter<String> stringCounter = new Transforms.Counter<>();
-        text( sourceFile ).transferTo(
-            Transforms.map(
-                stringCounter,
-                Transforms.map( new Function<String, String>()
-                {
-                    public String map( String s )
-                    {
-                        System.out.println( s );
-                        return s;
-                    }
-                }, Outputs.text( tempFile ) )
-            )
-        );
-
-        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( sourceFile.length() ) );
-        Assert.assertThat( stringCounter.count(), CoreMatchers.equalTo( 4L ) );
-    }
-
-    @Test
-    public void testCombineInputs()
-        throws IOException
-    {
-        File tempFile = File.createTempFile( "test", ".txt" );
-        tempFile.deleteOnExit();
-        File sourceFile = sourceFile();
-        Transforms.Counter<String> stringCounter = new Transforms.Counter<>();
-        Input<String, IOException> text1 = text( sourceFile );
-        Input<String, IOException> text2 = text( sourceFile );
-        List<Input<String, IOException>> list = createList( text1, text2 );
-        Inputs.combine( list ).transferTo(
-            Transforms.map(
-                stringCounter,
-                Transforms.map( new Function<String, String>()
-            {
-                public String map( String s )
-                {
-                    System.out.println( s );
-                    return s;
-                }
-                }, Outputs.text( tempFile ) )
-            )
-        );
-
-        Assert.assertThat( tempFile.length(), CoreMatchers.equalTo( sourceFile.length() * 2 ) );
-        Assert.assertThat( stringCounter.count(), CoreMatchers.equalTo( 8L ) );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private List<Input<String, IOException>> createList( Input<String, IOException> text1,
-                                                         Input<String, IOException> text2
-    )
-    {
-        return asList( text1, text2 );
-    }
-
-    @Test( expected = IOException.class )
-    public void testInputOutputOutputException()
-        throws IOException
-    {
-
-        text( sourceFile() ).
-            transferTo( writerOutput( new Writer()
-                    {
-                        @Override
-                        public void write( char[] cbuf, int off, int len )
-                        throws IOException
-                        {
-                            throw new IOException();
-                        }
-
-                        @Override
-                        public void flush()
-                        throws IOException
-                        {
-                            throw new IOException();
-                        }
-
-                        @Override
-                        public void close()
-                        throws IOException
-                        {
-                            throw new IOException();
-                        }
-            } ) );
-    }
-
-    @Test( expected = RemoteException.class )
-    public void testInputOutputInputException()
-        throws IOException
-    {
-
-        Input<String, RemoteException> input = new Input<String, RemoteException>()
-        {
-            @Override
-            public <OutputThrowableType extends Throwable> void transferTo( Output<? super String, OutputThrowableType> output )
-                throws RemoteException, OutputThrowableType
-            {
-                output.receiveFrom( new Sender<String, RemoteException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiverThrowableTypeReceiver )
-                        throws ReceiverThrowableType, RemoteException
-                    {
-                        throw new RemoteException();
-                    }
-                } );
-            }
-        };
-
-        input.transferTo(
-            Transforms.map(
-                new Transforms.Log<String>( Logger.getLogger( getClass().getName() ), "Line: {0}" ),
-                Outputs.systemOut()
-            )
-        );
-    }
-
-    @Test
-    public void testLock()
-        throws IOException
-    {
-        Lock inputLock = new ReentrantLock();
-        Lock outputLock = new ReentrantLock();
-
-        URL source = getClass().getResource( "/iotest.txt" );
-        File destination = File.createTempFile( "test", ".txt" );
-        destination.deleteOnExit();
-        lock( inputLock, text( source ) ).transferTo( lock( outputLock, Outputs.text( destination ) ) );
-    }
-
-    @Test
-    public void testGenerics()
-    {
-        ArrayList<Object> objects = new ArrayList<>( 3 );
-        Inputs.iterable( Arrays.asList( "Foo", "Bar", "Xyzzy" ) ).transferTo( Outputs.collection( objects ) );
-
-        Inputs.iterable( objects ).transferTo( Outputs.systemOut() );
-    }
-
-    @Test
-    public void testOutputstreamInput()
-        throws Throwable
-    {
-        Input<ByteBuffer, IOException> input = Inputs.output( new Visitor<OutputStream, IOException>()
-        {
-            @Override
-            public boolean visit( OutputStream visited )
-                throws IOException
-            {
-                try( PrintWriter writer = new PrintWriter( visited ) )
-                {
-                    writer.print( "Hello World!" );
-                }
-                return true;
-            }
-        }, 256 );
-
-        input.transferTo( Transforms.map( new Transforms.ByteBuffer2String( Charset.defaultCharset() ), Outputs.systemOut() ) );
-        input.transferTo( Transforms.map( new Transforms.ByteBuffer2String( Charset.defaultCharset() ), Outputs.systemOut() ) );
-    }
-
-    public Output<String, IOException> writerOutput( final Writer writer )
-    {
-        return new Output<String, IOException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
-            {
-                // Here we initiate the transfer
-                System.out.println( "Open output" );
-                final StringBuilder builder = new StringBuilder();
-                try
-                {
-                    sender.sendTo( new Receiver<String, IOException>()
-                    {
-                        @Override
-                        public void receive( String item )
-                            throws IOException
-                        {
-                            System.out.println( "Receive input" );
-
-                            // Here we can do batch writes if needed
-                            builder.append( item ).append( "\n" );
-                        }
-                    } );
-
-                    // If transfer went well, do something with it
-                    writer.write( builder.toString() );
-                    writer.flush();
-                    System.out.println( "Output written" );
-                }
-                catch( IOException e )
-                {
-                    // If transfer failed, potentially rollback writes
-                    System.out.println( "Input failed" );
-                    throw e;
-                }
-            }
-        };
-    }
-
-    private File sourceFile()
-    {
-        String path = getClass().getResource( "/iotest.txt" ).getFile();
-        return new File( path.replaceAll( "%20", " " ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
----------------------------------------------------------------------
diff --git a/core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java b/core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
deleted file mode 100644
index 9ff74a2..0000000
--- a/core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
+++ /dev/null
@@ -1,53 +0,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.
- */
-package org.apache.zest.io.docsupport;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
-
-// START SNIPPET: io2
-import org.apache.zest.io.Transforms.Counter;
-import static org.apache.zest.io.Transforms.map;
-// END SNIPPET: io2
-
-public class IoDocs
-{
-    public static void main( String[] args )
-        throws IOException
-    {
-        {
-// START SNIPPET: io1
-            File source = new File( "source.txt" );
-            File destination = new File( "destination.txt" );
-            Inputs.text( source ).transferTo( Outputs.text( destination ) );
-// END SNIPPET: io1
-        }
-        {
-// START SNIPPET: io2
-            File source = new File( "source.txt" );
-            File destination = new File( "destination.txt" );
-            Counter<String> counter = new Counter<String>();
-            Inputs.text( source ).transferTo( map(counter, Outputs.text(destination) ));
-            System.out.println( "Lines: " + counter.count() );
-// END SNIPPET: io2
-        }
-    }
-}


[40/51] [abbrv] [partial] zest-java git commit: Revert "First round of changes to move to org.apache.zest namespace."

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListener.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListener.java b/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListener.java
new file mode 100644
index 0000000..3562c6e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Listener for ActivationEvent events
+ */
+public interface ActivationEventListener
+{
+    void onEvent( ActivationEvent event )
+        throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListenerRegistration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListenerRegistration.java b/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListenerRegistration.java
new file mode 100644
index 0000000..41e3b5e
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivationEventListenerRegistration.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg.
+ * Copyright (c) 2012, Niclas Hedhman.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Use this to register listeners for ActivationEvents.
+ *
+ * This is implemented by Application, Layer, Module, for example.
+ */
+public interface ActivationEventListenerRegistration
+{
+    /**
+     * @param listener will be notified when Activation events occur
+     */
+    void registerActivationEventListener( ActivationEventListener listener );
+
+    /**
+     * @param listener will not be notified when Activation events occur anymore
+     */
+    void deregisterActivationEventListener( ActivationEventListener listener );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivationException.java b/core/api/src/main/java/org/qi4j/api/activation/ActivationException.java
new file mode 100644
index 0000000..30d06be
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivationException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2013 Niclas Hedhman.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Thrown when unable to activate.
+ */
+public class ActivationException extends Exception
+{
+    private static final long serialVersionUID = 1L;
+    public ActivationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/Activator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/Activator.java b/core/api/src/main/java/org/qi4j/api/activation/Activator.java
new file mode 100644
index 0000000..2cba184
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/Activator.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Assemble Activators to hook Services Activation.
+ *
+ * @param <ActivateeType> Type of the activatee.
+ *
+ * @see ActivatorAdapter
+ * @see org.qi4j.api.service.ServiceActivation
+ */
+public interface Activator<ActivateeType>
+{
+
+    /**
+     * Called before activatee activation.
+     */
+    void beforeActivation( ActivateeType activating )
+        throws Exception;
+
+    /**
+     * Called after activatee activation.
+     */
+    void afterActivation( ActivateeType activated )
+        throws Exception;
+
+    /**
+     * Called before activatee passivation.
+     */
+    void beforePassivation( ActivateeType passivating )
+        throws Exception;
+
+    /**
+     * Called after activatee passivation.
+     */
+    void afterPassivation( ActivateeType passivated )
+        throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivatorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivatorAdapter.java b/core/api/src/main/java/org/qi4j/api/activation/ActivatorAdapter.java
new file mode 100644
index 0000000..59652b9
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivatorAdapter.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+/**
+ * Adapter for Activator.
+ * <p>If you are thinking about Service activation, see {@link org.qi4j.api.service.ServiceActivatorAdapter}.</p>
+ *
+ * @param <ActivateeType> Type of the activatee.
+ */
+public class ActivatorAdapter<ActivateeType>
+    implements Activator<ActivateeType>
+{
+    /**
+     * Called before activatee activation.
+     * @param activating Activating activatee
+     */
+    @Override
+    public void beforeActivation( ActivateeType activating )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called after activatee activation.
+     * @param activated Activating activatee
+     */
+    @Override
+    public void afterActivation( ActivateeType activated )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called before activatee passivation.
+     * @param passivating Passivating activatee
+     */
+    @Override
+    public void beforePassivation( ActivateeType passivating )
+        throws Exception
+    {
+    }
+
+    /**
+     * Called after activatee passivation.
+     * @param passivated Passivated activatee
+     */
+    @Override
+    public void afterPassivation( ActivateeType passivated )
+        throws Exception
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ActivatorDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ActivatorDescriptor.java b/core/api/src/main/java/org/qi4j/api/activation/ActivatorDescriptor.java
new file mode 100644
index 0000000..bfe3fee
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ActivatorDescriptor.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.activation;
+
+/**
+ * Activator Descriptor.
+ */
+public interface ActivatorDescriptor
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/Activators.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/Activators.java b/core/api/src/main/java/org/qi4j/api/activation/Activators.java
new file mode 100644
index 0000000..8d0f7e6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/Activators.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2012 Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used in ServiceComposites to declare Activator implementation classes.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+public @interface Activators
+{
+
+    /**
+     * @return Activator implementation classes.
+     */
+    Class<? extends Activator<?>>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/ApplicationPassivationThread.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/ApplicationPassivationThread.java b/core/api/src/main/java/org/qi4j/api/activation/ApplicationPassivationThread.java
new file mode 100644
index 0000000..62b1f67
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/ApplicationPassivationThread.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2013 Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+import java.io.PrintStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.qi4j.api.structure.Application;
+
+/**
+ * Application Passivation Thread to use as a Shutdown Hook.
+ * <pre>Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application ) );</pre>
+ * <p>Constructors to control where errors are logged are provided. They support PrintStream (STDOUT/STDERR) and SLF4J
+ * Loggers. Defaults to STDERR.</p>
+ */
+public final class ApplicationPassivationThread
+    extends Thread
+{
+    /**
+     * Create a new Application Passivation Thread that output errors to STDERR.
+     * @param application The Application to passivate
+     */
+    public ApplicationPassivationThread( final Application application )
+    {
+        this( application, null, null );
+    }
+
+    /**
+     * Create a new Application Passivation Thread that output errors to a Logger.
+     * @param application The Application to passivate
+     * @param logger Logger for errors
+     */
+    public ApplicationPassivationThread( Application application, Logger logger )
+    {
+        this( application, null, logger );
+    }
+
+    /**
+     * Create a new Application Passivation Thread that output errors to a PrintStream.
+     * @param application The Application to passivate
+     * @param output PrintStream for errors
+     */
+    public ApplicationPassivationThread( Application application, PrintStream output )
+    {
+        this( application, output, null );
+    }
+
+    private ApplicationPassivationThread( Application application, PrintStream output, Logger logger )
+    {
+        super( new ApplicationPassivation( application, output, logger ),
+               application.name() + " Passivation Thread" );
+    }
+
+    private static class ApplicationPassivation
+        implements Runnable
+    {
+
+        private final Application application;
+        private final PrintStream output;
+        private final Logger logger;
+
+        private ApplicationPassivation( Application application, PrintStream output, Logger logger )
+        {
+            this.application = application;
+            this.output = output;
+            this.logger = logger;
+        }
+
+        @Override
+        public void run()
+        {
+            try
+            {
+                application.passivate();
+            }
+            catch( PassivationException ex )
+            {
+                String message = application.name() + " " + ex.getMessage();
+                if( logger != null )
+                {
+                    logger.log( Level.SEVERE, message, ex );
+                }
+                else if( output != null )
+                {
+                    output.println( message );
+                    ex.printStackTrace( output );
+                }
+                else
+                {
+                    ex.printStackTrace();
+                }
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/PassivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/PassivationException.java b/core/api/src/main/java/org/qi4j/api/activation/PassivationException.java
new file mode 100644
index 0000000..c3f33fe
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/PassivationException.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2009 Niclas Hedhman.
+ * Copyright 2013 Paul Merlin.
+ *
+ * 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.qi4j.api.activation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Thrown when unable to passivate.
+ *
+ * Printed StackTrace contains all causes in order as suppressed exceptions.
+ */
+public final class PassivationException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+    private final List<Exception> causes;
+
+    /**
+     * Create new PassivationException.
+     * @param exceptions All exceptions encountered during passivation, in order
+     */
+    public PassivationException( Collection<Exception> exceptions )
+    {
+        super( "Passivation Exception - [has " + exceptions.size() + " cause(s)]" );
+        for( Throwable cause : exceptions )
+        {
+            addSuppressed( cause );
+        }
+        this.causes = new ArrayList<>( exceptions );
+    }
+
+    /**
+     * @return All exceptions encountered during passivation, in order
+     */
+    public List<Exception> causes()
+    {
+        return causes;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/activation/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/activation/package.html b/core/api/src/main/java/org/qi4j/api/activation/package.html
new file mode 100644
index 0000000..47b333a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/activation/package.html
@@ -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.
+-->
+<html>
+    <body>
+        <h2>Activation API.</h2>
+        <p>
+            The Activation API package contains types used by client code to integrate with the Zest™ Runtime activation
+            mechanism. In assembly, client code can easily listen to Structure (Application, Layers and Modules) and
+            Services activation events, or, declare Structure and Service Activators.
+        </p>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AbstractAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AbstractAssociation.java b/core/api/src/main/java/org/qi4j/api/association/AbstractAssociation.java
new file mode 100644
index 0000000..60afce2
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AbstractAssociation.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+/**
+ * Base interface for all associations.
+ */
+public interface AbstractAssociation
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/Association.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/Association.java b/core/api/src/main/java/org/qi4j/api/association/Association.java
new file mode 100644
index 0000000..acd406f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/Association.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * Association to a single EntityComposite.
+ */
+public interface Association<T> extends AbstractAssociation
+{
+    /**
+     * Get the associated entity.
+     *
+     * @return the associated entity
+     */
+    T get();
+
+    /**
+     * Set the associated entity.
+     *
+     * @param associated the entity
+     *
+     * @throws IllegalArgumentException thrown if the entity is not a valid reference for this association
+     * @throws IllegalStateException    thrown if association is immutable
+     */
+    void set( T associated )
+        throws IllegalArgumentException, IllegalStateException;
+
+    /**
+     * @return the the reference of the associated entity.
+     */
+    EntityReference reference();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AssociationDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AssociationDescriptor.java b/core/api/src/main/java/org/qi4j/api/association/AssociationDescriptor.java
new file mode 100644
index 0000000..9f7576a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AssociationDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Type;
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.structure.MetaInfoHolder;
+
+/**
+ * Association Descriptor.
+ */
+public interface AssociationDescriptor extends MetaInfoHolder
+{
+    /**
+     * Get the qualified name of the association. This is constructed by
+     * concatenating the name of the declaring interface with the name
+     * of the method, using ":" as separator.
+     * <p>
+     * Example:
+     * </p>
+     * <p>
+     * com.somecompany.MyInterface with association method
+     * </p>
+     * <pre><code>
+     * Association&lt;String&gt; someAssociation();
+     * </code></pre>
+     * will have the qualified name:
+     * <pre><code>
+     * com.somecompany.MyInterface:someAssociation
+     * </code></pre>
+     *
+     * @return the qualified name of the association
+     */
+    QualifiedName qualifiedName();
+
+    /**
+     * Get the type of the associated Entities
+     *
+     * @return the type of the associated Entities
+     */
+    Type type();
+
+    boolean isImmutable();
+
+    boolean isAggregated();
+
+    AccessibleObject accessor();
+
+    boolean queryable();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AssociationMixin.java b/core/api/src/main/java/org/qi4j/api/association/AssociationMixin.java
new file mode 100644
index 0000000..ac26de3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AssociationMixin.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.injection.scope.State;
+
+/**
+ * Generic mixin for associations.
+ */
+@AppliesTo( { AssociationMixin.AssociationFilter.class } )
+public final class AssociationMixin
+    implements InvocationHandler
+{
+    @State
+    private AssociationStateHolder associations;
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        return associations.associationFor( method );
+    }
+
+    /**
+     * Associations generic mixin AppliesToFilter.
+     */
+    public static class AssociationFilter
+        implements AppliesToFilter
+    {
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
+        {
+            return Association.class.isAssignableFrom( method.getReturnType() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AssociationStateDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AssociationStateDescriptor.java b/core/api/src/main/java/org/qi4j/api/association/AssociationStateDescriptor.java
new file mode 100644
index 0000000..83c04a4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AssociationStateDescriptor.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008-2011, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.association;
+
+import org.qi4j.api.common.QualifiedName;
+import org.qi4j.api.composite.StateDescriptor;
+
+/**
+ * Associations State Descriptor.
+ */
+public interface AssociationStateDescriptor extends StateDescriptor
+{
+    AssociationDescriptor getAssociationByName( String name )
+        throws IllegalArgumentException;
+
+    AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException;
+
+    AssociationDescriptor getManyAssociationByName( String name )
+        throws IllegalArgumentException;
+
+    AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException;
+
+    AssociationDescriptor getNamedAssociationByName( String name )
+        throws IllegalArgumentException;
+
+    AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
+        throws IllegalArgumentException;
+
+    Iterable<? extends AssociationDescriptor> associations();
+
+    Iterable<? extends AssociationDescriptor> manyAssociations();
+
+    Iterable<? extends AssociationDescriptor> namedAssociations();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AssociationStateHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AssociationStateHolder.java b/core/api/src/main/java/org/qi4j/api/association/AssociationStateHolder.java
new file mode 100644
index 0000000..e33ff7f
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AssociationStateHolder.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2008-2013, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.association;
+
+import java.lang.reflect.AccessibleObject;
+import org.qi4j.api.property.StateHolder;
+
+/**
+ * This represents the state of a entity (properties+associations).
+ */
+public interface AssociationStateHolder
+    extends StateHolder
+{
+    /**
+     * Get an association for a specific accessor method
+     *
+     * @param associationMethod for the association
+     *
+     * @return the association
+     */
+    <T> Association<T> associationFor( AccessibleObject associationMethod );
+
+    /**
+     * Get all associations
+     *
+     * @return iterable of associations
+     */
+    Iterable<? extends Association<?>> allAssociations();
+
+    /**
+     * Get a many-association for a specific accessor method
+     *
+     * @param manyassociationMethod for the many-association
+     *
+     * @return the association
+     */
+    <T> ManyAssociation<T> manyAssociationFor( AccessibleObject manyassociationMethod );
+
+    /**
+     * Get all ManyAssociations
+     *
+     * @return iterable of many-associations
+     */
+    Iterable<? extends ManyAssociation<?>> allManyAssociations();
+
+    /**
+     * Get a named-association for a specific accessor method
+     *
+     * @param namedassociationMethod for the named-association
+     *
+     * @return the association
+     */
+    <T> NamedAssociation<T> namedAssociationFor( AccessibleObject namedassociationMethod );
+
+    /**
+     * Get all NmaedAssociations
+     *
+     * @return iterable of named-associations
+     */
+    Iterable<? extends NamedAssociation<?>> allNamedAssociations();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/AssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/AssociationWrapper.java b/core/api/src/main/java/org/qi4j/api/association/AssociationWrapper.java
new file mode 100644
index 0000000..68777b3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/AssociationWrapper.java
@@ -0,0 +1,79 @@
+/*
+ * 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.qi4j.api.association;
+
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * If you want to catch getting and setting association, then create a GenericConcern
+ * that wraps the Zest-supplied Association instance with AssociationWrappers. Override
+ * get() and/or set() to perform your custom code.
+ */
+public class AssociationWrapper
+    implements Association<Object>
+{
+    protected Association<Object> next;
+
+    public AssociationWrapper( Association<Object> next )
+    {
+        this.next = next;
+    }
+
+    public Association<Object> next()
+    {
+        return next;
+    }
+
+    @Override
+    public Object get()
+    {
+        return next.get();
+    }
+
+    @Override
+    public void set( Object associated )
+        throws IllegalArgumentException
+    {
+        next.set( associated );
+    }
+
+    @Override
+    public EntityReference reference()
+    {
+        return next.reference();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return next.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        return next.equals( obj );
+    }
+
+    @Override
+    public String toString()
+    {
+        return next.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java b/core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java
new file mode 100644
index 0000000..7173547
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Niclas Hedhman. 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.qi4j.api.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import static org.qi4j.api.util.Classes.typeOf;
+
+/**
+ * Generic Association info.
+ */
+public final class GenericAssociationInfo
+{
+    public static Type associationTypeOf( AccessibleObject accessor )
+    {
+        return toAssociationType( typeOf( accessor ) );
+    }
+
+    public static Type toAssociationType( Type methodReturnType )
+    {
+        if( methodReturnType instanceof ParameterizedType )
+        {
+            ParameterizedType parameterizedType = (ParameterizedType) methodReturnType;
+            if( AbstractAssociation.class.isAssignableFrom( (Class<?>) parameterizedType.getRawType() ) )
+            {
+                return parameterizedType.getActualTypeArguments()[ 0 ];
+            }
+        }
+
+        Type[] interfaces = ( (Class<?>) methodReturnType ).getGenericInterfaces();
+        for( Type anInterface : interfaces )
+        {
+            Type associationType = toAssociationType( anInterface );
+            if( associationType != null )
+            {
+                return associationType;
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/ManyAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/ManyAssociation.java b/core/api/src/main/java/org/qi4j/api/association/ManyAssociation.java
new file mode 100644
index 0000000..37d7211
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/ManyAssociation.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * Association to a collection of entities.
+ */
+public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
+{
+    /**
+     * Returns the number of references in this association.
+     * @return the number of references in this association.
+     */
+    int count();
+
+    boolean contains( T entity );
+
+    boolean add( int i, T entity );
+
+    boolean add( T entity );
+
+    boolean remove( T entity );
+
+    T get( int i );
+
+    List<T> toList();
+
+    Set<T> toSet();
+
+    /**
+     * Returns an unmodifiable Iterable of the references to the associated entities.
+     * @return the references to the associated entities.
+     */
+    Iterable<EntityReference> references();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/ManyAssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/ManyAssociationMixin.java b/core/api/src/main/java/org/qi4j/api/association/ManyAssociationMixin.java
new file mode 100644
index 0000000..5b2177d
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/ManyAssociationMixin.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.association;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.injection.scope.State;
+
+/**
+ * Generic mixin for associations.
+ */
+@AppliesTo( { ManyAssociationMixin.AssociationFilter.class } )
+public final class ManyAssociationMixin
+    implements InvocationHandler
+{
+    @State
+    private AssociationStateHolder associations;
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        return associations.manyAssociationFor( method );
+    }
+
+    /**
+     * ManyAssociations generic mixin AppliesToFilter.
+     */
+    public static class AssociationFilter
+        implements AppliesToFilter
+    {
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
+        {
+            return ManyAssociation.class.isAssignableFrom( method.getReturnType() );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/ManyAssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/ManyAssociationWrapper.java b/core/api/src/main/java/org/qi4j/api/association/ManyAssociationWrapper.java
new file mode 100644
index 0000000..aee7804
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/ManyAssociationWrapper.java
@@ -0,0 +1,123 @@
+/*
+ * 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.qi4j.api.association;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * If you want to catch calls to ManyAssociations, then create a GenericConcern
+ * that wraps the Zest-supplied ManyAssociation instance with ManyAssociationWrappers. Override
+ * methods to perform your custom code.
+ */
+public class ManyAssociationWrapper
+    implements ManyAssociation<Object>
+{
+    protected ManyAssociation<Object> next;
+
+    public ManyAssociationWrapper( ManyAssociation<Object> next )
+    {
+        this.next = next;
+    }
+
+    public ManyAssociation<Object> next()
+    {
+        return next;
+    }
+
+    @Override
+    public int count()
+    {
+        return next.count();
+    }
+
+    @Override
+    public boolean contains( Object entity )
+    {
+        return next.contains( entity );
+    }
+
+    @Override
+    public boolean add( int i, Object entity )
+    {
+        return next.add( i, entity );
+    }
+
+    @Override
+    public boolean add( Object entity )
+    {
+        return next.add( entity );
+    }
+
+    @Override
+    public boolean remove( Object entity )
+    {
+        return next.remove( entity );
+    }
+
+    @Override
+    public Object get( int i )
+    {
+        return next.get( i );
+    }
+
+    @Override
+    public List<Object> toList()
+    {
+        return next.toList();
+    }
+
+    @Override
+    public Set<Object> toSet()
+    {
+        return next.toSet();
+    }
+
+    @Override
+    public Iterable<EntityReference> references()
+    {
+        return next.references();
+    }
+
+    @Override
+    public Iterator<Object> iterator()
+    {
+        return next.iterator();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return next.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        return next.equals( obj );
+    }
+
+    @Override
+    public String toString()
+    {
+        return next.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/NamedAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/NamedAssociation.java b/core/api/src/main/java/org/qi4j/api/association/NamedAssociation.java
new file mode 100644
index 0000000..61c9c9a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/NamedAssociation.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.association;
+
+import java.util.Map;
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * Association to named Entities.
+ * The Iterable&lt;String&gt; returns the names in the association set.
+ * @param <T> Parameterized associatee type
+ */
+public interface NamedAssociation<T>
+    extends Iterable<String>, AbstractAssociation
+{
+    /**
+     * @return The number of named associations in this NamedAssociation.
+     */
+    int count();
+
+    /**
+     * Checks if there is an association with the given name.
+     * @param name The name of the association we are checking if it exists.
+     * @return true if it exists, false otherwise
+     */
+    boolean containsName( String name );
+
+    /**
+     * Adds a named assocation.
+     * @param name The name of the association.
+     * @param entity The entity for this named association.
+     * @return true if putted, false otherwise
+     */
+    boolean put( String name, T entity );
+
+    /**
+     * Remove a named association.
+     * @param name The name of the association.
+     * @return true if removed, false otherwise
+     */
+    boolean remove( String name );
+
+    /**
+     * Retrieves a named association.
+     * @param name The name of the association.
+     * @return The entity that has previously been associated.
+     */
+    T get( String name );
+
+    /**
+     * Checks if the entity is present.
+     * Note that this is potentially a very slow operation, depending on the size of the NamedAssociation.
+     * @param entity The entity to look for.
+     * @return The name of the entity if found, otherwise null.
+     */
+    String nameOf( T entity );
+
+    /**
+     * @return A fully populated Map with the content of this NamedAssociation.
+     */
+    Map<String, T> toMap();
+
+    /**
+     * Returns an unmodifiable Iterable of the references to the associated entities.
+     * @return the references to the associated entities.
+     */
+    Iterable<EntityReference> references();
+
+    /** Returns the EntityReference for the Association with the given name.
+     *
+     * @param name The name of the association to return the EntityReference for
+     * @return The EntityReference of the association.
+     */
+    EntityReference referenceOf( String name );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/NamedAssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/NamedAssociationMixin.java b/core/api/src/main/java/org/qi4j/api/association/NamedAssociationMixin.java
new file mode 100644
index 0000000..d612ed6
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/NamedAssociationMixin.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.association;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.qi4j.api.common.AppliesTo;
+import org.qi4j.api.common.AppliesToFilter;
+import org.qi4j.api.injection.scope.State;
+
+/**
+ * Generic mixin for NamedAssociations.
+ */
+@AppliesTo( NamedAssociationMixin.AssociationFilter.class )
+public final class NamedAssociationMixin
+    implements InvocationHandler
+{
+    @State
+    private AssociationStateHolder associations;
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        return associations.namedAssociationFor( method );
+    }
+
+    /**
+     * NamedAssociations generic mixin AppliesToFilter.
+     */
+    public static class AssociationFilter
+        implements AppliesToFilter
+    {
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
+        {
+            return NamedAssociation.class.isAssignableFrom( method.getReturnType() );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/NamedAssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/NamedAssociationWrapper.java b/core/api/src/main/java/org/qi4j/api/association/NamedAssociationWrapper.java
new file mode 100644
index 0000000..814644a
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/NamedAssociationWrapper.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011-2012, Niclas Hedhman. All Rights Reserved.
+ * Copyright (c) 2014, Paul Merlin. 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.qi4j.api.association;
+
+import java.util.Iterator;
+import java.util.Map;
+import org.qi4j.api.entity.EntityReference;
+
+/**
+ * If you want to catch calls to NamedAssociations, then create a GenericConcern
+ * that wraps the Zest-supplied NamedAssociations instance with NamedAssociationsWrapper. Override
+ * methods to perform your custom code.
+ */
+public class NamedAssociationWrapper
+    implements NamedAssociation<Object>
+{
+    protected NamedAssociation<Object> next;
+
+    public NamedAssociationWrapper( NamedAssociation<Object> next )
+    {
+        this.next = next;
+    }
+
+    public NamedAssociation<Object> next()
+    {
+        return next;
+    }
+
+    @Override
+    public Iterator<String> iterator()
+    {
+        return next.iterator();
+    }
+
+    @Override
+    public int count()
+    {
+        return next.count();
+    }
+
+    @Override
+    public boolean containsName( String name )
+    {
+        return next.containsName( name );
+    }
+
+    @Override
+    public boolean put( String name, Object entity )
+    {
+        return next.put( name, entity );
+    }
+
+    @Override
+    public boolean remove( String name )
+    {
+        return next.remove( name );
+    }
+
+    @Override
+    public Object get( String name )
+    {
+        return next.get( name );
+    }
+
+    @Override
+    public String nameOf( Object entity )
+    {
+        return next.nameOf( entity );
+    }
+
+    @Override
+    public Map<String, Object> toMap()
+    {
+        return next.toMap();
+    }
+
+    @Override
+    public Iterable<EntityReference> references()
+    {
+        return next.references();
+    }
+
+    @Override
+    public EntityReference referenceOf( String name )
+    {
+        return next.referenceOf( name );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return next.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        return next.equals( obj );
+    }
+
+    @Override
+    public String toString()
+    {
+        return next.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/association/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/association/package.html b/core/api/src/main/java/org/qi4j/api/association/package.html
new file mode 100644
index 0000000..cf48596
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/association/package.html
@@ -0,0 +1,21 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Association API.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/cache/CacheOptions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/cache/CacheOptions.java b/core/api/src/main/java/org/qi4j/api/cache/CacheOptions.java
new file mode 100644
index 0000000..ccfc286
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/cache/CacheOptions.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2010 Niclas Hedhman.
+ *
+ * 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.qi4j.api.cache;
+
+/**
+ * CacheOptions is a metaInfo class for the Cache system for Entity persistence.
+ * CacheOptions should be assigned to the Usecase of the UnitOfWork, to give hint on caching to entity stores.
+ * See {@link org.qi4j.api.usecase.UsecaseBuilder} on how to set the metaInfo on Usecases.
+ */
+public final class CacheOptions
+{
+    public static final CacheOptions ALWAYS = new CacheOptions( true, true, true );
+    public static final CacheOptions NEVER = new CacheOptions( false, false, false );
+
+    private final boolean cacheOnRead;
+    private final boolean cacheOnWrite;
+    private final boolean cacheOnNew;
+
+    /**
+     * Constructor for CacheOptions.
+     *
+     * @param cacheOnRead  if true, give the hint to the Cache system that it may not be a good idea to cache the
+     *                     read values. This is useful when it is known that the read will be over a large set and
+     *                     shouldn't affect the existing cached entities. For instance, when traversing the EntityStore
+     *                     this option is set to false.
+     * @param cacheOnWrite if true, give the hint to the Cache system that it may not be a good idea to cache the
+     *                     entity when the value is updated. If this is false, the cache should be emptied from any
+     *                     cached entity instead of updated. There are few cases when this is useful, and if this is
+     *                     false, it makes sense that the <i>cacheOnRead</i> is also false.
+     * @param cacheOnNew   if true, give the hint to the Cache system that it may not be a good idea to cache a newly
+     *                     created Entity, as it is not likely to be read in the near future. This is useful when
+     *                     batch inserts are being made.
+     */
+    public CacheOptions( boolean cacheOnRead, boolean cacheOnWrite, boolean cacheOnNew )
+    {
+        this.cacheOnRead = cacheOnRead;
+        this.cacheOnWrite = cacheOnWrite;
+        this.cacheOnNew = cacheOnNew;
+    }
+
+    /**
+     * @return if true, give the hint to the Cache system that it may not be a good idea to cache the
+     *         read values. This is useful when it is known that the read will be over a large set and
+     *         shouldn't affect the existing cached entities. For instance, when traversing the EntityStore
+     */
+    public boolean cacheOnRead()
+    {
+        return cacheOnRead;
+    }
+
+    /**
+     * @return if true, give the hint to the Cache system that it may not be a good idea to cache the
+     *         entity when the value is updated. If this is false, the cache should be emptied from any
+     *         cached entity instead of updated. There are few cases when this is useful, and if this is
+     *         false, it makes sense that the <i>cacheOnRead</i> is also false.
+     */
+    public boolean cacheOnWrite()
+    {
+        return cacheOnWrite;
+    }
+
+    /**
+     * @return if true, give the hint to the Cache system that it may not be a good idea to cache a newly
+     *         created Entity, as it is not likely to be read in the near future. This is useful when
+     *         batch inserts are being made.
+     */
+    public boolean cacheOnNew()
+    {
+        return cacheOnNew;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/cache/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/cache/package.html b/core/api/src/main/java/org/qi4j/api/cache/package.html
new file mode 100644
index 0000000..a62da34
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/cache/package.html
@@ -0,0 +1,40 @@
+<!--
+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.
+-->
+<html>
+    <body>
+        <h2>Cache API.</h2>
+        <p>
+            The Cache API/SPI is an extension point for Entity Store caching.
+        </p>
+        <p>
+            The API part is only to allow caching options to be passed to the underlying extension in a uniform and
+            standard way. CacheOptions are to be passed as meta info on the optional Cache extension that is specified
+            during assembly phase. Example;
+        </p>
+<pre><code>
+public void assemble( ModuleAssembly module )
+{
+    CacheOptions options = new CacheOptions( true, true, false );
+    module.addServices( EhCacheService.class ).setMetaInfo( options );
+}
+</code></pre>
+        <p>
+            Not all EntityStore implementations use the Cache extension, so check the implementation details of the
+            EntityStore whether the cache extension can bring any benefits or not.
+        </p>
+    </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/AppliesTo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/AppliesTo.java b/core/api/src/main/java/org/qi4j/api/common/AppliesTo.java
new file mode 100644
index 0000000..b23f204
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/AppliesTo.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.common;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Fragments that implement InvocationHandler and which should only be applied to methods that have a particular
+ * annotation or implement a known interface should use this annotation.
+ * <p>
+ * &#64;AppliesTo can specify one of;
+ * </p>
+ * <ul>
+ * <li>An annotation,</li>
+ * <li>An interface,</li>
+ * <li>An AppliesToFilter implementation.</li>
+ * </ul>
+ * <p>
+ * Example with annotation:
+ * </p>
+ * <pre><code>
+ *
+ * &#64;AppliesTo( Sessional.class )   // Tells Zest to apply this concern on methods with &#64;Sessional annotation
+ * public class SessionConcern extends GenericConcern
+ * {
+ *     public Object invoke( Object proxy, Method method, Object[] args )
+ *         throws Throwable
+ *     {
+ *         ... do session stuff ...
+ *     }
+ * }
+ *
+ * &#64;Retention( RetentionPolicy.RUNTIME )
+ * &#64;Target( ElementType.METHOD )
+ * &#64;Documented
+ * &#64;Inherited
+ * public @interface Sessional
+ * {
+ * }
+ *
+ * public class MyMixin
+ *     implements My
+ * {
+ *     &#64;Sessional
+ *     public void doSomethingSessional()
+ *     {
+ *        // ... do your logic wrapped in a session
+ *     }
+ *
+ *     public void doSomethingWithoutSession()
+ *     {
+ *        // ... do stuff that are not wrapped in session.
+ *     }
+ * }
+ *
+ * public interface My
+ * {
+ *     void doSomethingSessional();
+ *
+ *     void doSomethingWithoutSession();
+ * }
+ *
+ * &#64;Concerns( SessionConcern.class )
+ * &#64;Mixins( MyMixin.class )
+ * public interface MyComposite extends My, TransientComposite
+ * {}
+ * </code></pre>
+ * <p>
+ * The doSomethingWithoutSession method do not have the &#64;Sessional annotation, therefore the SessionConcern will
+ * not be placed into the call sequence of these methods, and
+ * vice-versa. The &#64;Sessional annotation can be placed either on the interface method or the implementation
+ * method, depending on whether it is a contract or implementation detail.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface AppliesTo
+{
+    /**
+     * List of interfaces, annotations or AppliesToFilter
+     * implementation classes.
+     * If one of them matches the current element it will be
+     * accepted, so this list can be considered an "or".
+     *
+     * @return array of classes or interfaces to be used by the filter
+     */
+    Class<?>[] value();
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/AppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/AppliesToFilter.java b/core/api/src/main/java/org/qi4j/api/common/AppliesToFilter.java
new file mode 100644
index 0000000..f356cf4
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/AppliesToFilter.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.common;
+
+import java.lang.reflect.Method;
+
+/**
+ * Implementations of this interface can be specified in the &#64;AppliesTo.
+ * <p>
+ * AppliesTo filters are one of the driving technologies in Zest. They allow you to apply fragments (Mixins,
+ * Concerns, SideEffects), often generic ones, depending on the context that they are evaluated under. This
+ * mechanism is heavily used internally in Zest to achieve many other features.
+ * </p>
+ * <p>
+ * The starting point is the basic use of AppliesToFilter, where the &#64;AppliesTo annotation is given an
+ * AppliesToFilter implementation as an argument, for instance at a Mixin implementation;
+ * </p>
+ * <pre><code>
+ * &#64;AppliesTo( MyAppliesToFilter.class )
+ * public class SomeMixin
+ *     implements InvocationHandler
+ * {
+ *
+ * }
+ *
+ * public class MyAppliesToFilter
+ *     implements AppliesToFilter
+ * {
+ *     public boolean appliesTo( Method method, Class&lt;?&gt; mixin, Class&lt;?&gt; compositeType, Class&lt;?&gt; fragmentClass )
+ *     {
+ *         return method.getName().startsWith( "my" );
+ *     }
+ * }
+ * </code></pre>
+ * <p>
+ * In the case above, the generic mixin will only be applied to the methods that that is defined by the
+ * AppliesToFilter. This is the primary way to define limits on the application of generic fragments, since
+ * especially mixins are rarely applied to all methods.
+ * </p>
+ */
+public interface AppliesToFilter
+{
+    /**
+     * This is an internal AppliesToFilter which is assigned if no other AppliesToFilters are found for a given
+     * fragment.
+     * <p>
+     * There is no reason for user code to use this AppliesToFilter directly, and should be perceived as an
+     * internal class in Zest.
+     * </p>
+     */
+    AppliesToFilter ALWAYS = new AppliesToFilter()
+    {
+        @Override
+        public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
+        {
+            return true;
+        }
+    };
+
+    /**
+     * Check if the Fragment should be applied or not. Will be call when applied to Mixins, Concerns, SideEffects.
+     *
+     * @param method        method that is invoked
+     * @param mixin         mixin implementation for the method
+     * @param compositeType composite type
+     * @param fragmentClass fragment that is being applies
+     *
+     * @return true if the filter passes, otherwise false
+     */
+    boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass );
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/ConstructionException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/ConstructionException.java b/core/api/src/main/java/org/qi4j/api/common/ConstructionException.java
new file mode 100644
index 0000000..9957e63
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/ConstructionException.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.common;
+
+/**
+ * Thrown when a Fragment or object could not be instantiated.
+ * This includes, but not be limited to;
+ * <ul>
+ * <li>private constructor.</li>
+ * <li>abstract class for Constraints.</li>
+ * <li>interface instead of a class.</li>
+ * <li>useful constructor missing.</li>
+ * <li>exception thrown in the constructor.</li>
+ * <li>Subclassing of org.qi4j.api.property.Property</li>
+ * </ul>
+ * <p>
+ * See the nested exception for additional details.
+ * </p>
+ */
+public class ConstructionException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 1L;
+
+    public ConstructionException()
+    {
+    }
+
+    public ConstructionException( String message )
+    {
+        super( message );
+    }
+
+    public ConstructionException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public ConstructionException( Throwable cause )
+    {
+        super( cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/InvalidApplicationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/InvalidApplicationException.java b/core/api/src/main/java/org/qi4j/api/common/InvalidApplicationException.java
new file mode 100644
index 0000000..5769fad
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/InvalidApplicationException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. 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.qi4j.api.common;
+
+/**
+ * Thrown when an application is considered to not be constructed properly.
+ * This happens primarily when client code tries to instantiate Composites
+ * and objects which have not been registered in the ModuleAssembly.
+ */
+public class InvalidApplicationException
+    extends RuntimeException
+{
+    private static final long serialVersionUID = 1L;
+
+    public InvalidApplicationException( String string )
+    {
+        super( string );
+    }
+
+    public InvalidApplicationException( String string, Throwable cause )
+    {
+        super( string, cause );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java b/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
new file mode 100644
index 0000000..b746711
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/MetaInfo.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2008, Rickard Öberg. 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.qi4j.api.common;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.qi4j.api.concern.Concerns;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.sideeffect.SideEffects;
+import org.qi4j.api.util.Classes;
+
+import static java.util.Arrays.asList;
+import static org.qi4j.api.util.Classes.typesOf;
+
+/**
+ * Used to declare and access meta-info.
+ * <p>
+ * <strong>This is effectively an internal class and should not be used directly.</strong>
+ * </p>
+ * <p>
+ * MetaInfo can be set on composites during the assembly phase, a.k.a the bootstrap
+ * process. MetaInfo is any additional data that one wishes to associate at the 'class level' instead of instance
+ * level of a composite declaration.
+ * </p>
+ * <p>
+ * To set the MetaInfo on a Composite, call the {@code setMetaInfo()} methods on the various composite declaration
+ * types, such as;
+ * </p>
+ * <pre><code>
+ * public void assemble( ModuleAssembly module )
+ *     throws AssemblyException
+ * {
+ *     Map&lt;String,String&gt; properties = ...;
+ *     module.services( MyService.class ).setMetaInfo( properties );
+ * }
+ * </code></pre>
+ * <p>
+ * which can later be retrieved by calling the {@code metaInfo()} method on the composite itself. For the example
+ * above that would be;
+ * </p>
+ * <pre><code>
+ * &#64;Mixins(MyServiceMixin.class)
+ * public interface MyService extends ServiceComposite
+ * {
+ *
+ * }
+ *
+ * public abstract class MyServiceMixin
+ *     implements MyService
+ * {
+ *     private Properties props;
+ *
+ *     public MyServiceMixin()
+ *     {
+ *         props = metaInfo( Map.class );
+ *     }
+ * }
+ * </code></pre>
+ */
+public final class MetaInfo
+{
+    private final static Collection<Class> ignored;
+
+    static
+    {
+        ignored = new HashSet<Class>( 4, 0.8f ); // Optimize size used.
+        ignored.addAll( asList( Mixins.class, Concerns.class, SideEffects.class ) );
+    }
+
+    private final Map<Class<?>, Object> metaInfoMap;
+
+    public MetaInfo()
+    {
+        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
+    }
+
+    public MetaInfo( MetaInfo metaInfo )
+    {
+        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
+        metaInfoMap.putAll( metaInfo.metaInfoMap );
+    }
+
+    public void set( Object metaInfo )
+    {
+        if( metaInfo instanceof Annotation )
+        {
+            Annotation annotation = (Annotation) metaInfo;
+            metaInfoMap.put( annotation.annotationType(), metaInfo );
+        }
+        else
+        {
+            Class<?> metaInfoclass = metaInfo.getClass();
+            Iterable<Type> types = typesOf( metaInfoclass );
+            for( Type type : types )
+            {
+                metaInfoMap.put( Classes.RAW_CLASS.map( type ), metaInfo );
+            }
+        }
+    }
+
+    public <T> T get( Class<T> metaInfoType )
+    {
+        return metaInfoType.cast( metaInfoMap.get( metaInfoType ) );
+    }
+
+    public <T> void add( Class<T> infoType, T info )
+    {
+        metaInfoMap.put( infoType, info );
+    }
+
+    public MetaInfo withAnnotations( AnnotatedElement annotatedElement )
+    {
+        for( Annotation annotation : annotatedElement.getAnnotations() )
+        {
+            if( !ignored.contains( annotation.annotationType() )
+                && get( annotation.annotationType() ) == null )
+            {
+                set( annotation );
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return metaInfoMap.toString();
+    }
+
+    public void remove( Class serviceFinderClass )
+    {
+        metaInfoMap.remove( serviceFinderClass );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a789141d/core/api/src/main/java/org/qi4j/api/common/Optional.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/common/Optional.java b/core/api/src/main/java/org/qi4j/api/common/Optional.java
new file mode 100644
index 0000000..3a070c3
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/common/Optional.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, Rickard Öberg. All Rights Reserved.
+ * Copyright (c) 2007, Niclas Hedhman. 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.qi4j.api.common;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to denote that something is optional.
+ * <ul>
+ * <li>
+ * If applied to a method parameter, then the value is allowed to be null. Default
+ * is that method parameters have to be non-null.
+ * </li>
+ * <li>
+ * If applied to a Property declaration, then the value may be null after construction of
+ * the instance, or may be set to null at a later time.
+ * </li>
+ * <li>
+ * If applied to an injected member field, it is allowed tha none get injected. For instance, an <code>&#64;Optional
+ * &#64;Service</code> would allow a service to not have been declared and the field will be null.
+ * </li>
+ * </ul>
+ * <p>
+ * Optionality is not the default in Zest, and if injections, property values and parameters in methods are not
+ * non-null, the Zest runtime will throw an {@link org.qi4j.api.constraint.ConstraintViolationException}, indicating
+ * which field/property/parameter in which composite and mixin the problem has been detected.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ * &#64;Optional &#64;Service
+ * MyService service;   // If no MyService instance is declared and visible to this service injection point
+ *                      // the 'service' field will be null.
+ *
+ * &#64;Service
+ * YourService other;   // If no YourService instance is declared and visible to this service injection point
+ *                      // the Zest runtime will throw a ConstraintViolationException.
+ *
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD } )
+@Documented
+public @interface Optional
+{
+}
\ No newline at end of file